All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ye Liu" <ye.liu@linux.dev>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v3 13/15] fs: convert process/thread iterators to for_each_*_rculock
Date: Fri, 11 Sep 2026 08:15:02 +0000	[thread overview]
Message-ID: <20260911081504.735D51F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911075800.491472-14-ye.liu@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Mixing `goto`-based error handling with scope-based cleanup helpers in `__set_oom_adj()`.
--

commit dca26f99f6fe0ae1bf52a29a296c82180cb53c70
Author: Ye Liu <liuye@kylinos.cn>
Subject: fs: convert process/thread iterators to for_each_*_rculock

This commit replaces the manual rcu_read_lock() and rcu_read_unlock() pairs
combined with for_each_process() and for_each_process_thread() loops in
the fs/ tree with the for_each_*_rculock() macros. These new macros scope
the RCU read lock to the loop body using scoped_guard().

> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 58be389424605..2c47d838a1c76 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -1161,8 +1161,7 @@ static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
>  	if (mm) {
>  		struct task_struct *p;
>  
> -		rcu_read_lock();
> -		for_each_process(p) {
> +		for_each_process_rculock(p) {

[Severity: Medium]
Does this code introduce a regression by mixing scope-based cleanup helpers
with goto-based error handling?

The newly introduced for_each_process_rculock() macro expands to use
scoped_guard(rcu). However, __set_oom_adj() still relies on goto-based
cleanup paths earlier in the function:

fs/proc/base.c:__set_oom_adj() {
	// ...
	mutex_lock(&oom_adj_mutex);
	if (legacy) {
		if (oom_adj < task->signal->oom_score_adj &&
				!capable(CAP_SYS_RESOURCE)) {
			err = -EACCES;
			goto err_unlock;
		}
	// ...
err_unlock:
	mutex_unlock(&oom_adj_mutex);
	put_task_struct(task);
	return err;
}

The kernel cleanup subsystem guidelines in include/linux/cleanup.h note
that goto and cleanup helpers should never be mixed in the same function,
as it creates confusing ownership semantics. Could this function either
avoid using the scoped cleanup loop or fully convert the oom_adj_mutex
to a guard() pattern as well?

>  			if (same_thread_group(task, p))
>  				continue;

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260911075800.491472-1-ye.liu@linux.dev?part=13

  reply	other threads:[~2026-09-11  8:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  7:57 [PATCH v3 00/15] sched: introduce for_each_process_rculock and for_each_thread_rculock Ye Liu
2026-09-11  7:57 ` [PATCH v3 01/15] " Ye Liu
2026-09-11  7:57 ` [PATCH v3 02/15] mm/oom_kill: convert process/thread iterators to for_each_*_rculock Ye Liu
2026-09-11  7:57 ` [PATCH v3 03/15] mm/ksm: convert process iterator to for_each_process_rculock Ye Liu
2026-09-11  7:57 ` [PATCH v3 04/15] mm/memory-failure: " Ye Liu
2026-09-11  8:13   ` sashiko-bot
2026-09-11  9:51     ` Ye Liu
2026-09-11  7:57 ` [PATCH v3 05/15] cpu/hotplug: convert thread iterator to for_each_thread_rculock Ye Liu
2026-09-11  8:11   ` sashiko-bot
2026-09-11  9:55     ` Ye Liu
2026-09-11  7:57 ` [PATCH v3 06/15] freezer: " Ye Liu
2026-09-11  7:57 ` [PATCH v3 07/15] hung_task: convert process/thread iterators to for_each_*_rculock Ye Liu
2026-09-11  7:57 ` [PATCH v3 08/15] locking/lockdep: " Ye Liu
2026-09-11  7:57 ` [PATCH v3 09/15] rcu: convert process/thread iterator to for_each_process_thread_rculock Ye Liu
2026-09-11  7:57 ` [PATCH v3 10/15] sched: convert process/thread iterators to for_each_*_rculock Ye Liu
2026-09-11  7:57 ` [PATCH v3 11/15] tracing/fgraph: convert process/thread iterator to for_each_process_thread_rculock Ye Liu
2026-09-11  8:10   ` sashiko-bot
2026-09-11 12:59   ` Steven Rostedt
2026-09-11  7:57 ` [PATCH v3 12/15] unwind: " Ye Liu
2026-09-11 12:57   ` Steven Rostedt
2026-09-11  7:57 ` [PATCH v3 13/15] fs: convert process/thread iterators to for_each_*_rculock Ye Liu
2026-09-11  8:15   ` sashiko-bot [this message]
2026-09-11  7:57 ` [PATCH v3 14/15] lib: convert process iterator to for_each_process_rculock Ye Liu
2026-09-11  7:58 ` [PATCH v3 15/15] security/landlock: convert thread iterator to for_each_thread_rculock Ye Liu

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=20260911081504.735D51F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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.