LinuxPPC-Dev Archive on lore.kernel.org
 help / color / Atom feed
From: Don Zickus <dzickus@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	ppc-dev <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [RFC GIT Pull] core watchdog sanitizing
Date: Mon, 2 Oct 2017 16:32:09 -0400
Message-ID: <20171002203209.rjug625pfmgh674j@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1710022105570.2114@nanos>

On Mon, Oct 02, 2017 at 07:32:57PM +0000, Thomas Gleixner wrote:
> On Mon, 2 Oct 2017, Linus Torvalds wrote:
> > Side note: would it perhaps make sense to have that
> > cpus_read_lock/unlock() sequence around the whole reconfiguration
> > section?
> > 
> > Because while looking at that sequence, it looks a bit odd to me that
> > cpu's can come and go in the middle of the nmi watchdog
> > reconfiguration sequence.
> > 
> > In particular, what happens if a new CPU is brought up just as the NMI
> > matchdog is being reconfigured? The NMI's have been stopped for the
> > old CPU's, what happens for the new one that came up in between that
> > watchdog_nmi_stop/start?
> > 
> > This may be all obviously safe, I'm just asking for clarification.
> 
> It's safe because the newly upcoming CPU will see an empty enabled mask in
> the powerpc implementation. The perf based implementation has a similar
> protection.
> 
> Though yes, it would be more obvious to expand the cpus locked
> section. That requires a bit of shuffling. Untested patch below.
> 
> Thanks,
> 
> 	tglx
> 
> 8<------------------
> 
> --- a/arch/powerpc/kernel/watchdog.c
> +++ b/arch/powerpc/kernel/watchdog.c
> @@ -359,21 +359,17 @@ void watchdog_nmi_stop(void)
>  {
>  	int cpu;
>  
> -	cpus_read_lock();
>  	for_each_cpu(cpu, &wd_cpus_enabled)
>  		stop_wd_on_cpu(cpu);
> -	cpus_read_unlock();
>  }
>  
>  void watchdog_nmi_start(void)
>  {
>  	int cpu;
>  
> -	cpus_read_lock();
>  	watchdog_calc_timeouts();
>  	for_each_cpu_and(cpu, cpu_online_mask, &watchdog_cpumask)
>  		start_wd_on_cpu(cpu);
> -	cpus_read_unlock();
>  }
>  
>  /*
> --- a/kernel/smpboot.c
> +++ b/kernel/smpboot.c
> @@ -351,7 +351,7 @@ void smpboot_update_cpumask_percpu_threa
>  	static struct cpumask tmp;
>  	unsigned int cpu;
>  
> -	get_online_cpus();
> +	lockdep_assert_cpus_held();
>  	mutex_lock(&smpboot_threads_lock);
>  
>  	/* Park threads that were exclusively enabled on the old mask. */
> @@ -367,7 +367,6 @@ void smpboot_update_cpumask_percpu_threa
>  	cpumask_copy(old, new);
>  
>  	mutex_unlock(&smpboot_threads_lock);
> -	put_online_cpus();
>  }
>  
>  static DEFINE_PER_CPU(atomic_t, cpu_hotplug_state) = ATOMIC_INIT(CPU_POST_DEAD);
> --- a/kernel/watchdog.c
> +++ b/kernel/watchdog.c
> @@ -535,7 +535,6 @@ static void softlockup_update_smpboot_th
>  
>  	smpboot_update_cpumask_percpu_thread(&watchdog_threads,
>  					     &watchdog_allowed_mask);
> -	__lockup_detector_cleanup();
>  }
>  
>  /* Temporarily park all watchdog threads */
> @@ -554,6 +553,7 @@ static void softlockup_unpark_threads(vo
>  
>  static void softlockup_reconfigure_threads(void)

There is a second copy of ^^^^, you will need to add identical locking there
too.

I can test both of these patches tomorrow.

Cheers,
Don

>  {
> +	cpus_read_lock();
>  	watchdog_nmi_stop();
>  	softlockup_park_all_threads();
>  	set_sample_period();
> @@ -561,6 +561,12 @@ static void softlockup_reconfigure_threa
>  	if (watchdog_enabled && watchdog_thresh)
>  		softlockup_unpark_threads();
>  	watchdog_nmi_start();
> +	cpus_read_unlock();
> +	/*
> +	 * Must be called outside the cpus locked section to prevent
> +	 * recursive locking in the perf code.
> +	 */
> +	__lockup_detector_cleanup();
>  }
>  
>  /*
> 

  reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <alpine.DEB.2.20.1710011217510.3874@nanos>
     [not found] ` <CA+55aFxQsmSb=zohGZOZK7eR4n5xOHNArmCa9j1b7+wJ+khQrg@mail.gmail.com>
2017-10-02 18:46   ` Thomas Gleixner
2017-10-02 19:04     ` Linus Torvalds
2017-10-02 19:32       ` Thomas Gleixner
2017-10-02 20:32         ` Don Zickus [this message]
2017-10-02 20:45           ` 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=20171002203209.rjug625pfmgh674j@redhat.com \
    --to=dzickus@redhat.com \
    --cc=benh@kernel.crashing.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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

LinuxPPC-Dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linuxppc-dev/0 linuxppc-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linuxppc-dev linuxppc-dev/ https://lore.kernel.org/linuxppc-dev \
		linuxppc-dev@lists.ozlabs.org linuxppc-dev@ozlabs.org
	public-inbox-index linuxppc-dev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.ozlabs.lists.linuxppc-dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git