From: Sven Schnelle <svens@linux.ibm.com>
To: Tejun Heo <tj@kernel.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>,
linux-kernel@vger.kernel.org, Heiko Carstens <hca@linux.ibm.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] workqueue: fix selection of wake_cpu in kick_pool()
Date: Fri, 19 Apr 2024 10:27:05 +0200 [thread overview]
Message-ID: <yt9dzftp3gh2.fsf@linux.ibm.com> (raw)
In-Reply-To: <ZiB9rYBu-0qjsCbF@slm.duckdns.org> (Tejun Heo's message of "Wed, 17 Apr 2024 15:55:57 -1000")
Hi Tejun,
Tejun Heo <tj@kernel.org> writes:
> On Wed, Apr 17, 2024 at 05:36:38PM +0200, Sven Schnelle wrote:
>> > This generally seems like a good idea but isn't this still racy? The CPU may
>> > go down between setting p->wake_cpu and wake_up_process().
>>
>> Don't know without reading the source, but how does this code normally
>> protect against that?
>
> Probably by wrapping determining the wake_cpu and the wake_up inside
> cpu_read_lock() section.
Do you mean rcu_read_lock()? cpus_read_lock() takes a mutex, and the
crash happens in softirq context - so cpus_read_lock() can't be the
correct lock.
If i read the code correctly, cpu hotplug uses stop_machine_cpuslocked()
- so rcu_read_lock() should be sufficient for non-atomic context.
Looking at the backtrace the crash is actually happening in
arch_vpu_is_preempted(). I don't know the semantics of that function,
whether it is ok to call it for offline CPUs, or whether the calling
code should make sure that the cpu is online (which would be my guess).
Following the backtrace from my initial mail, I can't find a place where
a check is done whether p->wake_cpu is actually online. Eventually
available_idle_cpu() is calling vcpu_is_preempted(). I wonder whether
available_idle_cpu() should do a cpu_online() check right at the
beginning?
Adding Peter to CC, he probably knows.
Thanks,
Sven
next prev parent reply other threads:[~2024-04-19 8:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-15 5:35 [PATCH] workqueue: fix selection of wake_cpu in kick_pool() Sven Schnelle
2024-04-16 23:06 ` Tejun Heo
2024-04-17 15:36 ` Sven Schnelle
2024-04-18 1:55 ` Tejun Heo
2024-04-18 5:54 ` Sven Schnelle
2024-04-18 15:56 ` Tejun Heo
2024-04-19 8:27 ` Sven Schnelle [this message]
2024-04-19 15:40 ` Tejun Heo
2024-04-22 22:44 ` Tejun Heo
2024-04-23 6:20 ` Sven Schnelle
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=yt9dzftp3gh2.fsf@linux.ibm.com \
--to=svens@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tj@kernel.org \
/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