Re: [PATCH v4 14/15] lib: convert process iterator to for_each_process_rculock
From: Oleg Nesterov
Date: Mon Sep 21 2026 - 16:38:49 EST
On 09/21, Ye Liu wrote:
>
> diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
> index 8c98b20bfc41..4e7fe85454ab 100644
> --- a/lib/is_single_threaded.c
> +++ b/lib/is_single_threaded.c
> @@ -26,8 +26,7 @@ bool current_is_single_threaded(void)
> return true;
>
> ret = false;
> - rcu_read_lock();
> - for_each_process(p) {
> + for_each_process_rculock(p) {
> if (unlikely(p->flags & PF_KTHREAD))
> continue;
> if (unlikely(p == task->group_leader))
> @@ -48,7 +47,5 @@ bool current_is_single_threaded(void)
> }
> ret = true;
> found:
> - rcu_read_unlock();
> -
Reviewed-by: Oleg Nesterov <oleg@xxxxxxxxxx>
but I think that the "found" label and "int ret" can now be removed,
the for_each_thread() loop can just do
...
if (unlikely(t->mm == mm))
return false;
and current_is_single_threaded() can simply return true after
the main for_each_process_rculock() loop.
But again, I agree with this patch, it looks simple and "obviously correct".
Even if I am right, the simplifications above need a separate change.
Oleg.