Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp223176imm; Mon, 4 Jun 2018 16:19:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLJgtT3tKXUaTLW7ffEDzOqf2FeX5nmQtAmG8q43hf3V+8Dk7VWHrW9gKWO7Y6mO77imXi1 X-Received: by 2002:a17:902:6ac7:: with SMTP id i7-v6mr23515173plt.288.1528154351699; Mon, 04 Jun 2018 16:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528154351; cv=none; d=google.com; s=arc-20160816; b=rAiN80DMYdpOoIZTQ6i0vbYhPdragZxR5S0FvAD4a5uuMKWtdk0qq/5rfdiM8Emfw3 PI0KuoCv7Jd/9B/NcinENf1QHNm04ikTarouyRwn9oaLnUA6/eyIDk/pEgciIE7PtMjE EEg5uHz/jgftN36z7Znk0JjY2GTne9qF78Od5rBeTiQ7rrvbb0aZvz+PMpobfIcj2reE Qy9GMAL4DrG4nzYAAnC4gGrvPnYWSDOr8KeRasHsT4fMDrJmfUfoB1YyTqILMCWjknD9 kfOh35m7AuGLEuq1EfUIhgiTHMLNHXOIcNSC2q2mNz3+WpBWCl27deseXKF/6CYBchvw PU2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature :arc-authentication-results; bh=mKFbwWaNxuAoZsJRIbr/n8280lGp7VZ3DjiTQtSNtHo=; b=YfB/3z/VLzVPs7Rp5jS6aMwqS8gVaMuP632PuDbK4cORL6ax+goA0S4hOMlOSCDd4A QETV6iS8pOBeQWl3ULV68yTuJB9/5oyb6a+jmfx9lqwcSi5yoobZmo9DpwIvfmBwloTQ icjPxgxDv+Sq6lerKjQSjVs7YxA+0LaN7A4a7tabv54UcgEbPom5BiYjIYVbmMmdV1A+ b6uVnBh5T5z/gNjpTsTicFZHkOdk0KWoxm8ZyYXr2OBQM1Jv02DPfTbqiCeUxh5J53+8 fcmJwnmmCz/qYxXE0pzt45zl9K4SMMdEvqrsR3bE7WL4xK67MetaCLHR9TPawB3rCNX4 +MMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=CRWcld90; 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 e1-v6si48904038plk.397.2018.06.04.16.18.57; Mon, 04 Jun 2018 16:19:11 -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; dkim=pass header.i=@sifive.com header.s=google header.b=CRWcld90; 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 S1752144AbeFDXSB (ORCPT + 99 others); Mon, 4 Jun 2018 19:18:01 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:42410 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751998AbeFDXRY (ORCPT ); Mon, 4 Jun 2018 19:17:24 -0400 Received: by mail-pl0-f65.google.com with SMTP id w17-v6so266172pll.9 for ; Mon, 04 Jun 2018 16:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=mKFbwWaNxuAoZsJRIbr/n8280lGp7VZ3DjiTQtSNtHo=; b=CRWcld90Nbbfvy1lO3I/+OktFSeDJgZmm3adpy8EHq70/J0Pvhd6YBeCuBsiNwoGdo e+jzWf57vf46YSqrqKJRUJDvvQi8Er0+KmpgdbqH5MOOTdoJisvPCGLrPiBTq2L0h2G2 wAHSaEYzMp882PcthdnjAxtutSW2iJmYBdWJrZGGcGEkUbceLHHx2GZBL1PqL4AKlK6i oXz9RepVzSR72jKkOL3WGLLBgKDCAyK5+Me8yGusKNgQzcIdvJBxqGOhK28s/LNuESJ2 pztojo1e/iLtoMZBb+taAJnoA884lbpC4g4lI1cm5deYaEWlEnypgid1APQ3fLbO+8/i Z9pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=mKFbwWaNxuAoZsJRIbr/n8280lGp7VZ3DjiTQtSNtHo=; b=gOGnZjEMivU1bhPUjMntE+rWdpuzaNoyCajCRJou4hqIOQ35s2E0neieVXyD8Jg18p YOsDR5ZIVTKqUcv8XuXhyb3nbOAgwQyN74iMzH3fkd4hSer3LQZS0qjaLJW+ZApd5MeC xmw93HYpcToYp3g5mg0FvMiIsm4k9Dfa6uHypTPtGoHGctm99GEwp1//UBaf9m0l6kbM V4aGt96AYiC3CWxWOliaq0I9mQuQoCHTTkU595UUziDDTepFXBe/pzyw79k3TffukblS 0ghdGj58EfWIkestHMgUJtdFaoS5xJU136XaAEv/7RzdmHgxyCOlCAxjgxXIKaRwCWFA P7og== X-Gm-Message-State: ALKqPwf+9gF3rcV3scmsM2nGtxp3qWxv3FzraLzEe3PogADSJF4dVZul gT8yj4evE8J7Rx6yhMGZeDZTjCsOAQ0= X-Received: by 2002:a17:902:b216:: with SMTP id t22-v6mr23619631plr.199.1528154243472; Mon, 04 Jun 2018 16:17:23 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id l85-v6sm8582456pfk.79.2018.06.04.16.17.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 16:17:22 -0700 (PDT) Date: Mon, 04 Jun 2018 16:17:22 -0700 (PDT) X-Google-Original-Date: Mon, 04 Jun 2018 15:50:06 PDT (-0700) Subject: Re: [PATCHv2 15/16] atomics/treewide: make unconditional inc/dec ops optional In-Reply-To: <20180529154346.3168-16-mark.rutland@arm.com> CC: linux-kernel@vger.kernel.org, mark.rutland@arm.com, boqun.feng@gmail.com, peterz@infradead.org, Will Deacon From: Palmer Dabbelt To: mark.rutland@arm.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 29 May 2018 08:43:45 PDT (-0700), mark.rutland@arm.com wrote: > Many of the inc/dec ops are mandatory, but for most architectures inc/dec are > simply trivial wrappers around their corresponding add/sub ops. > > Let's make all the inc/dec ops optional, so that we can get rid of these > boilerplate wrappers. > > The instrumented atomics are updated accordingly. > > There should be no functional change as a result of this patch. > > Signed-off-by: Mark Rutland > Cc: Boqun Feng > Cc: Peter Zijlstra > Cc: Will Deacon > --- > arch/alpha/include/asm/atomic.h | 12 ----- > arch/arc/include/asm/atomic.h | 11 ----- > arch/arm/include/asm/atomic.h | 11 ----- > arch/arm64/include/asm/atomic.h | 24 ---------- > arch/h8300/include/asm/atomic.h | 7 --- > arch/hexagon/include/asm/atomic.h | 6 --- > arch/ia64/include/asm/atomic.h | 9 ---- > arch/m68k/include/asm/atomic.h | 5 +- > arch/mips/include/asm/atomic.h | 38 ---------------- > arch/parisc/include/asm/atomic.h | 12 ----- > arch/powerpc/include/asm/atomic.h | 4 ++ > arch/riscv/include/asm/atomic.h | 76 ------------------------------- > arch/s390/include/asm/atomic.h | 8 ---- > arch/sh/include/asm/atomic.h | 6 --- > arch/sparc/include/asm/atomic_32.h | 5 -- > arch/sparc/include/asm/atomic_64.h | 12 ----- > arch/x86/include/asm/atomic.h | 5 +- > arch/x86/include/asm/atomic64_32.h | 4 ++ > arch/x86/include/asm/atomic64_64.h | 5 +- > arch/xtensa/include/asm/atomic.h | 32 ------------- > include/asm-generic/atomic-instrumented.h | 24 ++++++++++ > include/asm-generic/atomic.h | 13 ------ > include/asm-generic/atomic64.h | 5 -- > include/linux/atomic.h | 48 +++++++++++++++++++ > 24 files changed, 86 insertions(+), 296 deletions(-) > [...] > diff --git a/arch/riscv/include/asm/atomic.h b/arch/riscv/include/asm/atomic.h > index 68eef0a805ca..512b89485790 100644 > --- a/arch/riscv/include/asm/atomic.h > +++ b/arch/riscv/include/asm/atomic.h > @@ -209,82 +209,6 @@ ATOMIC_OPS(xor, xor, i) > #undef ATOMIC_FETCH_OP > #undef ATOMIC_OP_RETURN > > -#define ATOMIC_OP(op, func_op, I, c_type, prefix) \ > -static __always_inline \ > -void atomic##prefix##_##op(atomic##prefix##_t *v) \ > -{ \ > - atomic##prefix##_##func_op(I, v); \ > -} > - > -#define ATOMIC_FETCH_OP(op, func_op, I, c_type, prefix) \ > -static __always_inline \ > -c_type atomic##prefix##_fetch_##op##_relaxed(atomic##prefix##_t *v) \ > -{ \ > - return atomic##prefix##_fetch_##func_op##_relaxed(I, v); \ > -} \ > -static __always_inline \ > -c_type atomic##prefix##_fetch_##op(atomic##prefix##_t *v) \ > -{ \ > - return atomic##prefix##_fetch_##func_op(I, v); \ > -} > - > -#define ATOMIC_OP_RETURN(op, asm_op, c_op, I, c_type, prefix) \ > -static __always_inline \ > -c_type atomic##prefix##_##op##_return_relaxed(atomic##prefix##_t *v) \ > -{ \ > - return atomic##prefix##_fetch_##op##_relaxed(v) c_op I; \ > -} \ > -static __always_inline \ > -c_type atomic##prefix##_##op##_return(atomic##prefix##_t *v) \ > -{ \ > - return atomic##prefix##_fetch_##op(v) c_op I; \ > -} > - > -#ifdef CONFIG_GENERIC_ATOMIC64 > -#define ATOMIC_OPS(op, asm_op, c_op, I) \ > - ATOMIC_OP( op, asm_op, I, int, ) \ > - ATOMIC_FETCH_OP( op, asm_op, I, int, ) \ > - ATOMIC_OP_RETURN(op, asm_op, c_op, I, int, ) > -#else > -#define ATOMIC_OPS(op, asm_op, c_op, I) \ > - ATOMIC_OP( op, asm_op, I, int, ) \ > - ATOMIC_FETCH_OP( op, asm_op, I, int, ) \ > - ATOMIC_OP_RETURN(op, asm_op, c_op, I, int, ) \ > - ATOMIC_OP( op, asm_op, I, long, 64) \ > - ATOMIC_FETCH_OP( op, asm_op, I, long, 64) \ > - ATOMIC_OP_RETURN(op, asm_op, c_op, I, long, 64) > -#endif > - > -ATOMIC_OPS(inc, add, +, 1) > -ATOMIC_OPS(dec, add, +, -1) > - > -#define atomic_inc_return_relaxed atomic_inc_return_relaxed > -#define atomic_dec_return_relaxed atomic_dec_return_relaxed > -#define atomic_inc_return atomic_inc_return > -#define atomic_dec_return atomic_dec_return > - > -#define atomic_fetch_inc_relaxed atomic_fetch_inc_relaxed > -#define atomic_fetch_dec_relaxed atomic_fetch_dec_relaxed > -#define atomic_fetch_inc atomic_fetch_inc > -#define atomic_fetch_dec atomic_fetch_dec > - > -#ifndef CONFIG_GENERIC_ATOMIC64 > -#define atomic64_inc_return_relaxed atomic64_inc_return_relaxed > -#define atomic64_dec_return_relaxed atomic64_dec_return_relaxed > -#define atomic64_inc_return atomic64_inc_return > -#define atomic64_dec_return atomic64_dec_return > - > -#define atomic64_fetch_inc_relaxed atomic64_fetch_inc_relaxed > -#define atomic64_fetch_dec_relaxed atomic64_fetch_dec_relaxed > -#define atomic64_fetch_inc atomic64_fetch_inc > -#define atomic64_fetch_dec atomic64_fetch_dec > -#endif > - > -#undef ATOMIC_OPS > -#undef ATOMIC_OP > -#undef ATOMIC_FETCH_OP > -#undef ATOMIC_OP_RETURN > - > /* This is required to provide a full barrier on success. */ > static __always_inline int atomic_fetch_add_unless(atomic_t *v, int a, int u) > { As far as the RISC-V stuff goes: this works for me, as I always like to have less code in the arch port. Acked-by: Palmer Dabbelt Thanks!