Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "James Clark" <james.clark@linaro.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf test: Make leafloop workload immune to compiler options
Date: Fri, 08 May 2026 20:20:44 +0000	[thread overview]
Message-ID: <20260508202045.759CCC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260508-james-perf-leafloop-stack-v1-1-637c260b2da8@linaro.org>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Low] LTO build failure due to hardcoded static variable name in inline assembly.
- [Low] Missing ELF `.size` directive for inline assembly function.
- [Low] Fragile section management in top-level assembly.
--

commit 57b4e20838dd06862703b6049b087e60606a2dd4
Author: James Clark <james.clark@linaro.org>

perf test: Make leafloop workload immune to compiler options

This commit replaces the C implementation of the leaf function with an
inline assembly version for AArch64. This ensures compiler options like
-fstack-protector don't inadvertently add a stack frame, which would make
the test_arm_callgraph_fp test pass incorrectly.

> diff --git a/tools/perf/tests/workloads/leafloop.c b/tools/perf/tests/workloads/leafloop.c
> index f7561767e32cd..58367fd1daece 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;

[ ... ]

> -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"

Could using .text here instead of .pushsection .text and .popsection
interfere with the compiler's section tracking?

If the compiler assumes the previous section remains active after the asm
block, it might place subsequent data or code in the wrong section under
certain compilation flags.

> +	".global leaf\n"
> +	".type leaf, %function\n"
> +	"leaf:\n"
> +	"	adrp	x1, done\n"

Since done is declared as a static variable at the top of the file, if perf
is compiled with link-time optimization (LTO=1), the compiler might
partition and rename the C variable to avoid collisions across translation
units (e.g., done.lto_priv.0).

Will the hardcoded string "done" in this inline assembly cause an undefined
reference linker error under LTO builds?

> +	"	ldr	w2, [x1, #:lo12:done]\n"
> +	"	cbz	w2, leaf\n"
> +	"	ret\n"

This isn't a bug, but there doesn't appear to be a size directive
(.size leaf, . - leaf) at the end of the function.

While perf might handle 0-sized symbols internally, could omitting the size
cause issues with external ELF tools, debuggers, or profilers trying to
resolve the symbol bounds?

> +);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260508-james-perf-leafloop-stack-v1-1-637c260b2da8@linaro.org?part=1

      reply	other threads:[~2026-05-08 20:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08 10:33 [PATCH] perf test: Make leafloop workload immune to compiler options James Clark
2026-05-08 20:20 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260508202045.759CCC2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=james.clark@linaro.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox