Linux Trace Kernel
 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 5/8] kernel: convert process/thread iterators to for_each_*_rcu
Date: Fri, 04 Sep 2026 08:40:41 +0000	[thread overview]
Message-ID: <20260904084041.A0E611F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904083001.553587-6-ye.liu@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Mixing goto-based error cleanup with guard() scopes in the same function (`alloc_retstack_tasklist`).
--

commit f2b0046bb431ebefb3d059e22788f2810f0e6684
Author: Ye Liu <liuye@kylinos.cn>
kernel: convert process/thread iterators to for_each_*_rcu

This commit converts multiple manual rcu_read_lock() and iterator blocks
across the kernel to use the new for_each_*_rcu() macros.

> diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
> index 40d373d65f9b9..e522433ec8a5a 100644
> --- a/kernel/trace/fgraph.c
> +++ b/kernel/trace/fgraph.c
[ ... ]
> @@ -1057,11 +1057,10 @@ static int alloc_retstack_tasklist(unsigned long **ret_stack_list)
>  		}
>  	}
>  
> -	rcu_read_lock();
> -	for_each_process_thread(g, t) {
> +	for_each_process_thread_rcu(g, t) {
>  		if (start == end) {
>  			ret = -EAGAIN;
> -			goto unlock;
> +			goto free;

[Severity: Low]
Does this change violate the cleanup subsystem guidelines by mixing paradigms?

The for_each_process_thread_rcu() macro expands to include a
scoped_guard(rcu). However, alloc_retstack_tasklist() still uses a goto free
statement to manually clean up the ret_stack_list array allocations upon error.

According to the kernel guidelines in include/linux/cleanup.h, the
expectation is that a given function either converts all resources requiring
a goto cleanup to scope-based cleanup, or converts none of them. Mixing
goto-based error handling with guard() or scoped_guard() scopes in the same
function should be avoided.

>  		}
>  
>  		if (t->ret_stack == NULL) {
[ ... ]
> @@ -1074,9 +1073,6 @@ static int alloc_retstack_tasklist(unsigned long **ret_stack_list)
>  			t->ret_stack = ret_stack_list[start++];
>  		}
>  	}
> -
> -unlock:
> -	rcu_read_unlock();
>  free:
>  	for (i = start; i < end; i++)
>  		kmem_cache_free(fgraph_stack_cachep, ret_stack_list[i]);

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

  reply	other threads:[~2026-09-04  8:40 UTC|newest]

Thread overview: 5+ 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 5/8] kernel: convert process/thread iterators to for_each_*_rcu Ye Liu
2026-09-04  8:40   ` sashiko-bot [this message]
2026-09-04 11:06   ` Michal Hocko
2026-09-04 14:14   ` Günther Noack

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=20260904084041.A0E611F00A3D@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox