Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp124750lqo; Wed, 27 Mar 2024 08:33:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+d8HSqQ4hej+PhO1/dH6N+Lgaq164Vo+2k8z8OnKAn/+kDKRWqpF14vqbX2r83lFspgN0JvoCRSuYRHJ9u12ozGX1o55ONDjamhQIww== X-Google-Smtp-Source: AGHT+IFbS2uzK9Cfb6ATHwksie6e09xHFw1GncdhbRi9FVfQ25J29DHi57SUDA0yxUIEcNSTuvAd X-Received: by 2002:a17:906:6953:b0:a4d:ff1c:d259 with SMTP id c19-20020a170906695300b00a4dff1cd259mr1207950ejs.4.1711553597814; Wed, 27 Mar 2024 08:33:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711553597; cv=pass; d=google.com; s=arc-20160816; b=TsDV/WmSiIkyF7nC9dBNoQsNXCv+KxDGTtdO4f4STb4sakswEAijPKajcWtCft6bgL tHdBp5NlsnwhPlxLklxeyLjQGpulR/elWyAqXRwf4YFd4SUVyo5swCPBLabtGpWSW6/B 9lLh0FsM7hsgPPFuU6IksGjW7JOhbEQqq4qFikokePhh49VNMCOZiEfXYubqQG08zawz Ua3RLS/PvzGc6z7oIbD6gzhhKA+inHweXIenF1SNtm76iPI/KeNsPfPCD9K0oAtJhotd 4FuAP6Rctw8h+Se6Oaviw9bNP2bs+8QdzCfIQCG7F8HlI6Jmanw9VS/mcK3B/ag5rwz6 D4+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QL7Szr455KxQS6x8t1rzgdjyBuE65Ext6MC1kybQi+4=; fh=Z7nwqFw9jo7mwUVP6sFBJfcE9oHe3fvGcHvWZvLmnnc=; b=GotrzA0qxWoGWQ76pCHGq//hv1N7zQPWXjeWaT+kjKvmIlriFcKN0bWnZfiWpn8kCJ E2N6DfuBuB0pmfzm0uidJy3G+LYw5PMO99fFcsFD8GL09FNLFwDRinVpcWMky5TOG+iy 5WFFXnaRklTz5FSVg8OJsF/YOlVJLDvQ0/XKFgSktEMNaKw+fzPS3l65RaGboq+UsELw fJSdDp/gho8XZulOrm/qm0TTqYZgyDLpExi2xXn4DZyWRdj2VBGmOEijQvRSliJQYQEC AMPVFEQWz/gP/tdMADiu6Fje+GTGFN/7sMpfy3J++zNtuer0ihsv1edL7UDnpMa4364t tx+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HK1lDSNF; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-121517-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121517-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d25-20020a170906175900b00a4733fc6f33si4506456eje.1030.2024.03.27.08.33.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:33:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121517-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HK1lDSNF; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-121517-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121517-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8A8A71F28E42 for ; Wed, 27 Mar 2024 15:33:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A0AC8147C9E; Wed, 27 Mar 2024 15:24:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HK1lDSNF" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 284AD14600D; Wed, 27 Mar 2024 15:24:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711553098; cv=none; b=qlnpH/6a22vRHjnlcnX0m9cyZLcHRn3L0+OFOS7s77mnRUCr2NgG2uap4bjUFvRQiiQZbmNxjdeteVD+qqYByRXKNYrY/IIBjHnkCFdq/sU+husnAuv7cZ34NQwxYxjJF50hND3bxGvSuA930+Zeal/rxFes4YqScxp47rgzDe4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711553098; c=relaxed/simple; bh=fHKrQe3bBzItgstLrgiaiDzY5ndwXjcJKSMl9aWMRB0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M9KOgvcUNGjkW4dekr01YSuOJMO2x3NnzvAS2FRItOk2aswdyyUK0U4c4hCIUkHH0+7cq+80DnbcvXtnRKMdh52gH+/6DsDFtD9b8/6+2W8oDpdSqtpBHp8mRQePEI6KfM7XMpLZGLumFZFY1Lq8tqb7GdyK9quj731X7yfIjnw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HK1lDSNF; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711553097; x=1743089097; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fHKrQe3bBzItgstLrgiaiDzY5ndwXjcJKSMl9aWMRB0=; b=HK1lDSNFYgMg3FrlBHXswIFlafBgz4cLkRPOHvBr6AJpu29iGt6Rx+SK Qn9zvA0KybicJz1iW05UnSx5VSkN4vONsKkRtxlh2Zdx6fibe7vNmRqmV KaHNn2z21ysk7hP73mtd4RCm/spCEwQ4K4FHb49TrLgv8FwEw1N0qRqBB qqK1dIc90ifeoVD8mxq21/n/uAwphLb/JJ8DqQm4Lpyzk5/tNewG9kPV5 +ovy1GLBqu7/z5XRWTWEistW0C0u0KoWW137NQjhyliJ1TfrnwvlS4lB4 pLd0DBu72WcaF6w+qw8sNedji1QboLLAmywfj6HUwSLaGIv97jHx8OBfK g==; X-CSE-ConnectionGUID: RihNUBtQTAG7bzzE2bhJbQ== X-CSE-MsgGUID: s4LiGMR+Sx+G4Z96gh+IBw== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="6518155" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="6518155" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 08:24:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="16414186" Received: from newjersey.igk.intel.com ([10.102.20.203]) by fmviesa008.fm.intel.com with ESMTP; 27 Mar 2024 08:24:54 -0700 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Yury Norov , Alexander Potapenko , nex.sw.ncis.osdt.itp.upstreaming@intel.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Przemek Kitszel Subject: [PATCH net-next v6 07/21] linkmode: convert linkmode_{test,set,clear,mod}_bit() to macros Date: Wed, 27 Mar 2024 16:23:44 +0100 Message-ID: <20240327152358.2368467-8-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327152358.2368467-1-aleksander.lobakin@intel.com> References: <20240327152358.2368467-1-aleksander.lobakin@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Since commit b03fc1173c0c ("bitops: let optimize out non-atomic bitops on compile-time constants"), the non-atomic bitops are macros which can be expanded by the compilers into compile-time expressions, which will result in better optimized object code. Unfortunately, turned out that passing `volatile` to those macros discards any possibility of optimization, as the compilers then don't even try to look whether the passed bitmap is known at compilation time. In addition to that, the mentioned linkmode helpers are marked with `inline`, not `__always_inline`, meaning that it's not guaranteed some compiler won't uninline them for no reason, which will also effectively prevent them from being optimized (it's a well-known thing the compilers sometimes uninline `2 + 2`). Convert linkmode_*_bit() from inlines to macros. Their calling convention are 1:1 with the corresponding bitops, so that it's not even needed to enumerate and map the arguments, only the names. No changes in vmlinux' object code (compiled by LLVM for x86_64) whatsoever, but that doesn't necessarily means the change is meaningless. Reviewed-by: Przemek Kitszel Acked-by: Jakub Kicinski Acked-by: Yury Norov Signed-off-by: Alexander Lobakin --- include/linux/linkmode.h | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/include/linux/linkmode.h b/include/linux/linkmode.h index 287f590ed56b..d94bfd9ac8cc 100644 --- a/include/linux/linkmode.h +++ b/include/linux/linkmode.h @@ -43,29 +43,10 @@ static inline int linkmode_andnot(unsigned long *dst, const unsigned long *src1, return bitmap_andnot(dst, src1, src2, __ETHTOOL_LINK_MODE_MASK_NBITS); } -static inline void linkmode_set_bit(int nr, volatile unsigned long *addr) -{ - __set_bit(nr, addr); -} - -static inline void linkmode_clear_bit(int nr, volatile unsigned long *addr) -{ - __clear_bit(nr, addr); -} - -static inline void linkmode_mod_bit(int nr, volatile unsigned long *addr, - int set) -{ - if (set) - linkmode_set_bit(nr, addr); - else - linkmode_clear_bit(nr, addr); -} - -static inline int linkmode_test_bit(int nr, const volatile unsigned long *addr) -{ - return test_bit(nr, addr); -} +#define linkmode_test_bit test_bit +#define linkmode_set_bit __set_bit +#define linkmode_clear_bit __clear_bit +#define linkmode_mod_bit __assign_bit static inline void linkmode_set_bit_array(const int *array, int array_size, unsigned long *addr) -- 2.44.0