Date: Sun, 13 Jul 2008 23:22:55 -0500 From: Stacey Son <sson@freebsd.org> To: Kostik Belousov <kostikbel@gmail.com> Cc: Andrew Gallatin <gallatin@cs.duke.edu>, freebsd-arch@freebsd.org Subject: Re: ksyms pseudo driver Message-ID: <487AD49F.6040304@freebsd.org> In-Reply-To: <20080712045837.GD17123@deviant.kiev.zoral.com.ua> References: <4875A5D2.8030902@freebsd.org> <20080711155232.A96384@grasshopper.cs.duke.edu> <48780661.5050002@freebsd.org> <20080712045837.GD17123@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
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. 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. Best Regards, -stacey.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?487AD49F.6040304>