[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.10.1404161007080.9945@gentwo.org>
Date: Wed, 16 Apr 2014 10:08:03 -0500 (CDT)
From: Christoph Lameter <cl@...ux.com>
To: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
cc: linux-kernel@...r.kernel.org, mingo@...nel.org, tj@...nel.org,
grygorii.strashko@...com, peterz@...radead.org
Subject: Re: How do I increment a per-CPU variable without warning?
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.
> This is arguably better than the original __this_cpu_read() because it
> avoids overflow, but I thought I should check to see if there was some
> better way to do this.
If this is supposed to be totally race safe then you must disable
preemption.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists