From user-space we can use cpuset to actually isolate a specific core in our system and execute just one specific process to that core.
I'm trying to do the same thing with a kernel module. So I want the module to get executed in an isolated core. In other words: How do I use cpuset
's from inside a kernel module? *
Using linux/cpuset.h in my kernel module doesn't work. So, I have a module like this:
#include <linux/module.h>
#include <linux/cpuset.h>
...
#ifdef CONFIG_CPUSETS
printk(KERN_INFO, "cpusets is enabled!");
#endif
cpuset_init(); // this function is declared in cpuset.h
...
When trying to load this module I get (in dmesg
) the following message cpusets is enabled!
. But I also receive the message Unknown symbol cpu_init (err 0)
.
Similarly, I tried using sched_setaffinity
from linux/sched.h
in order to move all running procceses to a specific core and then run my module to an isolated core. I got the same error mesage: Unknown symbol sched_setaffinity (err 0)
. I guess I got the "unknown symbols" because those functions have no EXPORT_SYMBOL
in the kernel. So I went and tried to call the sys_sched_setaffinity
system call (based on this question) but again got this mesage: Unknown symbol sys_sched_setaffinity (err 0)
!
Furthermore, I am not looking for a solution that uses isolcpus
, which is set while booting. I would like to just load the module and afterwards the isolationo to occur.
- (More precise, I want its kernel threads to execute in isolated cores. I know that I can use affinity to bind threads to specific cores, but this does not guarantee me that the cores are going to be isolated by other processes running on them.)