From patchwork Wed Mar 22 05:03:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 13183544 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 DD346C6FD1F for ; Wed, 22 Mar 2023 05:04:46 +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=DKKVL0rMgRwsQ4c4vVV6RzjCYfstOfLogdMDV51aHwE=; b=D/xYbRFHnZuLKT hTUqEc+7JCCGN+JyUF8SP2MtcjWbqiG4/AjgUYUv7tsTTaOAPkmz2x34hXsWLcr5GWMEbR7tVYhUG Ksty7wVaqL9qTpwRlEExq/Mon2uY0jZMC0GbOJq42spjKdZYKCXuvNFt13QHvCX6PKFqwZbnQw9V3 oe+XpiP+faqGP3zyd3u923OHQ5fPC9B21mMHFR92QWDtyozlbQNh7VpLYxvm8cCkg1xuAShjJAQcg kKu1U0AIAL/wTmLgr8VVdDJ0OrIchiYK6dBaDzjayoS744L4m8f5v6cQy8SfbJ8M7IAbjdDLIpC5Y XI1GX7d79SySKHD9iIsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1peqd0-00EdFo-1i; Wed, 22 Mar 2023 05:03:14 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1peqcx-00EdEc-2O for linux-arm-kernel@lists.infradead.org; Wed, 22 Mar 2023 05:03:13 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AC308B81AF7; Wed, 22 Mar 2023 05:03:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E37E0C4339C; Wed, 22 Mar 2023 05:03:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679461388; bh=2KtW1Lnib2feHqEoqkzNfI71iObhYI3VaiAcQaFXJbY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lVgVWtLMsr4kdVscUtxoc3uxRNMkWoJW7QhRewmKMLEpokp3lC6+4RCsHKZG/X/TM ur9kXlShS+fe4vcsxA0zUxFrYpibCEnxYeLPVXDpWWApn1+56qmJvoLEIiQcBBfF4T v1y+S7OTlXFOrgO4NME5TyokgYTD4grjZm2mPbaqsduQNT1hS7E2GI+jmta6sjmoiJ 9w6RWbysbPXtA+fz8+4sxEnRPqKZE71R/883PVvmezNoknKdbP0lROk6HUSoNZRrg6 HzAoMwUrENCd4kmZCeXZGm9Qk/G92HpR342EAfXQioO/Rtqiz4gH+4uqHfrdkprfk7 hWQM+4VLHw9MQ== Date: Tue, 21 Mar 2023 22:03:06 -0700 From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Mark Rutland , Jason Baron , Steven Rostedt , Ard Biesheuvel , Christophe Leroy , Paolo Bonzini , Sean Christopherson , Sami Tolvanen , Nick Desaulniers , Will McVicker , Kees Cook , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2.1 02/11] static_call: Flip key type union bit Message-ID: <20230322050306.zizbrqc2hwl5s4tj@treble> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230321_220312_052738_4268C78F X-CRM114-Status: GOOD ( 17.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Flip the meaning of the key->type union field. This will make it easier to converge some of the DECLARE_STATIC_CALL() macros. Signed-off-by: Josh Poimboeuf --- include/linux/static_call.h | 3 --- include/linux/static_call_types.h | 4 ++-- kernel/static_call_inline.c | 8 ++++---- tools/include/linux/static_call_types.h | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/include/linux/static_call.h b/include/linux/static_call.h index 141e6b176a1b..f984b8f6d974 100644 --- a/include/linux/static_call.h +++ b/include/linux/static_call.h @@ -186,7 +186,6 @@ extern long __static_call_return0(void); DECLARE_STATIC_CALL(name, _func); \ struct static_call_key STATIC_CALL_KEY(name) = { \ .func = _func, \ - .type = 1, \ }; \ ARCH_DEFINE_STATIC_CALL_TRAMP(name, _func) @@ -194,7 +193,6 @@ extern long __static_call_return0(void); DECLARE_STATIC_CALL(name, _func); \ struct static_call_key STATIC_CALL_KEY(name) = { \ .func = NULL, \ - .type = 1, \ }; \ ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name) @@ -202,7 +200,6 @@ extern long __static_call_return0(void); DECLARE_STATIC_CALL(name, _func); \ struct static_call_key STATIC_CALL_KEY(name) = { \ .func = __static_call_return0, \ - .type = 1, \ }; \ ARCH_DEFINE_STATIC_CALL_RET0_TRAMP(name) diff --git a/include/linux/static_call_types.h b/include/linux/static_call_types.h index 87c3598609e8..c4c4efb6f6fa 100644 --- a/include/linux/static_call_types.h +++ b/include/linux/static_call_types.h @@ -61,10 +61,10 @@ struct static_call_site { struct static_call_key { void *func; union { - /* bit 0: 0 = mods, 1 = sites */ + /* bit 0: 0 = sites, 1 = mods */ unsigned long type; - struct static_call_mod *_mods; struct static_call_site *_sites; + struct static_call_mod *_mods; }; }; diff --git a/kernel/static_call_inline.c b/kernel/static_call_inline.c index 1328370d3cf6..41f6bda6773a 100644 --- a/kernel/static_call_inline.c +++ b/kernel/static_call_inline.c @@ -112,7 +112,7 @@ static inline void static_call_sort_entries(struct static_call_site *start, static inline bool static_call_key_has_mods(struct static_call_key *key) { - return !(key->type & 1); + return !!(key->type & 1); } static inline struct static_call_mod *static_call_key_mods(struct static_call_key *key) @@ -120,12 +120,13 @@ static inline struct static_call_mod *static_call_key_mods(struct static_call_ke if (!static_call_key_has_mods(key)) return NULL; - return key->_mods; + return (struct static_call_mod *)(key->type & ~1); } static inline void static_call_key_set_mods(struct static_call_key *key, struct static_call_mod *mods) { key->_mods = mods; + key->type |= 1; } static inline struct static_call_site *static_call_key_sites(struct static_call_key *key) @@ -133,13 +134,12 @@ static inline struct static_call_site *static_call_key_sites(struct static_call_ if (static_call_key_has_mods(key)) return NULL; - return (struct static_call_site *)(key->type & ~1); + return key->_sites; } static inline void static_call_key_set_sites(struct static_call_key *key, struct static_call_site *sites) { key->_sites = sites; - key->type |= 1; } void __static_call_update(struct static_call_key *key, void *tramp, void *func) diff --git a/tools/include/linux/static_call_types.h b/tools/include/linux/static_call_types.h index 87c3598609e8..c4c4efb6f6fa 100644 --- a/tools/include/linux/static_call_types.h +++ b/tools/include/linux/static_call_types.h @@ -61,10 +61,10 @@ struct static_call_site { struct static_call_key { void *func; union { - /* bit 0: 0 = mods, 1 = sites */ + /* bit 0: 0 = sites, 1 = mods */ unsigned long type; - struct static_call_mod *_mods; struct static_call_site *_sites; + struct static_call_mod *_mods; }; };