Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Dec 2007 12:52:54 +0100
From:      "Gerald Heinig" <gheinig@marvell.com>
To:        "Jeremy Chadwick" <koitsu@FreeBSD.org>
Cc:        freebsd-hackers@freebsd.org, Sonja Milicic <tanarri@geri.cc.fer.hr>
Subject:   RE: Large array in KVM
Message-ID:  <4D634BCFD1A2144ABECC75FF512D7A9001DF60C0@SKGExch01.marvell.com>

next in thread | raw e-mail | index | archive | help
> 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.
>=20
> Somewhat related question:
>=20
> 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:
>=20
> 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.
>=20
> 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?
>=20
> 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.
>=20
> 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.  :-)

I've only ever written device drivers; I haven't yet implemented a
system call so unfortunately I can't answer your questions, sorry.
I do know that system calls have to deal with the possibility of pages
being non-resident, and this prompted my suggestions above.

Cheers,
Gerald



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4D634BCFD1A2144ABECC75FF512D7A9001DF60C0>