From: Frederic Weisbecker <frederic@kernel.org>
To: Victor Hassan <victor@allwinnertech.com>
Cc: fweisbec@gmail.com, tglx@linutronix.de, mingo@kernel.org,
jindong.yue@nxp.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tick/broadcast: Do not set oneshot_mask except was_periodic was true
Date: Tue, 4 Apr 2023 14:21:39 +0200 [thread overview]
Message-ID: <ZCwWUyUkcC9PZlij@lothringen> (raw)
In-Reply-To: <b187d221-228a-f032-8c93-16e148ec49ca@allwinnertech.com>
On Tue, Apr 04, 2023 at 07:37:06PM +0800, Victor Hassan wrote:
> >
> > Leading to such race:
> >
> > * CPU 1 stop its tick, next event is in one hour
> > * CPU 0 registers new broadcast and sets CPU 1 in tick_broadcast_oneshot_mask
> > * CPU 1 runs into cpuidle_enter_state(), and tick_broadcast_enter() is ignored because
> > the CPU is already in tick_broadcast_oneshot_mask
>
> Yes.
>
> > * CPU 1 goes to sleep
> > * CPU 0 runs the broadcast callback, sees that the next timer for CPU 1
> > is in one hour, program the broadcast to that deadline
> > * CPU 1 gets an interrupt that enqueues a new timer expiring in the next jiffy
> > * CPU 1 don't call tick_broadcast_exit and thus don't remove itself from
> > tick_broadcast_oneshot_mask
>
> I'm not sure about this... Actually, I believe CPU 1 *will* call
> tick_broadcast_exit in this condition because I cannot find a limitation on
> this execution path.
You're right, what I wrote doesn't make sense. Let me try again:
* CPU 1 stop its tick, next event is in one hour. It calls
tick_broadcast_enter() and goes to sleep.
* CPU 1 gets an interrupt that enqueues a new timer expiring in the next jiffy
(note it's not yet actually programmed in the tick device)
* CPU 1 call tick_broadcast_exit().
* CPU 0 registers new broadcast device and sets CPU 1 in tick_broadcast_oneshot_mask
* CPU 0 runs the broadcast callback, sees that the next timer for CPU 1
is in one hour (because the recently enqueued timer for CPU 1 hasn't been programmed
yet), so it programs the broadcast to that 1 hour deadline.
* CPU 1 runs tick_nohz_idle_stop_tick() which eventually writes and program
dev->next_event to next jiffy
* CPU 1 runs into cpuidle_enter_state(), and tick_broadcast_enter() is ignored because
the CPU is already in tick_broadcast_oneshot_mask, so the dev->next_event
change isn't propagated to broadcast.
* CPU 1 goes to sleep for 1 hour.
Does it make more sense? There might be more simple scenario of course.
Thanks.
next prev parent reply other threads:[~2023-04-04 12:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 6:36 [PATCH] tick/broadcast: Do not set oneshot_mask except was_periodic was true Victor Hassan
2023-03-31 1:46 ` Victor Hassan
2023-04-03 10:26 ` Frederic Weisbecker
2023-04-04 11:37 ` Victor Hassan
2023-04-04 12:21 ` Frederic Weisbecker [this message]
2023-04-07 6:51 ` Victor Hassan
2023-04-10 7:06 ` Victor Hassan
2023-04-11 8:55 ` Frederic Weisbecker
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=ZCwWUyUkcC9PZlij@lothringen \
--to=frederic@kernel.org \
--cc=fweisbec@gmail.com \
--cc=jindong.yue@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=victor@allwinnertech.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