From patchwork Mon Dec 10 17:50:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 153333 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3832126ljp; Mon, 10 Dec 2018 09:50:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/VANI9apgquSQPjLRM6M3wGq4oKz+etvgFmGcTEtfig0VzNb9etm7fWMUjb6cOlyM1sv1cH X-Received: by 2002:a17:902:b83:: with SMTP id 3mr12336422plr.42.1544464249888; Mon, 10 Dec 2018 09:50:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544464249; cv=none; d=google.com; s=arc-20160816; b=wgH9sXBdz7eaHXEshjV7Pj0vMKYp0Xots9Ikfn70PYdQtFkPVzu26eFkdtiZQsCipn Z+bXR/D8SMFBRilTKarWgJvWcdsN3YTOGwFcSfS5muRX//ZDG6qQO0xbfi0VtwyAMIcV GG2WVHYW9dSt0f3OSc8UwKmBrTi/DOH0nrtWdR0or1Bf25on/Ozgdlrg+3c/BiVBRkDp vyjivxxedmBNjP+OB5w/6HKD314fSkXJhuNMVkw30Xb0shrVK8R2XstjpaUCbbQwPU1/ JMoFWqOTgoZrEET/A64+Ff0eFO6eN3f+qn3DRwt05EZE9bWNE0kK2d6rMGvphUGGLDSc iDmQ== 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=u1Qu1jFWNEBoaaYKfroRThus5zflRdqxrrCdYd5RuhI=; b=0b/d9k/O4TzS+OkcF6v1FvV2vdvctnobJqokr1+jG/HuG+spRy9eFuygBhrTj453pJ qIrwEmNTLC4+kBcf9Oo9NPC1LHpiminL2j7ktbj13GWw1mZ/uYSARvazrI+StLcIpqXc nvzflItL6UyulBynIV7k4JwJVldBMijse3R5gOF8y59PiNG+RjGJJ8YWt76tNJXPMNwD IV7CVc7eb1v6WFb57hig27B1pwcjtHpBnHEm/gMO8c/lyGzRyFD6dzn17vcvrRNS/+gz uwQ9ZTRF1xYdwNUg/LeJBJCacdgr3GP/sNgxjd4e8v4GW64gYkaPosHp9vTFVRmPcfa2 p/bQ== 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 j5si10891391pfg.254.2018.12.10.09.50.49; Mon, 10 Dec 2018 09:50:49 -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 S1728559AbeLJRus (ORCPT + 31 others); Mon, 10 Dec 2018 12:50:48 -0500 Received: from foss.arm.com ([217.140.101.70]:59864 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727781AbeLJRup (ORCPT ); Mon, 10 Dec 2018 12:50:45 -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 04FEA15BF; Mon, 10 Dec 2018 09:50:45 -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 50C7A3F6A8; Mon, 10 Dec 2018 09:50:43 -0800 (PST) From: Mark Rutland To: mingo@kernel.org Cc: linux-kernel@vger.kernel.org, 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: [PATCH 1/2] locking/atomics: Change 'fold' to 'grep' Date: Mon, 10 Dec 2018 17:50:34 +0000 Message-Id: <20181210175035.45096-2-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181210175035.45096-1-mark.rutland@arm.com> References: <20181210175035.45096-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 --- scripts/atomic/atomic-tbl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 Acked-by: Will Deacon 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 Dec 10 17:50:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 153334 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3832227ljp; Mon, 10 Dec 2018 09:50:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/VUA0dD/sCnJR/6SCeP55WhD3qlNkB3JHJcKPdcnaeWIdoMBOTIsFF4MBfcQWhVvSvPfqZ1 X-Received: by 2002:a63:4f5e:: with SMTP id p30mr11701706pgl.71.1544464255294; Mon, 10 Dec 2018 09:50:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544464255; cv=none; d=google.com; s=arc-20160816; b=ajIFP41XWFRVwfFLzapWJvbCZe2zfvbseTN+mG5K+uiFffqyESnjhFh4n0oPsyYRG6 t70Htz67JxHW7UrowOyKrd5f+/zEYsvC60m195emIE6ktRDQa4GMKiw6HI0o22JLc07W fguLJ1ijDaJlWvuDWvBzJYXcCwODmWoIrCxO6edMQNbPMGyJaaGK7rUWDrnViV+z/g3I b/4WeS0dz6hvSXUIuMpfg4wTyBP1BatTPBhJzNAfslSkx3Fqe9h6/6nvkhDqxDJlFBqW xdZDAllG1Uk3wuh53RoesFzElRAxkGGc4U7G21BT2OATF7Jem9H78orVjx/rnFN5v5hy v/3Q== 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=sphns2PRTsM++BxaHPK1axVuIj2hh31AaeanRPjXuz0=; b=dE6bdEGoHwLRC7O3fAdgSB+5+rNQKzOy2BvOn0Iku8W2b5cSuLfvQ9LDdIkLPK/HoI +7H6PhnISS+ha3eGyrHsp9dYX7zLWCrTtBC7itIOyeArx1LPo8GxrSH4w8MPs6GAYMKH 1wSSlO3tIiQu6eLyhFWwtb+OZSaddSg7imDNf3Hdbzi4dPkJJmCktK1RJ/GvefZIchqV negyb6eCFK8cISnhuVPkEzQXLZ8Cx8P58QfatKxe4X4WulPWMQEFzh6IFq9IJI2vLD2g fQZfhTWRxEcGhBIAqWZyTBd9xPmECBGobBR2PdRMzQ0L7WskJJT8h7VzJq7Fo46oyIE6 mZsw== 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 y6si10192100pgb.516.2018.12.10.09.50.55; Mon, 10 Dec 2018 09:50:55 -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 S1728627AbeLJRuw (ORCPT + 31 others); Mon, 10 Dec 2018 12:50:52 -0500 Received: from foss.arm.com ([217.140.101.70]:59878 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728424AbeLJRur (ORCPT ); Mon, 10 Dec 2018 12:50:47 -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 4C1491650; Mon, 10 Dec 2018 09:50:47 -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 A2CA33F6A8; Mon, 10 Dec 2018 09:50:45 -0800 (PST) From: Mark Rutland To: mingo@kernel.org Cc: linux-kernel@vger.kernel.org, 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: [PATCH 2/2] locking/atomics: Check atomic headers with sha1sum Date: Mon, 10 Dec 2018 17:50:35 +0000 Message-Id: <20181210175035.45096-3-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181210175035.45096-1-mark.rutland@arm.com> References: <20181210175035.45096-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 Cc: Andrew Morton Cc: Boqun Feng Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Will Deacon --- 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 Acked-by: Will Deacon 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