From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56414407CDF for ; Fri, 22 May 2026 14:35:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779460504; cv=none; b=tu7sLhbHlyEjgYADQnBcJvpAp1abIv8hmDyVQ0XXCp33H6CkK/w+Lii8ML6g/gnFSeBsfX3pu6bOx6tre41yiTHyY2l5py52R7wXaka+gX438+yEmINLSsA3HHyaMd7mtQcpWhVEcJ8l+RZHmgbdmc7a+jJVvcw3TtkRuJdOTJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779460504; c=relaxed/simple; bh=WVJEFkeBNBSTaAFRTLPVpP9nqvhaWceILqcbevNtZ+c=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=VgFDyRgppOcyDYVfWKXjV0Y4cedMy1utFXCJFkgdFy5i+Q/wbSS9kWjIdKJy6G7XZsZ8A9cu/1+KTZ6Lig6oPrM7/jPsXTqV+oCizgjWzN2YRrcH1HHaZ8N6RncEZ4YLpOAe8sW/kkL3pPfq4mUKr7hYoyvbZCXXlqtBlNZUy3k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XhDfrXhP; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XhDfrXhP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CE321F00A3F; Fri, 22 May 2026 14:35:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779460502; bh=Ijc/T8H7IkQi3O5/caNndvOiReMByEl6wUiqdBLZL50=; h=Date:From:To:Cc:Subject:References; b=XhDfrXhPoIpHxB2lj/qHK+RiLUOJS/V8DPqjd0LHg7U7vQiHU5C1VfwNpuMBfjN31 CunsSYBblyH6Cp680923p2w7et/aQDSQc0ZgRYIYqzsj3bG5NCggHUL2SCVaXVZ0CO UJETqrD4Ik79XTgg4MuLrx3vY+I9CTaBbIUuo3voEigO9vyfQdCFp5g5mM4SMjdDhW yXEII2WrISkdFGRsP0iSzmJ1lpXMU5nTBQceKVzR6tY7zujXQ7ssUxCjcRQv26j1wi xG8GRkQNnmJ/1h4W8CCeln1szLE20Z3rqXWP8zoa1HyCCQ8RW7k7HL69l1efbxHCUK 49Oskq8FQ6zng== Received: from rostedt by gandalf with local (Exim 4.99.2) (envelope-from ) id 1wQQyD-0000000667d-30Uf; Fri, 22 May 2026 10:35:25 -0400 Message-ID: <20260522143525.551205135@kernel.org> User-Agent: quilt/0.69 Date: Fri, 22 May 2026 10:35:12 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , "Vineeth Pillai (Google)" , Peter Zijlstra , David Carlier Subject: [for-next][PATCH 04/15] tracepoint: Add lockdep rcu_is_watching() check to trace_##name##_enabled() References: <20260522143508.298439732@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: David Carlier The trace_##name##_enabled() static call branch is used when work needs to be done for a tracepoint. It allows that work to be skipped when the tracepoint is not active and still uses the static_branch() of the tracepoint to keep performance. Tracepoints themselves require being called in "RCU watching" locations otherwise races can occur that corrupts things. In order to make sure lockdep triggers at tracepoint locations, the lockdep checks are added to the tracepoint calling location and trigger even if the tracepoint is not enabled. This is done because a poorly placed tracepoint may never be detected if it is never enabled when lockdep is enabled. As trace_##name##_enabled() also prevents the lockdep checks when the tracepoint is disabled add lockdep checks to that as well so that if one is placed in a location that RCU is not watching, it will trigger a lockdep splat even when the tracepoint is not enabled. Cc: Vineeth Pillai (Google) Cc: Mathieu Desnoyers Cc: Masami Hiramatsu Cc: Peter Zijlstra Link: https://patch.msgid.link/20260430144159.10985-1-devnexen@gmail.com Signed-off-by: David Carlier [ Updated the change log ] Signed-off-by: Steven Rostedt --- include/linux/tracepoint.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 763eea4d80d8..c29fc57392bb 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -293,6 +293,10 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) static inline bool \ trace_##name##_enabled(void) \ { \ + if (IS_ENABLED(CONFIG_LOCKDEP)) { \ + WARN_ONCE(!rcu_is_watching(), \ + "RCU not watching for tracepoint"); \ + } \ return static_branch_unlikely(&__tracepoint_##name.key);\ } -- 2.53.0