From patchwork Tue May 29 15:43:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 137180 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp4212134lji; Tue, 29 May 2018 08:44:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoUKQSQjkfBbQ5nOYndChaKA7on1zGqicxONRsM8UhGLCcugBbaoI5HiQbpIh9NF2yCxpA1 X-Received: by 2002:a17:902:8308:: with SMTP id bd8-v6mr18227424plb.195.1527608643783; Tue, 29 May 2018 08:44:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527608643; cv=none; d=google.com; s=arc-20160816; b=JofOwFVdY/pAqpRDgCrbUwTM56BqnBYZJqnwuaVyuIwdGIo5coelIK8PI4CXqjvOlT Owrm5FJcv8169S4A71XIAtkq1BBjNjYcB9ubJXLUKz8EpFzGnBg4QL3b0U4AfbmuiPyq NhfTNZ4XD8SWsJe8k1CkIzdS0O5/I2dUcF8rsX8QrvW1yIMf8liSeYib38A42qmhJ2u2 4hcWcUlHTWmrCZF/nzm2ErYmJMzBJAnvVJq83tb/3soo+b7ycOhxh5d04UoH4wNbA7Ay Io04B+i4ug672TDheXbTn8T6z8NXI1b6vCwywPfVxvoW4D0r1lrDi38fORQY65b+dtEa Qdcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=nclatshcSlLaDL0hRyVrytgLmOoy9HXTE6Jg8kSiqTs=; b=S3DK5DDYRCCRU9XTCaniurExwise0/bUXF6KMUhdo3SkIaw5jBeGTOeleBprBw99aD Ui+oq6jq02PbmNYCUF4Lb0PdNzYEiVWg+w2QoJY4geHCkhtY7aKJNbrRtT0m/EThtb8G sr0/UNX68RjaxmeEU1ZdhkDiZDj9796E+iCI4h9fjmGUDHuWOLLY4nZfQkuWmcPsxb0Z 3IjCUHgUGDdmGYW7e7z53znQ9lHRPM/z555+0HBuKnshfEfnVEsMUka1fYfDOlsynYM3 tCMifuKsYJQ75//lNYYkkQdR8qZjfrUSeKu1vidjjVISbFNR/JX24sTd8Vy6/LmDaDRq h5EA== 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 e90-v6si32554189pfb.355.2018.05.29.08.44.03; Tue, 29 May 2018 08:44:03 -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 S936447AbeE2PoB (ORCPT + 30 others); Tue, 29 May 2018 11:44:01 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43342 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934948AbeE2Pn7 (ORCPT ); Tue, 29 May 2018 11:43:59 -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 4F76280D; Tue, 29 May 2018 08:43:59 -0700 (PDT) Received: from lakrids.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 A503E3F25D; Tue, 29 May 2018 08:43:56 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org, Boqun Feng , Peter Zijlstra , Will Deacon Cc: Mark Rutland , Arnd Bergmann , Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Russell King , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Palmer Dabbelt , Albert Ou Subject: [PATCHv2 00/16] atomics: API cleanups Date: Tue, 29 May 2018 16:43:30 +0100 Message-Id: <20180529154346.3168-1-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series contains a few cleanups of the atomic API, fixing inconsistencies between atomic_* and atomic64_*, and minimizing repetition in arch code. This is nicer for arch code, and the improved regularity will help when generating the atomic headers in future. Since v1 [1]: * Add missing inc_not_zero #define for x86_32 * Remove newly redundant test op definitions for riscv * Remove atomic_inc_not_zero_hint() * Make inc/dec ops optional The bulk of the patches reorganise things so architectures consistently provide _fetch_add_unless(), with atomic_fetch_add_unless() provided as a wrapper by core code. A generic fallback is provided for _fetch_add_unless(), based on _read() and _try_cmpxchg(). Other patches in the series add common fallbacks for: * atomic64_inc_not_zero() * _inc_and_test() * _dec_and_test() * _sub_and_test() * add_negative() * _*inc*() * _*dec*() ... as almost all architectures provide (near-)identical implementation of these today. Where an architecture provides a non-trivial definition, it is updated to provide a matching preprocessor symbol, and the instrumented atomics are updated correspondingly. The end result is a strongly negative diffstat, though grows by a reasonable amount. We could halve this in future by templating the various fallbacks for atomic{,64}_t with code generation. I've pushed this out to my atomics/api-cleanup branch [2] on kernel.org. Thanks, Mark. [1] https://lkml.kernel.org/r/20180523133533.1076-1-mark.rutland@arm.com [2] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git atomics/api-cleanup Mark Rutland (16): atomics/treewide: s/__atomic_add_unless/atomic_fetch_add_unless/ atomics/treewide: remove redundant atomic_inc_not_zero() definitions atomics/treewide: make atomic64_inc_not_zero() optional atomics/treewide: make atomic_fetch_add_unless() optional atomics: prepare for atomic64_fetch_add_unless() atomics/generic: define atomic64_fetch_add_unless() atomics/alpha: define atomic64_fetch_add_unless() atomics/arc: define atomic64_fetch_add_unless() atomics/arm: define atomic64_fetch_add_unless() atomics/powerpc: define atomic64_fetch_add_unless() atomics/riscv: define atomic64_fetch_add_unless() atomics/treewide: make atomic64_fetch_add_unless() optional atomics/treewide: make test ops optional atomics/treewide: remove atomic_inc_not_zero_hint() atomics/treewide: make unconditional inc/dec ops optional atomics/treewide: make conditional inc/dec ops optional arch/alpha/include/asm/atomic.h | 56 ++--- arch/arc/include/asm/atomic.h | 78 ++----- arch/arm/include/asm/atomic.h | 55 ++--- arch/arm64/include/asm/atomic.h | 47 +--- arch/h8300/include/asm/atomic.h | 15 +- arch/hexagon/include/asm/atomic.h | 18 +- arch/ia64/include/asm/atomic.h | 81 ------- arch/m68k/include/asm/atomic.h | 24 +- arch/mips/include/asm/atomic.h | 172 -------------- arch/openrisc/include/asm/atomic.h | 4 +- arch/parisc/include/asm/atomic.h | 107 --------- arch/powerpc/include/asm/atomic.h | 52 ++--- arch/riscv/include/asm/atomic.h | 149 +----------- arch/s390/include/asm/atomic.h | 65 ------ arch/sh/include/asm/atomic.h | 35 --- arch/sparc/include/asm/atomic_32.h | 24 +- arch/sparc/include/asm/atomic_64.h | 65 +----- arch/sparc/lib/atomic32.c | 4 +- arch/x86/include/asm/atomic.h | 30 +-- arch/x86/include/asm/atomic64_32.h | 61 +---- arch/x86/include/asm/atomic64_64.h | 48 +--- arch/xtensa/include/asm/atomic.h | 98 -------- drivers/block/rbd.c | 2 +- drivers/infiniband/core/rdma_core.c | 2 +- fs/afs/rxrpc.c | 2 +- include/asm-generic/atomic-instrumented.h | 69 +++++- include/asm-generic/atomic.h | 33 --- include/asm-generic/atomic64.h | 14 +- include/linux/atomic.h | 371 +++++++++++++++++++++++++----- kernel/bpf/syscall.c | 4 +- lib/atomic64.c | 13 +- net/atm/pppoatm.c | 2 +- net/rxrpc/call_object.c | 2 +- net/rxrpc/conn_object.c | 4 +- net/rxrpc/local_object.c | 2 +- net/rxrpc/peer_object.c | 2 +- 36 files changed, 499 insertions(+), 1311 deletions(-) -- 2.11.0 Signed-off-by: Mark Rutland Acked-by: Peter Zijlstra (Intel)