linux-trace-kernel.vger.kernel.org archive mirror
 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 2/5] refcount: add refcount_final_put tracepoint
Date: Thu, 13 Aug 2026 03:59:03 +0000	[thread overview]
Message-ID: <20260813035903.F21061F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260813-refcount-final-put-trace-v5-2-6e8bf8a38b31@mavick.dev>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Exporting the trace wrapper via GPL-only symbols inside fundamental static inline refcount primitives breaks the ability of non-GPL modules to load.
- [Medium] The `caller` and `ip` fields recorded by the tracepoint yield fundamentally inconsistent addresses depending on whether the calling function is evaluated as inline or out-of-line.
--

--- Patch [2]: [PATCH v5 2/5] refcount: add refcount_final_put tracepoint ---
commit 89e648b43dd0e3f81f4dd1bfaaa093ab2953cba7
Author: Eugene Mavick <m@mavick.dev>

refcount: add refcount_final_put tracepoint
    
Add the refcount_final_put tracepoint to __refcount_sub_and_test()
and refcount_dec_if_one()

refcount_final_put fires when a reference
count reaches zero and the object enters its final release path.

> diff --git a/include/linux/refcount.h b/include/linux/refcount.h
> index ba7657ced2817..23291a31d1be2 100644
> --- a/include/linux/refcount.h
> +++ b/include/linux/refcount.h
[ ... ]
> @@ -393,6 +394,7 @@ bool __refcount_sub_and_test(int i, refcount_t *r, int *oldp)
>  
>  	if (old > 0 && old == i) {
>  		smp_acquire__after_ctrl_dep();
> +		do_trace_refcount_final_put(r);

[Severity: High]
Does this break out-of-tree non-GPL modules?

Since __refcount_sub_and_test() is a fundamental inline primitive, embedding
the tracepoint macro here forces callers to resolve the GPL-only tracepoint
symbols. This will cause non-GPL modules to fail to load when they include
<linux/refcount.h> and call this function.

[Severity: Medium]
Will this record inconsistent instruction pointers depending on whether the
function is evaluated inline?

Because __refcount_sub_and_test() is static inline, _RET_IP_ will evaluate to
the return address of the module invoking the refcount API (the caller's
caller), while _THIS_IP_ evaluates to the caller.

>  		return true;
>  	}
>  
> diff --git a/lib/refcount.c b/lib/refcount.c
> index a207a8f22b3ca..8b148b5765037 100644
> --- a/lib/refcount.c
> +++ b/lib/refcount.c
[ ... ]
> @@ -56,7 +57,10 @@ bool refcount_dec_if_one(refcount_t *r)
>  {
>  	int val = 1;
>  
> -	return atomic_try_cmpxchg_release(&r->refs, &val, 0);
> +	bool ret = atomic_try_cmpxchg_release(&r->refs, &val, 0);
> +
> +	do_trace_refcount_final_put_cond(ret, r);

[Severity: Medium]
In this out-of-line context, _RET_IP_ evaluates to the immediate caller.

Does this mean the caller and ip fields recorded by the tracepoint will yield
fundamentally inconsistent addresses compared to the inline usage in
__refcount_sub_and_test()?

> +	return ret;
>  }
>  EXPORT_SYMBOL(refcount_dec_if_one);

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

  reply	other threads:[~2026-08-13  3:59 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 [this message]
2026-08-13  3:49 ` [PATCH v5 3/5] percpu-refcount: " Eugene Mavick
2026-08-13  4:02   ` sashiko-bot
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=20260813035903.F21061F000E9@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;
as well as URLs for NNTP newsgroup(s).