Setting CPU affinity for current process on kernel module?
Bharath Vedartham
linux.bhar at gmail.com
Wed Sep 11 15:16:57 EDT 2019
On Wed, Sep 11, 2019 at 03:52:06PM -0300, Martin Galvan wrote:
> Hi,
>
> I have a kernel module which needs to perform CPU core-specific
> operations. I know that there's a kernel mode version of
> sched_setaffinity, however it's not exported to modules and can only
> be accessed through e.g. kallsyms_lookup_name, which is ugly. The
> alternative is to spawn a new kthread and bind it to the desired CPU
> before starting it, but I was wondering if there's a more
> straightforward method of doing this. Thanks!
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
So one thing that pops to my head is using cgroups. Create a cgroup,
modify the cpu file in cpusets cgroup and add the required task to it.
But I am not sure whether you can do all of this from a kernel module...
Thanks
Bharath
More information about the Kernelnewbies
mailing list