From nobody Thu Jan 30 17:33:30 2025 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (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 A87D11D5AA5 for ; Fri, 24 Jan 2025 01:58:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683929; cv=none; b=gNJ5RoQ/qNxKZ8lRpVPVLOg/aqEcmro29xH2dJoIIIEMDSlrPhxkU4PQ3JlEnFfBEZX3JkOxKjxWLndf4N4wf9q8QsRaVgLqPZ6bSuEmBD5J3iZySS7Ep4/zgE4CJs2mku35RNp8wP7qDJV4RNF/NX5xq6CYmWZV7mDZDoF7QRw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683929; c=relaxed/simple; bh=mlls54bce+0lvfNSi96vEZ6jU4CJvOJNuNga3KxcE+A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SIW2P4cVnWSHEhTgLpf57lu6XlqhKFykbqRIe1AYhrfp8ttGzoeJXbavTaCXS7ZpXhTQ0Z2ZqCqPpexLP82I7juWGERWVfhrZRbn/oMKn7oz/ZxMf/Taw4pu2hzY6pO8ExHvaqWRQp0lOSPe5ndAlVr8HmCiUux908I6F+xJ3uE= 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=YOwDyFgU; arc=none smtp.client-ip=209.85.222.182 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="YOwDyFgU" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7b6ef047e9bso154110885a.1 for ; Thu, 23 Jan 2025 17:58:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1737683926; x=1738288726; 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=qaQdwk1K6JMmpEpTCCMueooCLhtDXZocXZ+0dVMaVq8=; b=YOwDyFgUkwUyUl7OAe8ejSuXAMFVvQ5NSXSJN0jOvTDHjVmxxX0cISRJMYJRgOOjiJ G5k/PxzFQtJkkzvU8Yb6AROkcowPdlHMq8AlmUmHWwZFjhW1YcR6NDyoV1Zre5+KLaQz j70Z0HQzByW3gGiy+XB6L4TwopPb+X0VDBBRQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737683926; x=1738288726; 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=qaQdwk1K6JMmpEpTCCMueooCLhtDXZocXZ+0dVMaVq8=; b=ARTYtfHW554ShMBOi+tUnneWvGmrknsYPbxE+eyiH4cSO0JQ8yvO0rntF9FdSGfRdo dgT2k7ggkNpIgcKY34uZR/PbTuRW4wGIK3RY7AKtJ0Vysn8u397oabP+lqwtOKXztdOg 5kdsIj4NR9aXo2sY3MF3wtnI3JpFL7zsidRoy5IH2neue+LiT5nnQPhmiyLfFwooRzh4 ZP4ZUWBSoxCIIrLoQp1M/tUlJSFNCTJDX4pww0je3lzjBDvM+4CV6mgaWASWBiF3cRIA kCw/X7CEyQHnn7z136qi7TrNRzkrD3PUoOwNVGW6achJcDFaAJ6kPOfRtBdiy2aSouMn d5eQ== X-Gm-Message-State: AOJu0YyRFmS7I5NpDy1NQBIsp5bHlohwtZOw7ocJuOlzq7Wb/ZW5AgUO CmdWc0GwdinwVmiFm6aekjqZzVcg4u2TA5eHd/6+7EnfqntSPJsZquKytc5wvPxePaEeQdZUhFv r X-Gm-Gg: ASbGncsPIwzpFQrGg7Dqo/ZJYJf6ykJdlCrDTlj8t4bHHfn9eKPRmlWgmFNLQtOo2Ft 6ML6yg2phNbrxNQyl9loEO7Ls+JFkCygMCpasTEAq9o3vfQyB0jfPqD8+iK0HUQ4ihy2Idl/Q6I ksHNG+nDuyzMQsmRHT/AEgzCOCnaZnELS7d557sSa52ah9rx549pkgNKd+Cy7BiGGt8gjBO+Et5 MuUDvnYNDrvqOaajPdVkxzE0m+76L2gIKAQ6BWgGFIbxC3HPQvXmgDZKfE9xClwsuvx6S41OgIN 4PGpxbJrWO/05h5LlumjGa1vRdH5kfKb4sh0cvDcCUese78= X-Google-Smtp-Source: AGHT+IGedeLyH46JZ6ICjRhHLoRnczUEGAXR32xcGpowOpwEm6uqWspuRRdZr/IOKsIKbb8aqDrT3A== X-Received: by 2002:a05:620a:278e:b0:7be:73f6:9e86 with SMTP id af79cd13be357-7be9af69755mr301087285a.20.1737683926278; Thu, 23 Jan 2025 17:58:46 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 17:58:45 -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 1/5] rcutorture: kvm: Simplify invocation of mkinitrd.sh Date: Thu, 23 Jan 2025 20:58:32 -0500 Message-Id: <20250124015836.732086-2-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" The else block is unnecessary and we can simply clarify the if condition to remove the else clause. It is more readable. Signed-off-by: Joel Fernandes (Google) --- tools/testing/selftests/rcutorture/bin/kvm.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/= selftests/rcutorture/bin/kvm.sh index 42e5e8597a1a..4766c3023fed 100755 --- a/tools/testing/selftests/rcutorture/bin/kvm.sh +++ b/tools/testing/selftests/rcutorture/bin/kvm.sh @@ -275,10 +275,7 @@ do shift done =20 -if test -n "$dryrun" || test -z "$TORTURE_INITRD" || tools/testing/selftes= ts/rcutorture/bin/mkinitrd.sh -then - : -else +if test -z "$dryrun" && test -n "$TORTURE_INITRD" && !tools/testing/selfte= sts/rcutorture/bin/mkinitrd.sh echo No initrd and unable to create one, aborting test >&2 exit 1 fi --=20 2.34.1 From nobody Thu Jan 30 17:33:30 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 From nobody Thu Jan 30 17:33:30 2025 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (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 E68AB1D63E7 for ; Fri, 24 Jan 2025 01:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683933; cv=none; b=QGXNSPqVX8jDx8T+NQVJ5HLXwsQXaQFkziTnXfTA4LlhoeA9mR76B9Px7nMGLs30hp589GAq7oHbDBte9MKfr77rPINFeOMmLVuF9SpKsiJtsWtgsjHgaGvdVAK9njeUglbvdLmtSHV8C/uBPXv4L/cAAwZ1SRLtfNVd7zmZOiQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683933; c=relaxed/simple; bh=sh2unf8Xeoi6Q+VSDQ1CR6UU8KtcNX5rCfAveB7F7g4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qjzmTAaFPA1tjuC4rIQ+JD/9VZA3MR686sbpxMyw2AyZNVkE7FlygHVgECQl5+Wnd0/6sb6TlOAT9AEgYTtE5CIi9iTPDyxtHSGVt/bfsCwsTZOfSiV7Q8OhIdzvwVgrc+Hf1PkgvOECkDOjJRSolDlLi2xaoLMVFYG6bExRpzo= 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=QM5Znsjg; arc=none smtp.client-ip=209.85.222.170 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="QM5Znsjg" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-7b6ed9ed5b9so231652385a.2 for ; Thu, 23 Jan 2025 17:58:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1737683930; x=1738288730; 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=kRHySpG58abjuaHF+3dQ690cqYR/gs8q/AgyFnz04uw=; b=QM5ZnsjgRpfmjA2wejPdBLDlwknbe41yevnkg0RAp6+D9/52YSs3VwhNdspOHW5dMs sYD7zYueoMdANFOKNaDTCz96Ml9TCsImM7mbwnJ6CT7q6Pti220YKutJDQvKp8RaDO/Y wAjLHPk40ApzSeJw8UQqTxr9ej27gYBfUoWAA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737683930; x=1738288730; 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=kRHySpG58abjuaHF+3dQ690cqYR/gs8q/AgyFnz04uw=; b=AZEzSG1o/pBh41pcjzfgS5TPJQessDXotOhuf8rmqZwdYDrXvH0FqISUctUQU4v1uo pI5OIQH2llPbvryzAqEdrQ8osw4fueB0d8dRe+RZuKMi+qrwJNWpTWTQBvUDJgDIbya1 98piH6lkzgKFokHDOI88Ty6no65hhK/HsZH65p9utfwrZcmEwr6LdZzU8ur5Cl7tac7D /6kyoI6x6rZ5gFrkfKirHHkmpNiQk6CuW5H3GJjNyFyhuV8MqQLaLPfBSAoYC8VBPmgo izdB3jGcCM5uq5cQx8tm+Glnp57q8VZDVH7ExRcvVmrivaG93CzqoAjnax3/SNH2gy7L 9Zqw== X-Gm-Message-State: AOJu0YxD/fKEunbxlYItVjNPtx8ghjkDZCK2xKYcm2YpHL17PTSE2W4h J50IMh6vC7Eik4tamIOD6536i/zVGXsUHaWZK43f9QBN55rsq3PtObW2ukPqZemBIdepnZSAi1W K X-Gm-Gg: ASbGncswPg93GLmJH/QK8tRXZ7EDtVgctQJVDeWrLJ2D3wsCjfvBU5wX534L1dmmJIA k6BJlQT2fCzM+sx/KT0yBHpTVZLXTUu71WvEjky64o3BT8RKFMYI1qNaMXTE49Eh6czd57Vx63h 6xfdf+Y1raNbdWT7t11d/u57rUS8XdBtTo4u8CLA1s81oiQtdT6cvvX/5MxGbTv5Vit6EjMu3/B YZa1WrlxRql2x2sQcObRqMNdft796HgZyUvNrlN9aDP90ejBVnDay0kk+/7gCGX22zEtO1pFzRf Z0q654T333ueb21uHz5vfj1M8QPKAU2679IcBu/Q0E8L2+g= X-Google-Smtp-Source: AGHT+IHaXKdjk1Buyn6a6Xv4FIqoSmZ7YVk5544zLuI+aKxxiCP2bXeVGPwOfxrj/Gksc+jk8pGH9w== X-Received: by 2002:a05:620a:440f:b0:7b6:7a87:744a with SMTP id af79cd13be357-7be631e712amr4443518985a.5.1737683930638; Thu, 23 Jan 2025 17:58:50 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 17:58:49 -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 3/5] rcutorture: mkinitrd: Allow to run optional commands passed to it Date: Thu, 23 Jan 2025 20:58:34 -0500 Message-Id: <20250124015836.732086-4-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" Embed commands to invoke into init.c via mkinitrd.sh args. This allows init to spawn a child process running the command with the required arguments. Signed-off-by: Joel Fernandes (Google) --- .../selftests/rcutorture/bin/mkinitrd.sh | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/rcutorture/bin/mkinitrd.sh b/tools/tes= ting/selftests/rcutorture/bin/mkinitrd.sh index f3f867129560..4ba5e962e3cf 100755 --- a/tools/testing/selftests/rcutorture/bin/mkinitrd.sh +++ b/tools/testing/selftests/rcutorture/bin/mkinitrd.sh @@ -2,6 +2,9 @@ # SPDX-License-Identifier: GPL-2.0+ # # Create an initrd directory if one does not already exist. +# Usage: mkinitrd.sh [command [args...]] +# Example: mkinitrd.sh stress-ng --cpu 1 --cpu-method matrixprod --cpu-ops= 1000000 --perf -t 5 +# Note that command/args are optional. # # Copyright (C) IBM Corporation, 2013 # @@ -25,7 +28,9 @@ echo "Creating a statically linked C-language initrd" cd $D mkdir -p initrd cd initrd -cat > init.c << '___EOF___' + +# Generate the init.c with optional command +cat > init.c << 'EOF_HEAD' #ifndef NOLIBC #include #include @@ -33,6 +38,29 @@ cat > init.c << '___EOF___' =20 volatile unsigned long delaycount; =20 +void run_optional_command() { +EOF_HEAD + +if [ $# -gt 0 ]; then + # If command provided, generate run_optional_command() with the specif= ied command. + # We use printf to generate the command and args. + # Example: echo $(printf '"%s", ' cmd a1 a2) gives: "cmd", "a1", "a2", + cat >> init.c << EOF + pid_t pid =3D fork(); + if (pid =3D=3D 0) { + char *args[] =3D {$(printf '"%s", ' "$@")NULL}; + execve(args[0], args, NULL); + } +EOF +else + # If no command provided, function will be empty + echo " /* No command specified */" >> init.c +fi + +# Add the rest of the program +cat >> init.c << 'EOF_TAIL' +} + int main(int argc, char *argv[]) { int i; @@ -43,6 +71,9 @@ int main(int argc, char *argv[]) for (i =3D 0; i < argc; i++) printf(" %s", argv[i]); printf("\n"); + + run_optional_command(); + for (;;) { sleep(1); /* Need some userspace time. */ @@ -62,7 +93,7 @@ int main(int argc, char *argv[]) } return 0; } -___EOF___ +EOF_TAIL =20 # build using nolibc on supported archs (smaller executable) and fall # back to regular glibc on other ones. --=20 2.34.1 From nobody Thu Jan 30 17:33:30 2025 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (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 A3B021D7989 for ; Fri, 24 Jan 2025 01:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683936; cv=none; b=o8qb4It82zkG4gTboPYb639CXrhIfYFB8Bf9OK1K9nhL1Jj5XKoQxqc1Gt3g81DVHUerCc0dAqcscKN2xgWGv7hjBMT1XXK9CHPyCznej948ROQrXE/BM6aFsMkh4Rm+Gn+4+kh62bregxsh4K8pqCAJ1o88K5OBk4QUvoYpCSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683936; c=relaxed/simple; bh=14hdZvQy12znP3JBrDTEin8Vq/JMaX7z3pC3iDZMCHE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ANxLKWMpzzr8mQ3wh0zMaw5rk1NeKS5fZm5udq40h4GSi5zN7+Ijfwgaw6ygDDVugRyHL0PFnoWmpLtt51PgHFmaLRrkmtWRau/SZid6UiCxB61xDTjAPR8FRS1l/7r9fzQFJ4txAmcKpdnOuvEIIikti8czewp1oN1kLzk6Akc= 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=tQNRiiBI; arc=none smtp.client-ip=209.85.222.173 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="tQNRiiBI" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-7b6e9db19c8so143399485a.3 for ; Thu, 23 Jan 2025 17:58:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1737683933; x=1738288733; 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=WZvohp5XISf/Tn/4fv46H+WUbuRmv7JS7QX/Rz1OCJ8=; b=tQNRiiBI6/h6TBEY0YQL5rHaeScChu6j8UCh5D7jCO2dMa5kzHTHuYzC0Ms92qJRgn wyho/uHXGO7ZVOoQMLLoDWtLzCMPEndXMBRKwcvVlTShI9pZEbb+21LcV6xNqcTdN0VX kV0HVpY14gOsBbYd6mcxoM3x98EnCt0xx9IK0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737683933; x=1738288733; 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=WZvohp5XISf/Tn/4fv46H+WUbuRmv7JS7QX/Rz1OCJ8=; b=u8Ky5U0fUpD79VdSaZqbBffaO86uCbOVhZ+Fphh20scYtbhxOgRLZqoiVtWY7ljImu b+7PooMu2HH9RcVfXpiIyjuK9TR/1zuLTxQmmsXlFt+rzeXBDNrC223CQfFiLECmVSGS PkGpKcdWVAHxRsSr0JkB23oPs3TP15KP4BDzWWpeg6NZvNmOX2X9F1oHk4slaDIW1GLi Ew7+1c4qMp1L4ERG9WlhTK1AxN0Yz+Svs0i6Xk7fOHWTZoUc1OiDt/SHSuSiyY4U8Wqc XvURlem4l19KzuSrLZUhGHSiQu23vBNd0FftypaEKeTYNXoEbho15uWQiWTFK/JgcAf+ yqzg== X-Gm-Message-State: AOJu0YxgqzYuqWAbH4djNk66xFX3tS2KDhNdKN4EUG6BNJF8/mKuVnAK RJ9fTs7wysTVqmNKb/5PKoTXhSbB00IA9/4NWe+MeUmn6vFZWALoqp0YZlgcWxsVtXDpYWZ4Yud t X-Gm-Gg: ASbGncsl2Gx6/TbkHOq275vhSEYpN2wORvxc+7lWLjPfnYkaODj55uTOvpRVP2XC9UL NyTptq6GJn9WvT1PCcwGgqPtuaQzCYEcdReojl98sVZ/MPjBeMzjZCtppXNQUetXk/qVZYpXgSf yogSFcew2y09bu0i4w6sOAfGkY2mtsH762X+Z48j2drldoIlmGHNJmev3v2QDgwpJrYIZOKmgWu iQHjaI/QDHVtOMuJqwK+EImchMz2GCUsSU0kl2GzpN30fGIP6zHbner9TWtamEASmlNVbRHvui4 cP66gtaHOMGIpUMzaYhx3sq7h4HTkHOMTep21OguHhRA/o4= X-Google-Smtp-Source: AGHT+IEkcvw4t/4hDB4cpARpmSXHhl01930tx115y0v5Ooc1uQWUDLkSS1M1ktdAujYLyLZ2bXnA1A== X-Received: by 2002:a05:620a:2a0a:b0:7b8:5520:1888 with SMTP id af79cd13be357-7be6328a7d5mr4527305185a.57.1737683933360; Thu, 23 Jan 2025 17:58:53 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 17:58:52 -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 4/5] rcutorture: mkinitrd: Use previous init.c to check if rebuild needed Date: Thu, 23 Jan 2025 20:58:35 -0500 Message-Id: <20250124015836.732086-5-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" Create the init.c as a temporary init-tmp.c file, even if init already exists. Ensure the existing init.c matches this. If init.c doesn't exist in initrd/ then skip the check and assume init-tmp.c as the new init.c. After that, check if init binary already exists as we did before and skip the build if it does. This does mean we keep a copy of init.c around in the initrd but this is a small file and it is useful to see for debugging anyway. Signed-off-by: Joel Fernandes (Google) --- .../selftests/rcutorture/bin/mkinitrd.sh | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/rcutorture/bin/mkinitrd.sh b/tools/tes= ting/selftests/rcutorture/bin/mkinitrd.sh index 4ba5e962e3cf..d9fbfa205384 100755 --- a/tools/testing/selftests/rcutorture/bin/mkinitrd.sh +++ b/tools/testing/selftests/rcutorture/bin/mkinitrd.sh @@ -17,10 +17,6 @@ if [ ! -d "$D" ]; then echo >&2 "$D does not exist: Malformed kernel source tree?" exit 1 fi -if [ -s "$D/initrd/init" ]; then - echo "$D/initrd/init already exists, no need to create it" - exit 0 -fi =20 # Create a C-language initrd/init infinite-loop program and statically # link it. This results in a very small initrd. @@ -29,8 +25,10 @@ cd $D mkdir -p initrd cd initrd =20 -# Generate the init.c with optional command -cat > init.c << 'EOF_HEAD' +# Generate an init-tmp.c with optional command. This will then be compared +# with any existing init.c. The reason for this is, we want to force a +# rebuild if the optional command or command line arguments have changed. +cat > init-tmp.c << 'EOF_HEAD' #ifndef NOLIBC #include #include @@ -45,7 +43,7 @@ if [ $# -gt 0 ]; then # If command provided, generate run_optional_command() with the specif= ied command. # We use printf to generate the command and args. # Example: echo $(printf '"%s", ' cmd a1 a2) gives: "cmd", "a1", "a2", - cat >> init.c << EOF + cat >> init-tmp.c << EOF pid_t pid =3D fork(); if (pid =3D=3D 0) { char *args[] =3D {$(printf '"%s", ' "$@")NULL}; @@ -54,11 +52,11 @@ if [ $# -gt 0 ]; then EOF else # If no command provided, function will be empty - echo " /* No command specified */" >> init.c + echo " /* No command specified */" >> init-tmp.c fi =20 # Add the rest of the program -cat >> init.c << 'EOF_TAIL' +cat >> init-tmp.c << 'EOF_TAIL' } =20 int main(int argc, char *argv[]) @@ -95,6 +93,23 @@ int main(int argc, char *argv[]) } EOF_TAIL =20 +# Check if init.c exists and compare with init-tmp.c +if [ -f "init.c" ]; then + if ! cmp -s "init.c" "init-tmp.c"; then + mv "init-tmp.c" "init.c" + else + rm "init-tmp.c" + fi +else + mv "init-tmp.c" "init.c" +fi + +# Now check if init binary exists and is up to date +if [ -s "init" ] && [ "init" -nt "init.c" ]; then + echo "$D/initrd/init already exists and is up to date" + exit 0 +fi + # build using nolibc on supported archs (smaller executable) and fall # back to regular glibc on other ones. if echo -e "#if __x86_64__||__i386__||__i486__||__i586__||__i686__" \ @@ -120,7 +135,6 @@ then exit "$ret" fi =20 -rm init.c echo "Done creating a statically linked C-language initrd" =20 exit 0 --=20 2.34.1 From nobody Thu Jan 30 17:33:30 2025 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (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 78E9A1D7E57 for ; Fri, 24 Jan 2025 01:58:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683939; cv=none; b=bz0IP3Zzi/eZEWbZ33TUwZ9nwriWzKxm9lszxIZ8orVS6ftOTVW5DON/AR2UWlNMEs3rXthE89+C1EVw4gHCNXEBAVilaBme3qT0rgkCRvMfJ/eLkh+/zHj5DsJ/vKLOskRwdPAeuAcJ3xwVVmW/Steo94riLaUByai1cnel654= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683939; c=relaxed/simple; bh=OuvN4hSJXio2PoJiej9Y5bVI4DH3N1EbznQzh95Pj9Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cCz1FGOmPFimaHfnazO82fSNiCTSZbVb6y7IHI/Ec39Y0mUGyqBHQJqPJD1fJFPxiIwIeeeMt8sei/I85idnvJF3JeYALcW4QJPa4Xjh327JrGMx3dVvms3yuBJ8ohBEJfx1bi+ujjcNB1pNtj7R9w/1VHx+FiJV+yDA7Obr/ME= 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=p9sJ16iP; arc=none smtp.client-ip=209.85.222.171 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="p9sJ16iP" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-7b6f0afda3fso73763385a.2 for ; Thu, 23 Jan 2025 17:58:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1737683936; x=1738288736; 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=Y+QF5oSbZcs+JbJsvoCUbafjxE54u1Cr2sHAMeNdyY0=; b=p9sJ16iPpGjmXQzZZTBy6IXvDnvihbEf5W3TycdIx+HB+x8xYDfrsA14Jom8Co5Qye orhK+xwH8+i54VVjj1HuGFtetmd2P6fqdEU9WBrFz2BldUS4xGnDnON0/2q49kUlOSJc eCpsJkXXfzkAfdPp9oAocY5JIcsEjnTULcyzA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737683936; x=1738288736; 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=Y+QF5oSbZcs+JbJsvoCUbafjxE54u1Cr2sHAMeNdyY0=; b=Y97OoMvJVmDQuROCADsj7PYXwGXnq6uIjwgEaxMz+p4+ec2D4zqcnNoiHKy13LeXM7 b6VI5XToNPxKuSAZ4yO+V9Ck3+hgi0WC59h+dyLeIdy8b94XA0XM/ozeMMw7Oad56kEk IPTIyPV+LHCMIS3VmJc9BOetTD6nxXZYxZXUDXeAmQ3Rrl6DiQW8Yvn6jevy6gBX+Hbr BjTmNlrOzYJ6EKV4gA0BEPP2/JcrTmLOAt6+lotZ+D+pkyZlS7w8dNQEXpQHvcC6nhLb ORIkIL6nUs0SCqVDe0C4g4eU4L+sMyGLquqc9Hye64o2fIUApgsfP5DYK4TALbCZ8QKq ua8Q== X-Gm-Message-State: AOJu0Yxo6yFC8T5FudfWIdpG4AODnpQpetkecMR+mTRsGDxwGyWk0QuV 1Zmg1/fvYd18osQNxAr78T4mQmwyenrsyLIFAGFMCBUya+k5hX5hfbZ+eHD8t6jn751YT7z3QKc m X-Gm-Gg: ASbGncsGbRCkhDFg4140uLYsrP6glXVXIJFw8vsrZQ/Wp41pyCBSQt9dyrHDhOYZ000 xlalb4xkfGP/3llqzUU7QVcxF0eRCmT6OEPsOn9Jjx5moQeJ2zlhWD+5txmRsfSEHEVYaq9fEA9 MwUYDhURz5tMAa668Ue/TcabDvc2+Wu1GzLD3LKMFwMwJWo6tFrdx22VkQo/AH+7Rug5BOAc3z3 g0XoWhf+IRlvuMFW8pBPqBVyVdyTTkjzbkLonWOkXTIfDCXD6sQqeZJIio+OECyGz8rX5D8mJxg y3ckjhtSZZst1iW45loRvGtyIglmmAUIJ4xXrB57bEXSi9c= X-Google-Smtp-Source: AGHT+IH36P6Jv8uzjmbePn9/vGkZZmN7+mVBRG1wMuKKi1ngiL7zOS7+fOI/X1b/u1OyY3fqtN5Vkw== X-Received: by 2002:a05:620a:1a02:b0:7b6:6a76:3a44 with SMTP id af79cd13be357-7be631f2fe6mr3884618085a.17.1737683936019; Thu, 23 Jan 2025 17:58:56 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 17:58:55 -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 5/5] rcutorture: kvm: Invoke stress-ng building it if necessary Date: Thu, 23 Jan 2025 20:58:36 -0500 Message-Id: <20250124015836.732086-6-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" Invoke stress-ng from init using new --stress-ng and optional --stress-ng-args. Default --stress-ng-args are used if none are provided. Not passing --stress-ng does not change the behavior of kvm.sh from before. Signed-off-by: Joel Fernandes (Google) --- tools/testing/selftests/rcutorture/bin/kvm.sh | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/rcutorture/bin/kvm.sh b/tools/testing/= selftests/rcutorture/bin/kvm.sh index 4766c3023fed..d35496247ee6 100755 --- a/tools/testing/selftests/rcutorture/bin/kvm.sh +++ b/tools/testing/selftests/rcutorture/bin/kvm.sh @@ -42,13 +42,15 @@ TORTURE_JITTER_STOP=3D"" TORTURE_KCONFIG_KASAN_ARG=3D"" TORTURE_KCONFIG_KCSAN_ARG=3D"" TORTURE_KMAKE_ARG=3D"" +TORTURE_MOD=3Drcutorture TORTURE_NO_AFFINITY=3D"" TORTURE_QEMU_MEM=3D512 torture_qemu_mem_default=3D1 TORTURE_REMOTE=3D TORTURE_SHUTDOWN_GRACE=3D180 +TORTURE_STRESS_NG=3D +TORTURE_STRESS_NG_DEFAULT_ARGS=3D"--cpu 1 --cpu-method matrixprod --cpu-op= s 1000000 --perf -t 5" TORTURE_SUITE=3Drcu -TORTURE_MOD=3Drcutorture TORTURE_TRUST_MAKE=3D"" debuginfo=3D"CONFIG_DEBUG_INFO_NONE=3Dn CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_= DEFAULT=3Dy" resdir=3D"" @@ -90,6 +92,8 @@ usage () { echo " --remote" echo " --results absolute-pathname" echo " --shutdown-grace seconds" + echo " --stress-ng" + echo " --stress-ng-args \"stress-ng arguments\"" echo " --torture lock|rcu|rcuscale|refscale|scf|X*" echo " --trust-make" exit 1 @@ -251,6 +255,14 @@ do TORTURE_SHUTDOWN_GRACE=3D$2 shift ;; + --stress-ng) + TORTURE_STRESS_NG=3D1 + ;; + --stress-ng-args) + checkarg --stress-ng-args "(stress-ng arguments)" "$#" "$2" '.*' '^error' + TORTURE_STRESS_NG_DEFAULT_ARGS=3D"$2" + shift + ;; --torture) checkarg --torture "(suite name)" "$#" "$2" '^\(lock\|rcu\|rcuscale\|ref= scale\|scf\|X.*\)$' '^--' TORTURE_SUITE=3D$2 @@ -275,9 +287,27 @@ do shift done =20 -if test -z "$dryrun" && test -n "$TORTURE_INITRD" && !tools/testing/selfte= sts/rcutorture/bin/mkinitrd.sh - echo No initrd and unable to create one, aborting test >&2 - exit 1 +if test -n "$TORTURE_STRESS_NG" +then + if ! "$RCUTORTURE/bin/mkstress-ng.sh" + then + echo "Failed to build stress-ng, aborting test" >&2 + exit 1 + fi +fi + +if test -z "$dryrun" && test -n "$TORTURE_INITRD" +then + stress_args=3D"" + if test -n "$TORTURE_STRESS_NG" + then + stress_args=3D"stress-ng $TORTURE_STRESS_NG_DEFAULT_ARGS" + fi + if ! "$RCUTORTURE/bin/mkinitrd.sh" $stress_args + then + echo "No initrd and unable to create one, aborting test" >&2 + exit 1 + fi fi =20 CONFIGFRAG=3D${RCUTORTURE}/configs/${TORTURE_SUITE}; export CONFIGFRAG --=20 2.34.1