All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Günther Noack" <gnoack3000@gmail.com>
To: Ye Liu <ye.liu@linux.dev>
Cc: "Mickaël Salaün" <mic@digikod.net>,
	"Paul Moore" <paul@paul-moore.com>,
	"James Morris" <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>, "Ye Liu" <liuye@kylinos.cn>,
	"Günther Noack" <gnoack@google.com>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 8/8] security/landlock: convert thread iterator to for_each_thread_rcu
Date: Fri, 4 Sep 2026 16:17:46 +0200	[thread overview]
Message-ID: <20260904.01fcdd4c37b2@gnoack.org> (raw)
In-Reply-To: <20260904083001.553587-9-ye.liu@linux.dev>

On Fri, Sep 04, 2026 at 04:30:00PM +0800, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
> 
> Replace guard(rcu)() + for_each_thread() with for_each_thread_rcu(),
> so that the RCU read-side critical section is scoped to the loop body.
> 
> No functional change.
> 
> Signed-off-by: Ye Liu <liuye@kylinos.cn>
> ---
>  security/landlock/tsync.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/security/landlock/tsync.c b/security/landlock/tsync.c
> index 0b71e158c3f5..f1c08aae179b 100644
> --- a/security/landlock/tsync.c
> +++ b/security/landlock/tsync.c
> @@ -335,9 +335,7 @@ static size_t count_additional_threads(const struct tsync_works *works)
>  
>  	caller = current;
>  
> -	guard(rcu)();
> -
> -	for_each_thread(caller, thread) {
> +	for_each_thread_rcu(caller, thread) {
>  		/* Skip current, since it is initiating the sync. */
>  		if (thread == caller)
>  			continue;
> @@ -376,9 +374,7 @@ static bool schedule_task_work(struct tsync_works *works,
>  
>  	caller = current;
>  
> -	guard(rcu)();
> -
> -	for_each_thread(caller, thread) {
> +	for_each_thread_rcu(caller, thread) {
>  		/* Skip current, since it is initiating the sync. */
>  		if (thread == caller)
>  			continue;
> -- 
> 2.25.1
> 

Reviewed-by: Günther Noack <gnoack3000@gmail.com>

Looks good, provided that the for_each_thread_rcu() macro gets
accepted.

Although, I find that in the Landlock case, it does not provide a very
strong advantage over the explicit "guard(rcu)();", and I find it
normally preferrable to use orthogonal APIs.

–Günther

      parent reply	other threads:[~2026-09-04 14:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  8:29 [PATCH 0/8] mm: introduce for_each_process_rcu and for_each_thread_rcu Ye Liu
2026-09-04  8:29 ` [PATCH 2/8] mm/oom_kill: convert process/thread iterators to for_each_*_rcu Ye Liu
2026-09-04 11:04   ` Michal Hocko
2026-09-05  0:32   ` SJ Park
2026-09-04  8:29 ` [PATCH 3/8] mm/ksm: convert process iterator to for_each_process_rcu Ye Liu
2026-09-04 11:04   ` Michal Hocko
2026-09-05  0:33   ` SJ Park
2026-09-04  8:29 ` [PATCH 4/8] mm/memory-failure: " Ye Liu
2026-09-04 11:05   ` Michal Hocko
2026-09-05  0:39   ` SJ Park
2026-09-07  3:05   ` Miaohe Lin
2026-09-04  8:29 ` [PATCH 5/8] kernel: convert process/thread iterators to for_each_*_rcu Ye Liu
2026-09-04  8:40   ` sashiko-bot
2026-09-04 11:06   ` Michal Hocko
2026-09-04 14:14   ` Günther Noack
2026-09-04  8:29 ` [PATCH 6/8] fs: " Ye Liu
2026-09-04  9:05   ` Oleg Nesterov
2026-09-04  9:22   ` Lorenzo Stoakes (ARM)
2026-09-04 11:06   ` Michal Hocko
2026-09-08 16:45   ` Alexey Dobriyan
2026-09-08 17:10     ` Lorenzo Stoakes (ARM)
2026-09-08 17:26       ` Alexey Dobriyan
2026-09-08 17:41         ` Lorenzo Stoakes (ARM)
2026-09-08 17:12     ` Oleg Nesterov
2026-09-04  8:30 ` [PATCH 8/8] security/landlock: convert thread iterator to for_each_thread_rcu Ye Liu
2026-09-04 12:21   ` Justin Suess
2026-09-04 14:17   ` Günther Noack [this message]

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=20260904.01fcdd4c37b2@gnoack.org \
    --to=gnoack3000@gmail.com \
    --cc=gnoack@google.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=liuye@kylinos.cn \
    --cc=mic@digikod.net \
    --cc=paul@paul-moore.com \
    --cc=serge@hallyn.com \
    --cc=ye.liu@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.