From: Vineet Gupta <vineet.gupta@linux.dev>
To: rostedt@goodmis.org, mhiramat@kernel.org
Cc: mark.rutland@arm.com, mathieu.desnoyers@efficios.com,
andrii@kernel.org, peterz@infradead.org,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, kernel-team@meta.com,
Vineet Gupta <vineet.gupta@linux.dev>
Subject: [PATCH v2] tracing: fgraph: fix the quadratic shadow stack walk
Date: Mon, 28 Sep 2026 17:54:10 -0700 [thread overview]
Message-ID: <20260929005411.4105448-1-vineet.gupta@linux.dev> (raw)
v1 tried to make the sweep loop cheaper: raise the batch from 32 to
1024, and add a cond_resched() so the walk could not hold a CPU. Peter
pointed out that the loop does not need to be batched at all. Allocating
inline with GFP_NOWAIT is legal under rcu_read_lock() because it cannot
sleep, so a single sweep can serve every task and the pre-allocated
array becomes an out-of-memory fallback.
That removes the quadratic behaviour rather than dividing it by a
constant, so both v1 patches are dropped in favour of this one.
Measured at 400000 threads on a 60-core Sapphire Rapids machine,
PREEMPT_LAZY:
v1 base (batch 32) 227.8 s 12503 sweeps
v1 patch (batch 1024) 7.2 s 391 sweeps
v2 (this patch) 0.092 s 1 sweep
With one sweep there is no retry loop left, so the v1 cond_resched()
patch has nothing to attach to and is dropped too.
v1: https://lore.kernel.org/all/20260922225526.1554758-1-vineet.gupta@linux.dev/
Changes since v1:
- replace both patches with Peter's inline GFP_NOWAIT approach
- comment why returning from inside scoped_guard() skips the free
loop safely
Vineet Gupta (1):
tracing: fgraph: allocate shadow stacks inline with GFP_NOWAIT
kernel/trace/fgraph.c | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
--
2.53.0-Meta
next reply other threads:[~2026-09-29 0:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 0:54 Vineet Gupta [this message]
2026-09-29 0:54 ` [PATCH v2 1/1] tracing: fgraph: allocate shadow stacks inline with GFP_NOWAIT Vineet Gupta
[not found] ` <20260929010327.024281F000FF@smtp.kernel.org>
2026-09-29 1:22 ` Vineet Gupta
2026-09-29 2:25 ` Andrii Nakryiko
2026-09-29 8:03 ` Peter Zijlstra
2026-09-29 23:46 ` bot+bpf-ci
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=20260929005411.4105448-1-vineet.gupta@linux.dev \
--to=vineet.gupta@linux.dev \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®