From: Arnd Bergmann <arnd@kernel.org>
To: Robin Murphy <robin.murphy@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Nathan Chancellor <nathan@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Ilkka Koskinen <ilkka@os.amperecomputing.com>,
linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev
Subject: [PATCH] perf/arm-cmn: reduce stack usage in arm_cmn_probe()
Date: Fri, 20 Jun 2025 13:51:42 +0200 [thread overview]
Message-ID: <20250620115149.132845-1-arnd@kernel.org> (raw)
From: Arnd Bergmann <arnd@arndb.de>
This function has a rather large stack usage, which triggers the
warning limit with clang if I reduce the default to 1280 bytes:
drivers/perf/arm-cmn.c:2541:12: error: stack frame size (1312) exceeds limit (1280) in 'arm_cmn_probe' [-Werror,-Wframe-larger-than]
This is a combination of two problems:
- The arm_cmn_discover() function has some large local variables and
gets inlined here by clang (but not gcc)
- The (struct pmu) assignment adds an extra copy of the pmu structure
on the stack and does a memcpy() from that
Address the first one here by marking arm_cmn_discover() as noinline_for_stack,
making clang behave more like gcc here. This gets it under the warning
limit, though the total stack usage does not actually get reduced.
It would be nice to also change the way struct pmu is initialized, but I
see that this is done consistently for all pmu drivers. Ideally the function
pointers should be moved into a 'static const' structure per driver as this
is done in most other subsystems.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/perf/arm-cmn.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
index 031d45d0fe3d..430c89760391 100644
--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -2243,7 +2243,8 @@ static enum cmn_node_type arm_cmn_subtype(enum cmn_node_type type)
}
}
-static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
+static noinline_for_stack int arm_cmn_discover(struct arm_cmn *cmn,
+ unsigned int rgn_offset)
{
void __iomem *cfg_region;
struct arm_cmn_node cfg, *dn;
--
2.39.5
next reply other threads:[~2025-06-20 11:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 11:51 Arnd Bergmann [this message]
2025-06-27 17:57 ` [PATCH] perf/arm-cmn: reduce stack usage in arm_cmn_probe() Robin Murphy
2025-06-27 18:37 ` Arnd Bergmann
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=20250620115149.132845-1-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=arnd@arndb.de \
--cc=ilkka@os.amperecomputing.com \
--cc=justinstitt@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).