* [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
0 siblings, 1 reply; 2+ 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] 2+ 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
0 siblings, 0 replies; 2+ 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] 2+ messages in thread
end of thread, other threads:[~2026-03-03 11:31 UTC | newest]
Thread overview: 2+ 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox