Skip to contentSkip to conversation

tracing: fgraph: cut the cost of the shadow stack retry loop

PATCH In review Vineet Gupta 3 participants 12 messages Sep 22 – Nov 5

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover tracing: fgraph: cut the cost of the shadow stack retry loop

Turning on function-graph tracing, or attaching a kprobe_multi return probe, hands every thread a shadow stack. alloc_retstack_tasklist() does that 32 tasks at a time, and since for_each_process_thread() has no cursor, every sweep restarts from init_task and re-walks the tasks already served. Total work is quadratic O(N^2) on thread count.

On a 60-core Sapphire Rapids machine with 400000 idle threads the 0 -> 1 transition takes 227 s, inside a single bpf() syscall for the kprobe_multi case. On Meta fleet this showed up as RCU stalls and softlockup panics.

Patch 1 raises the batch to 1024, dividing the sweeps by 32:
227 s -> 7.2 s at 400000 threads. It helps on every preemption model.

Patch 2 adds a cond_resched() between sweeps. It is supplementary and
separable: a no-op on current x86 and arm64, but on !CONFIG_PREEMPTION builds it takes soft lockups from 3-of-3 runs to 0-of-3. Dropping it leaves patch 1 intact.

Neither changes the O(N^2) shape; a cursor-based walk would, but task_struct lifetime makes that considerably more involved.

Vineet Gupta (2):
tracing: fgraph: Raise FTRACE_RETSTACK_ALLOC_SIZE to 1024
tracing: fgraph: Add a cond_resched() to the shadow stack retry loop

 include/linux/ftrace.h | 7 ++++++-
 kernel/trace/fgraph.c  | 8 ++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
Signature · 1 line
2.53.0-Meta
#1 lore raw

PATCH 1/2 tracing: fgraph: Raise FTRACE_RETSTACK_ALLOC_SIZE to 1024

When ftrace graphing is turned on, all tasks in the system missing return stack page are assigned one. This is done in a simplistic multi-sweep loop of FTRACE_RETSTACK_ALLOC_SIZE (currently 32) tasks at a time as follows:

start_graph_tracing()

	do {
		alloc_retstack_tasklist
	} while (-EAGAIN);

alloc_retstack_tasklist()
alloc x32 # GFP_KERNEL, may sleep
rcu_read_lock() # preempt off
for_each_process_thread walk N_total, no cond_resched
t->ret_stack = new_page
rcu_read_unlock() # preempt enable but no explicit yield

Each successive iteration of loop invokes for_each_process_thread() which doesn't support cursor based resume and always restarts from the init_task. Thus each successive loop needs to skip the tasks assigned ret_stack in prior sweeps and thus take longer and longer to find the candidate 32 tasks. And while the loop end calls rcu unlock, and re-enables preemption briefly, there is no explicit yield.

The total number of iterations turn out to be

N_total * N_null / (2 * FTRACE_RETSTACK_ALLOC_SIZE)

where N_total is the number of threads on the system and N_null the number of those whose ret_stack is still NULL. After boot with no fgraph user that is every thread.

