From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 668763C5DA6 for ; Thu, 12 Mar 2026 15:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773327941; cv=none; b=nZ/3f8WBE8G5Z6WR6U++4zl86oo8dCfwWDqBmEtngoSq7hu4e9mwv+8mCvjr4rH2KvYt7b1Vp8/rbC8FpwA46pMitDr6wYOqd9H2LYJ+sTealm5j3BjefH4Pn/OwT+R+GIVToEiF3grKnvVNuHIIjmBpnNik9nGp5gLiNoodBB8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773327941; c=relaxed/simple; bh=10NVZYZNHh8UNRWWgIond7aYsxXBLnPZEqS+81FpWlI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lknd+h+JS7FCnyk/X3TFj+h9flfJ8Elmfv7iFd5XV2drOqR/8kzd9q8j9OC8nCbtGx/5XMLPuZZ2ZctlbQeeG0WcnHC0b2XCqz2JisdBJyVFDp78v9qPqOp/PKp0BTc/lXACOcxePFm0L7dq1/+v5cV/wQ+2pb3v/Kc1wiEkwgM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bitbyteword.org; spf=pass smtp.mailfrom=bitbyteword.org; dkim=pass (2048-bit key) header.d=bitbyteword.org header.i=@bitbyteword.org header.b=ZLuEADjS; arc=none smtp.client-ip=209.85.210.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bitbyteword.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bitbyteword.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bitbyteword.org header.i=@bitbyteword.org header.b="ZLuEADjS" Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-7d773a4af0aso570190a34.0 for ; Thu, 12 Mar 2026 08:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bitbyteword.org; s=google; t=1773327938; x=1773932738; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cNc1V3lTb2QUW0xjd0W9BOVRtnhujjy4WaV1yGr6BKQ=; b=ZLuEADjS5Wujf+hyGJOkQpr/wIKGuXs9OOEVT4XriJwtaGHICDf/fK7wgqCLEVshea ZPDoxRigGndBOJZknOWOvmoIvA5p5AflGvpUg/lYA1HOMVjGphlSfEEp2YUKFkCpsUjq iY7dYM6BX9/OyYunBFKZ1LEEd+dgcchthClyw8FTO8bR13lJBq1OLNQ6XV+bQEoEw0nW hc0H26Q0dFwWj47erVfvxfR6mSo6cPUE9ccQuUXIqrq+LZpon6yRikG/EMTJ4kvhBZ6x p+knU1eLD3OrfrwQaFIiU9k98YYy4T5TDHuUp8m0AMRLXmoPg+ykG9oMleXMnBAqpVBq 0UAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773327938; x=1773932738; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cNc1V3lTb2QUW0xjd0W9BOVRtnhujjy4WaV1yGr6BKQ=; b=SRy4Mdpv8dsO33hjklCoYF/sH6RqGxQP8CQYgx/la6/oCX1vbACf7BdgiB/0EPCGfD QqY57Ukg6uDmAvgsvyia/shVnR9b9uxgzEUGTt9Ih6iLjTlI4eMbN30gytOcUVXEpNI2 VNGVq/ol7m0OXBb0eDQlcn9Wcid0IGgdVhDMGSrEGhCoGn1XdciaxOF7/LDx8LpVBrql Xiwsx/IcxEE0CepK/5ivY98k6MwqaiA4p6ypAFFpumPlPMRapZBFb9F6rD2yyBqP4q/T qKkN7xRYUwj1wjpv+v8mRLuXesLrTdlEkr/46VP1UpjEVKUU9FIy9hyLaZcffrOSsGg2 orMQ== X-Forwarded-Encrypted: i=1; AJvYcCU/RlDJMnw3LI4C/+O6GibizhNlbT8OOH7QXxkEV2mmj9BVg9YWDE+M2mkFI33LJsVhcBA4SA1hdA==@vger.kernel.org X-Gm-Message-State: AOJu0YxJ6wXlTdJw+I2MVqLyFp4zzVDvfUW3q2Wm+J4An8nli+TAuxFb V9HOcw3sRAucqLrYY4Nrqb33Qf46erQ9LpAts9ymVLueYRazAOgDsReC1cjyYdbTWWk= X-Gm-Gg: ATEYQzyzn5JWFZG8t5lgvUHrHomiiynNwzYF8ZiGhzjB46ezPpROq4RRjAUBpvc+A60 2b788D8Jexk+u5tLxeHn1xfdaZF/45qQdItqbUlyHiAHyPBtfPAt05Dvi3/1osQJMwhp7Dx1oxm r/DOhaRb4JbXSwDQquYQUbOoUoWMj7pioh24Z4k9mYMfp+0FiqaIVi0+lK2rFde1qH7WwSTIViX 0oMnHWDsKcoiXimVxlWKFehCa/C4LNP6Hm2Vm83Vlc5sjr/oWSY0GfWcjH3bh9GUGjL9viTczMo eIux+smMYUsIMIaxSmBHyDsGlSIjDm0mZajkdvDzlXddSFOrTMgujtklHFY9D8wkLd8E7VDNn23 vVNx9GF51UnhJwwu4YpSibWoCbtKMtfiqUY+gbA8W5KJqBgNwx3+RskHJbfPrJgZQT1znUYg72m ykmWaI8zcHCKdJTc2GdMcMmHXJt+j36oufo+P/JNx39B9YytK5w69AwryWg+7itIxbUfevz5UfR 3+4 X-Received: by 2002:a05:6830:3113:b0:7c6:d001:afb2 with SMTP id 46e09a7af769-7d76a85b34cmr3668805a34.35.1773327936791; Thu, 12 Mar 2026 08:05:36 -0700 (PDT) Received: from vinmini.lan (c-73-143-21-186.hsd1.vt.comcast.net. [73.143.21.186]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7d76aedae57sm4321776a34.28.2026.03.12.08.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2026 08:05:36 -0700 (PDT) From: "Vineeth Pillai (Google)" To: Steven Rostedt , Peter Zijlstra , Dmitry Ilvokhin Cc: "Vineeth Pillai (Google)" , Masami Hiramatsu , Mathieu Desnoyers , Ingo Molnar , Jens Axboe , io-uring@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Marcelo Ricardo Leitner , Xin Long , Jon Maloy , Aaron Conole , Eelco Chaudron , Ilya Maximets , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-sctp@vger.kernel.org, tipc-discussion@lists.sourceforge.net, dev@openvswitch.org, Oded Gabbay , Koby Elbaz , dri-devel@lists.freedesktop.org, "Rafael J. Wysocki" , Viresh Kumar , "Gautham R. Shenoy" , Huang Rui , Mario Limonciello , Len Brown , Srinivas Pandruvada , linux-pm@vger.kernel.org, MyungJoo Ham , Kyungmin Park , Chanwoo Choi , =?UTF-8?q?Christian=20K=C3=B6nig?= , Sumit Semwal , linaro-mm-sig@lists.linaro.org, Eddie James , Andrew Jeffery , Joel Stanley , linux-fsi@lists.ozlabs.org, David Airlie , Simona Vetter , Alex Deucher , Danilo Krummrich , Matthew Brost , Philipp Stanner , Harry Wentland , Leo Li , amd-gfx@lists.freedesktop.org, Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, Wolfram Sang , linux-i2c@vger.kernel.org, Mark Brown , Michael Hennerich , =?UTF-8?q?Nuno=20S=C3=A1?= , linux-spi@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, Chris Mason , David Sterba , linux-btrfs@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/15] tracepoint: Add trace_invoke_##name() API Date: Thu, 12 Mar 2026 11:04:56 -0400 Message-ID: <20260312150523.2054552-2-vineeth@bitbyteword.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260312150523.2054552-1-vineeth@bitbyteword.org> References: <20260312150523.2054552-1-vineeth@bitbyteword.org> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add trace_invoke_##name() as a companion to trace_##name(). When a caller already guards a tracepoint with an explicit enabled check: if (trace_foo_enabled() && cond) trace_foo(args); trace_foo() internally repeats the static_branch_unlikely() test, which the compiler cannot fold since static branches are patched binary instructions. This results in two static-branch evaluations for every guarded call site. trace_invoke_##name() calls __do_trace_##name() directly, skipping the redundant static-branch re-check. This avoids leaking the internal __do_trace_##name() symbol into call sites while still eliminating the double evaluation: if (trace_foo_enabled() && cond) trace_invoke_foo(args); /* calls __do_trace_foo() directly */ Three locations are updated: - __DECLARE_TRACE: invoke form omits static_branch_unlikely, retains the LOCKDEP RCU-watching assertion. - __DECLARE_TRACE_SYSCALL: same, plus retains might_fault(). - !TRACEPOINTS_ENABLED stub: empty no-op so callers compile cleanly when tracepoints are compiled out. Suggested-by: Steven Rostedt Suggested-by: Peter Zijlstra Signed-off-by: Vineeth Pillai (Google) Assisted-by: Claude:claude-sonnet-4-6 --- include/linux/tracepoint.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 22ca1c8b54f32..07219316a8e14 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -294,6 +294,10 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) WARN_ONCE(!rcu_is_watching(), \ "RCU not watching for tracepoint"); \ } \ + } \ + static inline void trace_invoke_##name(proto) \ + { \ + __do_trace_##name(args); \ } #define __DECLARE_TRACE_SYSCALL(name, proto, args, data_proto) \ @@ -313,6 +317,11 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) WARN_ONCE(!rcu_is_watching(), \ "RCU not watching for tracepoint"); \ } \ + } \ + static inline void trace_invoke_##name(proto) \ + { \ + might_fault(); \ + __do_trace_##name(args); \ } /* @@ -398,6 +407,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) #define __DECLARE_TRACE_COMMON(name, proto, args, data_proto) \ static inline void trace_##name(proto) \ { } \ + static inline void trace_invoke_##name(proto) \ + { } \ static inline int \ register_trace_##name(void (*probe)(data_proto), \ void *data) \ -- 2.53.0