filemap feature 2.4.22-5um
Quoted 1 line · Jeff Dike
Why so pessimistic? I like filemap - IIRC, i suggested it.
Yeah, but finding the right interface to express it is tough. I don't even want to go in the whole *in* OS_ layer/*above* os_* layer argument again. :)
I am also thinking that the filemap database should be generalized so that
any translation can be supported - like an "xlate" table that can map Unix filenames to DOS filenames...
Quoted 2 lines
I'd also like people to use this to see what's missing, if anything, and to get any improvements on the command line syntax.
Just so SKAS users don't feel left out, I've attached a small patch that adds a "mm" table to filemap for chrooted SKAS mode operation. Just apply it after the first patch.
The following example shows how to use this patch to set up a chrooted SKAS UML with 20 available process slots:
chroot /home/uml /linux mem=32M filemap=mm,30-49 \
30>/proc/mm 31>/proc/mm 32>/proc/mm 33>/proc/mm 34>/proc/mm \
35>/proc/mm 36>/proc/mm 37>/proc/mm 38>/proc/mm 39>/proc/mm \
40>/proc/mm 41>/proc/mm 42>/proc/mm 43>/proc/mm 44>/proc/mm \
45>/proc/mm 46>/proc/mm 47>/proc/mm 48>/proc/mm 49>/proc/mm \
filemap=file,25,/proc/mm 25>/proc/mm \
filemap=vm,20 20<>/dev/shm/vm-$$.0 con=null con0=fd:0,fd:1
Note the dummy "file" table entry for /proc/mm. This is needed so the boot test for /proc/mm succeeds.
ISSUE: The UML will panic if it runs out of /proc/mm fds. ISSUE: What side effects does re-using an address space have? TODO: Make the filemap lookup routine re-entrant safe.
Comments? Concerns?
Steve Schmidtke
_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail
arch/um/kernel/filemap.c +5 -0
@@ -502,6 +502,11 @@ .entries = NULL, .ops = &fm_ops_pool, }, + { + .name = "mm", + .entries = NULL, + .ops = &fm_ops_pool, + }, };static struct filemap_table *filemap_get_table (const char * table_name)
arch/um/kernel/skas/process.c +18 -1
@@ -27,6 +27,8 @@#include "skas_ptrace.h" #include "chan_user.h" +#include "filemap.h" +int is_skas_winch (int pid,int fd,void *data) {if (pid !=getpid ())
@@ -340,12 +342,27 @@ int new_mm(int from) { struct proc_mm_op copy; - int n, fd = os_open_file("/proc/mm", + int n, fd; + + /* use the raw access since /proc/mm opens a new file every time */ + fd = filemap_access("mm", "/proc/mm"); + if(fd >= 0) { + printk("filemap aquire: fd=%d, file=%s\n", fd, "/proc/mm"); + goto handle_fd; + } + + /* if /proc/mm exists, the same fd would be returned over and over */ + if(filemap_access("file", "/proc/mm") >= 0) { + return(-1); + } + + fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0); if(fd < 0) return(fd); +handle_fd: if(from != -1){ copy = ((struct proc_mm_op) { .op = MM_COPY_SEGMENTS, .u =
arch/um/kernel/skas/mmu.c +9 -0
@@ -21,14 +21,23 @@ mm->context.skas.mm_fd =new_mm (from); if(mm->context.skas.mm_fd < 0) +#if 1 panic ("init_new_context_skas - new_mm failed, errno = %d\n" , mm->context.skas.mm_fd); +#else /* DON'T PANIC */ +return (mm->context.skas.mm_fd); +#endif return (0 ); }void destroy_context_skas (struct mm_struct *mm) { +/* filemapped files will return something other than -ENOENT */ +if (filemap_release ("mm" , mm->context.skas.mm_fd) != -ENOENT ) { +return ; + } +os_close_file (mm->context.skas.mm_fd); }
Quoted 1 line
ISSUE: The UML will panic if it runs out of
/proc/mmfds.
returning -ENOMEM for example triggers the oom-killer in my tests. and thats not what we want.
Quoted 1 line
ISSUE: What side effects does re-using an address space have?
it's slow, but should work:
you need to cleanup (unmap all pages or reopen the fd) an dirty address space before switching it if the mm differs.
the pager will map you all pages you need on demand.
i tested this by removing the premapping (removed the mmap() and mprotect() calls in fix_range()), but it's much slower.
access to userspace is always safe in skas-mode.
alex
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. SourceForge.net hosts over 70,000 Open Source Projects. See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 1 line · [email protected] said:
ISSUE: The UML will panic if it runs out of
/proc/mmfds.
This won't be an issue with the skas4 patch, which uses a system call to get new address spaces.
Quoted 1 line
TODO: Make the filemap lookup routine re-entrant safe.
Before you go wild with locking, look at the callers and see if they are re-entrant. This obviously won't work for things that are called from all over the place, but if something is called from one place that is itself locked, then you don't need to worry about it.
Jeff
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. SourceForge.net hosts over 70,000 Open Source Projects. See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel