Re: [PATCH v3 11/15] tracing/fgraph: convert process/thread iterator to for_each_process_thread_rculock
From: sashiko-bot@kernel.org
Date: 2026-09-11 08:10:14
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Mixing goto-based error handling and scope-based guard() cleanup in the same function. -- commit 70fc208f5f44114137a3c935785ed1ab665ae0e0 Author: Ye Liu [off-list ref] tracing/fgraph: convert process/thread iterator to for_each_process_thread_rculock This commit replaces the manual rcu_read_lock() and rcu_read_unlock() pair combined with the for_each_process_thread() loop in fgraph.c with the for_each_process_thread_rculock() macro, which scopes the RCU read lock to the loop body via scoped_guard(rcu).
quoted hunk ↗ jump to hunk
diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 40d373d65f9b9..f797ce1192233 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -1057,11 +1057,10 @@ static int alloc_retstack_tasklist(unsigned long **ret_stack_list) } } - rcu_read_lock(); - for_each_process_thread(g, t) { + for_each_process_thread_rculock(g, t) { if (start == end) { ret = -EAGAIN; - goto unlock; + goto free;
[Severity: Low] Does this mix scope-based cleanup with manual goto-based error handling? By replacing the manual RCU lock with for_each_process_thread_rculock() (which uses scoped_guard(rcu)), the function now relies on scope-based cleanup for the RCU lock, but still jumps to a manual "goto free" label for the memory cleanup below. The cleanup guidelines state that for a given routine, we should convert all resources that need a "goto" cleanup to scope-based cleanup, or convert none of them, avoiding mixed usage in the same function.
}
if (t->ret_stack == NULL) {[ ... ]
quoted hunk ↗ jump to hunk
@@ -1074,9 +1073,6 @@ static int alloc_retstack_tasklist(unsigned long **ret_stack_list) t->ret_stack = ret_stack_list[start++]; } } - -unlock: - rcu_read_unlock(); free: for (i = start; i < end; i++) kmem_cache_free(fgraph_stack_cachep, ret_stack_list[i]);
-- Sashiko AI review · https://sashiko.dev/#/patchset/20260911075800.491472-1-ye.liu@linux.dev?part=11