From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 AB7683ACF1A for ; Mon, 11 May 2026 09:19:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778491197; cv=none; b=WsyRdLI6hRKWxNZeczBTIfLnWZScDw7Ori+yRsnZrDxSuz4WHSoNlJoUtFerrnBn/q6w94g3FHc4WopXkC7wZ3VqyNOYzLuo1Apt1QgY0aMoZUNOTaG/Hf29W5QdQCooyVf9xD85mL6bsZGQBupXkFWfC0z0Zd7q8dUftEPNQYM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778491197; c=relaxed/simple; bh=CrbWv/+o15mvy9673dGVtso71ofEsxWnWpMd4FvQ1eA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=KQBdLnLqZtAbR/OI+v+1FWL6w05ZEv0/H3w4A680AdRu+42vN7nm9ZJDZFMc+yomfQXwyUbgTqoslFYJeBaAyS1gHZn4p1N4B3kpZ/9sz0G2wtlQKvL6kXSpAFxCGrGlz459F9AfFRh19oFDuIDwZVTNNEyQV7//pm24xrJ6RWc= 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=I1tK/1aw; arc=none smtp.client-ip=209.85.221.54 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="I1tK/1aw" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-452169ae568so3099123f8f.3 for ; Mon, 11 May 2026 02:19:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1778491194; x=1779095994; 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=M2qwjeFR+f82S2J46kJab8g15mwoOiMqUIGcgspw2vs=; b=I1tK/1aw6pSqVBrghLFy2ok5i331/PTnRU2STRZ0Zk40dumrukrxO4VXzdxYRYsJXE EwqXDk63aPoFic5fqhosk6j17wMzRy7KGI38dYeX+HYURbUxfMTUCOzYOj42kxBMLOFh PlPWkY2qcvnokilVMAYZtlxNNMpvXf1Hkbp0HWOF13kkRuknu97pmZW7ZVHZsaB6STEs k6TENuoumEa+pj3gDOalu60ULXiEq5ltUbzuLr+G8SUl59g6cwWgnHOQnOy/uDbwHWyh qCaVgk+92gXgb8I6i27vdSoPPkk/FO4ZeMyFxQs0YmDpprQrjhmh718mQu/tl4zh6trL +Cdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778491194; x=1779095994; 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=M2qwjeFR+f82S2J46kJab8g15mwoOiMqUIGcgspw2vs=; b=PmiAyJHDA/3XEbR/t7jWHXMZYNdUTUyuEY9n7wk0hE06J+ECIee4lWyxO/WQ7xqjV8 8r89uDqpjvpiTF2d7gl/O6KacB5iCJENdWgs+D2qpS0tKU80QaceyINcP4+OYIUMaYir GXX0zksxFxYVcgEBjvynuX7BP6Pd78M1LEqO51t62lZAOXpKwNFv9sACNDrte7c+JK6D XyClQ/qsVs9A+FaE36DzO37tqG7m84Tg3vV7LvJuuIE/Vgz30lzOyIm67gR4a7VL1+qZ r/T+vBaBOG5icCqsenh8W+ad4vLkutLPLs72G/Y4CVNnmTaVMTGKlpsw0RPU/BV1tjOW 64GQ== X-Forwarded-Encrypted: i=1; AFNElJ+peT2WYISMtyX0l7l2Alyty4sXmNF4knxKbqBST6ddnDjmaKIWkEgpd7m9PdKXqzFv5RGLynIOPP6WYlA=@vger.kernel.org X-Gm-Message-State: AOJu0YyaNoIsdefA73pt5eliG1oJedwznNSZ4ukFLQjJWGUFbquonPcO h/1qUFGoEgIOMpgNdfrtstuv3NhTZVMXPKkn2pB3TArNEHeLKptEwm+ZtJxsGHCMB1A= X-Gm-Gg: Acq92OEk2SameZizFtbzBRxxseNr18G5BhFhWYBA3Hr1J8kodnnp37LTCKDdE4wpswN +m2ARYad2qnvQ95NDR3RB4zpFJpm9sFg4W0r9bi/wzZ1CPzfZT2xgjAtl2F14tthpob3YStVIdq P9eyKevMG+OQBfnzYYa0jDhL73lq8LsWCV9hAGLHXtxwaaIdfj61vb0Eok5Lp/ygUFp0JjcuLLe rBk7shg0DlyfvujlZJtV06M5hvsVw9den0b7ICpJyq6GNonOgSXOFfHKWUT5V5RK0TQShxWzUae ixFFl7+1mZ9YQ+RpO6uAIrnP7c9N4ylnwnwWKS263iCd94uj8iyrswJ4VISnXtiYZYKKqcTUQHF m2n8yQCZuirfvSmmM8i13xa5aum+8L8YnitacwKFMgn9+O8i/thEx3j+3AG7EXLVDTLxwqPlIlt bQASShpFwOeqZJN417nmb8jxi61d8devoh X-Received: by 2002:adf:e604:0:b0:452:c246:ab69 with SMTP id ffacd0b85a97d-452c246ac50mr22531878f8f.13.1778491194013; Mon, 11 May 2026 02:19:54 -0700 (PDT) Received: from ho-tower-lan.lan ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-454917d57aesm24679319f8f.26.2026.05.11.02.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 02:19:53 -0700 (PDT) From: James Clark Date: Mon, 11 May 2026 10:19:35 +0100 Subject: [PATCH v2] 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: <20260511-james-perf-leafloop-stack-v2-1-79f7383f545e@linaro.org> X-B4-Tracking: v=1; b=H4sIACafAWoC/42NQQ6CMBBFr2Jm7Zh2jEhceQ/DorZTGEVKpoRoC He3cgKX7+f/9xfIrMIZLrsFlGfJkoYCtN+B79zQMkooDGSoMidT48O9OOPIGrFnF/uURsyT80/ 0RLYyhkOIBGU/Kkd5b+5bU7iTPCX9bFez/aX/WGeLFqvj2ZfmnYKrr70MTtMhaQvNuq5fJqmVn 8MAAAA= 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 --- Changes in v2: - Push and pop asm sections - (Sashiko) - Add .size directive - (Sashiko) - Add asm label for done and test with LTO enabled - (Sashiko) - Link to v1: https://lore.kernel.org/r/20260508-james-perf-leafloop-stack-v1-1-637c260b2da8@linaro.org --- tools/perf/tests/workloads/leafloop.c | 40 +++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/tools/perf/tests/workloads/leafloop.c b/tools/perf/tests/workloads/leafloop.c index f7561767e32c..c20c75f7ba49 100644 --- a/tools/perf/tests/workloads/leafloop.c +++ b/tools/perf/tests/workloads/leafloop.c @@ -6,26 +6,48 @@ #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 volatile sig_atomic_t done asm("leafloop_done"); 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( + ".pushsection .text,\"ax\",%progbits\n" + ".global leaf\n" + ".type leaf, %function\n" + "leaf:\n" + " adrp x1, leafloop_done\n" + " ldr w2, [x1, #:lo12:leafloop_done]\n" + " cbz w2, leaf\n" + " ret\n" + ".size leaf, .-leaf\n" + ".popsection\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 +61,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