From patchwork Mon Feb 11 13:22:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 158002 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2593299jaa; Mon, 11 Feb 2019 05:22:32 -0800 (PST) X-Google-Smtp-Source: AHgI3IaD0R47nia450VWg/WXmwsxGwWPRmFORPEHe1EzONRyeilmMYGX4gpPOiMQKuvCLAJkDffd X-Received: by 2002:a17:902:b203:: with SMTP id t3mr8974717plr.243.1549891352504; Mon, 11 Feb 2019 05:22:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549891352; cv=none; d=google.com; s=arc-20160816; b=VMfMJDe6X0t3mk5m30W1KNCwZJEb7WyYeVGc/VoW/JskUfATCEVd677vZQL5YC61BC 5fypPgD0xvW7SvBLq6H01tk723M/Rq8qsspTyx0b3DofL5uGCfTMKFb42D0T7Vlt5bCl 9hUDqyaUCi+mV0TsKtvUHS7jgcaNm9ZxVSpnmyRHNkjeQiNSsQOswRUvXTTVRoBjTwsT of5xrskBTT2+xyIrtsVwDa8dT8NM7/Qq2Q97NFo0fMGdnegte0H4noX1q2NQUWGQjgh4 QLd825HTM/F4JZKM87Qu3UlvF+CH2cdnqiGAwSZrz7NGkQabsxEaLUfWa69+BdV8EwVL RCYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=m9kdt/aCA8eidOTCUr7ZxGDY0zbFhIyqUIT5J5fxKX0=; b=VhVBi6YSs5aQPtKogOhGmqCLe8qcLCZ6DcNATZ52EnowXGK+HTB1So0Xfe2JNgHvdV ct6GKXbDF/nJHa7T+fO5CMINW8StVrJcksneEELI0yBw6SOZ8ZcT4KR0ljDBu9zSvmpI gXRZQqzRULMpq1F8ZvWGhyLFWDVo0RhqosFzv2dSgWOVuleyvxXkNXFjNGdTUnYmL3ZR hFAEXYAgRM7gTBSJqlq5D/X94FcbGX2sKTO9l8hBt7FaoKVrEV1Q3W/Qxnm9VGzhObML yWvLhXdg3VNRz11thzi7y+lija/fqgkBMob827XuRJSq0A9KDpVll2qChRY/ANYUQy6v NvJg== 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 e189si10165717pfc.156.2019.02.11.05.22.32; Mon, 11 Feb 2019 05:22:32 -0800 (PST) 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 S1728065AbfBKNWa (ORCPT + 31 others); Mon, 11 Feb 2019 08:22:30 -0500 Received: from foss.arm.com ([217.140.101.70]:48378 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727954AbfBKNW2 (ORCPT ); Mon, 11 Feb 2019 08:22:28 -0500 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 A56A91596; Mon, 11 Feb 2019 05:22:27 -0800 (PST) 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 F2F663F557; Mon, 11 Feb 2019 05:22:25 -0800 (PST) From: Mark Rutland To: linux-kernel@vger.kernel.org, mingo@kernel.org Cc: akpm@linux-foundation.org, anders.roxell@linaro.org, boqun.feng@gmail.com, mark.rutland@arm.com, naresh.kamboju@linaro.org, peterz@infradead.org, will.deacon@arm.com Subject: [PATCHv2 1/2] locking/atomics: Change 'fold' to 'grep' Date: Mon, 11 Feb 2019 13:22:12 +0000 Message-Id: <20190211132213.15249-2-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190211132213.15249-1-mark.rutland@arm.com> References: <20190211132213.15249-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anders Roxell Some distibutions and build systems doesn't include 'fold' from coreutils default. .../scripts/atomic/atomic-tbl.sh: line 183: fold: command not found Rework to use 'grep' instead of 'fold' to use a dependency that is already used a lot in the kernel. Reported-by: Naresh Kamboju Suggested-by: Will Deacon Signed-off-by: Anders Roxell [Mark: rework commit message] Signed-off-by: Mark Rutland Acked-by: Will Deacon --- scripts/atomic/atomic-tbl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 diff --git a/scripts/atomic/atomic-tbl.sh b/scripts/atomic/atomic-tbl.sh index 9d6be538a987..81d5c32039dd 100755 --- a/scripts/atomic/atomic-tbl.sh +++ b/scripts/atomic/atomic-tbl.sh @@ -180,7 +180,7 @@ gen_proto_variants() #gen_proto(meta, ...) gen_proto() { local meta="$1"; shift - for m in $(echo "${meta}" | fold -w1); do + for m in $(echo "${meta}" | grep -o .); do gen_proto_variants "${m}" "$@" done } From patchwork Mon Feb 11 13:22:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 158003 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2593342jaa; Mon, 11 Feb 2019 05:22:35 -0800 (PST) X-Google-Smtp-Source: AHgI3IZt2RfPf1qn/yuxdQt6QYG63t19iS9XRxmVau/jzXPk6eGgGUB19vslKmLnzrbs1rfwtK+o X-Received: by 2002:a62:76c9:: with SMTP id r192mr19571158pfc.251.1549891355722; Mon, 11 Feb 2019 05:22:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549891355; cv=none; d=google.com; s=arc-20160816; b=YTAUCUh1P+AYAXwSVifED3+Sk1bcZS7y/J4AK6v6nqsxoqOh3UxtrAswyXwjSGAjSO Fjn39NNvtkrzS1zS5FXDkwRKQ5mucgcnKYKM+t/xIu6b+jU0DJwy2gywOtVW+N3rUkXF kOT/A4uaP+e5MPH0yaVhuFD93gHIZrbOV2Ypvv/YiJVfZJr4oJLQwe+9YV8KR5hYts0m QiIIDhecuvFmtuxi65zxT1EHoFOxItixXP1SwStrU6K+K44Bm60c88G/Dj7o5kA2ZNDx czMw40SJWIG+fMPuafD08eMey42UceCKaiLuQQh1h0cYwJtTWmmtNae/g85zgP1g+SlV Mg4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=3zrvX+SZCUf/RJ1UFHhh0IV6QiY7njBNyqPu2d5m6uA=; b=NqYXT5CeZP/D6g3OJiNfPGDBiV615cFqqNagVos/fpQPUpqBcyC7wLlahJJvWQV139 awaidTTBxLdUhVWfZaz2X+3upz/z8ORU97UUhCA/pm58jcYSBqt/yvRFPuZPyxby2bdW z3Y6e2ZfgFtjUxlxV4gHLfYaf2bxZXaGmnc9bWubE3Q/SusTVYrz3IHwnezRmVgzcAk0 N8JXe53Gm8CqC6pvpwdz2P6b7is9mruFKMPEAXvmf8X/lpX6cZdWLuTlNNOCdsoFLNnP b2IqwD+k5ur7xdjLLoXM9a2p00VNMZjHv7qiWepAdCmIiZFD3pKSALxNp0eJmOjHxndr LOqg== 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 e189si10165717pfc.156.2019.02.11.05.22.35; Mon, 11 Feb 2019 05:22:35 -0800 (PST) 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 S1728075AbfBKNWe (ORCPT + 31 others); Mon, 11 Feb 2019 08:22:34 -0500 Received: from foss.arm.com ([217.140.101.70]:48392 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727913AbfBKNWa (ORCPT ); Mon, 11 Feb 2019 08:22:30 -0500 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 2C96F80D; Mon, 11 Feb 2019 05:22:30 -0800 (PST) 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 8390B3F557; Mon, 11 Feb 2019 05:22:28 -0800 (PST) From: Mark Rutland To: linux-kernel@vger.kernel.org, mingo@kernel.org Cc: akpm@linux-foundation.org, anders.roxell@linaro.org, boqun.feng@gmail.com, mark.rutland@arm.com, naresh.kamboju@linaro.org, peterz@infradead.org, will.deacon@arm.com Subject: [PATCHv2 2/2] locking/atomics: Check atomic headers with sha1sum Date: Mon, 11 Feb 2019 13:22:13 +0000 Message-Id: <20190211132213.15249-3-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190211132213.15249-1-mark.rutland@arm.com> References: <20190211132213.15249-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We currently check the atomic headers at build-time to ensure they haven't been modified directly, and these checks require regenerating the headers in full. As this takes a few seconds, even when parallelized, this is too slow to run for every kernel build. Instead, we can generate a hash of each header as we generate them, which we can cheaply check at build time (~0.16s for all headers). This patch does so, updating headers with their hashes using the new gen-atomics.sh script. As some users apparently build the kernel wihout coreutils, lacking sha1sum, the checks are skipped in this case. Presumably, most developers have a working coreutils installation. Signed-off-by: Mark Rutland Acked-by: Will Deacon Cc: Andrew Morton Cc: Boqun Feng Cc: Ingo Molnar Cc: Peter Zijlstra --- include/asm-generic/atomic-instrumented.h | 1 + include/asm-generic/atomic-long.h | 1 + include/linux/atomic-fallback.h | 1 + scripts/atomic/check-atomics.sh | 26 ++++++++++++++++++++------ scripts/atomic/gen-atomics.sh | 20 ++++++++++++++++++++ 5 files changed, 43 insertions(+), 6 deletions(-) create mode 100755 scripts/atomic/gen-atomics.sh -- 2.11.0 diff --git a/include/asm-generic/atomic-instrumented.h b/include/asm-generic/atomic-instrumented.h index b8f5b35216e1..e8730c6b9fe2 100644 --- a/include/asm-generic/atomic-instrumented.h +++ b/include/asm-generic/atomic-instrumented.h @@ -1785,3 +1785,4 @@ atomic64_dec_if_positive(atomic64_t *v) }) #endif /* _ASM_GENERIC_ATOMIC_INSTRUMENTED_H */ +// b29b625d5de9280f680e42c7be859b55b15e5f6a diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h index a833d385a70b..881c7e27af28 100644 --- a/include/asm-generic/atomic-long.h +++ b/include/asm-generic/atomic-long.h @@ -1010,3 +1010,4 @@ atomic_long_dec_if_positive(atomic_long_t *v) #endif /* CONFIG_64BIT */ #endif /* _ASM_GENERIC_ATOMIC_LONG_H */ +// 77558968132ce4f911ad53f6f52ce423006f6268 diff --git a/include/linux/atomic-fallback.h b/include/linux/atomic-fallback.h index 1c02c0112fbb..a7d240e465c0 100644 --- a/include/linux/atomic-fallback.h +++ b/include/linux/atomic-fallback.h @@ -2292,3 +2292,4 @@ atomic64_dec_if_positive(atomic64_t *v) #define atomic64_cond_read_relaxed(v, c) smp_cond_load_relaxed(&(v)->counter, (c)) #endif /* _LINUX_ATOMIC_FALLBACK_H */ +// 25de4a2804d70f57e994fe3b419148658bb5378a diff --git a/scripts/atomic/check-atomics.sh b/scripts/atomic/check-atomics.sh index c30101cddf2d..cfa0c2f71c84 100755 --- a/scripts/atomic/check-atomics.sh +++ b/scripts/atomic/check-atomics.sh @@ -7,13 +7,27 @@ ATOMICDIR=$(dirname $0) ATOMICTBL=${ATOMICDIR}/atomics.tbl LINUXDIR=${ATOMICDIR}/../.. +echo '' | sha1sum - > /dev/null 2>&1 +if [ $? -ne 0 ]; then + printf "sha1sum not available, skipping atomic header checks.\n" + exit 0 +fi + cat < /dev/null); then - printf "warning: include/${header} is out-of-date.\n" +while read header; do + OLDSUM="$(tail -n 1 ${LINUXDIR}/include/${header})" + OLDSUM="${OLDSUM#// }" + + NEWSUM="$(head -n -1 ${LINUXDIR}/include/${header} | sha1sum)" + NEWSUM="${NEWSUM%% *}" + + if [ "${OLDSUM}" != "${NEWSUM}" ]; then + printf "warning: generated include/${header} has been modified.\n" fi done + +exit 0 diff --git a/scripts/atomic/gen-atomics.sh b/scripts/atomic/gen-atomics.sh new file mode 100755 index 000000000000..27400b0cd732 --- /dev/null +++ b/scripts/atomic/gen-atomics.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# Generate atomic headers + +ATOMICDIR=$(dirname $0) +ATOMICTBL=${ATOMICDIR}/atomics.tbl +LINUXDIR=${ATOMICDIR}/../.. + +cat < ${LINUXDIR}/include/${header} + HASH="$(sha1sum ${LINUXDIR}/include/${header})" + HASH="${HASH%% *}" + printf "// %s\n" "${HASH}" >> ${LINUXDIR}/include/${header} +done