Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753277AbbF2Jce (ORCPT ); Mon, 29 Jun 2015 05:32:34 -0400 Received: from casper.infradead.org ([85.118.1.10]:40095 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752996AbbF2Jc0 (ORCPT ); Mon, 29 Jun 2015 05:32:26 -0400 Date: Mon, 29 Jun 2015 11:32:19 +0200 From: Peter Zijlstra To: Tejun Heo Cc: Nicholas Mc Guire , oleg@redhat.com, paulmck@linux.vnet.ibm.com, mingo@redhat.com, linux-kernel@vger.kernel.org, dave@stgolabs.net, riel@redhat.com, viro@ZenIV.linux.org.uk, torvalds@linux-foundation.org Subject: Re: [RFC][PATCH 05/13] percpu-rwsem: Optimize readers and reduce global impact Message-ID: <20150629093219.GD3644@twins.programming.kicks-ass.net> References: <20150622121623.291363374@infradead.org> <20150622122256.064223889@infradead.org> <20150623072811.GB20073@opentech.at> <20150625190800.GW19282@twins.programming.kicks-ass.net> <20150625191701.GA5013@mtj.duckdns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150625191701.GA5013@mtj.duckdns.org> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1315 Lines: 36 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/