This is not a tracing-only path. Since commit 4346ba160409 ("fprobe:
Rewrite fprobe on function-graph tracer") fprobe is built on fgraph, so an ordinary kprobe_multi BPF attach that flips ftrace_graph_active from 0 to 1 pays the whole cost inside one bpf() syscall. Commit 2c67dc457bc6 ("tracing: fprobe: optimization for entry only case") narrows that to return and session probes but does not remove it.

A host running hundreds of thousands of threads, with the current batch size of 32, turns the ftrace_graph_active 0 -> 1 transition into a multi-second, and eventually multi-minute, operation which showed up as RCU stall and softlockup_panic on heavily loaded Meta Fleet machines with preemption disabled.

    rcu: INFO: rcu_sched self-detected stall on CPU
    rcu: 0-....: (20718 ticks this GP) (t=21000 jiffies g=913 q=8 ncpus=8)
    CPU: 0 UID: 0 PID: 160141 Comm: bpftrace
     ___slab_alloc+0x549/0xa20
     kmem_cache_alloc_noprof+0x16c/0x340
     register_ftrace_graph+0x3d7/0x6c0
     register_fprobe_ips+0x2d5/0x310
     bpf_kprobe_multi_link_attach+0x218/0x7e0
     __sys_bpf+0x267a/0x27a0

Fix this by raising the batch to 1024.

Measured on a 60-core Sapphire Rapids machine, running a PREEMPT_LAZY kernel (CONFIG_PREEMPT_DYNAMIC=y, mode lazy) timing the write that drives the ftrace_graph_active 0 -> 1 transition. Threads are spawned while fgraph is inactive so every one of them has ret_stack == NULL, and the loop was instrumented to count passes:

	threads   batch 32              batch 1024
	          passes   time         passes   time     speedup
	100000     3126     15.3 s        98      0.44 s   34.8x
	200000     6253     59.1 s       196      1.61 s   36.7x
	400000    12503    227.8 s       391      7.25 s   31.4x

At smaller thread counts (<= 200k), speedups are better than expected due to cache locality, and degrade at 400k threads due to cache misses.

This is a latency fix, specially on preemptible kernels. On !CONFIG_PREEMPTION builds, where the walk is not preemptible, the same loop additionally produces RCU stall and soft lockup splats; those are a separate problem, and raising the batch only helps there by making the operation too short to trip the thresholds.

The cost is a larger allocation burst. Shadow stacks are SHADOW_STACK_SIZE (4K) each, so a batch is a 4M GFP_KERNEL burst out of fgraph_stack_cachep taken while ftrace_lock and fprobe_mutex are held, and the pointer array kcalloc()'d by start_graph_tracing() grows from 256 bytes to 8K. Both are still ordinary kmalloc sizes, and any unused tail of the batch is freed at the end of the pass as before. 1024 was picked to keep that array a single order-1 allocation; going much higher would need kvmalloc.

This is a constant-factor improvement, not a cure: the retry loop stays O(N_total * N_null), so wall time still grows quadratically with the thread count and the batch will need revisiting as hosts get bigger. Making the walk resume from a cursor instead of restarting from the head would fix this properly, but task_struct lifetime makes it considerably more involved, so it is left for later.

Fixes f201ae2356c7 ("tracing/function-return-tracer: store return stack into task_struct and allocate it dynamically")
---
 include/linux/ftrace.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
include/linux/ftrace.h +6 -1
index bd76a16a63af..d2f8e433ce53 100644
@@ -1317,7 +1317,12 @@ unsigned long *fgraph_get_task_var(struct fgraph_ops *gops);
 #define __notrace_funcgraph		notrace
 
 #define FTRACE_RETFUNC_DEPTH 50
-#define FTRACE_RETSTACK_ALLOC_SIZE 32
+/*
+ * Batch for handing out Shadow stacks in one sweep.
+ * This bounds how many times task list is walked and the allocation
+ * burst given page size of 4K.
+ */
+#define FTRACE_RETSTACK_ALLOC_SIZE 1024
 
 extern int register_ftrace_graph(struct fgraph_ops *ops);
 extern void unregister_ftrace_graph(struct fgraph_ops *ops);
Signature · 1 line
2.53.0-Meta
#8 lore raw

PATCH 2/2 tracing: fgraph: Add a cond_resched() to the shadow stack retry loop

In reply to Vineet Gupta

This is supplementary to previous patch and is effective only for !PREEMPTION kernels.

The preceding patch cuts the number of sweeps over the thread list by 32x, but the loop is still O(N^2). Each pass walks from the same start init_task under rcu_read_lock() with no reschedule point. On a kernel that cannot preempt the walk, a large enough thread count lets one task monopolize a CPU until the walk completes.

Add a cond_resched() between sweeps which is safe since it is outside the RCU read-side critical section.

It is understood that this is effectively a no-op for CONFIG_PREEMPTION builds, which is what default x86 and arm64 kernels are today. A CONFIG_PREEMPT_DYNAMIC build with "preempt={none,voluntary}" used to work but even that got inhibited since the commit 7dadeaa6e851 ("sched: Further restrict the preemption modes"). Measured on a 60-core machine with a PREEMPT_LAZY kernel and 400000 idle threads, this patch changes neither the runtime nor the yield count, which stays at zero.

Where it does have effect is !CONFIG_PREEMPTION builds: architectures that still offer PREEMPT_NONE or PREEMPT_VOLUNTARY, and the stable kernels where x86 PREEMPT_NONE remains a build-time choice. Verified on a 6.16 PREEMPT_NONE kernel, 240000 idle threads, three runs each, with the loop instrumented to count passes and cond_resched() yields:

	                 time            yields   soft lockup
	unpatched        51.3-54.6 s     -        3 of 3
	cond_resched()   52.7-53.0 s     592-609  0 of 3

The runtime is unchanged and the soft lockups are gone. Every need_resched() converts to a yield, giving an average of about 98 ms between reschedules.

There is a second effect on those builds. When cond_resched() does not reschedule it still calls rcu_all_qs() on !CONFIG_PREEMPT_RCU kernels, reporting a quiescent state. So the two failures seen in the field are addressed by two mechanisms: the soft lockup by yielding so the watchdog can run, and the RCU stall by reporting a quiescent state even on passes where no yield happens.

This is deliberately separable from the preceding patch. If the view is that a no-op on the architectures anyone runs is not worth carrying, dropping this one leaves the batch-size fix intact.

---
 kernel/trace/fgraph.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kernel/trace/fgraph.c +8 -0
index ed455b53513b..86d11217c584 100644
@@ -1249,6 +1249,14 @@ static int start_graph_tracing(void)
 
 	do {
 		ret = alloc_retstack_tasklist(ret_stack_list);
+		/*
+		 * Each pass rescans the thread list from the head, so the
+		 * loop is O(threads^2) overall. The RCU read-side section
+		 * ends with the pass, and both locks held here (ftrace_lock,
+		 * and fprobe_mutex for fprobe users) are mutexes, so it is
+		 * safe to give the CPU up in between.
+		 */
+		cond_resched();
 	} while (ret == -EAGAIN);
 
 	if (!ret) {
Signature · 1 line
2.53.0-Meta
maintainer
#9 lore raw

Re: [PATCH 2/2] tracing: fgraph: Add a cond_resched() to the shadow stack retry loop

Quoted 2 lines · On Tue, 22 Sep 2026 15:55:26 -0700 Vineet Gupta <[email protected]> wrote:

This is supplementary to previous patch and is effective only for !PREEMPTION kernels.

FYI, a patch in a series should never mention "the previous patch" as if it gets committed, order in git history is not easily seen. Thus, a change log should mention the added functionality itself and not a patch sent to the mailing list.

But that said, this patch is likely not going to be added because !PREEMPTION is being deprecated specifically to get rid of cond_rescheds. Hence, I'm not adding any new ones.

-- Steve

#2 lore raw

Re: [PATCH 1/2] tracing: fgraph: Raise FTRACE_RETSTACK_ALLOC_SIZE to 1024

In reply to Vineet Gupta
Quoted 17 lines · Vineet Gupta

When ftrace graphing is turned on, all tasks in the system missing return stack page are assigned one. This is done in a simplistic multi-sweep loop of FTRACE_RETSTACK_ALLOC_SIZE (currently 32) tasks at a time as follows:

start_graph_tracing()

	do {
		alloc_retstack_tasklist
	} while (-EAGAIN);

alloc_retstack_tasklist()
alloc x32 # GFP_KERNEL, may sleep
rcu_read_lock() # preempt off
for_each_process_thread walk N_total, no cond_resched
t->ret_stack = new_page
rcu_read_unlock() # preempt enable but no explicit yield

Quoted 5 lines

Each successive iteration of loop invokes for_each_process_thread() which doesn't support cursor based resume and always restarts from the init_task. Thus each successive loop needs to skip the tasks assigned ret_stack in prior sweeps and thus take longer and longer to find the candidate 32 tasks.

Does this work?

kernel/trace/fgraph.c +16 -14
index ed455b53513b..155dafad474d 100644
@@ -1036,10 +1036,9 @@ trace_func_graph_ent_t ftrace_graph_entry = ftrace_graph_entry_stub;
 /* Try to assign a return stack array on FTRACE_RETSTACK_ALLOC_SIZE tasks. */
 static int alloc_retstack_tasklist(unsigned long **ret_stack_list)
 {
-	int i;
-	int ret = 0;
 	int start = 0, end = FTRACE_RETSTACK_ALLOC_SIZE;
 	struct task_struct *g, *t;
+	int i, ret = 0;
 
 	if (WARN_ON_ONCE(!fgraph_stack_cachep))
 		return -ENOMEM;
@@ -1054,26 +1053,29 @@ static int alloc_retstack_tasklist(unsigned long **ret_stack_list)
 		}
 	}
 
-	rcu_read_lock();
-	for_each_process_thread(g, t) {
-		if (start == end) {
-			ret = -EAGAIN;
-			goto unlock;
-		}
+	scoped_guard (rcu) {
+		for_each_process_thread(g, t) {
+			unsigned long *rs;
+
+			if (t->ret_stack)
+				continue;
+
+			rs = kmem_cache_alloc(fgraph_stack_cachep, GFP_NOWAIT);
+			if (!rs) {
+				if (start == end)
+					return -EAGAIN;
+				rs = ret_stack_list[start++];
+			}
 
-		if (t->ret_stack == NULL) {
 			atomic_set(&t->trace_overrun, 0);
-			ret_stack_init_task_vars(ret_stack_list[start]);
+			ret_stack_init_task_vars(rs);
 			t->curr_ret_stack = 0;
 			t->curr_ret_depth = -1;
 			/* Make sure the tasks see the 0 first: */
-			smp_wmb();
-			t->ret_stack = ret_stack_list[start++];
+			smp_store_release(&t->ret_stack, rs);
 		}
 	}
 
-unlock:
-	rcu_read_unlock();
 free:
 	for (i = start; i < end; i++)
 		kmem_cache_free(fgraph_stack_cachep, ret_stack_list[i]);
maintainer
#10 lore raw
In reply to Vineet Gupta

Just an FYI. My wife flew into Europe today and I'll be touring Europe with her until Oct 3rd. I may get time to look at patches, but it will be very limited. And then LPC starts and who knows when I'll get a chance.

Thus I may not be very responsive for the next couple of weeks.

-- Steve

Quoted 29 lines · On Tue, 22 Sep 2026 15:55:24 -0700 Vineet Gupta <[email protected]> wrote:

Turning on function-graph tracing, or attaching a kprobe_multi return probe, hands every thread a shadow stack. alloc_retstack_tasklist() does that 32 tasks at a time, and since for_each_process_thread() has no cursor, every sweep restarts from init_task and re-walks the tasks already served. Total work is quadratic O(N^2) on thread count.

On a 60-core Sapphire Rapids machine with 400000 idle threads the 0 -> 1 transition takes 227 s, inside a single bpf() syscall for the kprobe_multi case. On Meta fleet this showed up as RCU stalls and softlockup panics.

Patch 1 raises the batch to 1024, dividing the sweeps by 32:
227 s -> 7.2 s at 400000 threads. It helps on every preemption model.

Patch 2 adds a cond_resched() between sweeps. It is supplementary and
separable: a no-op on current x86 and arm64, but on !CONFIG_PREEMPTION builds it takes soft lockups from 3-of-3 runs to 0-of-3. Dropping it leaves patch 1 intact.

Neither changes the O(N^2) shape; a cursor-based walk would, but task_struct lifetime makes that considerably more involved.

Vineet Gupta (2):
tracing: fgraph: Raise FTRACE_RETSTACK_ALLOC_SIZE to 1024
tracing: fgraph: Add a cond_resched() to the shadow stack retry loop

 include/linux/ftrace.h | 7 ++++++-
 kernel/trace/fgraph.c  | 8 ++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
#11 lore raw
Quoted 6 lines · Steven Rostedt

Just an FYI. My wife flew into Europe today and I'll be touring Europe with her until Oct 3rd. I may get time to look at patches, but it will be very limited. And then LPC starts and who knows when I'll get a chance.

Thus I may not be very responsive for the next couple of weeks.

Thx for the reply Steve. I understand it is that time of the year with travels and such. No rush, just wanted to push it out of mailbox, to yours :-)
Besides it might all be moot as Peter's solution is much more elegant and efficient (as always). I will reply to that but don't feel pressed to respond.

Thx,
-Vineet

Quoted 36 lines

-- Steve

Quoted 29 lines · On Tue, 22 Sep 2026 15:55:24 -0700 Vineet Gupta <[email protected]> wrote:

Turning on function-graph tracing, or attaching a kprobe_multi return probe, hands every thread a shadow stack. alloc_retstack_tasklist() does that 32 tasks at a time, and since for_each_process_thread() has no cursor, every sweep restarts from init_task and re-walks the tasks already served. Total work is quadratic O(N^2) on thread count.

On a 60-core Sapphire Rapids machine with 400000 idle threads the 0 -> 1 transition takes 227 s, inside a single bpf() syscall for the kprobe_multi case. On Meta fleet this showed up as RCU stalls and softlockup panics.

Patch 1 raises the batch to 1024, dividing the sweeps by 32:
227 s -> 7.2 s at 400000 threads. It helps on every preemption model.

Patch 2 adds a cond_resched() between sweeps. It is supplementary and
separable: a no-op on current x86 and arm64, but on !CONFIG_PREEMPTION builds it takes soft lockups from 3-of-3 runs to 0-of-3. Dropping it leaves patch 1 intact.

Neither changes the O(N^2) shape; a cursor-based walk would, but task_struct lifetime makes that considerably more involved.

Vineet Gupta (2):
tracing: fgraph: Raise FTRACE_RETSTACK_ALLOC_SIZE to 1024
tracing: fgraph: Add a cond_resched() to the shadow stack retry loop

  include/linux/ftrace.h | 7 ++++++-
  kernel/trace/fgraph.c  | 8 ++++++++
  2 files changed, 14 insertions(+), 1 deletion(-)
#3 lore raw

Re: [PATCH 1/2] tracing: fgraph: Raise FTRACE_RETSTACK_ALLOC_SIZE to 1024

In reply to Peter Zijlstra
Quoted 18 lines · Peter Zijlstra
Quoted 17 lines · Vineet Gupta

When ftrace graphing is turned on, all tasks in the system missing return stack page are assigned one. This is done in a simplistic multi-sweep loop of FTRACE_RETSTACK_ALLOC_SIZE (currently 32) tasks at a time as follows:

start_graph_tracing()
do {
alloc_retstack_tasklist
} while (-EAGAIN);

alloc_retstack_tasklist()
alloc x32 # GFP_KERNEL, may sleep
rcu_read_lock() # preempt off
for_each_process_thread walk N_total, no cond_resched
t->ret_stack = new_page
rcu_read_unlock() # preempt enable but no explicit yield

Quoted 6 lines
Quoted 5 lines

Each successive iteration of loop invokes for_each_process_thread() which doesn't support cursor based resume and always restarts from the init_task. Thus each successive loop needs to skip the tasks assigned ret_stack in prior sweeps and thus take longer and longer to find the candidate 32 tasks.

Does this work?

Yes it does and much better at that: test run for 400k threads went down from 227 s (stock) to 7.2 s (my patch) to 92 ms. Woo hoo ! I didn't know about this cool trick.

A couple of things worth pointing out:

Quoted 24 lines
kernel/trace/fgraph.c +1 -6
index ed455b53513b..155dafad474d 100644
@@ -1036,10 +1036,9 @@ trace_func_graph_ent_t ftrace_graph_entry = ftrace_graph_entry_stub;
  /* Try to assign a return stack array on FTRACE_RETSTACK_ALLOC_SIZE tasks. */
  static int alloc_retstack_tasklist(unsigned long **ret_stack_list)
  {
-	int i;
-	int ret = 0;
  	int start = 0, end = FTRACE_RETSTACK_ALLOC_SIZE;
  	struct task_struct *g, *t;
+	int i, ret = 0;
 
  	if (WARN_ON_ONCE(!fgraph_stack_cachep))
  		return -ENOMEM;
@@ -1054,26 +1053,29 @@ static int alloc_retstack_tasklist(unsigned long **ret_stack_list)
  		}
  	}
 
-	rcu_read_lock();
-	for_each_process_thread(g, t) {
-		if (start == end) {
-			ret = -EAGAIN;

kernel/trace/fgraph.c static int alloc_retstack_tasklist(unsigned long **ret_stack_list) · line 1063

Quoted 10 lines
kernel/trace/fgraph.c +8 -2
-			goto unlock;
-		}
+	scoped_guard (rcu) {
+		for_each_process_thread(g, t) {
+			unsigned long *rs;
+
+			if (t->ret_stack)
+				continue;
+
+			rs = kmem_cache_alloc(fgraph_stack_cachep, GFP_NOWAIT);

It still pre-allocates FTRACE_RETSTACK_ALLOC_SIZE reserves in the fast path - my (limited) testing never hit the reserves, but I agree better to keep it and 32 seems like a reasonably low number?

kernel/trace/fgraph.c static int alloc_retstack_tasklist(unsigned long **ret_stack_list) · line 1066

Quoted 3 lines
kernel/trace/fgraph.c +3 -0
+			if (!rs) {
+				if (start == end)
+					return -EAGAIN;

This indicates the reserve pool is exhausted so it safe to elide the free: loop at the end: warrants a comment IMO.

For submission, would you take this up as reported-by me or do you prefer I send a v2 (your authorship and SoB etc) ? No big deal either ways just not sure what the std operating procedure is and nuances of all the tags etc.

Thx,
-Vineet

Quoted 21 lines
kernel/trace/fgraph.c +4 -6
+				rs = ret_stack_list[start++];
+			}
 
-		if (t->ret_stack == NULL) {
  			atomic_set(&t->trace_overrun, 0);
-			ret_stack_init_task_vars(ret_stack_list[start]);
+			ret_stack_init_task_vars(rs);
  			t->curr_ret_stack = 0;
  			t->curr_ret_depth = -1;
  			/* Make sure the tasks see the 0 first: */
-			smp_wmb();
-			t->ret_stack = ret_stack_list[start++];
+			smp_store_release(&t->ret_stack, rs);
  		}
  	}
 
-unlock:
-	rcu_read_unlock();
  free:
  	for (i = start; i < end; i++)
  		kmem_cache_free(fgraph_stack_cachep, ret_stack_list[i]);
maintainer
#7 lore raw

Re: [PATCH 1/2] tracing: fgraph: Raise FTRACE_RETSTACK_ALLOC_SIZE to 1024

In reply to Peter Zijlstra
Quoted 32 lines · On Thu, 24 Sep 2026 12:00:40 +0200 Peter Zijlstra <[email protected]> wrote:

Does this work?

kernel/trace/fgraph.c +4 -8
index ed455b53513b..155dafad474d 100644
@@ -1036,10 +1036,9 @@ trace_func_graph_ent_t ftrace_graph_entry = ftrace_graph_entry_stub;
 /* Try to assign a return stack array on FTRACE_RETSTACK_ALLOC_SIZE tasks. */
 static int alloc_retstack_tasklist(unsigned long **ret_stack_list)
 {
-	int i;
-	int ret = 0;
 	int start = 0, end = FTRACE_RETSTACK_ALLOC_SIZE;
 	struct task_struct *g, *t;
+	int i, ret = 0;
 
 	if (WARN_ON_ONCE(!fgraph_stack_cachep))
 		return -ENOMEM;
@@ -1054,26 +1053,29 @@ static int alloc_retstack_tasklist(unsigned long **ret_stack_list)
 		}
 	}
 
-	rcu_read_lock();
-	for_each_process_thread(g, t) {
-		if (start == end) {
-			ret = -EAGAIN;
-			goto unlock;
-		}
+	scoped_guard (rcu) {
+		for_each_process_thread(g, t) {
+			unsigned long *rs;

kernel/trace/fgraph.c static int alloc_retstack_tasklist(unsigned long **ret_stack_list) · line 1068

Quoted 10 lines
kernel/trace/fgraph.c +10 -0
+
+			if (t->ret_stack)
+				continue;
+
+			rs = kmem_cache_alloc(fgraph_stack_cachep, GFP_NOWAIT);
+			if (!rs) {
+				if (start == end)
+					return -EAGAIN;
+				rs = ret_stack_list[start++];
+			}

Yeah this is fine. This iteration code goes back to when function graph was first added back in 2008. Back then, looping all tasks required taking the task_list lock and I remember we didn't want to call kmalloc() while holding that. This code could definitely use some reassessment.

-- Steve

Quoted 19 lines
kernel/trace/fgraph.c +2 -6
-		if (t->ret_stack == NULL) {
 			atomic_set(&t->trace_overrun, 0);
-			ret_stack_init_task_vars(ret_stack_list[start]);
+			ret_stack_init_task_vars(rs);
 			t->curr_ret_stack = 0;
 			t->curr_ret_depth = -1;
 			/* Make sure the tasks see the 0 first: */
-			smp_wmb();
-			t->ret_stack = ret_stack_list[start++];
+			smp_store_release(&t->ret_stack, rs);
 		}
 	}
 
-unlock:
-	rcu_read_unlock();
 free:
 	for (i = start; i < end; i++)
 		kmem_cache_free(fgraph_stack_cachep, ret_stack_list[i]);
maintainer
#4 lore raw

Re: [PATCH 1/2] tracing: fgraph: Raise FTRACE_RETSTACK_ALLOC_SIZE to 1024

In reply to Vineet Gupta
Quoted 4 lines · On Fri, 25 Sep 2026 12:32:49 -0700 Vineet Gupta <[email protected]> wrote:

For submission, would you take this up as reported-by me or do you prefer I send a v2 (your authorship and SoB etc) ? No big deal either ways just not sure what the std operating procedure is and nuances of all the tags etc.

Please implement Peter's suggestion and send a v2 with the tags:

Thanks,

-- Steve

#5 lore raw

Re: [PATCH 1/2] tracing: fgraph: Raise FTRACE_RETSTACK_ALLOC_SIZE to 1024

Quoted 11 lines · Steven Rostedt
Quoted 4 lines · On Fri, 25 Sep 2026 12:32:49 -0700 Vineet Gupta <[email protected]> wrote:

For submission, would you take this up as reported-by me or do you prefer I send a v2 (your authorship and SoB etc) ? No big deal either ways just not sure what the std operating procedure is and nuances of all the tags etc.

Please implement Peter's suggestion and send a v2 with the tags:

I think you have some catching up to do still :-)
This is v1, we are currently at v4 [1] with Peter's suggestion and further split up for ease of backport and use of new rcu_scope constructs as suggested by Masami san. It has been Acked by Andrii [2] and Alexei [3]

Thx,
-Vineet

[1] https://lore.kernel.org/bpf/[email protected]/
[2] https://lore.kernel.org/bpf/CAEf4BzaTYgNwiBtvYoSw1wzuFZchs-2CCP93gh2OeDt-919-eQ@mail.gmail.com/
[3] https://lore.kernel.org/bpf/[email protected]/

maintainer
#6 lore raw

Re: [PATCH 1/2] tracing: fgraph: Raise FTRACE_RETSTACK_ALLOC_SIZE to 1024

Quoted 5 lines · On Thu, 5 Nov 2026 09:56:07 -0800 Vineet Gupta <[email protected]> wrote:

I think you have some catching up to do still :-)
This is v1, we are currently at v4 [1] with Peter's suggestion and further split up for ease of backport and use of new rcu_scope constructs as suggested by Masami san. It has been Acked by Andrii [2] and Alexei [3]

Bah, this one wasn't superseded in patchwork, and I'm going from oldest to newest.

Sorry about that ;-)

-- Steve