From patchwork Fri Jan 24 01:58:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Joel Fernandes (Google)" X-Patchwork-Id: 13948806 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 6E8721D54CF for ; Fri, 24 Jan 2025 01:58:47 +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=1737683928; cv=none; b=cRQHc1sHXN8Co4FffnAIiRmBLrY25Aqk32FVQZw5NdT5DRI7EL/1Ed4HvnpCBwUk7KPr6jlTgQsIkOsp/Z9Eac30hM6twqC0uw4BxdmkKbqohwOBzI3rxyOiausDKI4570wcOAImV7NDiPS7d5EJeXQWHgY+zsJZQ5liskXJh7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683928; c=relaxed/simple; bh=mlls54bce+0lvfNSi96vEZ6jU4CJvOJNuNga3KxcE+A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Xezieit4w/A/C9S4wzU7oQyXcCsTn7v2VJ8O0fTVpIECJ382TLull4hke64LLU2mCl4LdZJkCUxzQZqEvP2tXdaxFRXS3Z+T1HTDP5j4xc5EgoSOiOq3sHdfhTeBFHhFih2bztY6II3yQ9xYSIOHAcRW+cqiosNLFTJQllcmlFo= 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.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="YOwDyFgU" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-7b6ed0de64aso158295785a.0 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=wv/yMc/DFS5SBbOHb8kB3CtgKrb38LcO0f5xG5tc/NXg/9gg4Acy+noTdwasGz6uFH ZmFrRXMao3zbZ6EMCCFmxDplaXEjKMYqIn4ESXtyjh75St6gWdsr7+SuIxL23LxpHGLF omYkA0Th7gLKXGQ6AxR4OldLxc1sckhTDXq5szHind/34uG57PmR23FNuT1JVxjMdvg9 sIevs7SP9CfazNNu+tkey2hYZFaK+7SYOIT13zIKxOwVzrj2NLIaMMKvrxcvlEsWQll3 P/iFkrFe7iplNsV1Gcp5eEgpL2FBRqKjg8fg1q6lVTytdRkApZkDrq+cK8JHmqAZOj5D 446g== X-Forwarded-Encrypted: i=1; AJvYcCV9OG4VzhFyAVM70lKdwG5qiXvf/n5rbJM1j5xJvpMxOFX1DtoZpIC40243m7Y4vDI97ZVQT+OKGCJbe4oVo+s=@vger.kernel.org X-Gm-Message-State: AOJu0YwRG9/ntNlAT7g476IeUHu0F48WqekVjppj9m1GvbqzpcETPG1U 1m15aZaXSGCEJKP+QNNrh4KtbSGq0Jh8UninCCBkwyd9n85uSJsbScym6SCKiZI= X-Gm-Gg: ASbGncuc9ZmjsXMmw68QVzYlMrVcalkyCvalUm3+zu45eLjaM9L3qMiGj5WsumhPcKe E7WCIkpRmHW6vZswnbqytSQQsmvkHohaa3SdX+pFLXyxn/1YoFdvdj6BpqKNoe/VvmKHnhJrFHf EnQdRsH95i8SsUcs/LsvVPhkDBMwJ2ZwrLEGwdZCUXqctERzOEEeVaKHJ1LWDbAybRSmjEApajb SAhk2tyPi51/Z5G2PXx3DS4Dmh9bbc64tO7h2p5qeFmeehPWC45+tbbmL1gEKa+VcNPo/1cAZKC +Xtu15AxHfrNIno9UprQy4x26TI79GImgk++lZFNALzv2Tc= 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-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 -if test -n "$dryrun" || test -z "$TORTURE_INITRD" || tools/testing/selftests/rcutorture/bin/mkinitrd.sh -then - : -else +if test -z "$dryrun" && test -n "$TORTURE_INITRD" && !tools/testing/selftests/rcutorture/bin/mkinitrd.sh echo No initrd and unable to create one, aborting test >&2 exit 1 fi From patchwork Fri Jan 24 01:58:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Joel Fernandes (Google)" X-Patchwork-Id: 13948807 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 16D811D5CDE for ; Fri, 24 Jan 2025 01:58:48 +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=1737683930; cv=none; b=GyNlpLP4cTKR9SbTj/qnI3xCIurpFiTQASlf0rnLP24LzBe5eECpvAyuH3ifZxnPJsHJFFS4Bs/yBm2vk5UA0H1HFe1MfemkzmsQNRrZPE+Fa1Hzst3nddVpvcdDJTYqz2KTG5MHP+Y5jlEksG/ITYOgRQOBWcdyISjJqW9BzPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683930; c=relaxed/simple; bh=2/LB3V5JWdcgf4tsAt88qzoc3B9PT+ZPjL3M7JzTYTA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Geh0mt4quY5bKVaXXWfax+fQfVn/3N3ctcDopIV9uRWxMN4be3YhgyvwHL5rlDoMmULOmP8PRfRV8oTa49Je1mFyJMgTOyg4GTRTvfDrFYks9Uxw2j2Q+71DLcUOA44r5dD60Qq7y2I8wXg86bNLNnZAWwgzZT+XqQSpyMQX5HQ= 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.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="FRq9ATeL" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-7be44a90468so181233685a.3 for ; Thu, 23 Jan 2025 17:58:48 -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=HCRPHxSyVZXaSMNrPIFSI8sT0AkHo2hV66DpWsDosO2tFMqNr1BWj+N7RXHcHfTBLf PJm9SwWXWjTG21roqs5tZhJA7GyDWKLYCAxBqwniQwLijm28HQN0U0SHHy9cp/gd14gI +crqqddedU659SlhrcyFTdMlI+kA96qEYzN34lyXSaE1+HVgak/S5WMrjPsFUlQGE/q/ GxmOm268YzdIQMRVQiPiPuX00caSFR6BEUq2et0Pnmop8p87DI+GUVkT2TouKudGp1v+ y6tR1vIOYraEDy4zVp545FMCY1TW7QlxlLjEp/Rx76b1QhHCBtWFzl3Ki6ARZXYTmPCW 7Kww== X-Forwarded-Encrypted: i=1; AJvYcCXYtBP7HaMUXJ0c1wXuXu1zJr5POJEFEfGGrxER0f6oiLwlnbPzyAYyuI9B9ynZ7YrcxtTGeMLH71oI8q0K85Y=@vger.kernel.org X-Gm-Message-State: AOJu0YzJyqnamhHY2keUlMfiqTlAOiMKn1sUlDcHgZyt0jgFBZynJx1m 70OGBmh8aHILHZH6E5MnBQCVjonbrzxFds2IP4TrQaY/ZaQhWL+aKrdw9kdibws= X-Gm-Gg: ASbGncuERLnlcjA5QAg+nlHeC0cBuht/Fcf7rgBQ/f8fK33YX45kImwiXPHG06At4S1 w4VO2IAEUyxNG0L0Z122f34MOPZ9F8DgIZ0CTnbnMKHCpEjrKDc4SrstJ2/ecApUI7To0xRmJ0G UiP5xN/FvnnzIZoIRqLQup1fm1J3UwqpYM/TeION+4AfwNeGqbuX6yQ4W+OkiV6Dbt2ieU5reQa +lxSmQwZJPUy6PHxhIEhmAxuaCefmHntZVhg6VTNGsYmWB+uin5S7deM1DnbVTx19TPtCMqiRSB 5exqTUD9A1Lvb/NDCMBuoILQpFx+/OQWdGdbFoNIRWcG418= 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-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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="$(dirname "$(readlink -f "$0")")" + +REPO_URL="https://github.com/ColinIanKing/stress-ng.git" +SRC_DIR="${SCRIPT_DIR}/../res/stress-ng" +INITRD_DIR="${SCRIPT_DIR}/../initrd" +BIN_NAME="stress-ng" +export COMPILER="${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=1 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 From patchwork Fri Jan 24 01:58:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Joel Fernandes (Google)" X-Patchwork-Id: 13948808 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (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 B3EBD1D5172 for ; Fri, 24 Jan 2025 01:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683933; cv=none; b=ZtIHeRE1fDU1oqzHUF4/t3QLbWGxt878Q2eQdVC90wxH+nFGMXP2+F/titNBHgDHTRl7V331YzpdP7gzdLE5sfJD1g5uFGkgdGnwYPFfT6256O+DzuwHTSh696pHFrLhb6tLd3An1VTVE58Vj6HLH13BDV00EpZ0+xhG1YS53Jc= 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.181 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-f181.google.com with SMTP id af79cd13be357-7b6ed9ed5b9so231652085a.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=u/EXYcPYP/R2VZdUknSx7xqyLkJXXYpa/jFXlsnn21oeCjJ9oyPBZE74KNtVqwz3kM s2o8ZQ6e4Klaa4wMMUH4QY+lJy4WM1k6m1oHbLNfQIEh+o9BhQ7fgXHYr0qxgXtmRbo6 4RJ3dwv4NbSHEn/we+5DDx+iKjm4ec7QEG+fdH/CB1drWw+rAc47OCsQWxBh/jvswVFr NQeOweEPqhvi/vKRNDWR5m/plH15ujx/3HHaLZfc1C8iQcWav2Isivb5xKB6TGrve8PQ gUJXCO/ieujXyfUU9uv+DC3kn6Y1bAf3Zgap/9Fb/di6rHH2k5JALfoCyh+IVGerrGVt lj3Q== X-Forwarded-Encrypted: i=1; AJvYcCWKVvFJtglyvkeyLFG6baBBwhiim6tICcmj6PswUb1eeRVbvfat4qmSOB+4jktm26VCi1DoBMYNaFx5u4NG01s=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7Z0TC+Az6w+9BT7ByuZXyXmR4Zm/9VM86L1aacq6L1rCXEYbk NzvtH7JEVRO4N3Cdzhi49SIpaaQBmU8QW/Hp3tTk5w6B4i5uYPUNwT1Wi2u94lI= X-Gm-Gg: ASbGncvnvrCoKpvGRjbP275E8xS3SRiJ1Pu/A9+fSa+ukkK4g6xkfR39by03/S34Ste 1iFRXWe15VQgOBkR/sSjm9pEbHqCXzy4UN3/z6zvjPvlK4UL9g1eKaQPATjD3NjqsQicD6r6JVo KmMGf6IFxAoNDq79iYQ5wPejHZxfr+bZ/QRxsauO7loPkJrUrNB/t+yVPt+/RIxRgS62ZkvkqLs Faajdb7RRRJ/VCLOU5B+t8owPh1QmE05dZRbATKgruyOilHVPpogIDKN8V/+1j92uJmKgGGL9Yo /9AF63lSPTTzDJZ3Lc1r6yNUzWfYjJGLDtilA+KDQZmt/SQ= 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-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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/testing/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___' volatile unsigned long delaycount; +void run_optional_command() { +EOF_HEAD + +if [ $# -gt 0 ]; then + # If command provided, generate run_optional_command() with the specified 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 = fork(); + if (pid == 0) { + char *args[] = {$(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 = 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 # build using nolibc on supported archs (smaller executable) and fall # back to regular glibc on other ones. From patchwork Fri Jan 24 01:58:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Joel Fernandes (Google)" X-Patchwork-Id: 13948809 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 5E3481D6DCC for ; Fri, 24 Jan 2025 01:58:54 +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=1737683936; cv=none; b=cwk7kIH9zqujwmRkiibHbP5Mnlu+xkatnxUIA0hVzm2cxGjXIyNrIa05ioBFA4tFMXIyqcshxV0L+FSNxuOoqyv+lTXBae3KFikHseVGNYzs+2BnVfLQ4c1z77+ghD/WBkLbu29aQ7r7qTbKjXpMhiq+cZSYdnKaDzB2XG6lt7w= 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.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="tQNRiiBI" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-7b6e5ee6ac7so129823085a.0 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=YiWFc8iDVH3Va4hOsmw4Ht8wk9nh8vitKzYMemTs2BsQnfB+Y0KZp9A0ehh+ASbjn9 h9cw7Iz271I/UabcmM3uU9YIB1slVH/+7vdx6kvbAz37zP2QpZMfYx9/aGEoF8K6nuU6 1k9P0lOuHJdoJdWkvmuBelCfxbzZCpRQ1RwjXEi8vE0azLZTeKoCRYQs835cDBVWD3LF mFs1gQB5scPGngyFc35i/EDR0P9AgDGdqXQEZp1fVMcFsRiFh6+EY0OtdOZR9KTuMS+x BaMAdl9kjys0FRpVHl3h685B9PumVbVenwbcpd/oy7GA9iAo5vdH6BH4zR3rE3YDAZVV ZXSg== X-Forwarded-Encrypted: i=1; AJvYcCW7VvoSpXaSqIicNyQhgTtQHgjhx+lCA6j0pUG43KzuUXipNeLdmiB5KmElqLeltFGC8lqpKLJQl+/uh08PrKM=@vger.kernel.org X-Gm-Message-State: AOJu0YwKsAASEX3xNt4MNraXLjd2osZ5hX26zy7V8dF0g7Xm7sfERLF3 rS79SGGTNIe8zLh3FrC7h/8duA9sggAQ8TiiXw4oK/ut1XJyKJVuUef6NRopymw= X-Gm-Gg: ASbGncutNJEq3cRxQ0UT+f2j8CG9PX2kyBv8YQ1dmzqr5C/6GmTMZkj8jyaUSxhN8Rt WH5+Yt849eckd9Bq/kANAyYIaTo/lIpulihIiWcludPU0avznLf8T3NXtF6ZHdGrok46YrQ/2k4 41HRm92oUi7kkrOaPTbUIz1kju6uZzqzTfRmq5Cuun9Er05ERkPO9Mo8DtYlwO8jVAxLPeOMXjO wMRlRU6u8/WwPFFKwhN63JB9BQpwmeLcJ391QB51/s5ifCRLaf5vfqv57cj2BPsEfNSAsw52+/K wsWpH0IxY7fKKx9jtrsjEm7+asllYm/8ibiwogoK66gW8o4= 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-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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/testing/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 # 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 -# 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 specified 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 = fork(); if (pid == 0) { char *args[] = {$(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 # Add the rest of the program -cat >> init.c << 'EOF_TAIL' +cat >> init-tmp.c << 'EOF_TAIL' } int main(int argc, char *argv[]) @@ -95,6 +93,23 @@ int main(int argc, char *argv[]) } EOF_TAIL +# 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 -rm init.c echo "Done creating a statically linked C-language initrd" exit 0 From patchwork Fri Jan 24 01:58:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Joel Fernandes (Google)" X-Patchwork-Id: 13948810 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 0BA371D63E7 for ; Fri, 24 Jan 2025 01:58:56 +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=1737683938; cv=none; b=JyQCwLrFTfLmr6tStbSsoP834jqPFN0lp0iGwIgsH48K1sIye3l6erPGLKFUoa7QIYBRlqntLzhjezOnNs0Qn1qAutPMf4qFki258OT45iju9kNJtU4YpRS7GcSY2CjgRK6c9uIxu4dcvVd/BlLlcc+isUekr7sY7s15AlGDR2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683938; c=relaxed/simple; bh=OuvN4hSJXio2PoJiej9Y5bVI4DH3N1EbznQzh95Pj9Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i/oNBsx+IInSE+yWIVAGGx+2lOx5q/bWMqgGRwIE0VjvgtQkj7o0VGMxmd/SCjRK4WfAXLTEdZkczc9LlPLUbA6/cTcVsYR6AI0i1zwZYoT2mMwk4WS25b8NfB7rCfTAYl9f59PTYZNBMDWistMB4d73Jiqr0pwgzTPqiOrBUeE= 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.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="p9sJ16iP" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7b9bc648736so158634685a.1 for ; Thu, 23 Jan 2025 17:58:56 -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=clxzH/foCN/AUUiGe4ReLk7Tbgq2nTffXbQPbQHK9cw+eMkgWuCyz8M9F84onP/Ytb RmL+NeyEkfbZr4n0raMyfMjbWwOAO/yD2TZT6jKuJoOI/BzBkK3678xwpYFT9hcLfjXs JSMIjdPE50tVPlDEgwHPCpTrn0+jh9kOaZDXEDpcKu6+kyD+cisey/+3XdL39/Be/0i9 fJDM4g1SQtkguLOKnDrB78TRYKPkfunZfbtuH7Vw1pd65I4JbTYbORFEZoTxnMu06KGk eswKg4a1T/BwaKyD8KTKWo1EG2FWlzZGJPz78rvLUEYbko4xSzaUdWGZgAgLuLO/txop W73Q== X-Forwarded-Encrypted: i=1; AJvYcCW/QT3EC+uClzSRPAGiGQtio+Jr2X7V1Xh4xlGNn2Ehu2Ul3EQaR1EX6RndpxQqjWmpjkhW1ZnLqtCiRTaFFls=@vger.kernel.org X-Gm-Message-State: AOJu0YyhgykYhk05hye+N05RcSn0FEIxFDPRlZQbBhEjrSY4xAszlcS1 LuDwT+yyO7wU94BNL8SvuEOLtg8rD10APwPvcLX+q+bd1oj8U+Wd/w9MTvSqEXY= X-Gm-Gg: ASbGnctIEGz47vrdf7aZfejwFtMbJ+DtujqUzVIqDcPnLxA+6P4IMEHPPilU94p1M4m TkkMC+yod9fUaQC+LEsvK4ijc/3bfK/8SU2JAhiLJNrFv7DHMDqWPoIuomg35UEesiuOQqQmL/o n1jOOXw6EhvciRnVL/QH2CegDYtJUxtbwKT8NFs8T8f9eW05eVr8TZS+e0819V/JT6MDbX/zzt1 WLA7VucetZnqV841r2IEDbxwHlceVoHgsHYk/LgCAJ++0bXTEl+7/oovUmEI4td6yA3JCXhVJBc x/iCmhUMTkuJxztnoRtA8v9jECSXrE/K1U7Z9ci3lC+x+4U= 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-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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="" TORTURE_KCONFIG_KASAN_ARG="" TORTURE_KCONFIG_KCSAN_ARG="" TORTURE_KMAKE_ARG="" +TORTURE_MOD=rcutorture TORTURE_NO_AFFINITY="" TORTURE_QEMU_MEM=512 torture_qemu_mem_default=1 TORTURE_REMOTE= TORTURE_SHUTDOWN_GRACE=180 +TORTURE_STRESS_NG= +TORTURE_STRESS_NG_DEFAULT_ARGS="--cpu 1 --cpu-method matrixprod --cpu-ops 1000000 --perf -t 5" TORTURE_SUITE=rcu -TORTURE_MOD=rcutorture TORTURE_TRUST_MAKE="" debuginfo="CONFIG_DEBUG_INFO_NONE=n CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y" resdir="" @@ -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=$2 shift ;; + --stress-ng) + TORTURE_STRESS_NG=1 + ;; + --stress-ng-args) + checkarg --stress-ng-args "(stress-ng arguments)" "$#" "$2" '.*' '^error' + TORTURE_STRESS_NG_DEFAULT_ARGS="$2" + shift + ;; --torture) checkarg --torture "(suite name)" "$#" "$2" '^\(lock\|rcu\|rcuscale\|refscale\|scf\|X.*\)$' '^--' TORTURE_SUITE=$2 @@ -275,9 +287,27 @@ do shift done -if test -z "$dryrun" && test -n "$TORTURE_INITRD" && !tools/testing/selftests/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="" + if test -n "$TORTURE_STRESS_NG" + then + stress_args="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 CONFIGFRAG=${RCUTORTURE}/configs/${TORTURE_SUITE}; export CONFIGFRAG