From nobody Tue Apr 7 16:15:39 2026 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (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 6E2083C73FD for ; Thu, 12 Mar 2026 15:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773327941; cv=none; b=jCADZip0BtEdj6QHYcgFc2uYez8TaztA+0sXBLnv/io9VeHZesC2BsjN5SjkAwd84j7IoDGYCA96SZeECIlT5H6/Wz9UEBv1OTfnwvTKAR892+pPhJWrsT7LfSdb2MZFdOgfnQL0zGfDxXH93RNOD2BXImYoKlikxBiGZ/fw95U= 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.45 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-f45.google.com with SMTP id 46e09a7af769-7d73e0e0a36so514602a34.1 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=w1W8bN/qE8UJR2+Iy8NadW6+AU+udGSyrpS0ILM2P0i+gOgaCc0cArnyyKWtNqu/cO f6E0w4QYUSMts9MWSN6Vk4NqOdbUFco1EMNX0QhEOvk5SbQoyyjaIgt4pdo+/Q1GDIvT wxC+HVnA7kfX7kZH3NjNV6ARBF0jKSPZgNbs2DKSJVyFUj+5funVStmZKOR9Apl1of57 cbXY8gihEV7AE5ZDIZi0pjLDY5Y+kls3GrtrG8NjvlxzA3L5JmfaUBJrxVlsTz9+WIm8 Z4LVomlWlMviPPVTFY7adqeRn+/7nzB03ra0FFO9Iv2f7jmu8Bsg5Xk5cyNV+QAwTbTQ jrRA== X-Forwarded-Encrypted: i=1; AJvYcCXFPzo5XYsu5QQHAoQDLhFySHvq6JJxPz4/9tq0hFgxvNt6McRZdc318jjo78JFcZpjS9yH85+Ja9nn6PU=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3Ax6oW3Eie+s2fEpX/HsGKYkj/uVwZzXKoIol0D2C2Rd/cAen OP/sOMJ8V6rC6drhbLGgCl+9qMwks72uK71koOaPCylwva48aNwFYpTe1Uyll/c95K8= X-Gm-Gg: ATEYQzyLTSGSV2ZGa4KOFtBSd4STdtcb7KX9UJqxkWaAqXaeSZeSwcix84losjdvEeJ xQz5UAjZyoVaGeiv0vF01xVwTBjZlTbf4jAL00A3/j2XnMRqG3PsYMf9qA8lCPoraAxjvEq5NBf EgVze/FlVuaW5gGqH+yAVZyl0StYPKlxpdHQmhP+SO4kfEz51zbcNCghIt8vhgiu/Jf7Nkb7+tJ OMwP34NM2rRT0JEECPEjCWfV23LWOJ5PUCh6eVAu6Rya/H8uYr6PKuftF0VGeFEq122kRtP402V /w9PEIpecGedyD/q1xjBqtvapdIMkcIZuxv5AGyrj/296De1RLZktU/8ro/lE+NliPpMmBTsdBx cZD8Q9vR2Pl3Ld7/0+7WKI0TdQ32LltMQtKvT4JJP8L4EjupRUzHX8FzE9RJuNAQazoyVROcDSe 6VmADrbk/WIrZFLeiQaskS9380ws17jaBReJjZK+qjfIDiQ182HDscDqdfEp1rZPAZ3FDq0C1/p 7Td 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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); \ } =20 #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); \ } =20 /* @@ -398,6 +407,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(t= racepoint_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) \ --=20 2.53.0