Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp142467rdb; Thu, 1 Feb 2024 04:47:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IEpRuxO82Me2oFLO3IgYM3mA5lpbM0LE2F0Z9H0uSPU+VgXI2ygPV0ov5tDU4VuA0OBRwM4 X-Received: by 2002:a9d:7a4d:0:b0:6e0:d4d0:eece with SMTP id z13-20020a9d7a4d000000b006e0d4d0eecemr4684625otm.19.1706791654412; Thu, 01 Feb 2024 04:47:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706791654; cv=pass; d=google.com; s=arc-20160816; b=E3kUZcorhZeNWCuE2o+TgMxHzNDkpbJQyaSKoLW2Mlp5AsMzKXFaY2Qwpm+ydKaKdk tLz5ytz/wisBgHYScsrys0f97vlvQjJAauwlBNB3Cc/BKxl6rSMyckACyXGS1VE9mN63 JdILdwLBdH2BSNUZ6nw8GkqbpQHVG3QKFUvd/4nMeiwaqkV8kcWQAZvemSEUeKU921rz Ye2sD06nhqv2BfsID9o1GQZQaMJhscnt7pKWvaYvRfWZDsBGih45HqyP3pYSGbDNJmer wdRi2Jx5AMypEfEQKeavaWIuD8OaoTDBcTXy/tdk5HKqsL4DoYquqOHey15tS1qXwR3c M4bg== 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=XZOpbUnsbtRePmg1TceY2O3lEdM8KQ2pZ30iHF9h8SE=; fh=T1jvHyA7itNcTosCBndxvkiNAiGtD9cUhriThCSBG38=; b=QkTGORgkfBwQixi1cL+w5EYIMgr1kgms3U2K+sad3cVQJt6zFe7zB7X1iYd+LqgCdc AHT0PzZTEDFteZw9jeGpD25aHPRmDAzKsAhsgrjPS2PwFI3AA29XoOrLLYqjZffjqLfg q1FgvFCyv29WVNhtrabO5fKAsAnTxqfkGAf6QdRrAT4LkW4Z5hTmNDv5qxYvjyRmr/sy V0G0nYMlHfCuYJsrFFUKyt/qzl2aGjIke5CC7No3anqlRFs26QrHvawLFXMWPHeF5Mw8 KjEq85S+YFQ7w4LgCZyJdC4BZ413HMYF1x/VswQ6uy2EiFPQZAtGJZ0OM20KGwM8a5Al 1/6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dhIqul19; 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-48119-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48119-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCV0KnQ/AfQxAyZ8pY5iGCdJ+SLxFzz4mTtiK4Q48GMtwqy9y7oirTeddoIcQ8tI4WK/ALfEjZRALcFDbwN5qahsoWI3phqnBZo0xh2oyg== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id f17-20020a637551000000b005d2c05c7039si11970419pgn.865.2024.02.01.04.47.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 04:47:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48119-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dhIqul19; 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-48119-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48119-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 122DDB2A895 for ; Thu, 1 Feb 2024 12:26:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4123453388; Thu, 1 Feb 2024 12:24:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dhIqul19" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 DD36015F318; Thu, 1 Feb 2024 12:24:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706790249; cv=none; b=O/B96T+BgZVi13NC95nKZlUZoNnN0xMr7GXiMh6gn8lJFYAQVwIAu41Iy5JAIHOAWShATdJHRBJkVU8ZO6VryHN/FY/8sBUtml/w6ZKG1bcAFjM2TMnp3jtyfe9r3/jW4u90vBYBS8ovarPjXdOEo+JWy5GpZAB+D8PNcscEzfg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706790249; c=relaxed/simple; bh=7hQbTbBHJUnj59SwHJFVRJ8NAAFr11mdikwNORShsF0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LJ9C5SBoBL+bPOYHp8eGgQ51ZoySUA+PWsMZBID+vokhk5fmonEUyMFrWbyhr+k2YIhrhURTEDcbaVTOh8Lj5g/Qqncz8UsJVGRvFUCdicU5IP5ff9KWMr9HyrFYh9Al9/Btzq1db4VlFuQ/chDaTAyTqtTa6eO9EezCIVElmX8= 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=dhIqul19; arc=none smtp.client-ip=198.175.65.15 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=1706790248; x=1738326248; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7hQbTbBHJUnj59SwHJFVRJ8NAAFr11mdikwNORShsF0=; b=dhIqul19FerNAfAYtVb3TDX5ktN5m0+m6dEMr545ATqSf8XqCF/+pAL9 i7ywq3Fuw75Dm9hSUBWY7Vce9JfgkXoHZIi/MW9SU1rrUClCwPdsBr8tS xAObjbgygrlfr83pixDlIy93rqxxr0QtvkEwXSXehTbc7HnpiZkfO2WnR MMvz1uAfgYAdzePHB9Q1JM2HlrBY7UPBBLCyTpFkW1qavISUVV41KvLsD Njfew4vafXNUjuhY5oGX59SBX5zADHcHYnlCQwd2epyULQW/jz1a8TJVw 2Mp/3dwaqYc7wp5/nncrSzhGvm4T7n2mo7lF9ESlJ0lMMFw4y0yAo5wI1 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="3747011" X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="3747011" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 04:24:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="4499108" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orviesa004.jf.intel.com with ESMTP; 01 Feb 2024 04:24:03 -0800 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Michal Swiatkowski , Marcin Szycik , Wojciech Drewek , Yury Norov , Andy Shevchenko , Rasmus Villemoes , Alexander Potapenko , Jiri Pirko , Ido Schimmel , Przemek Kitszel , Simon Horman , linux-btrfs@vger.kernel.org, dm-devel@redhat.com, ntfs3@lists.linux.dev, linux-s390@vger.kernel.org, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v5 07/21] linkmode: convert linkmode_{test,set,clear,mod}_bit() to macros Date: Thu, 1 Feb 2024 13:22:02 +0100 Message-ID: <20240201122216.2634007-8-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240201122216.2634007-1-aleksander.lobakin@intel.com> References: <20240201122216.2634007-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 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.43.0