From nobody Thu Jan 30 23:21:39 2025 Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8E7E1D61A3 for ; Fri, 24 Jan 2025 01:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683931; cv=none; b=RZoxROoE9vkaHv7Lnb5qaoaeYIUVqiuFFdAaApEWF9eLOF23MIQLaI2WQaE/vO/QVJwzJflCOm5gbxFSFdUcrdc79nrwBdmJGvI4KE0w3AU7cTdCMAXTWLfSSngj1/QHS4VHJM1eTTSYz9D8Tfgnz8ERAebV/GTxI8eiVvT2Dwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683931; c=relaxed/simple; bh=2/LB3V5JWdcgf4tsAt88qzoc3B9PT+ZPjL3M7JzTYTA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Tp/wfwuL5JNcMhNlFfJcDI4LHUR3OMbsXpzRgUDMLfgicPYgssHN2rUUw7jSnkN1ClOadhUZwxgiJzNwb5vZfVJvrXgdS6fO43qUub4BgBSKizlK2QH0XYhFFqV7Hi+DTs0fc9cNRcKO7S/oQ6EkXhQowoF2CAPgIv/NvAsvArE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org; spf=pass smtp.mailfrom=joelfernandes.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b=FRq9ATeL; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=joelfernandes.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="FRq9ATeL" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-7be44a90468so181234885a.3 for ; Thu, 23 Jan 2025 17:58:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1737683928; x=1738288728; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EOszlMe/TkxR9TrVzVzkXceOdLnBKIK5m4j/zRnrkWk=; b=FRq9ATeL8byd0qZjRMKs5GoVDNwzxC79MSg+ZyeqO/OzOzHeGIX2bSn+qMpf1xifv0 6XvN3iMkrle08eJu/Fb3gBqaWwq/zNK5v4MvfGFeEn1tGkOSh3WAT7Y1nFxN5IB2Jb0n ETVwM6N/f0Ly3R85j6OUDKXUlXuDNbNe2hfJA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737683928; x=1738288728; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EOszlMe/TkxR9TrVzVzkXceOdLnBKIK5m4j/zRnrkWk=; b=qyfQ33jG6yvBoMF26pCIF0ot+hhOjbEHB1iIQlvA5j+nFpqgPCnlQ5bNkJVkFBbx1O M2DMfQ30NMVo0Y1gIluycPJy7aoFD0JJxlT2p3agp3uIJ1c6ts3s4hGcVzcdyuSk12wa Tb72nfqyhsRh49zlxhfUVEJ+phLtJZDIcsuWGso4AHXOx5tRKS+8rhQu5mxRg+v4xyNO o91aDxbHAw7JwyHHnBPBfBcA5QDlcsZFXJSfiwA9gB9bf5GmsSszJSmiH60Hdk+wnr5D H829Gc1AE78dJIcKS5yE3/hQUG7PyyQgJNkYIBg3IUUOKbJjSwn7j35P9FdYCfRBhE0Y CG0g== X-Gm-Message-State: AOJu0Yw7lhpR0OM4+wUQMXLW5SOodIBsLIlvWxromqImnsGAqmdz14AZ Pd/XX5If97nZ8x6Tsw0ORCumha+Jlh3tQg94niMRkF9ucHyHp8VI+9EsJcWzJbHOfaj58ZHMow+ d X-Gm-Gg: ASbGncuviaaEq4Iol4CCLG9ihxnHgAOkCw6jS35Lf0wIFi8oaXSRMnOjbZz6RY2cf5O DinZ148k7xUVaE6mq2tRq9RVB4ue292hkRPLhhVg3iDNyiykzwIS9K+Q2c6TThtzu7nXzmURvEi GVUNloKWifDwKFto/pvl11DhCimOukl/ZW/EFlWhhd7WDKa5X+NQG5Gw4lsVz5Cq/2kfcRxsJr8 GCWl8bjMpWL1HH3LKvE+a/hdH/ewlpx/YqFQQn7FjVewidZpppX+dWmNwXIyk34eIeSdglaH0k8 VWRrjRQ5eYq6OjX5CnW+uEU+6i+BMM65ZDskiBFqdku+pBI= X-Google-Smtp-Source: AGHT+IH9ySNTqIGTKZEGcsDbyErRXUpqlMVIGd6POYjLkXuAG73cMWZAVXL3Cixc0SCiAmr0lb4wWg== X-Received: by 2002:a05:620a:2b9b:b0:7b6:d1e1:a239 with SMTP id af79cd13be357-7be631e58d9mr4060955685a.2.1737683927847; Thu, 23 Jan 2025 17:58:47 -0800 (PST) Received: from joelbox2.. (c-73-251-172-144.hsd1.va.comcast.net. [73.251.172.144]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7be9ae8a5fbsm44741985a.31.2025.01.23.17.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 17:58:47 -0800 (PST) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Shuah Khan Cc: "Joel Fernandes (Google)" , rcu@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH RFC 2/5] rcutorture: Add a stress-ng build script Date: Thu, 23 Jan 2025 20:58:33 -0500 Message-Id: <20250124015836.732086-3-joel@joelfernandes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250124015836.732086-1-joel@joelfernandes.org> References: <20250124015836.732086-1-joel@joelfernandes.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This script automates the building of stress-ng and can be run from any directory. It also support cross-compilation. The output is placed into the initrd directory. Signed-off-by: Joel Fernandes (Google) --- .../selftests/rcutorture/bin/mkstress-ng.sh | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 tools/testing/selftests/rcutorture/bin/mkstress-ng.sh diff --git a/tools/testing/selftests/rcutorture/bin/mkstress-ng.sh b/tools/= testing/selftests/rcutorture/bin/mkstress-ng.sh new file mode 100755 index 000000000000..e5a19cca6923 --- /dev/null +++ b/tools/testing/selftests/rcutorture/bin/mkstress-ng.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0+ +# +# Clone and build the stress-ng tool, placing the binary in the +# initrd directory. Ensure binary is up-to-date. +# +# Usage: ./bin/mkstress-ng.sh (run from any where). +# +# Copyright (C) Google LLC, 2024 +# Author: Joel Fernandes (Google) + +# Get the directory where the script is located +SCRIPT_DIR=3D"$(dirname "$(readlink -f "$0")")" + +REPO_URL=3D"https://github.com/ColinIanKing/stress-ng.git" +SRC_DIR=3D"${SCRIPT_DIR}/../res/stress-ng" +INITRD_DIR=3D"${SCRIPT_DIR}/../initrd" +BIN_NAME=3D"stress-ng" +export COMPILER=3D"${CROSS_COMPILE}gcc" + +is_statically_linked() { + if file "$1" | grep -q "statically linked"; then + return 0 + else + return 1 + fi +} + +needs_build() { + if [ ! -f "$INITRD_DIR/$BIN_NAME" ]; then + return 0 + fi + if [ "$(find "$SRC_DIR" -newer "$INITRD_DIR/$BIN_NAME")" ]; then + return 0 + fi + if ! is_statically_linked "$INITRD_DIR/$BIN_NAME"; then + return 0 + fi + return 1 +} + +if [ ! -d "$INITRD_DIR" ]; then + echo "Error: INITRD_DIR ($INITRD_DIR) does not exist" + exit 1 +fi + +if ! which "$COMPILER" &> /dev/null; then + echo "Error: Compiler $COMPILER not found." + exit 1 +fi + +if [ ! -d "$SRC_DIR" ]; then + echo "Cloning stress-ng repository..." + if ! git clone "$REPO_URL" "$SRC_DIR"; then + echo "Failed to clone stress-ng repository." + rm -rf "$SRC_DIR" + exit 1 + fi +else + echo "Updating stress-ng repository..." + cd "$SRC_DIR" || exit 1 + git pull || { echo "Failed to update stress-ng repository"; exit 1; } + cd - > /dev/null || exit 1 +fi + +# Build stress-ng binary if needed +if needs_build; then + echo "Building stress-ng binary..." + cd "$SRC_DIR" || exit 1 + STATIC=3D1 make -j 8 || { echo "stress-ng build failed"; exit 1; } + cd - > /dev/null || exit 1 + + # Verify the stress-ng binary is static + if ! is_statically_linked "$SRC_DIR/$BIN_NAME"; then + echo "Error: The stress-ng binary is not statically linked." + exit 1 + fi + + echo "Copying stress-ng binary to initrd directory..." + cp "$SRC_DIR/$BIN_NAME" "$INITRD_DIR" || { echo "Failed to copy stress= -ng binary"; exit 1; } +else + echo "stress-ng binary is up-to-date, no build needed." +fi + +echo "stress-ng build process completed successfully." +exit 0 \ No newline at end of file --=20 2.34.1