From: Steven Rostedt <rostedt@goodmis.org>
To: Christoph Lameter <cl@linux.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
stable <stable@vger.kernel.org>,
Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
Subject: Re: [GIT PULL] ring-buffer: Replace this_cpu_*() with __this_cpu_*()
Date: Mon, 23 Mar 2015 13:48:39 -0400 [thread overview]
Message-ID: <20150323134839.29dfdd08@gandalf.local.home> (raw)
In-Reply-To: <CA+55aFwABeHiPK4fsn1g=V-PR88UnNqCADzVWAzWGORtNFs2Jw@mail.gmail.com>
Christoph,
Any comment on this?
-- Steve
On Thu, 19 Mar 2015 15:16:25 -0700
Linus Torvalds <torvalds@linux-foundation.org> wrote:
> Ugh.
>
> I think this is bogus.
>
> Why?
>
> On Thu, Mar 19, 2015 at 3:02 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
> >
> > The generic version of this_cpu_read() and write() are:
> >
> > #define this_cpu_generic_read(pcp) \
> > ({ typeof(pcp) ret__; \
> > preempt_disable(); \
> > ret__ = *this_cpu_ptr(&(pcp)); \
> > preempt_enable(); \
> > ret__; \
> > })
> >
> > #define this_cpu_generic_to_op(pcp, val, op) \
> > do { \
> > unsigned long flags; \
> > raw_local_irq_save(flags); \
> > *__this_cpu_ptr(&(pcp)) op val; \
> > raw_local_irq_restore(flags); \
> > } while (0)
>
> Let's just fix the generic versions of this_cpu_read/write.
>
> Now, it is true that for the "op" versions of "this_cpu_xyz" we need
> to disable preemption or interrupts or something for the generic case
> (where "generic case" is weasel-wording for "the architecture is crap
> and has horrible problems with any kinds of atomics, even just per-cpu
> ones").
>
> But that is *not* true for plain read/write. There is no point in
> disabling preemption, because in the end, if preemption was enabled,
> it happens on a random CPU anyway (and that may be fine - many
> heuristics may not care *which* exact CPU it's about), and unlike the
> "op" cases, the actual read or write is a single access, so there's no
> reason to disable preemption/interrupts to make it "atomic" on that
> random CPU.
>
> If you pair a this_cpu_read with a this_cpu_write and expect them to
> go to the same cpu, such a user obviously needs to disable preemption
> etc for bigger reasons - but disabling preemption inside the operation
> itself does absolutely nothing.
>
> So is there really any reason to not make those simpler forms just do
> something simpler like
>
> #define this_cpu_generic_read(pcp) \
> READ_ONCE(*this_cpu_ptr(&(pcp)))
>
> #define this_cpu_generic_read(pcp, val) \
> WRITE_ONCE(*this_cpu_ptr(&(pcp)), val)
>
> instead?
>
> Even if we end up being preempted in the middle, do we *care*? It's
> going to one or the other CPU.
>
> The only issue might be CPU hotplug in between (the previous CPU going
> away), but I'm not sure even that matterts.
>
> So I don't think the ring-buffer change is necessarily _wrong_, but if
> this is a performance issue, why don't we just fix it up for the
> generic case rather than for just one user?
>
> Or is the hotplug issue a big deal? I thought we already had some
> rcu-sched point for the cpu going away, so that even the hotplug case
> should be ok.
>
> Linus
next prev parent reply other threads:[~2015-03-23 17:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-19 22:02 Steven Rostedt
2015-03-19 22:16 ` Linus Torvalds
2015-03-19 22:34 ` Steven Rostedt
2015-03-19 22:42 ` Steven Rostedt
2015-05-19 15:35 ` Christoph Lameter
2015-05-19 15:42 ` Steven Rostedt
2015-05-19 16:20 ` Christoph Lameter
2015-03-23 17:48 ` Steven Rostedt [this message]
2015-03-24 18:47 ` Christoph Lameter
2015-03-24 19:37 ` Christoph Lameter
2015-05-18 19:50 ` Linus Torvalds
2015-05-18 20:40 ` Steven Rostedt
2015-03-20 7:26 ` Uwe Kleine-König
2015-03-20 11:55 ` 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=20150323134839.29dfdd08@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=u.kleine-koenig@pengutronix.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®