Configuring process affinity in kernel mode

How can I establish affinity for a processor in a kernel module? There is syscall in user mode sched_setaffinity, but I'm looking for the equivalent of kernel mode.

There is also a feature in the Linux kernel code sched_setaffinity. It is called from a function sys_sched_setaffinitythat is being called system_call. From what seems to be, this is the function I want to use. However, the fact that it has the same name as the system call makes me awkward.

But, as we all know, it's best to just try. So I did, and my module compiled. However, when I try to load the module, it complains that the name sched_setaffinityis undefined.

Any ideas?

+5
source share
1 answer

sched_setaffinity not exported to modules.

If you change /usr/src/linux/kernel/sched.c, you can call sched_setaffinityto export to modules.

 long sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
 {
...
 }
+EXPORT_SYMBOL_GPL(sched_setaffinity);
+2
source

All Articles