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 [off-list ref]
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.
quoted hunk ↗ jump to hunk
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
[ ... ]
quoted hunk ↗ jump to hunk
@@ -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?
quoted hunk ↗ jump to hunk
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