From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Christoph Lameter <cl@linux.com>
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, tj@kernel.org,
grygorii.strashko@ti.com, peterz@infradead.org
Subject: Re: How do I increment a per-CPU variable without warning?
Date: Wed, 16 Apr 2014 11:47:55 -0700 [thread overview]
Message-ID: <20140416184755.GY4496@linux.vnet.ibm.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1404161328410.21030@gentwo.org>
On Wed, Apr 16, 2014 at 01:29:21PM -0500, Christoph Lameter wrote:
> On Wed, 16 Apr 2014, Paul E. McKenney wrote:
>
> > On Wed, Apr 16, 2014 at 09:06:21AM -0700, Paul E. McKenney wrote:
> > > On Wed, Apr 16, 2014 at 10:08:03AM -0500, Christoph Lameter wrote:
> > > > On Tue, 15 Apr 2014, Paul E. McKenney wrote:
> > > >
> > > > > Hello, Christoph,
> > > > >
> > > > > I have a patch that currently uses __this_cpu_inc_return() to increment a
> > > > > per-CPU variable, but without preemption disabled. Of course, given that
> > > > > preemption is enabled, it might well end up picking up one CPU's counter,
> > > > > adding one to it, then storing the result into some other CPU's counter.
> > > > > But this is OK, the test can be probabilistic. And when I run this
> > > > > against v3.14 and earlier, it works fine.
> > > >
> > > > We introduced raw_cpu_inc_return to squish these warnings.
> > >
> > > Cool, this is a good short-term fix.
> >
> > Or at least it is given the following patch. Was this the intent?
>
> Correct. Thanks for the fix.
>
> Acked-by: Christoph Lameter <cl@linux.com>
Queued, thank you. I don't need this until 3.16, but I am tempted
to push it in this cycle in case others need it. Any objections?
Thanx, Paul
> > ------------------------------------------------------------------------
> >
> > percpu: Fix raw_cpu_inc_return()
> >
> > The definition for raw_cpu_add_return() uses the operation prefix
> > "raw_add_return_", but the definitions in the various percpu.h files
> > expect "raw_cpu_add_return_". This commit therefore appropriately
> > adjusts the definition of raw_cpu_add_return().
> >
> > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > Cc: Christoph Lameter <cl@linux.com>
> >
> > diff --git a/include/linux/percpu.h b/include/linux/percpu.h
> > index e7a0b95ed527..495c6543a8f2 100644
> > --- a/include/linux/percpu.h
> > +++ b/include/linux/percpu.h
> > @@ -639,7 +639,7 @@ do { \
> > # define raw_cpu_add_return_8(pcp, val) raw_cpu_generic_add_return(pcp, val)
> > # endif
> > # define raw_cpu_add_return(pcp, val) \
> > - __pcpu_size_call_return2(raw_add_return_, pcp, val)
> > + __pcpu_size_call_return2(raw_cpu_add_return_, pcp, val)
> > #endif
> >
> > #define raw_cpu_sub_return(pcp, val) raw_cpu_add_return(pcp, -(typeof(pcp))(val))
> >
>
next prev parent reply other threads:[~2014-04-16 18:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-15 22:17 How do I increment a per-CPU variable without warning? Paul E. McKenney
2014-04-15 22:29 ` Dave Jones
2014-04-15 22:47 ` Paul E. McKenney
2014-04-16 3:54 ` Paul E. McKenney
2014-04-16 5:21 ` Peter Zijlstra
2014-04-16 13:03 ` Paul E. McKenney
2014-04-16 15:12 ` Christoph Lameter
2014-04-16 5:19 ` Peter Zijlstra
2014-04-16 15:08 ` Christoph Lameter
2014-04-16 16:06 ` Paul E. McKenney
2014-04-16 17:12 ` Paul E. McKenney
2014-04-16 18:29 ` Christoph Lameter
2014-04-16 18:47 ` Paul E. McKenney [this message]
2014-04-17 17:36 ` Christoph Lameter
2014-04-17 17:46 ` Paul E. McKenney
2014-04-17 17:53 ` Christoph Lameter
2014-04-17 18:21 ` Paul E. McKenney
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=20140416184755.GY4496@linux.vnet.ibm.com \
--to=paulmck@linux.vnet.ibm.com \
--cc=cl@linux.com \
--cc=grygorii.strashko@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tj@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).