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
Subject: Re: [PATCH v3] tracing: fgraph: fix the quadratic shadow stack walk
Date: Sun, 11 Oct 2026 09:58:37 +0530 [thread overview]
Message-ID: <44b54799-6cab-4bcd-bce9-d8d55517a7a2@linux.dev> (raw)
In-Reply-To: <20261001102909.1152572-1-vineet.gupta@linux.dev>
On 10/1/26 15:59, Vineet Gupta wrote:
> alloc_retstack_tasklist() assigns a shadow stack to every thread when
> fgraph is enabled. It did so FTRACE_RETSTACK_ALLOC_SIZE (32) tasks at a
> time, and since for_each_process_thread() has no cursor, every sweep
> restarted from init_task and re-walked the tasks already served, making
> the ftrace_graph_active 0 -> 1 transition quadratic in the thread count.
> On a 60-core Sapphire Rapids machine with 400000 idle threads it took
> 227 s, inside a single bpf() syscall for the kprobe_multi case.
>
> Allocating inline with GFP_NOWAIT removes the batching: a single sweep
> serves every task, 227 s -> 0.092 s.
>
> v1: https://lore.kernel.org/all/20260922225526.1554758-1-vineet.gupta@linux.dev/
> v2: https://lore.kernel.org/all/20260929005411.4105448-1-vineet.gupta@linux.dev/
>
> Changes since v2:
> - update the stale alloc_retstack_tasklist() comment, which still
> described the old batch-of-32 behaviour (bot+bpf-ci)
>
> Sashiko flagged the mix of goto-based cleanup and scoped_guard() in
> this function. Peter and Andrii both considered it fine as is, so it
> is unchanged:
> https://lore.kernel.org/all/20260929080346.GR4120091@noisy.programming.kicks-ass.net/
>
> Changes since v1:
> - replace both v1 patches with Peter's inline GFP_NOWAIT approach,
> which removes the quadratic behaviour rather than dividing it by a
> constant. With a single sweep there is no retry loop left, so the
> v1 cond_resched() patch has nothing to attach to and is dropped.
> - 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 | 44 ++++++++++++++++++++++++++++---------------
> 1 file changed, 29 insertions(+), 15 deletions(-)
Gentle ping !
I appreciate folks might still be on the way home and the mayhem of
merge window.
Thx,
-Vineet
next prev parent reply other threads:[~2026-10-11 4:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 10:29 [PATCH v3] tracing: fgraph: fix the quadratic shadow stack walk Vineet Gupta
2026-10-01 10:29 ` [PATCH v3 1/1] tracing: fgraph: allocate shadow stacks inline with GFP_NOWAIT Vineet Gupta
2026-10-01 10:37 ` sashiko-bot
2026-10-01 11:31 ` Masami Hiramatsu
2026-10-01 13:19 ` Andrii Nakryiko
2026-10-11 4:28 ` Vineet Gupta [this message]
2026-10-12 13:42 ` [PATCH v3] tracing: fgraph: fix the quadratic shadow stack walk Steven Rostedt
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=44b54799-6cab-4bcd-bce9-d8d55517a7a2@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