All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: WARNING: possible circular locking dependency detected
Date: Thu, 31 Aug 2017 09:55:57 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1708310952490.1874@nanos> (raw)
In-Reply-To: <20170831073739.ytexc7omldyb5lgy@hirez.programming.kicks-ass.net>

On Thu, 31 Aug 2017, Peter Zijlstra wrote:
> On Thu, Aug 31, 2017 at 09:08:05AM +0200, Thomas Gleixner wrote:
> > On Wed, 30 Aug 2017, Peter Zijlstra wrote:
> > > On offline it basically does perf_event_disable() for all CPU context
> > > events, and then adds HOTPLUG_OFFSET (-32) to arrive at: OFF +
> > > HOTPLUG_OFFSET = -33.
> > > 
> > > That's smaller than ERROR and thus perf_event_enable() no-ops on events
> > > for offline CPUs (maybe we should try and plumb an error return for
> > > IOC_ENABLE).
> > > 
> > > On online we subtract the HOTPLUG_OFFSET again and the event becomes a
> > > regular OFF, after which perf_event_enable() should work again.
> > 
> > I haven't come around to test that as I was busy cleaning up the unholy
> > mess in the watchdog code.
> > 
> > One other thing I stumbled over is:
> > 
> >     perf_event_create()
> >       ....
> >       x86_hw_reserve(event)
> > 
> >       if (__x86_pmu_event_init(event) < 0)
> >       	    event->destroy(event);
> > 	    	x86_hw_release()
> > 		    ....
> > 		    cpus_read_lock();
> > 
> > If that happens from a hotplug function, we are doomed.
> > 
> > I mean, that particular watchdog event won't fail if the watchdog code
> > would verify that already at init time (which it does soon), but in general
> > event creation during hotplug is dangerous.
> 
> Arghh!!!
> 
> And allowing us to create events for offline CPUs (possible I think, but
> maybe slightly tricky) won't solve that, because we're already holding
> the hotplug_lock during PREPARE.

There are two ways to cure that:

1) Have a pre cpus_write_lock() stage which is serialized via
   cpus_add_remove_lock, which is the outer lock for hotplug.

   There we can sanely create stuff and fail with all consequences.

2) Have some deferred mechanism, which is destroying the event after
   failure, but that might be tricky as RCU and workqueues might end up
   being flushed during hotplug, which creates the same mess again.

Thanks,

	tglx

  reply	other threads:[~2017-08-31  7:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-25 10:03 WARNING: possible circular locking dependency detected Borislav Petkov
2017-08-25 11:45 ` Borislav Petkov
2017-08-25 14:47 ` Sebastian Andrzej Siewior
2017-08-25 16:12   ` Byungchul Park
2017-08-25 16:21     ` Thomas Gleixner
2017-08-28  7:41   ` Peter Zijlstra
2017-08-28 14:11   ` Peter Zijlstra
2017-08-29 19:34   ` Peter Zijlstra
2017-08-25 16:42 ` Sebastian Andrzej Siewior
2017-08-28 14:58 ` Peter Zijlstra
2017-08-28 15:06   ` Peter Zijlstra
2017-08-28 16:32     ` Peter Zijlstra
2017-08-29 17:40   ` Thomas Gleixner
2017-08-29 19:49     ` Peter Zijlstra
2017-08-29 20:10       ` Thomas Gleixner
2017-08-30  5:47         ` Peter Zijlstra
2017-08-31  7:08           ` Thomas Gleixner
2017-08-31  7:37             ` Peter Zijlstra
2017-08-31  7:55               ` Thomas Gleixner [this message]
2017-08-31  8:09                 ` Peter Zijlstra
2017-08-31  8:15                   ` Thomas Gleixner
2017-08-31 21:24                     ` Thomas Gleixner
2017-09-01 20:32                       ` Peter Zijlstra
2018-11-14  2:41 Qian Cai

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=alpine.DEB.2.20.1708310952490.1874@nanos \
    --to=tglx@linutronix.de \
    --cc=bigeasy@linutronix.de \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.