linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] mm/oom_kill.c: simpilfy rcu call with guard(rcu)
       [not found] <CGME20260303102608epcas5p159cd0ad7dfd939c4a67fab3c7ecd7bfd@epcas5p1.samsung.com>
@ 2026-03-03 10:26 ` Maninder Singh
  2026-03-03 11:31   ` Michal Hocko
                     ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Maninder Singh @ 2026-03-03 10:26 UTC (permalink / raw)
  To: mhocko, rientjes, shakeel.butt, akpm
  Cc: linux-mm, linux-kernel, Maninder Singh

guard(rcu)() simplifies code readability and there is
no need of extra goto labels.

Thus replacing rcu_read_lock/unlock with guard(rcu)().

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
---
 mm/oom_kill.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 5c6c95c169ee..9e3e88c06ead 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -135,19 +135,16 @@ struct task_struct *find_lock_task_mm(struct task_struct *p)
 {
 	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;
 }
 
 /*
-- 
2.34.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] mm/oom_kill.c: simpilfy rcu call with guard(rcu)
  2026-03-03 10:26 ` [PATCH 1/1] mm/oom_kill.c: simpilfy rcu call with guard(rcu) Maninder Singh
@ 2026-03-03 11:31   ` Michal Hocko
  2026-03-03 12:57   ` Dmitry Ilvokhin
  2026-03-03 13:40   ` Shakeel Butt
  2 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2026-03-03 11:31 UTC (permalink / raw)
  To: Maninder Singh; +Cc: rientjes, shakeel.butt, akpm, linux-mm, linux-kernel

On Tue 03-03-26 15:56:00, Maninder Singh wrote:
> guard(rcu)() simplifies code readability and there is
> no need of extra goto labels.
> 
> Thus replacing rcu_read_lock/unlock with guard(rcu)().
> 
> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>

Yes this simpliefies the code indeed
Acked-by: Michal Hocko <mhocko@suse.com>
Thanks!

> ---
>  mm/oom_kill.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 5c6c95c169ee..9e3e88c06ead 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -135,19 +135,16 @@ struct task_struct *find_lock_task_mm(struct task_struct *p)
>  {
>  	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;
>  }
>  
>  /*
> -- 
> 2.34.1

-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] mm/oom_kill.c: simpilfy rcu call with guard(rcu)
  2026-03-03 10:26 ` [PATCH 1/1] mm/oom_kill.c: simpilfy rcu call with guard(rcu) Maninder Singh
  2026-03-03 11:31   ` Michal Hocko
@ 2026-03-03 12:57   ` Dmitry Ilvokhin
  2026-03-03 13:40   ` Shakeel Butt
  2 siblings, 0 replies; 4+ messages in thread
From: Dmitry Ilvokhin @ 2026-03-03 12:57 UTC (permalink / raw)
  To: Maninder Singh
  Cc: mhocko, rientjes, shakeel.butt, akpm, linux-mm, linux-kernel

On Tue, Mar 03, 2026 at 03:56:00PM +0530, Maninder Singh wrote:
> guard(rcu)() simplifies code readability and there is
> no need of extra goto labels.
> 
> Thus replacing rcu_read_lock/unlock with guard(rcu)().
> 
> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>

Reviewed-by: Dmitry Ilvokhin <d@ilvokhin.com>

> ---
>  mm/oom_kill.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 5c6c95c169ee..9e3e88c06ead 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -135,19 +135,16 @@ struct task_struct *find_lock_task_mm(struct task_struct *p)
>  {
>  	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;
>  }
>  
>  /*
> -- 
> 2.34.1
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] mm/oom_kill.c: simpilfy rcu call with guard(rcu)
  2026-03-03 10:26 ` [PATCH 1/1] mm/oom_kill.c: simpilfy rcu call with guard(rcu) Maninder Singh
  2026-03-03 11:31   ` Michal Hocko
  2026-03-03 12:57   ` Dmitry Ilvokhin
@ 2026-03-03 13:40   ` Shakeel Butt
  2 siblings, 0 replies; 4+ messages in thread
From: Shakeel Butt @ 2026-03-03 13:40 UTC (permalink / raw)
  To: Maninder Singh; +Cc: mhocko, rientjes, akpm, linux-mm, linux-kernel

On Tue, Mar 03, 2026 at 03:56:00PM +0530, Maninder Singh wrote:
> guard(rcu)() simplifies code readability and there is
> no need of extra goto labels.
> 
> Thus replacing rcu_read_lock/unlock with guard(rcu)().
> 
> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>

Thanks for the patch.

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-03 13:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20260303102608epcas5p159cd0ad7dfd939c4a67fab3c7ecd7bfd@epcas5p1.samsung.com>
2026-03-03 10:26 ` [PATCH 1/1] mm/oom_kill.c: simpilfy rcu call with guard(rcu) Maninder Singh
2026-03-03 11:31   ` Michal Hocko
2026-03-03 12:57   ` Dmitry Ilvokhin
2026-03-03 13:40   ` Shakeel Butt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox