All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: Maninder Singh <maninder1.s@samsung.com>
Cc: rientjes@google.com, shakeel.butt@linux.dev,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] mm/oom_kill.c: simpilfy rcu call with guard(rcu)
Date: Tue, 3 Mar 2026 12:31:41 +0100	[thread overview]
Message-ID: <aabGnaO1l9rsbNia@tiehlicka> (raw)
In-Reply-To: <20260303102600.105255-1-maninder1.s@samsung.com>

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


  reply	other threads:[~2026-03-03 11:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 message]
2026-03-03 12:57   ` Dmitry Ilvokhin
2026-03-03 13:40   ` Shakeel Butt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aabGnaO1l9rsbNia@tiehlicka \
    --to=mhocko@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=maninder1.s@samsung.com \
    --cc=rientjes@google.com \
    --cc=shakeel.butt@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.