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]
Message-ID: <20150629093219.GD3644@twins.programming.kicks-ass.net>
Date:	Mon, 29 Jun 2015 11:32:19 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Tejun Heo <tj@...nel.org>
Cc:	Nicholas Mc Guire <der.herr@...r.at>, oleg@...hat.com,
	paulmck@...ux.vnet.ibm.com, mingo@...hat.com,
	linux-kernel@...r.kernel.org, dave@...olabs.net, riel@...hat.com,
	viro@...IV.linux.org.uk, torvalds@...ux-foundation.org
Subject: Re: [RFC][PATCH 05/13] percpu-rwsem: Optimize readers and reduce
 global impact

On Thu, Jun 25, 2015 at 03:17:01PM -0400, Tejun Heo wrote:

> Hmmm... the only worry I have about this is people using it on u64 on
> 32bit machines.  CPU local ops can do split updates on lower and upper
> halves and the remotely-read value will be surprising.  We have the
> same issues w/ regular per_cpu accesses to but the summing function /
> macro is better at giving the false sense of security.  Prolly
> limiting it upto ulong size is a good idea?

Agreed, luckily we already have the infrastructure for this, something
like so?

--- a/include/linux/percpu-defs.h
+++ b/include/linux/percpu-defs.h
@@ -287,6 +287,16 @@ do {									\
 	preempt_enable();						\
 } while (0)
 
+#define per_cpu_sum(var)						\
+({									\
+	typeof(var) __sum = 0;						\
+	int cpu;							\
+	compiletime_assert_atomic_type(__sum);				\
+	for_each_possible_cpu(cpu)					\
+		__sum += per_cpu(var, cpu);				\
+	__sum;								\
+})
+
 /*
  * Branching function to split up a function into a set of functions that
  * are called for different scalar sizes of the objects handled.
--
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