Reputation: 5911
I am trying to record a huge data output from the kernel. Essentially I am trying to log all how processes context switches in a kernel. For even a 1min of profiling the data recorded will be huge, How can I do this.I have to open a huge buffer, record the data in it, and then send it to user-space for further analysis.
EDIT: To clarify how big is "BIG" below is the exact problem I am trying to solve its roughly about 10000 lines of output
Upvotes: 4
Views: 190
Reputation: 2049
Well, the "standard" way to export such a lot of data is using debugfs. You can take a look at how ftrace (kernel/trace/ftrace.c) does this.
And, for even more data, you can use relayfs interface (kernel/relay.c). You can take a look at how blktrace (kernel/trace/blktrace.c) does this.
Upvotes: 0
Reputation: 33655
My suggestion is to use the same idea used by the linux kernel for capturing packets, specifically the packet ring buffer (search: PACKET_RX_RING).
The idea is quite simple, in your user space program, allocate the ring. Then pass this ring to the "driver" (your kernel module), then your driver can simply write the data points to the ring, and your user space program can read these off. Because it's a ring, you can simply continue writing and the client can continue to read - if the client falls behind, there is a chance that your driver may over take (once it's been around the ring), but I'm sure you can size the ring appropriately.
Each slot in the ring should contain your "serialized" data which the user space program can simply read off. This type of ring should be fairly easy to implement lock free, and most likely you want your client to spin to see if there is data.
Upvotes: 6