This little bugger exists because of tmpfs. I have always wanted to create a virtual memory filesystem, like Solaris' tmpfs. Currently, doing this involves sticking your hands DEEP into the guts of the page cache, swap cache, and other nastiness. The main reason such nastiness is necessary, AFAICS, is that swappable pages are tied a process fairly closely. ie. current->mm is referenced quite a bit in the MM/swap code. For tmpfs and other uses the kernel may have for VM, we want driver<->VM association, not process<->VM association. So, I hacked up some code which allows kernel drivers to use swappable VM too. The main idea behind the hack is to create kernel threads, and associate MAP_ANONYMOUS mappings with those kernel threads, at the request of any random kernel driver. I think this hack makes it possible to use the page cache and swap cache as a general cache, without having to rewrite the MM subsystem or adding memory-pressure callbacks or stuff like that. It seems like filesystems would find kvmd most useful, but there are probably others uses for it as well. Attached is the kernel api (kvmd.h) and sample implementation for this idea (kvmd.c). The API can be summarized as kvmd_open - attach to a VM kernel thread kvmd_alloc - allocate some swappable memory (create new MAP_ANONYMOUS mapping) kvmd_map - fault a region of swappable memory into RAM, for subsequent access by kernel driver kvmd_unmap - release region locked into RAM by kvmd_map kvmd_free - release MAP_ANONYMOUS mapping kvmd_close - release attachment to VM kernel thread Random notes... * A thread pool is used to distribute the mappings, and in the process create a nicely parallel system * It would probably be nice to be able to expand and shrink mappings too. * It would be simple to expand the system to support apache-style min/max process thresholds Disclaimers... * The big disclaimer :) I am not am MM guru. This may not solve the problems described at all... * THE ATTACHED CODE EXISTS ONLY TO ILLUSTRATE A POINT. It was typed straight off-the-cuff, and I never even attempted to compile it. * the SMP locking may be off, and in some places it might be good to replace wait queue with semaphore Comments welcome... -- Jeff Garzik | Tact is the ability to tell a man Building 1024 | he has an open mind when he has a MandrakeSoft, Inc. | hole in his head. (-random fortune)