Kernel Newbies archive on
 help / color / Atom feed
From: Bharath Vedartham <>
To: Martin Galvan <>
Subject: Re: Setting CPU affinity for current process on kernel module?
Date: Thu, 12 Sep 2019 00:46:57 +0530
Message-ID: <20190911191657.GA11969@bharath12345-Inspiron-5559> (raw)
In-Reply-To: <>

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
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...


Kernelnewbies mailing list

  reply index

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-11 18:52 Martin Galvan
2019-09-11 19:16 ` Bharath Vedartham [this message]
2019-09-11 19:19   ` Martin Galvan
2019-09-12  9:26     ` Bharath Vedartham
2019-09-12 14:03       ` Martin Galvan
2019-09-13  4:50         ` Greg KH
2019-09-13 12:43           ` Martin Galvan
2019-09-13 12:55             ` Greg KH
2019-09-13 12:56               ` Martin Galvan
2019-09-13 14:13                 ` Greg KH

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190911191657.GA11969@bharath12345-Inspiron-5559 \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Kernel Newbies archive on

Archives are clonable:
	git clone --mirror kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ \
	public-inbox-index kernelnewbies

Newsgroup available over NNTP:

AGPL code for this site: git clone public-inbox