From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) (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 66D9E13C8F4 for ; Wed, 31 Jul 2024 18:58:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.40.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722452324; cv=none; b=deJP8PhRhPb6wVSFuMxAHFAdU89c+IShT1THO7HgiwBig6CidGr0kKJYCT7n8xXaygoRwFLLs+H/ZFshf9cGeCQJ2gK3DBOYUJxYNefqcymGnyzyR30teAobolLBbJn4YTw3weP+bxvRvRKkasW9CfOakTuRZ+E43WPExP18GTM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722452324; c=relaxed/simple; bh=Os8qowKsxDSRcPHPF/e1AaWARnryjEqWztOmIrjOGZI=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Drmf2BBzs4MoMPU7y6ZfxONBO2aPcTf6J162RfQH+lA1xk93IetdoRwDo4+8cTzSF4ZHaZdJPbBEH11UeLptv+9OkhrVJdVKv/otaAwj+rQkFbfnixvLGKIAseiQD/T7kM49OH/zwbh+TCQ355iHjTkMgO1KfzV6BbQSj/lNE1s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=b1nTHKn2; arc=none smtp.client-ip=185.70.40.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="b1nTHKn2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1722452314; x=1722711514; bh=Ok2jcwhhpJcH2GHlECFhqT7lAO056VLfnNsP0CYcDJg=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=b1nTHKn2T1dmR8vteP/M2sWrDZnltmVMV+WeJpQaWHdshFgouh8mtm6NWkSOyvsxv zbvWJCt5CARyolCYp8jYPTiMMC2/kamd6t1bN+hVlgjMjCiCQAFbJEnz1IMoa3ET7b dv/+gkT8NoDZWbongMdRmVuvEm5gxl2UjI9LZZyU/hVmY7z8FZclgaMloojKNlSXGl 3JDlf6u0EO7lKkTxR5KncuBvKc2QYLLC9GUUqnUn8OIok9sbIj5OjDnyv1rHUrCrft 30wBI2Y8WrNCEUZoxCwk/KYw5Ic9fuzfIcT71pq+GI6qDGIg08sGLP7pGBPC44S4xU 28vEKBj2xRsUw== Date: Wed, 31 Jul 2024 18:58:28 +0000 To: Alice Ryhl , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Peter Zijlstra , Josh Poimboeuf , Jason Baron , Ard Biesheuvel , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg From: Benno Lossin Cc: linux-trace-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann , linux-arch@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Peter Zijlstra (Intel)" , Sean Christopherson , Uros Bizjak , Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Mark Rutland , Ryan Roberts , Fuad Tabba , linux-arm-kernel@lists.infradead.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Andrew Jones , Alexandre Ghiti , Conor Dooley , Samuel Holland , linux-riscv@lists.infradead.org, Huacai Chen , WANG Xuerui , Bibo Mao , Tiezhu Yang , Andrew Morton , Tianrui Zhao , loongarch@lists.linux.dev Subject: Re: [PATCH v4 2/2] rust: add tracepoint support Message-ID: In-Reply-To: <20240628-tracepoint-v4-2-353d523a9c15@google.com> References: <20240628-tracepoint-v4-0-353d523a9c15@google.com> <20240628-tracepoint-v4-2-353d523a9c15@google.com> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: 8ba1730ad398f749464698fd1f1be0f27b26c0d0 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 28.06.24 15:23, Alice Ryhl wrote: > diff --git a/rust/kernel/tracepoint.rs b/rust/kernel/tracepoint.rs > new file mode 100644 > index 000000000000..1005f09e0330 > --- /dev/null > +++ b/rust/kernel/tracepoint.rs > @@ -0,0 +1,47 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +// Copyright (C) 2024 Google LLC. > + > +//! Logic for tracepoints. > + > +/// Declare the Rust entry point for a tracepoint. > +#[macro_export] > +macro_rules! declare_trace { > + ($($(#[$attr:meta])* $pub:vis fn $name:ident($($argname:ident : $arg= typ:ty),* $(,)?);)*) =3D> {$( > + $( #[$attr] )* > + #[inline(always)] > + $pub unsafe fn $name($($argname : $argtyp),*) { > + #[cfg(CONFIG_TRACEPOINTS)] > + { > + use $crate::bindings::*; Why is this needed, can't you put this into the invocation of `paste!`? ie `[< $crate::bindings::__tracepoint_ $name >]`? > + > + // SAFETY: It's always okay to query the static key for = a tracepoint. > + let should_trace =3D unsafe { > + $crate::macros::paste! { > + $crate::static_key::static_key_false!( > + [< __tracepoint_ $name >], > + $crate::bindings::tracepoint, > + key > + ) > + } > + }; > + > + if should_trace { > + $crate::macros::paste! { > + // SAFETY: The caller guarantees that it is okay= to call this tracepoint. Can you add this on the docs of `$name`? ie add a Safety section. The docs should still appear when creating them/when LSPs show them to you. --- Cheers, Benno > + unsafe { [< rust_do_trace_ $name >]($($argname),= *) }; > + } > + } > + } > + > + #[cfg(not(CONFIG_TRACEPOINTS))] > + { > + // If tracepoints are disabled, insert a trivial use of = each argument > + // to avoid unused argument warnings. > + $( let _unused =3D $argname; )* > + } > + } > + )*} > +} > + > +pub use declare_trace; >=20 > -- > 2.45.2.803.g4e1b14247a-goog >=20