Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3747159imm; Mon, 25 Jun 2018 04:03:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJPNmI+yhIc2gEmQQ2YW55cCjw9fyMJ27ISoHr1kGJt8tHREBG0V5l5e9+TpuKhnHDZL8SY X-Received: by 2002:a65:6004:: with SMTP id m4-v6mr10354530pgu.124.1529924635048; Mon, 25 Jun 2018 04:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529924635; cv=none; d=google.com; s=arc-20160816; b=racxVcVOhnoICyhIWe47zJJLo/IhLw2GoszGJiowyneh2CiKB48khEkwnBqDokMFyk QogvD3cX3HqWtc1oDZMIW9MVZNQZVUI36YuHZQa4W0wtiT5PSfqRDoHR4wd14pLmryDD SceKrARn+D3afhunp9lqD6VUiS/j1i8YKVtM6zj6T4zCHmMTsD/p99G2A9NGsIWF3yGc yU3pgYrHCV2yQtTpT/xXqUtU5HVIo050P96ytokAka9Chg7vLaJnC2+rHMJlvjSg79aQ xNBdMKz2an1i1aR3nVyoK8fDGX/B+9v5ij9LJCBg5ClcNkVKF8xFu15b+feMx+6VIuXT rYsw== 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=Bd2Bv2XqwoE4yoh2ig/WZrooH+Sn8/AhYKnxfrf2d3U=; b=vU38WB6Ox+BQK3iL4uHYopDpWKUIdyWhNpLXCHwxGsTE2fmvWYr8aNNjpdetB4jEdx G58zuyZVTFepDm3K057Bg/ejrn4S9loqSGF2VzGZgKAsGjk/jcp4rCBIAQGymilPXVbg 8yrsV/5bRgMMJQAj6/pUXASx72xwcENME9UhldU98ojHab03Cq7wE5ApLd4fjB7sdp6G vlJEP2G9dAYt6XvAmi7HW6RJX6L+x+DiEZplplDQgLqZ2n5gKyM5pAZZ4zbU3QUVaTCU rSEy193T7mzyA8dKIkqq6eVO5akKK5SfQh0tSkh9TUhNVtUImW7ELrrWLphvn6xecXR4 dSCQ== 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 e67-v6si5684077pfg.35.2018.06.25.04.03.40; Mon, 25 Jun 2018 04:03:55 -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 S1755297AbeFYLAB (ORCPT + 99 others); Mon, 25 Jun 2018 07:00:01 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54512 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755242AbeFYLAA (ORCPT ); Mon, 25 Jun 2018 07:00:00 -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 060CD18A; Mon, 25 Jun 2018 04:00:00 -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 5BFF73F73D; Mon, 25 Jun 2018 03:59:57 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org, will.deacon@arm.com, peterz@infradead.org, boqun.feng@gmail.com Cc: Mark Rutland , arnd@arndb.de, aryabinin@virtuozzo.com, catalin.marinas@arm.com, dvyukov@google.com, glider@google.com, hpa@zytor.com, linuxdrivers@attotech.com, mingo@redhat.com, parri.andrea@gmail.com, peter@hurleysoftware.com, tglx@linutronix.de Subject: [PATCHv2 00/11] atomics: generate atomic headers / instrument arm64 Date: Mon, 25 Jun 2018 11:59:41 +0100 Message-Id: <20180625105952.3756-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 scripts the generation of the various atomic headers, to ensure that the various atomic APIs remain consistent, reducing the risk of human error, and simplifying future rework. This fleshes out the instrumented atomics such that arm64 can be migrated over to them. Since v1 [1]: * Use 'p' instead of 'I' for pointer to base int type * Use Peter's patch for ldsem * Rename atomic acquire/release barriers * Handle xchg/cmpxchg variants * Typo fixes * Migrate arm64 to instrumented atomics The series is based on my atomic API cleanup patches [2], which have been queued in the tip locking/core branch. The first six patches clean up some issues with the existing atomic instrumentation, with patch six introducing the header generation infrastructure. The subsequent three patches migrate to each generated header in turn, with the final patch moving arm64 over to the instrumented atomics. The scripts themselves are mostly POSIX sh (modulo local), without bashisms, and work in dash and bash. Per Linus request that it is possible to use git grep to inspect the atomic headers [3], the headers are committed (and not generated by kbuild). Since we now expand the fallback definitions inline, each *should* be easier to find with grep. Each header also has a comment at the top with a path to the script used to generate it. While the diff stat looks like a huge addition, the majority of this is generated by the scripts added by this series. The patches remove ~1700 lines of hand-written boilerplate code, replacing this with ~900 lines of script, which generate That scripting comes to ~900 lines, and replaces ~1700 lines of hand-written boilerplate with ~4700 lines of generated code. Some of that increase in line count is due to filling in missing portions of the API (e.g. adding all the ordering variants to the instrumented atomics), while some of that is due to expanding fallbacks in place, and consistently spreading these across multiple lines. I've build-tested this for x86_64 and arm64 (with and without LSE), and given this some basic boot testing on an Arm Juno platform. I've pushed the series out to my atomics/generated branch [3], based atop of tip locking/core. Thanks, Mark. [1] https://lkml.kernel.org/r/20180529180746.29684-1-mark.rutland@arm.com [2] https://lkml.kernel.org/r/20180621121321.4761-1-mark.rutland@arm.com [3] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git atomics/generated Mark Rutland (10): atomics/x86: reduce arch_cmpxchg64*() instrumentation atomics: simplify cmpxchg() instrumentation atomics/treewide: instrument xchg() atomics: instrument cmpxchg_double*() atomics/treewide: rework ordering barriers atomics: add common header generation files atomics: switch to generated fallbacks atomics: switch to generated atomic-long atomics: switch to generated instrumentation arm64: use instrumented atomics Peter Zijlstra (1): atomic/tty: Fix up atomic abuse in ldsem MAINTAINERS | 1 + arch/alpha/include/asm/atomic.h | 8 +- arch/arm64/include/asm/atomic.h | 237 +-- arch/arm64/include/asm/atomic_lse.h | 51 +- arch/arm64/include/asm/cmpxchg.h | 106 +- arch/arm64/include/asm/lse.h | 2 +- arch/arm64/include/asm/sync_bitops.h | 16 +- arch/powerpc/include/asm/atomic.h | 17 +- arch/riscv/include/asm/atomic.h | 17 +- arch/x86/include/asm/atomic.h | 2 +- arch/x86/include/asm/atomic64_64.h | 2 +- arch/x86/include/asm/cmpxchg.h | 2 +- arch/x86/include/asm/cmpxchg_64.h | 4 +- drivers/tty/tty_ldsem.c | 82 +- include/asm-generic/atomic-instrumented.h | 1770 +++++++++++++++++--- include/asm-generic/atomic-long.h | 1171 ++++++++++--- include/linux/atomic-fallback.h | 2294 ++++++++++++++++++++++++++ include/linux/atomic.h | 1286 +-------------- include/linux/tty_ldisc.h | 4 +- scripts/atomic/atomic-tbl.sh | 186 +++ scripts/atomic/atomics.tbl | 41 + scripts/atomic/fallbacks/acquire | 9 + scripts/atomic/fallbacks/add_negative | 16 + scripts/atomic/fallbacks/add_unless | 16 + scripts/atomic/fallbacks/andnot | 7 + scripts/atomic/fallbacks/dec | 7 + scripts/atomic/fallbacks/dec_and_test | 15 + scripts/atomic/fallbacks/dec_if_positive | 15 + scripts/atomic/fallbacks/dec_unless_positive | 14 + scripts/atomic/fallbacks/fence | 11 + scripts/atomic/fallbacks/fetch_add_unless | 23 + scripts/atomic/fallbacks/inc | 7 + scripts/atomic/fallbacks/inc_and_test | 15 + scripts/atomic/fallbacks/inc_not_zero | 14 + scripts/atomic/fallbacks/inc_unless_negative | 14 + scripts/atomic/fallbacks/read_acquire | 7 + scripts/atomic/fallbacks/release | 8 + scripts/atomic/fallbacks/set_release | 7 + scripts/atomic/fallbacks/sub_and_test | 16 + scripts/atomic/fallbacks/try_cmpxchg | 11 + scripts/atomic/gen-atomic-fallback.sh | 180 ++ scripts/atomic/gen-atomic-instrumented.sh | 181 ++ scripts/atomic/gen-atomic-long.sh | 98 ++ 43 files changed, 5979 insertions(+), 2011 deletions(-) create mode 100644 include/linux/atomic-fallback.h create mode 100755 scripts/atomic/atomic-tbl.sh create mode 100644 scripts/atomic/atomics.tbl create mode 100644 scripts/atomic/fallbacks/acquire create mode 100644 scripts/atomic/fallbacks/add_negative create mode 100644 scripts/atomic/fallbacks/add_unless create mode 100644 scripts/atomic/fallbacks/andnot create mode 100644 scripts/atomic/fallbacks/dec create mode 100644 scripts/atomic/fallbacks/dec_and_test create mode 100644 scripts/atomic/fallbacks/dec_if_positive create mode 100644 scripts/atomic/fallbacks/dec_unless_positive create mode 100644 scripts/atomic/fallbacks/fence create mode 100644 scripts/atomic/fallbacks/fetch_add_unless create mode 100644 scripts/atomic/fallbacks/inc create mode 100644 scripts/atomic/fallbacks/inc_and_test create mode 100644 scripts/atomic/fallbacks/inc_not_zero create mode 100644 scripts/atomic/fallbacks/inc_unless_negative create mode 100644 scripts/atomic/fallbacks/read_acquire create mode 100644 scripts/atomic/fallbacks/release create mode 100644 scripts/atomic/fallbacks/set_release create mode 100644 scripts/atomic/fallbacks/sub_and_test create mode 100644 scripts/atomic/fallbacks/try_cmpxchg create mode 100755 scripts/atomic/gen-atomic-fallback.sh create mode 100755 scripts/atomic/gen-atomic-instrumented.sh create mode 100755 scripts/atomic/gen-atomic-long.sh -- 2.11.0