From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7CD69C3DA4A for ; Thu, 1 Aug 2024 10:28:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Vx4T5i0uPFDEsx8F7lPOuqP100EbQhBcHpPEerY0tSM=; b=AiZaj8FHiIFKl/ nHyucpGwro+YsFktSfuegtyfZopGwhZpkiJ/UAdEsSIg/rXrrqiB0XpTwwfVzRA9BYly5pSpvuR++ PUJkdWN6lcA2Q6xQs0KukRbrSm9Yh9G4yfivfZSO0iPzLybDFRoGn/nPNmAQAiwsiUTn/LIwD5ReR s2sB2nqgh+2q1KhP/TyqJl4aWbv1SB1o6mquFAkYr+KIT5/VkyoCm4j8p6gcoITxiP+M3Zpbpf9Rw cvT4VTvi1xRuQJNwHuPistPMLpGU34zrXFC675Z7J73OuSNcqCNcAX31nylwtLAwLmbcTrsy3BP5u i1eOe5fL//gQUEIK8oFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZT2k-00000004kB2-3xV0; Thu, 01 Aug 2024 10:28:22 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZT2h-00000004k9b-3UZy; Thu, 01 Aug 2024 10:28:19 +0000 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=v1s+5Bi9d041LGdTeseO3YDdAQzIcr7DZg2LK0/Pvu0=; b=qLqxu/A7f3yE8trlCtn2zwr4Sr HsLHcEDK9/3J6tw7LUc6f6UbjMMG4sOJfSifCTcBNiwZSAV/P3ODLWlG7yA2knS7LCa0qhRE4PlrQ ylZjSUWBL9DxVjhdQzws15gwx0gi0lDvz7cXdxLOsjy7w+Ib4IOHWMokdPVtwpOChpjjVn+ye1Uld GFG+rsmUPvDikDI9xHGuE71rzQkSd89IUW183/BHQCmgpPHLpOyMsudNwch8jn/2BqO15VJiimQxp xtAjbcKmLuxcKg2Ku/JMxVsbtgiI4S+inNFNHpfHD9Z1+dwbMwwNH7EbzTp55VBxzAL5Gb3OZJgjQ lwCLoQBw==; 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 1sZT2T-00000005RW8-1u0R; Thu, 01 Aug 2024 10:28:06 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 8B25A30074E; Thu, 1 Aug 2024 12:28:04 +0200 (CEST) Date: Thu, 1 Aug 2024 12:28:04 +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: <20240801102804.GQ33588@noisy.programming.kicks-ass.net> References: <20240628-tracepoint-v4-0-353d523a9c15@google.com> <20240628-tracepoint-v4-1-353d523a9c15@google.com> <20240731170508.GJ33588@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Wed, Jul 31, 2024 at 11:34:13PM +0200, Alice Ryhl wrote: > > Please work harder to not have to duplicate stuff like this. > > I really didn't want to duplicate it, but it's very hard to find a > performant alternative. Is there any way we could accept duplication > only in the cases where an 'i' parameter is used? I don't have the > choice of using a Rust helper for 'i' parameters. > > Perhaps one option could be to put the Rust code inside jump_label.h > and have the header file evaluate to either C or Rust depending on the > value of some #ifdefs? > > #ifndef RUST_ASM > /* existing C code goes here */ > #endif > #ifdef RUST_ASM > // rust code goes here > #endif > > That way the duplication is all in a single file. It would also avoid > the need for duplicating the nop5 string, as the Rust case is still > going through the C preprocessor and can use the existing #define. I suppose that is slightly better, but ideally you generate the whole of the Rust thing from the C version. After all, Clang can already parse this. That said, with the below patch, I think you should be able to reuse the JUMP_TABLE_ENTRY macro like: JUMP_TABLE_ENTRY({0}, {1}, {2} + {3}) > I'm also open to other alternatives. But I don't have infinite > resources to drive major language changes. Yes, well, you all picked this terrible language full well knowing it hated C/C++ and had not a single effort put into integration with existing code bases. I find it very hard to care for the problems you've created for yourself. --- diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h index cbbef32517f0..6cff7bf5e779 100644 --- a/arch/x86/include/asm/jump_label.h +++ b/arch/x86/include/asm/jump_label.h @@ -12,12 +12,12 @@ #include #include -#define JUMP_TABLE_ENTRY \ - ".pushsection __jump_table, \"aw\" \n\t" \ - _ASM_ALIGN "\n\t" \ - ".long 1b - . \n\t" \ - ".long %l[l_yes] - . \n\t" \ - _ASM_PTR "%c0 + %c1 - .\n\t" \ +#define JUMP_TABLE_ENTRY(l_yes, key, branch) \ + ".pushsection __jump_table, \"aw\" \n\t" \ + _ASM_ALIGN "\n\t" \ + ".long 1b - . \n\t" \ + ".long " __stringify(l_yes) "- . \n\t" \ + _ASM_PTR " " __stringify(key) " + " __stringify(branch) " - . \n\t" \ ".popsection \n\t" #ifdef CONFIG_HAVE_JUMP_LABEL_HACK @@ -26,7 +26,7 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran { asm goto("1:" "jmp %l[l_yes] # objtool NOPs this \n\t" - JUMP_TABLE_ENTRY + JUMP_TABLE_ENTRY(%[l_yes], %c0, %c1) : : "i" (key), "i" (2 | branch) : : l_yes); return false; @@ -40,7 +40,7 @@ static __always_inline bool arch_static_branch(struct static_key * const key, co { asm goto("1:" ".byte " __stringify(BYTES_NOP5) "\n\t" - JUMP_TABLE_ENTRY + JUMP_TABLE_ENTRY(%[l_yes], %c0, %c1) : : "i" (key), "i" (branch) : : l_yes); return false; @@ -54,7 +54,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key * const ke { asm goto("1:" "jmp %l[l_yes]\n\t" - JUMP_TABLE_ENTRY + JUMP_TABLE_ENTRY(%[l_yes], %c0, %c1) : : "i" (key), "i" (branch) : : l_yes); return false; _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv