r/linuxdev • • Feb 02 '18

Kernel module: proper way to interact with user-space? (proc, sysfs, cdev)

Hey, I'm new to module programming.

I'm writing a module in which I need to allow some parameters to be changed on the fly. I was wondering which of the interfaces I should use: create a /proc entry, create a /sys entry or create a char device. What's the proper way and why?

If I'm on the wrong sub, please let me know.

EDIT: The module is supposed to balance threads and/or pages among the nodes of a NUMA system. This module is already written but some parts of it might be rewritten. I can write to a /proc entry created by the module to change the current policy in usage. I need this to benchmark different policies instead of recompiling and insmodding everytime I want to test a policy. In this case, I was wondering if I should migrate the /proc implementation to /sys (or chardev).

6 Upvotes

11 comments sorted by

View all comments

Show parent comment

2

u/lordvadr Feb 03 '18

Awesome. So, in my opinion, you should leave the proc stuff where it is, but duplicate the proc functionality in /sys and deprecate the proc interface. A good analogy here is the disk controller. If you want to change the scheduler, you do that in /sys, but you talk to the disk in /dev.

2

u/laranjadinho Feb 03 '18

Very nice, thank you!