From: Thomas Gleixner <tglx@linutronix.de>
To: Frederic Weisbecker <frederic@kernel.org>
Cc: 朱恺乾 <zhukaiqian@xiaomi.com>,
"Daniel Lezcano" <daniel.lezcano@linaro.org>,
张嘉伟 <zhangjiawei8@xiaomi.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
王韬 <lingyue@xiaomi.com>, 熊亮 <xiongliang@xiaomi.com>,
"isaacmanjarres@google.com" <isaacmanjarres@google.com>,
"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
梁伟鹏 <weipengliang@xiaomi.com>, 翁金飞 <wengjinfei@xiaomi.com>
Subject: Re: [PATCH] tick/broadcast: Plug clockevents replacement race
Date: Sat, 05 Sep 2026 22:54:17 +0200 [thread overview]
Message-ID: <87qzj74dxi.ffs@fw13> (raw)
In-Reply-To: <ZxE4U0YzXAY9RPOp@pavilion.home>
On Thu, Oct 17 2024 at 18:16, Frederic Weisbecker wrote:
> Le Mon, Aug 12, 2024 at 04:19:48PM +0200, Thomas Gleixner a écrit :
>> 朱恺乾 reported and decoded the following race condition when a broadcast
>> device is replaced:
>>
>> CPUA CPUB
>> __tick_broadcast_oneshot_control()
>> bc = tick_broadcast_device.evtdev;
>> tick_install_broadcast_device(dev)
>> clockevents_exchange_device(cur, dev)
>> shutdown(cur);
>> detach(cur);
>> cur->handler = noop;
>> tick_broadcast_device.evtdev = dev;
>>
>> tick_broadcast_set_event(bc, next_event); <- FAIL: arms a detached device.
>>
>> If the original broadcast device has a restricted interrupt affinity mask
>> and the last CPU in that mask goes offline then the BUG() in
>> tick_cleanup_dead_cpu() triggers because the clockevent device is not in
>> detached state.
>>
>> The reason for this is that tick_install_broadcast_device() is not
>> serialized vs. tick broadcast operations.
>>
>> The obvious cure is to serialize tick_install_broadcast_device() with
>> tick_broadcast_lock against a concurrent tick broadcast operation.
>>
>> That requires to split clockevents_exchange_device() into two parts, one
>> which does the exchange, shutdown and detach operation and the other which
>> drops the module reference count. This is required because the module
>> reference cannot be dropped while holding tick_broadcast_lock.
>
> The reason why the module reference can not be dropped while holding
> tick_broadcast_lock is not obvious though. What can go wrong?
tick_broadcast_lock() is a raw_spinlock and deeply nested ...
next prev parent reply other threads:[~2026-09-05 20:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <042520850d394f0bb0004a226db63d0d@xiaomi.com>
2024-06-27 11:26 ` Race condition when replacing the broadcast timer Thomas Gleixner
2024-06-28 1:59 ` [External Mail]Re: " 朱恺乾
2024-06-28 7:22 ` Daniel Lezcano
2024-07-01 2:11 ` 朱恺乾
2024-07-10 20:30 ` Thomas Gleixner
2024-07-29 11:44 ` Thomas Gleixner
2024-08-12 14:19 ` [PATCH] tick/broadcast: Plug clockevents replacement race Thomas Gleixner
2024-09-25 9:45 ` Anna-Maria Behnsen
2024-10-17 16:16 ` Frederic Weisbecker
2026-09-05 20:54 ` Thomas Gleixner [this message]
2026-08-28 9:08 ` 回复: [External Mail][PATCH] " 刘术高
2026-09-03 6:33 ` 刘术高
2026-09-03 15:12 ` Bradley Morgan
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=87qzj74dxi.ffs@fw13 \
--to=tglx@linutronix.de \
--cc=anna-maria@linutronix.de \
--cc=daniel.lezcano@linaro.org \
--cc=frederic@kernel.org \
--cc=isaacmanjarres@google.com \
--cc=lingyue@xiaomi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=weipengliang@xiaomi.com \
--cc=wengjinfei@xiaomi.com \
--cc=xiongliang@xiaomi.com \
--cc=zhangjiawei8@xiaomi.com \
--cc=zhukaiqian@xiaomi.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
all inboxes | Powered by JetHome®