kernelspace -> userspace communication
aoiko at cc.ece.ntua.gr
Mon Jun 4 12:39:31 PDT 2007
On Monday 04 June 2007, Matthew Dillon wrote:
> :I'd like to move some trivial kernel stats to userspace for further
> :examination. ktr seems ok for small amounts of data gathered in a small
> : time period. Periodically running ktrdump (polling the ktr indexes and
> : using the timestamps to know when you've missed any events) would
> : probably work, but it's a rather dumb solution. Am I missing some other
> : mechanism?
> KTR is the best way to log realtime data.
Yes, but I only want to log some data on thread exit, I'm just using ktr to
pass it to userspace because I couldn't find a simpler way.
> The kernel just maintains a per-cpu memory buffer and operates it like
> a FIFO, with a revovling read and write index. There is nothing
> preventing ktrdump from sticking around and polling the FIFO for
> new events, then only reporting the new information.
Polling is, well, ugly. In my case it makes no real difference, but in the
future, it would be nice to have a way to move large amounts of data (for
profiling, say) to userspace. Maybe a special device interface (that would
allow blocking) to the ktr buffers or something custom made. Well, if I ever
have a need for that I'll ask again about what people think.
BTW, do you think moving the tsc-specific bits in kern_ktr.c to platform/
would be worthwhile? (I'm not volunteering to do it now, just asking for
> It would take maybe an hour for a good programmer to modify ktrdump to
> do that. It isn't difficult at all. I eagerly away your patch! :-)
Is this the part where I'm supposed to present a patch and claim "It only took
me twenty minutes"? :-) Actually, I was looking into modifying ktrdump when I
stopped ("Wait. ktr wasn't designed for this, there must be a better way")
and sent the previous mail. I'll try and do it sometime in the next few days.
More information about the Kernel