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 X-Patchwork-Id: 13948811 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (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 694651D514C for ; Fri, 24 Jan 2025 01:58:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683928; cv=none; b=GVZPysjFKroJDsCtrzrw6RZt/JK+awI6QyOnPcEzGkGpQPhADzlZf4rPamEda3G5q4eulSKkghpfUuUnh3s5h6Cfbq9jimr4pWWYq59fUfjV1QEx5PGJc0dSggwd8/qEXdhc9InMCRghsGY1oJ2BQp9jsUlrmCAzZO6ClqMVHTs= 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.178 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-f178.google.com with SMTP id af79cd13be357-7b6ef047e9bso154110285a.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=LakFJPGGrHVNzS5YsHfTwicR2czCV/jenVh9L6Kk1/Dl+9xP0V4LalFtVHCr71T2/O dgc58AluIM04rRLIAYdpF68rrwe6s0F6JI/KSIgHyaLxnwc9P/Rm+lug2jPtzRyVjATD 8VmnlPl+fiMkpiLUT8oKedQ48S0m7A1y1n8I/9zh+MNvVS+jfwCwPquicNu8R0u079L4 aaRCgr9HCxaSzVwbirtHbubl+uHzomHcefnvDCVkHmxMUt/b97PA6LpGIB7RyJBVDC3x 26k+6Dm7d2NRijCVmEMWShk7hCJuWZxCReiyxOHwCXJFAKLXsCUTF/LretROdSz4SORu VPbg== X-Forwarded-Encrypted: i=1; AJvYcCWSEi37AKPWiFpZn6UhfXsmwVOb2VxcWHS9wKsA45XEw5/UnrElTiT272Stl0UQHwHwqWQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzCPLOl18TA4+AwkK7T4JHWHV5EgPIfaxbNVxq8MHyX6ltJkeFP gBQl4WsmX5Auqmp8TRe+vnCMEemFOaGy0xmzpqiOlaBMM03iJ0Ypt0YacDrWdTs= X-Gm-Gg: ASbGnctd8EHwqIdlQavuH/TvJMaNKDfbbLo03HIzd3go66gxlEx6Iss5cBeSWnszbzo 4gWL+9r5Sk81cxv71tkTqjC76tpy9PdzVopabetxdX7ui4jA57j911BO9P0w7ba1+Gw9VCRJ3QF 2z/5x/2U9K9Bv+O3Zed1inMzXZZ2FnhEVIT5/tQwvxtynoo4ty1Lx9SJvPpLCTunmnS09cOVrde twcDq5q/kiSO4cZptjIWMqQtYvlp0LZWnjIQizDIMk1e1wYrLw2LwKCvcDL4ZRqb1bZsgg8FPYx KTuemVibLEK3j6/hxQFJnXUQ8O0IOn6w3Ms5f81LrymnE6U= 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: rcu@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 X-Patchwork-Id: 13948812 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (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 19BBB1D5CEB for ; Fri, 24 Jan 2025 01:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683930; cv=none; b=drXDm48QqlmlkNz37mRoc3A5plXJcHjkutWej+qt/btk3YCd2e/N6T0Em8cUeVdBJxi/RqZHg2j9IC1hl9dHp8N5g8Rqaei/OGWYNnZ0DVd9Cx8URC05Aw6NGe3Pvk3Fd8PBxrHVg4F9ChxVLspMOw40XTmY18F7aevmO2IJ9VY= 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.172 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-f172.google.com with SMTP id af79cd13be357-7b9ad0e84e6so177567285a.0 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=fFUd7stzst1+mBfMsZ2VqF7cStk1ZPEXsjzNctZICJc2Rqn0pZGCeejayiqA2FDgg6 AsooyJZqdqeXRKfKr1XSNA3q45vX2DeIvhl8s2ZpDVK1Ey/meKMdiwNS6c9TauIo3CFp FAiNXdDKHwlOCnhs0h7nppZDZMM/IFAD/0IEuy5lG1ER5suhLzNki5hlBq4CNY5r8XlS fOMM1kU3S8VyqDlIm0bNQAO4ibPyoh7yxIRIdyh+V8sLDMhlGOM5/iTpg6wOIXtgBYAO onQOpzbUEVoSVHoovpVhLcw2xZ83qo503R5W0XevFDw18iJAMVgXKm+rvNhEVd2qyyd7 tTCg== X-Forwarded-Encrypted: i=1; AJvYcCXCVqn3Dtw2070js3YKDdx59Kftc9kmqwdljRyaliStfHgd2qmJRIYuCb/o/eoFCBRM0s4=@vger.kernel.org X-Gm-Message-State: AOJu0YwzZN4LPZ51iFHqXDD37CrPcBZsF3NP5MSJnGSh7TsGCCd/DTMk EcHgrRJ71w8oM1y8FvNhFYHGUI9G3St3Bwx3VW/M91tNO13yWEPAAp/1DCyjE8k= X-Gm-Gg: ASbGncvg1d6BXoBzyYQ9tNw49sbjPR4PXYi3JqurAscydV8by7KHIVW0jw9rOT4lczM JuIvO4pozrQEQYXCtUaCFIfqmlQlh7TEu4EVG9qkZH49U35852sHFg1+zhOTKe99IVefhpSTBZf oc09KTO6sJMLjkD4CfudBmxz53ouZ9o+S7Z53cQpooW/g6q6q5YrLv+L1tOoZMQQy2CuvcgyVxi kbdnHn9oNUgX5mIJQN0JMKtRX5Ei5ZV+19tTHDgrkvGnlMh+bOfX/smQPtAu5+aPM3oTpq6gj8J QzlDk4Lr8m0REHpp3EKQKcf9Dr5JZMg4o8zihBDTRZ31oDM= 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: rcu@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 X-Patchwork-Id: 13948813 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 9CAC91D63E0 for ; Fri, 24 Jan 2025 01:58:51 +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=1737683933; cv=none; b=hqIXWLfwQ4MEg5Prfev+CNKDvhB4dTOKtQ1JWuhlwly8PYpCgPUBwwh9Bu/iVMEw+/3bSmnSVtYdU9RXNvLIjqY6KAgOgaUjRIN6QIbl9CmRY1bwP1sgnDoYdgAWUSsnH1KOWkB3hN6uvn3eZkhZUs+avQXtlQ17zytJjfa15zs= 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.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="QM5Znsjg" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7b6edb82f85so220751985a.3 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=NCKZwUXVo8tZf4cz1kQbg55LCeRQfLDINN5YzEe8m2k2KzY4Y8B+dBoMMYYdrghL7l N0MK1aN9tL9Lx3CsdCSg6HLsSV+hPIrh+ff3icjK7sRZW+fWOnuWelqmEkVv6xIu6mYq 4wlNyE2E39Tqp5y1oq3YGSPziWKy5UPYRSfFfnz5t663Kp3+GaxuM83Se6cJK45HvPb6 jz+u9kq6BdrhadN7hjPQzW63ad3jaCSL5OtRxjAn5juAn/c7BpYkijTv+yggbeaH4q7W uzR7KP2khBBBEOkStQgSHnvoAp7gECFSPMGNrI+A0VgCYlBJ2dyf1T3Hssr1ACKaSIHO z24g== X-Forwarded-Encrypted: i=1; AJvYcCVCG0i9YeiWv2zt/Ye7InLGgvK71k66uxGWZNU7j8V/1vbZ+obstkOBG/3sxmdlkZb/3T0=@vger.kernel.org X-Gm-Message-State: AOJu0YyrPyl7qEdmBfUpo3N4G+NcbCMF1qk87p/xnd2z7cil4meBqfm7 8tyDK8wJ5ipbW2r54I7wn6z2wwwUlnoLe5eKn2penfimV4NGaMyvxVOQfWGo2b4= X-Gm-Gg: ASbGncve7KIGvHrRlv56grZCWmm+fzt5bh2v6ki1ebfpHTPmpwWckwA9upm8O0jMF0L muxpC0SU7Rs/1KY5Et0EClbEZmpk9UG8uE9k2w8ZTKEx3mSDs3773ZcOwLdcnPFKcKcciSXx4uC ae426sdTXIvZENb8suuPZzp9E1W/obq8d9CEibOaj1Ew4NZPZZIC2uSy3Q1wjyyCxQQUYSyY0g8 PX5HfPwUHqU8mjiVBuGGpWeZKE2cMvUrvcmxy2r1nR+6CoQ3Dim0K6f5ukdJufAcisHy9rsaB56 DKLwdu+/Ni1vJArIHHhfn5nEKpeRQAkApASStd4P9okyZxQ= 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: rcu@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 X-Patchwork-Id: 13948814 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (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 6ABE51D6DDD for ; Fri, 24 Jan 2025 01:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683936; cv=none; b=XEtp2W81FKh2cRhjUtFmYbYzisRm+mKCz267q5+ItzkdO6WHmP/++iKH1+BJi8aVJ0ZKJIrcER1WOzf/o+60sdFcWIFXi2FPyI6eU449S/uR0jzAmrsHSggFgCdFax6t8P1GHhzB7+JP0bRAjEGbnPFYNO+7nySSksLAS/HsZpY= 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.180 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-f180.google.com with SMTP id af79cd13be357-7b6e5ee6ac7so129823185a.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=bbcu93E7ug1ShMWe/JEZlpTNcnBd2LvK44GC489vvK3EOpcpYIheRwSejiHo7Kaveu BT2GqAiDsTI1VRaCEYGNAKsrqIMunwFXnEFyJ3RMg6eE974yfIWsSir/zuZ1QFZ+iWf2 LgN+HEH61qA/9EOr9NLynsNBTyKmaUMwLOAavGsXiZ8A5EYpRWKYSTLBEh3lqob8gX8U Kz9uLbU3fgbwUaKGHBH8CN3PQ6aqeRniQcGJwCYLEFSz/jO7pv999NFhZtA3KqpXaE9y IUltzPB7b/qbmUnTj2LyR68oNXqpn5zf19/wEWtCdbbERSMgrBIRXZ9zaaStYTN7VBms 1Ekg== X-Forwarded-Encrypted: i=1; AJvYcCVV3nHhawSykf1HuGXg0O290q1/f/cT5h/t629iv3yGGq+tMpF5sUiJK8XHztWiL/dhBTk=@vger.kernel.org X-Gm-Message-State: AOJu0YxgrPFUAl6HRtn6LVy9hwM5tgC4gTpMLiCaDmRIkzshHyfF6tr5 hfSjR5cxSJuTGQ9innXjUcT+Wq9vOkal+yXpAdRIuW41uOKc3IvsWDjc74T0kZs= X-Gm-Gg: ASbGncuerAbWKYLLnNWXfjs3mbIZWLTqr0JNpTbFk/HToqfAWR54EH0TDUqpnOc7xhb uIu6TCIToZMJvu4Nk5Vk9LWF/ZvADjxV37agUmCktEEeMX6CimjLjhX9LKgsqOXMDmErwYF24cx byQghGPEQO1xRk602ggyhxeXWDrRqX0bsbYxqBOwaZ539CL9kgQv7FsIj0jRUzkXjgrcbbufi7i o830OyU6nvM4CbnKCuhzVem7vcx01M6cdFCJDRqbx2zpgzMJFKc8ZXUu+jU9SYu/F4nf28IOLkX lc7Ps/um2IEXlF603iKd7+DDbM2/levyZvFi+2smTiU8LTc= 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: rcu@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 X-Patchwork-Id: 13948815 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (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 3E1C91D7E4B for ; Fri, 24 Jan 2025 01:58:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737683938; cv=none; b=p7j7m6ij3DYOhYh0kUFK5YxaNg3KcrcSCGh0aifXD87WdD5mgIszEeghO+LtNsmJwZ6GX2pvxnVf3C1wKO7zk3jBqAoq+kmF227KS2XgBik5F1EFdPTN3EkOvHhUpaW6K4O2zDJ243aThFVuZ6s9NMpBCirkiSZk3SoQteVY1p4= 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.172 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-f172.google.com with SMTP id af79cd13be357-7b6f0afda3fso73761985a.2 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=Evfyy4YDg4Yag1sErSdhzLfgNc55DTtJ3qIAE06Gubew0BSe5Ik6hk3XUyDhX4KWWE VBN+9JABS003eCAbUoST+B7C13NHWLnoYForRaP5LiAofp1nugUId0Em28Cn1uQPDmvX Upf7NmfA/D/9YHyb6vLWaih3QRqUaru5q1xWFqe0ksHKGn7ZbVj5Z66GJKLbNpSPb16M PmSzQk+i71fFQ9aA84lxBRMrKu/UrOuIF3hhVhVMp6CHRtgKzuE0H80e/rJAtV7nPYeu QR53qGBNHPO39U7NVyVNHem5ECf+2EZWvMTDopJLOVX2zp6qtkNLW/rivdxO7ZrcR9hj HE9Q== X-Forwarded-Encrypted: i=1; AJvYcCXXnimdmSFvI7WpQq8tBaIW60tjBk7k0++mNyjjCZKxGBGxWCGRgNcW006gTgS31VrNp2A=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9hu+YMSwBDwDWMmqrMFmUpOVKMXdKnDcfWnHL2R/boCrfc8CF Nwp+TcmYKxtlKOXzU9lpzoia+NxS7J1/hIRyqM+y85Nbh0qE4/vMNlQ/gepGo4c= X-Gm-Gg: ASbGnctqvhPiFZZdIMooEV8vtNb2MQ7IOtwV63cOTpOO1JboyLKdxijbC2dZuhdWeWj ghnkQPVljtUQ0TgJ6wDYo24riHt2QgiGmj7ai+qd4JbJdb7rkVUa6rx2F00AQtIcnNfuLEnQ6kJ QOuPdAmxewWMqPTBRrEhKZgAl83qzvWg7UCX5REYQWRm2b2/A6WKkQ1lYzijBV6KWoX950WvkhZ umtiBMUXloxVqFJ6uZwpst2zUewl4uYD87t4dlbdA9lj3iHNNouSSV7SmeeWIbMynkaQMGoDFvb 60IiF05efUCfgB6ncSU3A4tcRWYyx9yfQWhkQSlQRiVcjzk= 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: rcu@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