lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 16 Apr 2014 07:21:48 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
Cc:	Dave Jones <davej@...hat.com>, cl@...ux.com,
	linux-kernel@...r.kernel.org, mingo@...nel.org, tj@...nel.org,
	grygorii.strashko@...com
Subject: Re: How do I increment a per-CPU variable without warning?

On Tue, Apr 15, 2014 at 08:54:19PM -0700, Paul E. McKenney wrote:
> But falling back on the old ways of doing this at least looks a bit
> nicer:
> 
> 	static inline bool rcu_should_resched(void)
> 	{
> 		int t;
> 		int *tp = &per_cpu(rcu_cond_resched_count, raw_smp_processor_id());
> 
> 		t = ACCESS_ONCE(*tp) + 1;
> 		if (t < RCU_COND_RESCHED_LIM) {

<here>

> 			ACCESS_ONCE(*tp) = t;
> 			return false;
> 		}
> 		return true;
> 	}
> 
> Other thoughts?

Still broken, if A starts out on CPU1, gets migrated to CPU0 at <here>,
then B starts the same on CPU1. It is possible for both CPU0 and CPU1 to
write a different value into your rcu_cond_resched_count.

You really want to disable preemption around there. The proper old way
would've been get_cpu_var()/put_cpu_var().

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