From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 DA73B373BEC for ; Fri, 8 May 2026 10:33:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778236432; cv=none; b=lnpAQ0M9QTMA1hFCvzup9YoER2tmSrajvhHzxs1A+LToJE7r1zri00BhsVtjJvsWuZ6F7g+vxOfWopslNUkHU88oSRBvuepZ9Yi+MLUg4DXFgdL0LzgdE1x2sNoXBvr3RQGmT8s7cWJqqTKvtW21ZfmfGa9LhgCExg6gwCoArYM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778236432; c=relaxed/simple; bh=Ux+3kgTkIIgPsw6UVLLH50fXpp6ZfvYFKK4jNtQqzaM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=KjvldGVbG7BNhGyji2LaSt1EZ2ttsPbY7QxpM09YbIi3OXLf539yuo6mDlR75pAJUQRfqLyojKenOZmW8N+BZDHJjKiLbX0upmCufH/yI9Dge4Iq60tuHMdcUZbKWTDpR2LcnAY1b7sGhjsbAPTHi93x74BDgafYBV9QwJJa8X0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Fy49egWv; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Fy49egWv" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-444826c16ffso1664653f8f.1 for ; Fri, 08 May 2026 03:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778236429; x=1778841229; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=U8xHZ9vH0OOXv8/65iQxAO1DN2jmxRH2008U7T+k0WE=; b=Fy49egWvS1fJ6URBchClKF3TcR14XvS/tOfYXWThCuKzvXqmUZT+8k8J8L6ZMx4gX5 zac8U3Kxfla4oY1qr4GvwSVdeaCG0L61vtmO/bMdCVbFO8fhwzSvprBO71HaviIHHMxM ylccwlAx0DuRUvSIALwv6pRj2azB/gUqv5DKFTbObLFAHE8vhjDanF2ECp1FN4YtvBUz e93w9azrWd2QfcFvx+Z30RAzJYU1WQ9vSEglOOCJLJPWzY7lzDFVf0svMPf/Kjr//7PV YcJw3HWakz84Vtrn35TzdjAjCIOI7/kF3RF3r2lKjkugEvdOTEMYDRAr1Yqf9V0FrrDW n0PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778236429; x=1778841229; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=U8xHZ9vH0OOXv8/65iQxAO1DN2jmxRH2008U7T+k0WE=; b=K0H+1oMDt9i+hlLsB3HqB0hm0IT4qu/ZlZfJw7D83UkiaoUlcZ/QElekg0MnXZzPR9 zs8JMoWSpACkPAz5INPC7Ey6zsC3tCvTnJGauhyNjEDjmdVHsBlE4k+vlZHbGhdv5AQ9 4mbSbX0rpHMErD2LP5QNfdFROieoY5HVlIijPlNZdJubWgRYyxfQuq0FzmHDh9zJ9BQA BNFrJRmCi+8slOMAEnxQhFAdxkXOO9dolwmVQ3JGCSSqeusdma2wE8h3kbiGXpFeEOqg +ZaXJOaGUDwhPvSdqjzgeJrh4q+rGY3gq3gQqLGn4SC6yZQ2k2U3bcnf4REvF6vZrbaX ocYw== X-Forwarded-Encrypted: i=1; AFNElJ/a+m43J2ZamK01bXbkF/VMYoYpGfMSJatkrYgyqLrALkmu3c6KyeiS0YZPHmy7USRYFhFUgeqLIzFI7Ko=@vger.kernel.org X-Gm-Message-State: AOJu0YwTDtqXckjRg/2kuxlGoXfUiv1kfJKMHs/LYVpA3JKRpM7AN/Cf 9QhR0gs/B+bPgZFP8Uy+NF6PxnVk2HOcqQ8BQmBzSdyCkNWaBuimWGuE8+k9Q5GA51E= X-Gm-Gg: Acq92OHfZ1XJ0iFC58QIRJ+T6M9pF5g4WMSX69kgerZB0bTbf95EQ5ezIB87sXiUosI ZEuMWlWOnKXaVN1GE6PEfCHaF397izz/1f98giwoW+BcMkZIifn+DvNqGrGUkSuYZt5RP0opxNx CS8w/8l8IKxjkRahnQsff5rRzXHAAMH0LfF54ctP0bVsxbO8eAvQryqKnbSkpnppfBTOpNXDkdt aqC4ozLbpINQxI4Cmk6r5W9oXwTsUPIT/dMfEMvU+SjUzySSABixqJ1Li4YHMRxqFjFyh5GnPcu KKqF9WKn/t0W7WxllZS4hR+yOK5z2VdFM4Nn0BtZQNXsJOdi75zxMjhRI9+53xhL2pYgm39ByvP CYLh0lazRFqiCZr/zK8W2kqrxzTchxQ0cEfT0eIUVaLivjNWEhe4V1CSzPPxzHp3vyGcnIuVtVs 1RG2OCOipQ2L6hlzdoXhvSBKl72po6Ze2a X-Received: by 2002:a5d:64e3:0:b0:449:cfea:ca91 with SMTP id ffacd0b85a97d-4515da96254mr17777880f8f.37.1778236429088; Fri, 08 May 2026 03:33:49 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45491f8d4c3sm3225842f8f.34.2026.05.08.03.33.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2026 03:33:48 -0700 (PDT) From: James Clark Date: Fri, 08 May 2026 11:33:36 +0100 Subject: [PATCH] perf test: Make leafloop workload immune to compiler options Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260508-james-perf-leafloop-stack-v1-1-637c260b2da8@linaro.org> X-B4-Tracking: v=1; b=H4sIAP+7/WkC/x3MQQrCMBBG4auUWTswHbCIVxEXIflTR2sTMiJC6 d0NXX6L9zZyNIPTddio4WtuZe0YTwPFR1hnsKVuUtFJznLhZ3jDuaJlXhDyUkpl/4T44qg6TiJ IKSv1vjZk+x3v233f//i7qyVrAAAA To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, James Clark X-Mailer: b4 0.14.0 Since the leafloop test program was moved into the main Perf binary as a workload, it inherited the same compiler options as Perf. In this case the -fstack-protector option broke the assumption that simple leaf frames don't have a stack frame on Arm. This causes test_arm_callgraph_fp.sh to pass even if the stack isn't augmented with the link register, making the test useless. Fix it by rewriting the leaf function in assembly seeing as it's so simple. Adding -fno-stack-protector would also work, but wouldn't be robust against other future compiler option additions. The local variables and 'a' variable were never needed so remove them to simplify. Assisted-by: GitHub-Copilot:GPT-5.5 Signed-off-by: James Clark --- tools/perf/tests/workloads/leafloop.c | 36 +++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/tools/perf/tests/workloads/leafloop.c b/tools/perf/tests/workloads/leafloop.c index f7561767e32c..58367fd1daec 100644 --- a/tools/perf/tests/workloads/leafloop.c +++ b/tools/perf/tests/workloads/leafloop.c @@ -6,10 +6,9 @@ #include "../tests.h" /* We want to check these symbols in perf script */ -noinline void leaf(volatile int b); -noinline void parent(volatile int b); +noinline void leaf(void); +noinline void parent(void); -static volatile int a; static volatile sig_atomic_t done; static void sighandler(int sig __maybe_unused) @@ -17,15 +16,36 @@ static void sighandler(int sig __maybe_unused) done = 1; } -noinline void leaf(volatile int b) +#if defined(__aarch64__) +/* + * Write leaf() in assembly so it stays as a minimal leaf function with no + * stack frame and won't get silently broken in the future by any Perf wide + * compilation options like -fstack-protector-all. + */ +asm( + ".text\n" + ".global leaf\n" + ".type leaf, %function\n" + "leaf:\n" + " adrp x1, done\n" + " ldr w2, [x1, #:lo12:done]\n" + " cbz w2, leaf\n" + " ret\n" +); + +#else + +noinline void leaf(void) { while (!done) - a += b; + ; } -noinline void parent(volatile int b) +#endif + +noinline void parent(void) { - leaf(b); + leaf(); } static int leafloop(int argc, const char **argv) @@ -39,7 +59,7 @@ static int leafloop(int argc, const char **argv) signal(SIGALRM, sighandler); alarm(sec); - parent(sec); + parent(); return 0; } --- base-commit: 8c8f2093614373ea8179b562320212a25cf937c0 change-id: 20260508-james-perf-leafloop-stack-c221600eddf2 Best regards, -- James Clark