linux-kernellinux-device-driverbinary-datasysfs

Making available medium-sized (>4K) binary information from Linux kernel to userland


According to this answer Linux sysfs entries are limited to a page, which is 4 KiB on most architectures.

I’m currently working on a net/sched/ module (a fork of fq_codel with slightly changed behaviour to test something) and need to expose largish statistics to userspace. One of the KPIs is about 800 bytes, the other is expected to be 10–50 KiB or so (back-of-the-envelope, not fixed yet). The latter obviously won’t fit into sysfs.

The information is generated during operation but stored into a preallocated array, and userspace is expected to fetch it (and thus empty the array) twice per second or so. Raising that interval might be possible but increase system load by quite some amount.

What other ways of exposing such information to userspace exist that would fit my scenario?


Solution

  • How about relay interface (/Documentation/filesystems/relay.txt) to log large quantities of data from the kernelto userspace