mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <jstultz@google.com>,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	Stephen Boyd <sboyd@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	x86@kernel.org
Subject: Re: [PATCH] clocksource: disable irq when holding watchdog_lock.
Date: Fri, 20 Oct 2023 11:02:45 +0200	[thread overview]
Message-ID: <20231020090245.cPAViz09@linutronix.de> (raw)
In-Reply-To: <878r826xys.ffs@tglx>

On 2023-10-16 23:47:55 [+0200], Thomas Gleixner wrote:
>   But the explicit local_irq_disable()/enable() pair around the readout
>   means that the patch above is obviously broken:
> 
>     spin_lock_irqsave(&watchdog_lock, flags);
>     cs_watchdog_read()
>       local_irq_disable();
>       ...
>       local_irq_enable();  <--- FAIL
> 
>   Lockdep should have yelled at that too, but even if it failed to do
>   so then it's still very obviously wrong.

Lockdep will shout from local_irq_enable() if the lock is still held.
That is working and I just verified it. However I didn't get to that
part in cs_watchdog_read() in my testing so that might be why lockdep
didn't complain in Tetsuo's case. After adding a irq-enable before the
unlock for lockdep-testing I did see the splat.

> Something like the uncompiled/untested below should cure it for real. It
> really does not matter whether the TSC unstable event happens a bit
> later. The system is unhappy no matter what.
The snippet below is perfect :)

> That said, this whole clocksource watchdog mess wants a proper
> overhaul. It has become a pile of warts and duct tape by now and after
> staring at it long enough there is no real reason to run it in a timer
> callback anymore. It just can move into delayed work and the whole
> locking problem can be reduced to the clocksource_mutex and some well
> thought out atomic operations to handle the mark unstable case. But
> that's a different story and not relevant for curing the problem at
> hand.

A pile of warts. Okay. This explains why the lock is acquired everywhere
with irqsave while in-IRQ access is not desired.

> Thanks,
> 
>         tglx

Sebastian

  parent reply	other threads:[~2023-10-20  9:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13 14:51 Tetsuo Handa
2023-10-16 17:46 ` John Stultz
2023-10-16 21:47   ` Thomas Gleixner
2023-10-16 23:03     ` Paul E. McKenney
2023-10-17  6:49       ` Thomas Gleixner
2023-10-17 14:11         ` Paul E. McKenney
2023-10-17 10:37     ` Tetsuo Handa
2023-10-17 14:10       ` Paul E. McKenney
2023-10-19  9:30         ` Tetsuo Handa
2023-10-19 12:14           ` Thomas Gleixner
2023-10-19 14:26             ` Tetsuo Handa
2023-10-20  3:30               ` Paul E. McKenney
2023-10-20 12:50                 ` Tetsuo Handa
2023-10-20 13:40                   ` Paul E. McKenney
2023-10-24 13:00               ` Thomas Gleixner
2023-10-24 14:52                 ` Tetsuo Handa
2023-10-25 21:28                   ` Thomas Gleixner
2023-10-25 21:31       ` [PATCH] x86/tsc: Defer marking TSC unstable to a worker Thomas Gleixner
2023-10-26  9:39         ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2023-10-27 18:46         ` tip-bot2 for Thomas Gleixner
2023-10-20  9:02     ` Sebastian Andrzej Siewior [this message]
2023-10-26  2:33 ` [PATCH] clocksource: disable irq when holding watchdog_lock kernel test robot

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=20231020090245.cPAViz09@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@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

all inboxes | Powered by JetHome®