# Re: \[PATCH 2/4\] refcount: add ref\_trace\_final\_put tracepoint

- From: Usama Arif \<usama.arif@linux.dev\>
- Date: 2026-07-06 10:07:21 
- List: linux-trace-kernel
- Page: https://ratatoskr.run/linux-trace-kernel/2026/07/17218153
- Thread: https://ratatoskr.run/linux-trace-kernel/2026/07/17214500/t.md

```text
On Sun, 05 Jul 2026 09:20:52 +0800 Eugene Mavick via B4 Relay [ref] wrote:

> From: Eugene Mavick <redacted>
> 
> Add the ref_trace_final_put tracepoint to __refcount_sub_and_test().
> This fires when a refcount_t reaches zero, capturing the caller
> address, the function name, and the refcount_t address.
> 
> Signed-off-by: Eugene Mavick <redacted>
> ---
>  include/linux/refcount.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/refcount.h b/include/linux/refcount.h
> index ba7657ced281..7b1fbf326a21 100644
> --- a/include/linux/refcount.h
> +++ b/include/linux/refcount.h
> @@ -107,6 +107,7 @@
>  #include <linux/limits.h>
>  #include <linux/refcount_types.h>
>  #include <linux/spinlock_types.h>
> +#include <linux/ref_trace.h>
>  
>  struct mutex;
>  
> @@ -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();
> +		trace_ref_final_put(r);

Should refcount_dec_if_one() also fire the tracepoint?

>  		return true;
>  	}
>  
> 
> -- 
> 2.51.2
> 
> 
> 
```
