From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Masami Hiramatsu <mhiramat@kernel.org>
Subject: Re: [RFC][PATCH 0/5] perf/tracing/cpuhotplug: Fix locking order
Date: Wed, 17 May 2017 20:58:19 -0700 [thread overview]
Message-ID: <20170518035819.GA2652@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170517145520.GI3956@linux.vnet.ibm.com>
On Wed, May 17, 2017 at 07:55:20AM -0700, Paul E. McKenney wrote:
> On Wed, May 17, 2017 at 12:40:10PM +0200, Peter Zijlstra wrote:
> > On Tue, May 16, 2017 at 07:27:42AM -0700, Paul E. McKenney wrote:
> > > On Tue, May 16, 2017 at 05:46:06AM -0700, Paul E. McKenney wrote:
[ . . . ]
> >
> > With the above change any chance of a race is gone and we don't need to
> > worry about hotplug ordering too much.
>
> Nice!!!
>
> > Now I just need to do something about the swevent hash, because that's
> > got a hole in now.
>
> On the styles, here is a more coherence list:
>
> 1. Use get_online_cpus(), but no CPU-hotplug notifiers. You can
> use cpu_online() and cpu_is_offline() straightforwardly while
> get_online_cpus() is in effect, but these two may only be used
> for statistical/heuristic purposes otherwise.
And I forgot about the disable-preemption trick...
Of course you can also use cpu_online() and cpu_is_offline() more or less
straightforwardly when preemption is disabled, but if your code is making
use of subsystems that disable themselves early on outgoing CPUs or enable
themselves late on incoming CPUs, life can be difficult. These subsystems
can make things easier, for example, smp_call_function_single() will
give a failure indication if it cannot help you because the CPU isn't
all there. (RCU does OK, but could use a bit more improvement.)
Also, you can use the disable-preemption trick to prevent a CPU from
leaving (if you get there early enough in the offlining), but it won't
necessarily prevent a CPU from showing up. Yes, there seem to be a
fair number of notifiers that wait for grace periods (perhaps too many),
but you cannot necessarily count on them being configured into the
kernel.
> 2a. Use CPU-hotplug notifiers, but not get_online_cpus().
> The notifiers maintain some sort of bitmask tracking which CPUs
> are present from the viewpoint of this subsystem. This bitmask
> provides exact CPU presence/absence indications, at least
> assuming the appropriate lock is held. The cpu_online() and
> cpu_is_offline() macros should be avoided, except possibly for
> statistical/heuristic purposes.
>
> For your perf patch, the bitmask is a cpumask_var_t. For RCU,
> it is the combination of the ->qsmaskinitnext fields of the leaf
> rcu_node structures.
>
> 2b. Like 2a, except that instead of a bitmask, the CPU online/offline
> information is implicit in other data structures. For example,
> per-CPU structures might be allocated only when the corresponding
> CPU is online, so that a given per-CPU pointer is non-NULL
> iff the corresponding CPU is online.
Here, disabling preemption will still prevent any CPU from responding
to the stop-CPUs mechanism, but it cannot prevent your own notifier from
executing. So care is required using cpu_online() and cpu_is_offline()
even when preemption is disabled.
Thanx, Paul
> So I was (confusingly) initially using "style" to distinguish #1 on the
> one hand from #2a and #2b on the other. Later on, I was using "style"
> to distinguish #2a from #2b.
>
> At this point, I am not sure that it makes all that much sense to
> distinguish 2a from 2b. Or you could argue that use of a cpumask_var_t
> is its own substyle, with hand-crafted bitmasks (such as RCU's) are
> separate substyles. Can't say that I care all that much about that
> fine-grained gradiations. ;-)
>
> Thanx, Paul
next prev parent reply other threads:[~2017-05-18 3:58 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-12 17:15 [RFC][PATCH 0/5] perf/tracing/cpuhotplug: Fix locking order Steven Rostedt
2017-05-12 17:15 ` [RFC][PATCH 1/5] tracing: Make sure RCU is watching before calling a stack trace Steven Rostedt
2017-05-12 18:25 ` Paul E. McKenney
2017-05-12 18:36 ` Steven Rostedt
2017-05-12 18:50 ` Paul E. McKenney
2017-05-12 20:05 ` Steven Rostedt
2017-05-12 20:31 ` Paul E. McKenney
2017-05-17 16:46 ` Steven Rostedt
2017-05-12 17:15 ` [RFC][PATCH 2/5] cpu-hotplug: Allow get_online_cpus() to nest Steven Rostedt
2017-05-12 18:35 ` Paul E. McKenney
2017-05-12 18:40 ` Steven Rostedt
2017-05-12 18:52 ` Paul E. McKenney
2017-05-12 22:15 ` Thomas Gleixner
2017-05-13 0:23 ` Steven Rostedt
2017-05-12 17:15 ` [RFC][PATCH 3/5] kprobes: Take get_online_cpus() before taking jump_label_lock() Steven Rostedt
2017-05-12 18:39 ` Paul E. McKenney
2017-05-12 18:44 ` Steven Rostedt
2017-05-17 17:50 ` Masami Hiramatsu
2017-05-12 17:15 ` [RFC][PATCH 4/5] tracepoints: Grab get_online_cpus() before taking tracepoints_mutex Steven Rostedt
2017-05-12 17:15 ` [RFC][PATCH 5/5] perf: Grab event_mutex before taking get_online_cpus() Steven Rostedt
2017-05-12 18:13 ` [RFC][PATCH 0/5] perf/tracing/cpuhotplug: Fix locking order Paul E. McKenney
2017-05-12 19:49 ` Peter Zijlstra
2017-05-12 20:14 ` Steven Rostedt
2017-05-12 21:34 ` Steven Rostedt
2017-05-13 13:40 ` Paul E. McKenney
2017-05-15 9:03 ` Peter Zijlstra
2017-05-15 18:40 ` Paul E. McKenney
2017-05-16 8:19 ` Peter Zijlstra
2017-05-16 12:46 ` Paul E. McKenney
2017-05-16 14:27 ` Paul E. McKenney
2017-05-17 10:40 ` Peter Zijlstra
2017-05-17 14:55 ` Paul E. McKenney
2017-05-18 3:58 ` Paul E. McKenney [this message]
2017-05-15 19:06 ` Steven Rostedt
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=20170518035819.GA2652@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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