From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 1CC1D1B14F1 for ; Wed, 31 Jul 2024 17:05:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722445515; cv=none; b=WjXUf9v2zj9tfeT8RsyCTTzGbt64YOzgpjRaPjF42i4NlNefspHI26GRqkLsYRJP0GrCqlD080xSYxurs+Oby5GdkfS6M2oT29wak/CsAtl1Oi3vUjUUfZ2aNJj9vh0K1CKnBnxhoEy8/8rpqzY4NhovL3TjNjzoxOyI35yFsMQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722445515; c=relaxed/simple; bh=Kvo+Qg69Lf9bUXUEg3NaEQbb4hHBPQA3suJvsVKDU/Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=izfuiloSXwP8VMx6JaVIKTiejL3yPQ9v0R5fspqU0kj4SuLJaQueMQ9jiCJW1laZ20EghJbIa7fWGeI5xdfs8HJV3QuykswUMNPEn5069c4374j7npaJkaCe5C+WXNT+EJPdPazCfYPmIpn8iXk7QwLdr8FLBfJDQgz5u6fTwKU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=A299j2p6; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="A299j2p6" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=loxjFiVI2FUEfLt+uJa/RoAUGOvN0EDyWPzOQRMKPYM=; b=A299j2p6C5t3QILhmGu+4OptoB DEDPpwwicYTOiSmZrfN8QkSyLmvqEKKL8x4ait9egjTmsIHMFlf6sBNI9xT1f9LSOQlyBgsBhugge 6WMJM2OknlCd4a9bzxDTKXBemcoVPUUKVu63y34dxstuwFJB4w1keafIsm8AXP3wmyOsy47IdPmGp lZ4w3WM2rUg56Mwldouc0i//33E0NB6oSP0haibnEyzdbJ/m99z4E7VVQiAnpz/VzcTIZkXEsACd8 fL8UwCvcq+OScm+mL8o6b+eXnfxebOqg0N73CCOWcZK2RC3Q7gPLAit+lESVUzGcPfeQwyBi63Kda X/pllEsQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZClB-00000005GdC-0y78; Wed, 31 Jul 2024 17:05:09 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 3BB5F300820; Wed, 31 Jul 2024 19:05:08 +0200 (CEST) Date: Wed, 31 Jul 2024 19:05:08 +0200 From: Peter Zijlstra To: Alice Ryhl Cc: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Jason Baron , Ard Biesheuvel , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , 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 1/2] rust: add static_key_false Message-ID: <20240731170508.GJ33588@noisy.programming.kicks-ass.net> References: <20240628-tracepoint-v4-0-353d523a9c15@google.com> <20240628-tracepoint-v4-1-353d523a9c15@google.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240628-tracepoint-v4-1-353d523a9c15@google.com> On Fri, Jun 28, 2024 at 01:23:31PM +0000, Alice Ryhl wrote: > rust/kernel/arch/arm64/jump_label.rs | 34 ++++++++++++++++++++++++++++ > rust/kernel/arch/loongarch/jump_label.rs | 35 +++++++++++++++++++++++++++++ > rust/kernel/arch/mod.rs | 24 ++++++++++++++++++++ > rust/kernel/arch/riscv/jump_label.rs | 38 ++++++++++++++++++++++++++++++++ > rust/kernel/arch/x86/jump_label.rs | 35 +++++++++++++++++++++++++++++ > rust/kernel/lib.rs | 2 ++ > rust/kernel/static_key.rs | 32 +++++++++++++++++++++++++++ > scripts/Makefile.build | 2 +- > 8 files changed, 201 insertions(+), 1 deletion(-) So I really find the amount of duplicated asm offensive. Is is far too easy for any of this to get out of sync. > diff --git a/rust/kernel/arch/x86/jump_label.rs b/rust/kernel/arch/x86/jump_label.rs > new file mode 100644 > index 000000000000..383bed273c50 > --- /dev/null > +++ b/rust/kernel/arch/x86/jump_label.rs > @@ -0,0 +1,35 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +// Copyright (C) 2024 Google LLC. > + > +//! X86 Rust implementation of jump_label.h > + > +/// x86 implementation of arch_static_branch > +#[macro_export] > +#[cfg(target_arch = "x86_64")] > +macro_rules! arch_static_branch { > + ($key:path, $keytyp:ty, $field:ident, $branch:expr) => {'my_label: { > + core::arch::asm!( > + r#" > + 1: .byte 0x0f,0x1f,0x44,0x00,0x00 > + > + .pushsection __jump_table, "aw" > + .balign 8 > + .long 1b - . > + .long {0} - . > + .quad {1} + {2} + {3} - . > + .popsection > + "#, > + label { > + break 'my_label true; > + }, > + sym $key, > + const ::core::mem::offset_of!($keytyp, $field), > + const $crate::arch::bool_to_int($branch), > + ); > + > + break 'my_label false; > + }}; > +} Note that this uses the forced 5 byte version, and not the dynamic sized one. On top of that it hard-codes the nop5 string :/ Please work harder to not have to duplicate stuff like this. NAK.