From: Ye Liu <[email protected]> Replace the manual rcu_read_lock()/rcu_read_unlock() pair combined with for_each_process_thread() loop in kernel/trace/fgraph.c with for_each_process_thread_rculock(), which scopes the RCU read lock to the loop body via scoped_guard(rcu).
No functional change. Signed-off-by: Ye Liu <[email protected]> Acked-by: Michal Hocko <[email protected]> Reviewed-by: SJ Park <[email protected]> Reviewed-by: Lorenzo Stoakes (ARM) <[email protected]> Reviewed-by: Oleg Nesterov <[email protected]> --- Changes in v3: - Split from kernel/ patch in v2 (Peter Zijlstra, Steven Rostedt) Changes in v2: - Rename *_rcu to *_rculock kernel/trace/fgraph.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 40d373d65f9b..f797ce119223 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -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; } if (t->ret_stack == NULL) { @@ -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]); -- 2.25.1
