From: Steven Rostedt <rostedt@goodmis.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Christoph Lameter <cl@gentwo.org>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [RFC][PATCH 0/5] Introduce checks for preemptable code for this_cpu_read/write()
Date: Tue, 20 Sep 2011 12:00:41 -0400 [thread overview]
Message-ID: <1316534441.29966.79.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <20110920154610.GB28952@Krystal>
On Tue, 2011-09-20 at 11:46 -0400, Mathieu Desnoyers wrote:
> * Steven Rostedt (rostedt@goodmis.org) wrote:
> > [ Added Mathieu as I've been discussing this with him on IRC ]
> [...]
> > My suggestion is to nuke the __this_cpu*() functions and have them
> > called this_cpu*(). And change the locations that allow for preemption
> > enabled to be called preemptsafe_cpu_*() just like the irqsafe_cpu*()
> > are used.
> >
> > Thoughts?
>
> I fully agreed with this proposal.
>
> this_cpu_*() should be a sane default, which is cases that require
> preemption to be disabled. Warning about use without preemption disabled
> is important, because most users will _assume_ that they stay on the
> same CPU across multiple calls.
>
> preemptsafe_cpu_*() is an optimisation made for those who know that
> they don't care about having consistent view of the variables across
> multiple operations, e.g. statistics, or deal with this explicitly, like
> SLUB. Typical use require either add_return or cmpxchg for validation.
The funny thing is, the few uses where preemption is enabled in slub,
happens to use the __this_cpu_() version. Which shows me that this whole
concept is completely flawed.
>
> In the past, we used to have something like raw_smp_processor_id()
> though, for sites where racy use does not matter. So probably having a
> raw_this_cpu_*() that behaves like "this_cpu_*()" proposed here, but
> does not check for preemption disabled would also be useful.
I'm going with all users of this_cpu_*() must be used in a preempt
disabled section. Byte the bullet. I doubt any sane benchmark shows any
improvement by removing preempt_disable() from small code paths. If a
longer code path is needed, then the code was probably buggy to begin
with.
For those cases that really do not care about preemption enabled, maybe
we could add a single this_cpu() function that allows that.
this_cpu_snapshot();
This would be the only function that can be used with preemption
enabled. It is read only (no modification of the variable). It is used
in cases that you really don't care what CPU you are on. For instance
the const_udelay() could use this.
The term "snapshot" should document very nicely that you do not care
that you migrated in the next moment. As a snapshot is just a quick
instance of time.
I really mean all other users of this_cpu_*(), including the cmpxchg and
friends, still need to have preemption disabled.
-- Steve
next prev parent reply other threads:[~2011-09-20 16:00 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-19 21:20 Steven Rostedt
2011-09-19 21:20 ` [RFC][PATCH 1/5] x86: Remove const_udelay() caring about which cpu var it uses Steven Rostedt
2011-09-19 21:51 ` Christoph Lameter
2011-09-19 23:31 ` Steven Rostedt
2011-09-19 21:20 ` [RFC][PATCH 2/5] mm: Switch mod_state() to __this_cpu_read() Steven Rostedt
2011-09-19 22:02 ` Christoph Lameter
2011-09-19 23:48 ` Steven Rostedt
2011-09-20 14:46 ` Christoph Lameter
2011-09-20 15:16 ` Steven Rostedt
2011-09-20 15:54 ` Christoph Lameter
2011-09-20 16:07 ` Steven Rostedt
2011-09-20 22:19 ` Valdis.Kletnieks
2011-09-20 13:49 ` Thomas Gleixner
2011-09-20 14:01 ` Steven Rostedt
2011-09-20 14:51 ` Christoph Lameter
2011-09-20 15:11 ` Steven Rostedt
2011-09-20 15:59 ` Christoph Lameter
2011-09-20 16:03 ` Steven Rostedt
2011-09-20 16:07 ` Christoph Lameter
2011-09-20 15:27 ` Thomas Gleixner
2011-09-20 16:02 ` Christoph Lameter
2011-09-20 16:51 ` Thomas Gleixner
2011-09-20 17:08 ` Steven Rostedt
2011-09-19 21:20 ` [RFC][PATCH 3/5] memcg: Disable preemption in memcg_check_events() Steven Rostedt
2011-09-20 14:20 ` Johannes Weiner
2011-09-20 14:24 ` Johannes Weiner
2011-09-20 14:33 ` Steven Rostedt
2011-09-24 0:46 ` Steven Rostedt
2011-09-19 21:20 ` [RFC][PATCH 4/5] printk: Have wake_up_klogd() use __this_cpu_write() Steven Rostedt
2011-09-19 21:54 ` Christoph Lameter
2011-09-19 23:33 ` Steven Rostedt
2011-09-20 14:54 ` Christoph Lameter
2011-09-20 14:55 ` Peter Zijlstra
2011-09-19 21:20 ` [RFC][PATCH 5/5] percpu: Add preempt checks back into this_cpu_read/write() Steven Rostedt
2011-09-19 21:49 ` [RFC][PATCH 0/5] Introduce checks for preemptable code for this_cpu_read/write() Christoph Lameter
2011-09-20 3:06 ` Steven Rostedt
2011-09-20 12:44 ` Valdis.Kletnieks
2011-09-20 13:51 ` Thomas Gleixner
2011-09-20 14:58 ` Christoph Lameter
2011-09-20 15:17 ` Steven Rostedt
2011-09-20 14:57 ` Christoph Lameter
2011-09-20 15:19 ` Steven Rostedt
2011-09-20 16:08 ` Christoph Lameter
2011-09-20 16:31 ` Steven Rostedt
2011-09-20 16:56 ` Steven Rostedt
2011-09-20 17:09 ` Peter Zijlstra
2011-09-20 17:15 ` Steven Rostedt
2011-09-20 17:25 ` Mathieu Desnoyers
2011-09-20 18:03 ` Steven Rostedt
2011-09-20 18:12 ` Mathieu Desnoyers
2011-09-20 18:27 ` Steven Rostedt
2011-09-20 18:34 ` Mathieu Desnoyers
2011-09-20 22:32 ` Valdis.Kletnieks
2011-09-20 22:17 ` Valdis.Kletnieks
2011-09-21 1:33 ` Steven Rostedt
2011-09-20 15:46 ` Mathieu Desnoyers
2011-09-20 16:00 ` Steven Rostedt [this message]
2011-09-20 16:10 ` Christoph Lameter
2011-09-20 16:50 ` Peter Zijlstra
2011-09-20 18:54 ` Steven Rostedt
2011-09-21 15:16 ` Christoph Lameter
2011-09-21 15:31 ` Steven Rostedt
2011-09-21 15:59 ` Christoph Lameter
2011-09-21 16:12 ` Steven Rostedt
2011-09-21 16:32 ` Thomas Gleixner
2011-09-20 2:20 ` Andi Kleen
2011-09-20 3:12 ` Steven Rostedt
2011-09-20 3:17 ` Steven Rostedt
2011-09-20 8:32 ` Thomas Gleixner
2011-09-20 12:10 ` Steven Rostedt
2011-09-20 15:03 ` Christoph Lameter
2011-09-20 15:07 ` Peter Zijlstra
2011-09-20 16:05 ` Christoph Lameter
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=1316534441.29966.79.camel@gandalf.stny.rr.com \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®