From nobody Thu Jan 30 23:12:37 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