From: "Mateusz Jończyk" <mat.jonczyk@o2.pl>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>,
linux-rtc@vger.kernel.org,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
lkml <linux-kernel@vger.kernel.org>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Chris Bainbridge <chris.bainbridge@gmail.com>
Subject: Re: [PATCH] timekeeping: Add a lockdep override in tick_freeze().
Date: Fri, 4 Apr 2025 20:47:42 +0200 [thread overview]
Message-ID: <dab534b6-d83b-40de-b6d0-77c40350627d@o2.pl> (raw)
In-Reply-To: <20250404133429.pnAzf-eF@linutronix.de>
W dniu 4.04.2025 o 15:34, Sebastian Andrzej Siewior pisze:
> tick_freeze() acquires a raw_spinlock_t (tick_freeze_lock). Later in the
> callchain (timekeeping_suspend() -> mc146818_avoid_UIP()) the RTC driver
> can acquire a spinlock_t which becomes a sleeping lock on PREEMPT_RT.
> Lockdep complains about this lock nesting.
>
> Add a lockdep override for this special case and a comment explaining
> why it is okay.
>
> Reported-by: Borislav Petkov <bp@alien8.de>
> Closes: https://lore.kernel.org/all/20250330113202.GAZ-krsjAnurOlTcp-@fat_crate.local/
> Reported-by: Chris Bainbridge <chris.bainbridge@gmail.com>
> Closes: https://lore.kernel.org/all/CAP-bSRZ0CWyZZsMtx046YV8L28LhY0fson2g4EqcwRAVN1Jk+Q@mail.gmail.com/
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> kernel/time/tick-common.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
> index a47bcf71defcf..8fd8e2ee09fa1 100644
> --- a/kernel/time/tick-common.c
> +++ b/kernel/time/tick-common.c
> @@ -509,6 +509,7 @@ void tick_resume(void)
>
> #ifdef CONFIG_SUSPEND
> static DEFINE_RAW_SPINLOCK(tick_freeze_lock);
> +static DEFINE_WAIT_OVERRIDE_MAP(tick_freeze_map, LD_WAIT_SLEEP);
> static unsigned int tick_freeze_depth;
>
> /**
> @@ -528,9 +529,20 @@ void tick_freeze(void)
> if (tick_freeze_depth == num_online_cpus()) {
> trace_suspend_resume(TPS("timekeeping_freeze"),
> smp_processor_id(), true);
> + /*
> + * All other CPUs have their interrupts disabled and are
> + * suspended to idle. Other tasks have been frozen so there is
> + * no scheduling happening. This means that there is no
> + * concurrency in the system at this point. Therefore it is okay
> + * to acquire a sleeping lock on PREEMPT_RT, such as spinlock_t,
> + * because the lock can not be acquired and can not block.
because the lock cannot be held by other CPUs / threads and
acquiring it cannot block.
> + * Inform lockdep about the situation.
> + */
Greetings,
Mateusz
next prev parent reply other threads:[~2025-04-04 18:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-30 11:32 [ BUG: Invalid wait context ] rtc_lock at: mc146818_avoid_UIP Borislav Petkov
2025-03-30 12:23 ` Mateusz Jończyk
2025-03-30 12:32 ` Mateusz Jończyk
2025-04-03 13:12 ` Thomas Gleixner
2025-04-03 13:50 ` Sebastian Andrzej Siewior
2025-04-03 19:36 ` Sebastian Andrzej Siewior
2025-04-03 20:26 ` Thomas Gleixner
2025-04-04 6:16 ` Sebastian Andrzej Siewior
2025-04-04 13:34 ` [PATCH] timekeeping: Add a lockdep override in tick_freeze() Sebastian Andrzej Siewior
2025-04-04 18:47 ` Mateusz Jończyk [this message]
2025-04-09 19:13 ` Peter Zijlstra
2025-04-09 21:12 ` [tip: timers/urgent] " tip-bot2 for Sebastian Andrzej Siewior
2025-05-31 18:27 ` [PATCH] " Chris Bainbridge
2025-05-31 19:16 ` Chris Bainbridge
2025-06-02 19:52 ` Mateusz Jończyk
2025-06-02 20:20 ` [DRAFT PATCH] rtc-cmos: use spin_lock_irqsave in cmos_interrupt Mateusz Jończyk
2025-06-02 21:19 ` Chris Bainbridge
2025-06-03 6:47 ` Sebastian Andrzej Siewior
2025-04-03 23:46 ` [ BUG: Invalid wait context ] rtc_lock at: mc146818_avoid_UIP Mateusz Jończyk
2025-04-04 7:39 ` 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=dab534b6-d83b-40de-b6d0-77c40350627d@o2.pl \
--to=mat.jonczyk@o2.pl \
--cc=alexandre.belloni@bootlin.com \
--cc=anna-maria@linutronix.de \
--cc=bigeasy@linutronix.de \
--cc=bp@alien8.de \
--cc=chris.bainbridge@gmail.com \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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®