mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: akpm@linux-foundation.org
Cc: loberman@redhat.com, mhocko@suse.com, mingo@kernel.org,
	mm-commits@vger.kernel.org, pmladek@suse.com, tglx@linutronix.de,
	vincent.whitchurch@axis.com
Subject: Re: + watchdog-fix-barriers-when-printing-backtraces-from-all-cpus.patch added to -mm tree
Date: Tue, 16 Mar 2021 12:48:45 +0100	[thread overview]
Message-ID: <YFCbHVcvyyGFFp7g@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20210311212207.2aUhwqqUh%akpm@linux-foundation.org>

On Thu, Mar 11, 2021 at 01:22:07PM -0800, akpm@linux-foundation.org wrote:
> --- a/kernel/watchdog.c~watchdog-fix-barriers-when-printing-backtraces-from-all-cpus
> +++ a/kernel/watchdog.c
> @@ -409,12 +409,18 @@ static enum hrtimer_restart watchdog_tim
>  		if (kvm_check_and_clear_guest_paused())
>  			return HRTIMER_RESTART;
>  
> +		/*
> +		 * Prevent multiple soft-lockup reports if one cpu is already
> +		 * engaged in dumping all cpu back traces.
> +		 */
>  		if (softlockup_all_cpu_backtrace) {
> -			/* Prevent multiple soft-lockup reports if one cpu is already
> -			 * engaged in dumping cpu back traces
> -			 */
>  			if (test_and_set_bit(0, &soft_lockup_nmi_warn))
>  				return HRTIMER_RESTART;
> +			/*
> +			 * Make sure that reports are serialized. Start
> +			 * printing after getting the exclusive rights.
> +			 */
> +			smp_mb__after_atomic();

test_and_set_bit() is a value returning atomic and therefore already
implies a full smp_mb() on both ends.

>  		}
>  
>  		/* Start period for the next softlockup warning. */
> @@ -431,14 +437,14 @@ static enum hrtimer_restart watchdog_tim
>  			dump_stack();
>  
>  		if (softlockup_all_cpu_backtrace) {
> -			/* Avoid generating two back traces for current
> -			 * given that one is already made above
> -			 */
>  			trigger_allbutself_cpu_backtrace();
> -
> +			/*
> +			 * Make sure that everything is printed before
> +			 * another CPU is allowed to report lockup again.
> +			 */

This is not something smp_mb() ensures. smp_mb() is only concerned with
memory access ordering, not completion, and certainly not some random
IO.

IOW, that comment is complete bollocks.

> +			smp_mb__before_atomic();
> +			/* Allow a further report. */
>  			clear_bit(0, &soft_lockup_nmi_warn);


That said, this looks like a test-and-set lock and clear_bit unlock like
situation. In fact it doesn't seem to use anything other than bit0 of
that word.

FWIW we have test_and_set_bit_lock() / clear_bit_unlock().

  reply	other threads:[~2021-03-16 11:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11 21:22 + watchdog-fix-barriers-when-printing-backtraces-from-all-cpus.patch added to -mm tree akpm
2021-03-16 11:48 ` Peter Zijlstra [this message]
2021-03-17  9:14   ` Petr Mladek
2021-03-19 12:14     ` [PATCH] watchdog: Use bit lock operations to prevent multiple soft-lockup reports Petr Mladek
2021-03-19 12:29       ` Peter Zijlstra
2021-03-20 16:32       ` Andrew Morton
2021-03-22 13:41         ` Petr Mladek

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=YFCbHVcvyyGFFp7g@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loberman@redhat.com \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=tglx@linutronix.de \
    --cc=vincent.whitchurch@axis.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;
as well as URLs for NNTP newsgroup(s).