On Mon, Sep 07, 2026 at 04:13:32PM +0800, Ye Liu wrote: > From: Ye Liu <[email protected]> > > Replace the manual rcu_read_lock()/rcu_read_unlock() pairs combined > with for_each_process() and for_each_process_thread() loops in fs/ > with the for_each_*_rculock() macros, which scope 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]>
LGTM so: Reviewed-by: Lorenzo Stoakes (ARM) <[email protected]> > --- > Changes in v2: > - Rename *_rcu to *_rculock > fs/proc/base.c | 4 +--- > fs/resctrl/rdtgroup.c | 8 ++------ > 2 files changed, 3 insertions(+), 9 deletions(-) > > diff --git a/fs/proc/base.c b/fs/proc/base.c > index 6a39de424f62..3de4f4557e4c 100644 > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > @@ -1160,8 +1160,7 @@ static int __set_oom_adj(struct file *file, int > oom_adj, bool legacy) > if (mm) { > struct task_struct *p; > > - rcu_read_lock(); > - for_each_process(p) { > + for_each_process_rculock(p) { > if (same_thread_group(task, p)) > continue; > > @@ -1177,7 +1176,6 @@ static int __set_oom_adj(struct file *file, int > oom_adj, bool legacy) > } > task_unlock(p); > } > - rcu_read_unlock(); > mmdrop(mm); > } > err_unlock: > diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c > index 5dcbb0a964e8..b14df8b23f1a 100644 > --- a/fs/resctrl/rdtgroup.c > +++ b/fs/resctrl/rdtgroup.c > @@ -709,14 +709,12 @@ int rdtgroup_tasks_assigned(struct rdtgroup *r) > > lockdep_assert_held(&rdtgroup_mutex); > > - rcu_read_lock(); > - for_each_process_thread(p, t) { > + for_each_process_thread_rculock(p, t) { > if (is_closid_match(t, r) || is_rmid_match(t, r)) { > ret = 1; > break; > } > } > - rcu_read_unlock(); > > return ret; > } > @@ -826,15 +824,13 @@ static void show_rdt_tasks(struct rdtgroup *r, struct > seq_file *s) > struct task_struct *p, *t; > pid_t pid; > > - rcu_read_lock(); > - for_each_process_thread(p, t) { > + for_each_process_thread_rculock(p, t) { > if (is_closid_match(t, r) || is_rmid_match(t, r)) { > pid = task_pid_vnr(t); > if (pid) > seq_printf(s, "%d\n", pid); > } > } > - rcu_read_unlock(); > } > > static int rdtgroup_tasks_show(struct kernfs_open_file *of, > -- > 2.25.1 > -- Cheers, Lorenzo
