On Fri, Dec 07, 2007 at 10:43:00AM +0100, Gerald Heinig wrote:
> Hi Sonja,
> 
> > Hi everyone.
> > 
> > I'm working on a kernel module that needs to maintain a large
> structure
> > in memory. As this structure could grow too big to be stored in
> memory,
> > it would be good to offload parts of it to the disk. What would be the
> > best way to do this? Could using a memory-mapped file help?
> 
> How about implementing your code as a system call, which is called from
> a process that maps a large file into memory, as you suggested above.
> I presume you'd have to handle the question of whether or not your pages
> are in memory yourself, ie. pretty much like any other system call.
> 
> Interesting question.

Somewhat related question:

What purpose does SYSCALL_MODULE(9) serve?  I attempted to use this last
month while writing a kernel module of my own, and was never able to get
it to work for (what understood to be) a couple different reasons:

1) There's a maximum # of syscalls permitted (see SYS_MAXSYSCALL in
include/sys/sycall.h), which means a dynamically-allocated syscall via
SYSCALL_MODULE(9) cannot be inserted into the syscalls list.

2) The example code in share/examples/kld/syscall/module/syscall.c
specifies the sysent offset as NO_SYSCALL (e.g. -1).  You can't pick an
arbitrary number here (from what I could tell), because the kernel
explicitly ensures that the syscall number being called is not larger
than SYS_MAXSYSCALL.  This forces you to "steal" a syscall number
between 1 and SYS_MAXSYSCALL, no?

3) I tried using a syscall number (115, deprecated vtrace), using it as
the offset when calling SYSCALL_MODULE, but the userland program calling
syscall(2) returned an error.  I didn't research this too thoroughly.

As this was the first (only?) kernel module I attempted to write, it's
safe to say I'm missing some key knowledge, hence my question.  :-)

-- 
| Jeremy Chadwick                                    jdc at parodius.com |
| Parodius Networking                           http://www.parodius.com/ |
| UNIX Systems Administrator                      Mountain View, CA, USA |
| Making life hard for others since 1977.                  PGP: 4BD6C0CB |

_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to