Received: by 10.192.165.148 with SMTP id m20csp5495542imm; Wed, 9 May 2018 06:04:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZopxW2icRt7OWVZCMpkLCSOHg8x73lIqRVhdcCG7NpvwMpWcOxitn2b82iWcpCaKZbBgNUU X-Received: by 2002:a63:8dc1:: with SMTP id z184-v6mr35930976pgd.114.1525871049506; Wed, 09 May 2018 06:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525871049; cv=none; d=google.com; s=arc-20160816; b=1Gwxm7JdUR3I7nEWwHxAdT3WyiBpjC6Pusrs4CmgZUso+DnUQnjDhcC+H4VBoO2ojE Y7hNAEPs/fpzxdyg+igTwQL3EiO6uU5+VRFtPSk58wfi0dHi+w5cyiuJkibYKqmUtHe4 SgGRnFVAjT156eJHaOG7QhI34ExefDSsYAg2KRbjADpoSudaKZZZPIOHlj8jKbY1IZdx iF6SQFS01etLCxL5VS1TA5GJR4lvpobSiG2J5QjH/GVESGELSpkxrB29Mx2s+PGNDQnX j7Qab+onHwR+ernfw+QLktHrkv03D0N2nixDuA+7N4yg5FlyxFAd+YKRLOBoSDrmJxID TH6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=Edm+9iraFvEn7wHW2760UD0cXE0ulJQFuafldJ/aG18=; b=IAlohSO2mp0p02zsQXp/28HrGVoHj2+3Zkm3sgoM1djcuC2Hz5FDRur8TGywv9TApg 3LU5fpTy/yUFavysnc+tIslzKnDJv0mnUGKASy0n/qd6NVAdRufPLyNO+qM+Ou2Agb2k s3uqwtrkaK4OsBCyf2MkNiz4wq0jyC+ykvHIJK0fURwuKcnvSSj5yF/4XRWaKtBFfYXO dCX8ScOlfuQzGQovjYUidwgnI5ho/X8MDlSrPASKOvNcvsJ+lc6p6Wr/Osuu+QLfR9Xi 3E2eK2q2IqXumM6hvynfb4uFuP2hwzumZ28QV4suTQA6nBQYDOC2H49R9iA9h1C2ElJo TItw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a33-v6si25268595plc.507.2018.05.09.06.03.54; Wed, 09 May 2018 06:04:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935229AbeEINC4 (ORCPT + 99 others); Wed, 9 May 2018 09:02:56 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43496 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935024AbeEINCx (ORCPT ); Wed, 9 May 2018 09:02:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 20ABE80D; Wed, 9 May 2018 06:02:53 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E59233F25D; Wed, 9 May 2018 06:02:52 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id A412D1AE3564; Wed, 9 May 2018 14:03:16 +0100 (BST) Date: Wed, 9 May 2018 14:03:16 +0100 From: Will Deacon To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, mark.rutland@arm.com, torvalds@linux-foundation.org, paulmck@linux.vnet.ibm.com, mingo@kernel.org, tglx@linutronix.de, hpa@zytor.com, linux-tip-commits@vger.kernel.org Subject: Re: [tip:locking/core] locking/atomics: Simplify the op definitions in atomic.h some more Message-ID: <20180509130316.GB20254@arm.com> References: <20180505083635.622xmcvb42dw5xxh@gmail.com> <20180509073327.GE12217@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180509073327.GE12217@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ingo, Peter, [I was at a conference last week and not reading email] On Wed, May 09, 2018 at 09:33:27AM +0200, Peter Zijlstra wrote: > On Sun, May 06, 2018 at 05:14:36AM -0700, tip-bot for Ingo Molnar wrote: > > Commit-ID: 87d655a48dfe74293f72dc001ed042142cf00d44 > > Gitweb: https://git.kernel.org/tip/87d655a48dfe74293f72dc001ed042142cf00d44 > > Author: Ingo Molnar > > AuthorDate: Sat, 5 May 2018 10:36:35 +0200 > > Committer: Ingo Molnar > > CommitDate: Sat, 5 May 2018 15:22:44 +0200 > > > > locking/atomics: Simplify the op definitions in atomic.h some more > > > > Before: > > > > #ifndef atomic_fetch_dec_relaxed > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) > > # define atomic_fetch_dec_relaxed(v) atomic_fetch_sub_relaxed(1, (v)) > > # define atomic_fetch_dec_acquire(v) atomic_fetch_sub_acquire(1, (v)) > > # define atomic_fetch_dec_release(v) atomic_fetch_sub_release(1, (v)) > > # else > > # define atomic_fetch_dec_relaxed atomic_fetch_dec > > # define atomic_fetch_dec_acquire atomic_fetch_dec > > # define atomic_fetch_dec_release atomic_fetch_dec > > # endif > > #else > > # ifndef atomic_fetch_dec_acquire > > # define atomic_fetch_dec_acquire(...) __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > > # endif > > # ifndef atomic_fetch_dec_release > > # define atomic_fetch_dec_release(...) __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > > # endif > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(...) __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > > # endif > > #endif > > > > After: > > > > #ifndef atomic_fetch_dec_relaxed > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(v) atomic_fetch_sub(1, (v)) > > # define atomic_fetch_dec_relaxed(v) atomic_fetch_sub_relaxed(1, (v)) > > # define atomic_fetch_dec_acquire(v) atomic_fetch_sub_acquire(1, (v)) > > # define atomic_fetch_dec_release(v) atomic_fetch_sub_release(1, (v)) > > # else > > # define atomic_fetch_dec_relaxed atomic_fetch_dec > > # define atomic_fetch_dec_acquire atomic_fetch_dec > > # define atomic_fetch_dec_release atomic_fetch_dec > > # endif > > #else > > # ifndef atomic_fetch_dec > > # define atomic_fetch_dec(...) __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) > > # define atomic_fetch_dec_acquire(...) __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) > > # define atomic_fetch_dec_release(...) __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) > > # endif > > #endif > > > > The idea is that because we already group these APIs by certain defines > > such as atomic_fetch_dec_relaxed and atomic_fetch_dec in the primary > > branches - we can do the same in the secondary branch as well. > > > > ARGH, why did you merge this? It's pointless wankery, and doesn't solve > anything wrt. the annotated atomic crap. > > And if we're going to do codegen, we might as well all generate this > anyway, so all this mucking about is a complete waste of time. I have to agree here. The reason we allowed the atomic primitives to be overridden on a fine-grained basis is because there are often architecture-specific barriers or instructions which mean that it is common to be able to provide optimised atomics in some cases, but not others. Given that this stuff is error-prone, having the generic code provide a safe and correct fallback for all of the atomics that the architecture doesn't implement seemed like a good thing to me. New architecture ports basically just have to provide the weakest thing they have and a fence to get started, then they can optimise where they can and not have to worry about the rest of the atomics API. With this patch, we're already seeing arch code (powerpc, risc-v) having to add what is basically boiler-plate code, and it seems like we're just doing this to make the generic code more readable! I'd much prefer we kept the arch code simple, and took on the complexity burden in the generic code where it can be looked after in one place. For instrumentation, we're going to need to generate this stuff *anyway*, so I think the readability argument mostly disappears. Will