From nobody Sun Apr 5 13:12:44 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 83D523DFC82 for ; Tue, 24 Mar 2026 09:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774345833; cv=none; b=MmHWi12CvV9qsbmrBQEreQ/9B/0swVCv0m3rDcsE7KORFesQh2J7EqeZ2pReFrgK5f1TJvrd+8XWfwPr4W8h1CA6LSJzJLa1I6Wh8sMqJcvZL4Rox21SUwL0T8HWNBDA6R6pEXqBB3BAY6nfmjIcN3XieCNnqLkgxEXM5m0/LNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774345833; c=relaxed/simple; bh=hDR6aj4CEOylmPGqbtIXro21hvw+cK0laBn2ySWqW3Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DHksXV3K7dDR4c3tw2zO5NZ+BOlRagZyIeldNWluX/4ZVzooVOSmifLBB06z1a8N3Epsld1R9pBCzVdPlCrjztSIpNZQgjlJyHvNTkVgfYjZRhHqNPvqhNDbUeWW/NJcgqoYSKjxAF6ItZY8yNCAuIk5Gj4xgFirJQGMnuPzars= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=YplABxfn; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YplABxfn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774345831; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gs9VmOHHSiH2vTwCJERGvoDC9R184iNrGHNb0XwJL0A=; b=YplABxfnh1215omD8VmL5ZFu6x3JjkbDSHvLEdKWnOgYFDGF6U2RNf/jkW8GegMZqyJL5e OqZvuau+PaWjy6ZyVbZhsKH9exWrLxtwf5e2vE1LGdofrdqnqmYSv8yn+JS/1Qqi9ypA/2 5h5StEQFeXQCgPtSk+7ktWGeCgx/NmU= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-445-V_v494rdMsmtuLvusHWzzw-1; Tue, 24 Mar 2026 05:50:25 -0400 X-MC-Unique: V_v494rdMsmtuLvusHWzzw-1 X-Mimecast-MFC-AGG-ID: V_v494rdMsmtuLvusHWzzw_1774345821 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 72B261800281; Tue, 24 Mar 2026 09:50:21 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.34.246]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0B28C300019F; Tue, 24 Mar 2026 09:50:08 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Cc: Frederic Weisbecker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Arnaldo Carvalho de Melo , Josh Poimboeuf , Paolo Bonzini , Arnd Bergmann , "Paul E. McKenney" , Jason Baron , Steven Rostedt , Ard Biesheuvel , Sami Tolvanen , "David S. Miller" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Mathieu Desnoyers , Mel Gorman , Andrew Morton , Masahiro Yamada , Han Shen , Rik van Riel , Jann Horn , Dan Carpenter , Oleg Nesterov , Juri Lelli , Clark Williams , Tomas Glozar , Yair Podemsky , Marcelo Tosatti , Daniel Wagner , Petr Tesarik , Shrikanth Hegde Subject: [RFC PATCH v8 07/10] x86/jump_label: Add ASM support for static_branch_likely() Date: Tue, 24 Mar 2026 10:47:58 +0100 Message-ID: <20260324094801.3092968-8-vschneid@redhat.com> In-Reply-To: <20260324094801.3092968-1-vschneid@redhat.com> References: <20260324094801.3092968-1-vschneid@redhat.com> 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 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" A later commit will add some early entry code that only needs to be executed if nohz_full is present on the cmdline, not just if CONFIG_NO_HZ_FULL is compiled in. Add an ASM-callable static branch macro. Note that I haven't found a way to express unlikely (i.e. out-of-line) static branches in ASM macros without using extra jumps, which kind of defeats the purpose. Consider: .macro FOOBAR // Key enabled: JMP .Ldostuff_\@ // Key disabled: NOP STATIC_BRANCH_UNLIKELY key, .Ldostuff_\@ // Patched to JMP if enabled jmp .Lend_\@ .Ldostuff_\@: .Lend_\@: .endm Instead, this should be expressed as a likely (i.e. in-line) static key: .macro FOOBAR // Key enabled: NOP // Key disabled: JMP .Lend_\@ STATIC_BRANCH_LIKELY key, .Lend\@ // Patched to NOP if enabled .Lend_\@: .endm Suggested-by: Frederic Weisbecker Signed-off-by: Valentin Schneider --- arch/x86/include/asm/jump_label.h | 33 ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_= label.h index 05b16299588d5..ea587598abe7c 100644 --- a/arch/x86/include/asm/jump_label.h +++ b/arch/x86/include/asm/jump_label.h @@ -7,7 +7,38 @@ #include #include =20 -#ifndef __ASSEMBLER__ +#ifdef __ASSEMBLER__ + +/* + * There isn't a neat way to craft unlikely static branches in ASM, so they + * all have to be expressed as likely (inline) static branches. This macro + * thus assumes a "likely" usage. + */ +.macro ARCH_STATIC_BRANCH_LIKELY_ASM key, label, jump, hack +1: +.if \jump || \hack + jmp \label +.else + .byte BYTES_NOP5 +.endif + .pushsection __jump_table, "aw" + _ASM_ALIGN + .long 1b - . + .long \label - . + /* LIKELY so bit0=3D1, bit1=3Dhack */ + _ASM_PTR \key + 1 + (\hack << 1) - . + .popsection +.endm + +.macro STATIC_BRANCH_TRUE_LIKELY key, label + ARCH_STATIC_BRANCH_LIKELY_ASM \key, \label, 0, IS_ENABLED(CONFIG_HAVE_JUM= P_LABEL_HACK) +.endm + +.macro STATIC_BRANCH_FALSE_LIKELY key, label + ARCH_STATIC_BRANCH_LIKELY_ASM \key, \label, 1, 0 +.endm + +#else /* !__ASSEMBLER__ */ =20 #include #include --=20 2.52.0