Flushing pages to vfs will work, but the issue is that while vfs is

serving mm0, if it page faults, system deadlocks because mm0 is waiting to be served by vfs.

FIX: To fix this, mm0 will need to fork itself and keep a separate thread solely for
page fault handling.
This commit is contained in:
Bahadir Balban
2008-05-28 23:37:41 +03:00
parent 98888a94b5
commit f561d885d5
6 changed files with 39 additions and 9 deletions

View File

@@ -30,6 +30,8 @@ int pager_sys_open(l4id_t sender, int fd, unsigned long vnum, unsigned long size
{
int err;
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
l4_save_ipcregs();
write_mr(L4SYS_ARG0, sender);
@@ -104,6 +106,8 @@ int pager_sys_close(l4id_t sender, l4id_t closer, int fd)
struct tcb *task;
int err;
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
BUG_ON(!(task = find_task(closer)));
printf("Deleting fd: %d\n", fd);
@@ -132,6 +136,7 @@ int sys_open(l4id_t sender, const char *pathname, int flags, unsigned int mode)
int fd;
int retval, err;
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
/* Get the task */
BUG_ON(!(task = find_task(sender)));
@@ -337,6 +342,7 @@ int pager_sys_read(l4id_t sender, unsigned long vnum, unsigned long f_offset,
struct vnode *v;
int err, retval = 0;
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
if (sender != PAGER_TID) {
retval = -EINVAL;
goto out;
@@ -370,6 +376,7 @@ int pager_update_stats(l4id_t sender, unsigned long vnum,
struct vnode *v;
int retval = 0;
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
if (sender != PAGER_TID) {
retval = -EINVAL;
goto out;
@@ -402,6 +409,7 @@ int pager_sys_write(l4id_t sender, unsigned long vnum, unsigned long f_offset,
struct vnode *v;
int err, retval = 0;
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
if (sender != PAGER_TID) {
retval = -EINVAL;
goto out;
@@ -419,6 +427,9 @@ int pager_sys_write(l4id_t sender, unsigned long vnum, unsigned long f_offset,
goto out;
}
printf("%s/%s: Writing to vnode %lu, at pgoff 0x%x, %d pages, buf at 0x%x\n",
__TASKNAME__, __FUNCTION__, vnum, f_offset, npages, pagebuf);
/*
* If the file is extended, write silently extends it.
* But we expect an explicit pager_update_stats from the
@@ -430,7 +441,9 @@ int pager_sys_write(l4id_t sender, unsigned long vnum, unsigned long f_offset,
}
out:
printf("%s/%s: Returning ipc result.\n", __TASKNAME__, __FUNCTION__);
l4_ipc_return(retval);
printf("%s/%s: Done.\n", __TASKNAME__, __FUNCTION__);
return 0;
}
@@ -482,6 +495,7 @@ int sys_readdir(l4id_t sender, int fd, void *buf, int count)
struct dentry *d;
struct tcb *t;
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
/* Get the task */
BUG_ON(!(t = find_task(sender)));

View File

@@ -55,6 +55,8 @@ int vfs_read(unsigned long vnum, unsigned long file_offset,
{
int err;
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
l4_save_ipcregs();
write_mr(L4SYS_ARG0, vnum);
@@ -90,6 +92,8 @@ int vfs_receive_sys_open(l4id_t sender, l4id_t opener, int fd,
struct vm_file *vmfile;
struct tcb *t;
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
/* Check argument validity */
if (sender != VFS_TID) {
l4_ipc_return(-EPERM);
@@ -214,6 +218,7 @@ int vfs_write(unsigned long vnum, unsigned long file_offset,
{
int err;
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
l4_save_ipcregs();
write_mr(L4SYS_ARG0, vnum);
@@ -241,6 +246,7 @@ int vfs_close(l4id_t sender, int fd)
{
int err;
printf("%s/%s Sending to %d\n", __TASKNAME__, __FUNCTION__, VFS_TID);
l4_save_ipcregs();
write_mr(L4SYS_ARG0, sender);
@@ -250,6 +256,7 @@ int vfs_close(l4id_t sender, int fd)
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
return err;
}
printf("%s/%s Received from %d\n", __TASKNAME__, __FUNCTION__, VFS_TID);
/* Check if syscall was successful */
if ((err = l4_get_retval()) < 0) {
@@ -267,6 +274,7 @@ int vfs_update_file_stats(struct vm_file *f)
{
int err;
printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
l4_save_ipcregs();
write_mr(L4SYS_ARG0, vm_file_to_vnum(f));
@@ -373,7 +381,7 @@ int sys_close(l4id_t sender, int fd)
l4_ipc_return(retval);
return 0;
}
/* Close the file descriptor. */
retval = fd_close(sender, fd);
printf("%s: Closed fd %d. Returning %d\n",
@@ -454,6 +462,7 @@ copy:
copy_offset = (unsigned long)buf;
page_copy(head, task_virt_to_page(task, copy_offset),
cursor_offset, copy_offset & PAGE_MASK, copysize);
head->flags |= VM_DIRTY;
left -= copysize;
last_pgoff = head->offset;
@@ -473,6 +482,7 @@ copy:
page_copy(this, task_virt_to_page(task, copy_offset),
0, 0, copysize);
this->flags |= VM_DIRTY;
left -= copysize;
last_pgoff = this->offset;
}

View File

@@ -84,9 +84,15 @@ int file_page_out(struct vm_object *vm_obj, unsigned long page_offset)
if (!(page->flags & VM_DIRTY))
return 0;
paddr = (void *)page_to_phys(page);
vaddr = phys_to_virt(paddr);
/* Map the page to vfs task */
l4_map(paddr, vaddr, 1, MAP_USR_RW_FLAGS, VFS_TID);
printf("%s/%s: Writing to vnode %d, at pgoff 0x%x, %d pages, buf at 0x%x\n",
__TASKNAME__, __FUNCTION__, vm_file_to_vnum(f), page_offset, 1, vaddr);
/* Syscall to vfs to write page back to file. */
if ((err = vfs_write(vm_file_to_vnum(f), page_offset, 1, vaddr)) < 0)
goto out_err;

View File

@@ -21,7 +21,7 @@ int fileio2(void)
perror("OPEN");
return -1;
}
printf("Created newfile.txt\n");
printf("Created newfile2.txt\n");
printf("%s: write.\n", __TASKNAME__);
if ((int)(cnt = write(fd, str, strlen(str))) < 0) {