From: Tejun Heo <tj@kernel.org>
To: qiang.zhang@windriver.com
Cc: pmladek@suse.com, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] kthread_worker: re-set CPU affinities if CPU come online
Date: Mon, 26 Oct 2020 09:50:11 -0400 [thread overview]
Message-ID: <20201026135011.GC73258@mtj.duckdns.org> (raw)
In-Reply-To: <20201026065213.30477-1-qiang.zhang@windriver.com>
On Mon, Oct 26, 2020 at 02:52:13PM +0800, qiang.zhang@windriver.com wrote:
> @@ -737,8 +741,11 @@ __kthread_create_worker(int cpu, unsigned int flags,
> if (IS_ERR(task))
> goto fail_task;
>
> - if (cpu >= 0)
> + if (cpu >= 0) {
> kthread_bind(task, cpu);
> + worker->bind_cpu = cpu;
> + cpuhp_state_add_instance_nocalls(kworker_online, &worker->cpuhp_node);
> + }
>
> worker->flags = flags;
> worker->task = task;
...
> +static int kworker_cpu_online(unsigned int cpu, struct hlist_node *node)
> +{
> + struct kthread_worker *worker = hlist_entry(node, struct kthread_worker, cpuhp_node);
> + struct task_struct *task = worker->task;
> +
> + if (cpu == worker->bind_cpu)
> + WARN_ON_ONCE(set_cpus_allowed_ptr(task, cpumask_of(cpu)) < 0);
> + return 0;
> +}
I don't think this works. The kthread may have changed its binding while
running using set_cpus_allowed_ptr() as you're doing above. Besides, when a
cpu goes offline, the bound kthread can fall back to other cpus but its cpu
mask isn't cleared, is it?
Thanks.
--
tejun
next prev parent reply other threads:[~2020-10-26 13:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-26 6:52 [PATCH] kthread_worker: re-set CPU affinities if CPU come online qiang.zhang
2020-10-26 13:50 ` Tejun Heo [this message]
2020-10-26 16:45 ` Petr Mladek
2020-10-26 16:53 ` Tejun Heo
2020-10-27 16:39 ` Petr Mladek
2020-10-27 19:19 ` Thomas Gleixner
Reply instructions:
You may reply publicly 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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201026135011.GC73258@mtj.duckdns.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pmladek@suse.com \
--cc=qiang.zhang@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).