How to share linux kernel memory with userspace (read only)

user663896 picture user663896 · Nov 27, 2013 · Viewed 9.3k times · Source

I need to share about 100KiB of kernel memory to userspace. Userspace daemon will access this memory in read-only manner several (5-10) times a second. Does procfs is the best way for implementing it?

Answer

CKmum picture CKmum · Nov 29, 2013

kmalloc and vmalloc are the way to go.

But check these before proceeding: What is the difference between vmalloc and kmalloc?

mmap kernel buffer to user space

Allocating memory for user space from kernel thread

As already mentioned, procfs is poor way to share data. It is used for settings per se.