From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eugene Mavick Date: Fri, 10 Jul 2026 13:30:41 +0800 Subject: [PATCH v2 3/5] percpu-refcount: add ref_trace_final_put trace MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260710-refcount-final-put-trace-v2-3-557cfce860a2@mavick.dev> References: <20260710-refcount-final-put-trace-v2-0-557cfce860a2@mavick.dev> In-Reply-To: <20260710-refcount-final-put-trace-v2-0-557cfce860a2@mavick.dev> To: Will Deacon , Peter Zijlstra , Boqun Feng , Mark Rutland , Gary Guo , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Andrew Morton , Dennis Zhou , Tejun Heo , Christoph Lameter Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, Eugene Mavick X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1198; i=m@mavick.dev; h=from:subject:message-id; bh=vVWsfTjSGw6e33WP2d/uyqteLjy9dxiqe2AmCt04NhY=; b=owGbwMvMwCU2V/5U3e1aE3/G02pJDFkBzT23Y8+p1rz80Pf3zukIvlrR8BPlk+R2vosu3mV2d LV6zJ2GjlIWBjEuBlkxRZaarAT3jJWzEo2PTuqBmcPKBDKEgYtTACaikcnw33GWVshuP6V7871q F876Xb3cRlpp61dTl08/Ttf0FjyYVcjI0DhBdLP4GyN3Hak/N6we3ausMRAOW5Uovu/0vzVGEf3 9nAA= X-Developer-Key: i=m@mavick.dev; a=openpgp; fpr=7C6A604768A99A6133C5928C9D1FCA7EDB7D344F X-Endpoint-Received: by B4 Relay for m@mavick.dev/default with auth_id=850 List-Id: B4 Relay Submissions Add the ref_trace_final_put tracepoint to percpu_ref_put_many(). The tracepoint fires when the atomic counter reaches zero in the atomic fallback path (after percpu_ref_kill() has been called). Signed-off-by: Eugene Mavick --- include/linux/percpu-refcount.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h index d73a1c08c3e3..f870ac0e8c06 100644 --- a/include/linux/percpu-refcount.h +++ b/include/linux/percpu-refcount.h @@ -55,6 +55,7 @@ #include #include #include +#include struct percpu_ref; typedef void (percpu_ref_func_t)(struct percpu_ref *); @@ -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_ref_final_put(ref); ref->data->release(ref); + } rcu_read_unlock(); } -- 2.51.2