guard(rcu)() simplifies code readability and there is no need of extra
goto labels.
Thus replacing rcu_read_lock/unlock with guard(rcu)().
Link: https://lkml.kernel.org/r/20260303102600.105255-1-maninder1.s@samsung.com
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: Dmitry Ilvokhin <d@ilvokhin.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
{
struct task_struct *t;
- rcu_read_lock();
+ guard(rcu)();
for_each_thread(p, t) {
task_lock(t);
if (likely(t->mm))
- goto found;
+ return t;
task_unlock(t);
}
- t = NULL;
-found:
- rcu_read_unlock();
- return t;
+ return NULL;
}
/*