Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Eugene Mavick" <m@mavick.dev>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v5 3/5] percpu-refcount: add refcount_final_put tracepoint
Date: Thu, 13 Aug 2026 04:02:39 +0000	[thread overview]
Message-ID: <20260813040240.0418F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260813-refcount-final-put-trace-v5-3-6e8bf8a38b31@mavick.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The tracepoint incorrectly uses `_RET_IP_` in a `static inline` function, causing it to report the caller's caller instead of the actual caller depending on compiler inlining.
--

--- Patch [3]: [PATCH v5 3/5] percpu-refcount: add refcount_final_put tracepoint ---
commit 9f895c01ce2cdf26a289904e12ffb409aa7dc2a0
Author: Eugene Mavick <m@mavick.dev>

percpu-refcount: add refcount_final_put tracepoint

This commit adds the refcount_final_put tracepoint to the atomic fallback
path in percpu_ref_put_many(). It fires when the atomic counter reaches
zero, recording the caller function, the instruction pointer, and the
refcount object.

> diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h
> index d73a1c08c3e3c..244992b2f746e 100644
> --- a/include/linux/percpu-refcount.h
> +++ b/include/linux/percpu-refcount.h

[ ... ]

> @@ -331,8 +332,10 @@ static inline void percpu_ref_put_many(struct percpu_ref *ref, unsigned long nr)
>  
>  	if (__ref_is_percpu(ref, &percpu_count))
>  		this_cpu_sub(*percpu_count, nr);
> -	else if (unlikely(atomic_long_sub_and_test(nr, &ref->data->count)))
> +	else if (unlikely(atomic_long_sub_and_test(nr, &ref->data->count))) {
> +		do_trace_refcount_final_put(ref);

[Severity: Medium]
Since percpu_ref_put_many() is a static inline function, won't using _RET_IP_
inside the trace macro evaluate to the caller's caller when inlined?

When inlined by the compiler, _RET_IP_ (which expands to
__builtin_return_address(0)) will yield the instruction pointer of the
enclosing function rather than the caller of percpu_ref_put_many().

Could the instruction pointer be passed as an explicit argument from the call
site instead?

>  		ref->data->release(ref);
> +	}
>  
>  	rcu_read_unlock();
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260813-refcount-final-put-trace-v5-0-6e8bf8a38b31@mavick.dev?part=3

  reply	other threads:[~2026-08-13  4:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13  3:49 [PATCH v5 0/5] tracing: add refcount_final_put tracing Eugene Mavick
2026-08-13  3:49 ` [PATCH v5 1/5] tracing: add refcount_final_put tracepoint Eugene Mavick
2026-08-13  4:02   ` sashiko-bot
2026-08-13  3:49 ` [PATCH v5 2/5] refcount: " Eugene Mavick
2026-08-13  3:59   ` sashiko-bot
2026-08-13  3:49 ` [PATCH v5 3/5] percpu-refcount: " Eugene Mavick
2026-08-13  4:02   ` sashiko-bot [this message]
2026-08-13  3:49 ` [PATCH v5 4/5] kunit: add test for refcount_final_put Eugene Mavick
2026-08-13  4:01   ` sashiko-bot
2026-08-13  3:49 ` [PATCH v5 5/5] MAINTAINERS: add entries for refcount_final_put trace Eugene Mavick

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