ksyms pseudo driver

Kostik Belousov kostikbel at gmail.com
Tue Jul 15 09:34:10 UTC 2008

On Sun, Jul 13, 2008 at 11:22:55PM -0500, Stacey Son wrote:
> Kostik Belousov wrote:
> >Most likely, I miss some obvious reason there. But for me it looks
> >like you do it in the reverse. The natural setup would be to require
> >userspace to supply an allocated memory to the driver, and then the
> >driver fills the memory with symbol table. This solves the problem of
> >exhaustion of kernel address space.
> >   
> The snapshot of the consolidated symbol table is made when /dev/ksyms is 
> opened.   The storage for the snapshot is allocated in the memory map of 
> the calling process.  No kernel address space is used for the snapshot.
Again, why this is done this way ? Why not creating snapshot when the
user process issues ioctl that supplies neccessary usermode memory
to the driver ?

> A temporary buffer is allocated in kernel space in the read() handler 
> (ksyms_read).    Right now, for a read, it does two copies:  one from 
> user space to the temporary kernel space buffer and a second copy from 
> the kernel space temp buffer and back out to user space.   Ideally, it 
> would be nice to do just one user space to user space copy directly in 
> the kernel.
> >As usual, when user-supplied region is too small, driver shall return
> >both an error and new required size. It is understandable that the size
> >is volatile and may be too small for the next call too. But, in fact,
> >kernel symtable does not change too often, so I think even the one
> >iteration mostly succeed.
> >   
> The reason the driver tries three times to create a valid snapshot is I 
> couldn't figure out a way (without creating a lock reversal) to 
> temporarily keep modules from being loaded or unloaded while the 
> snapshot is created.   I agree that it should be able to create the 
> snapshot on the first iteration in most cases.
> BTW, you may have noticed the ksyms driver now uses your per-open file 
> private data code which I like much better than using clone_create() for 
> per-descriptor storage.
Does it work ? Do you have any suggestions for the KPI ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20080715/1c3319e6/attachment.pgp

More information about the freebsd-arch mailing list