[net-next,v5,14/21] lib/bitmap: add compile-time test for __assign_bit() optimization
Message ID | 20240201122216.2634007-15-aleksander.lobakin@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-48126-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp112791dyb; Thu, 1 Feb 2024 04:29:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFTyBfotaLnm/GjIPfc6NDoqtQDmyCd9plCcfi5O+VD8JZjiX9qpnGg9sdnRT+bXdy7U6Hu X-Received: by 2002:aa7:d9d6:0:b0:55f:c62e:fae7 with SMTP id v22-20020aa7d9d6000000b0055fc62efae7mr869964eds.1.1706790580841; Thu, 01 Feb 2024 04:29:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706790580; cv=pass; d=google.com; s=arc-20160816; b=xWMCChiPc01dHSi3HEJJAj3LWY5JI9RXvFs/belrY3mJ2BcROiZ3wZW35mg7Bmgv9G OinaDFAGkHNJ5tjtf7lwzLqS4B6MF7pdzQ9fxNqqsYaWwglWh/wHb59e2RngztjXF6ks IaJH0ahF8PaKiClBuTG2Cn6mbtjN4X6b2gyKDfJKkb8WUY7ZVpRFZKMRCOEhYPTAtA3V zuMc3G8s+lgqDM5a44g2QA8iAEo6Fyr9VXBNiQm09ibIA6bfr75tJ/oLY9MFJhSUZiQ7 otijdKK8hkP2qmM2cG8JcvzHzgu5KOddxbFmdJ4Jx/yybTtlSexyW5st9QtjPmvnMjmx nmUg== 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=vuNRF8jlYYS2JRzR/WIq+7/Z9O8zoMGB9W9g8LjfE6s=; fh=hcQB1tt5lrpP2+f1MPu/mOrVsay8hcKv49XYrrSUd6o=; b=Xz19f19GHPYtMjneKzxVXa6OHQJEzU8MOijzKZMSO9+Y5i90SMn2yyJ0eYN6dFhIo7 r+nkags+kmZ1OTMYvKEfTEahcBvyEKEFXlM09e6vqqUoJX0qU9352Rdeq9wiOyTO7uNG 0Np6+me8hEqZQDxjFI37Lb5tg0gHiU1lWiekFOFmr5Pr3axq8HGaGNLe6jmFdnlAWyoT 8UxyNVl0wGH33wvwODteVDOZX2Yx0NQzoKL6k7JHo47fR/VWd66mT/XhQGKV+y1dlYUK IWA5zHb9mTemAebN/x0A6N3+hJmp7gDrgQsvK35+A4eWwcVXVDtS7wiYuCXxya8bjodw cFRQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Mn2OEGCH; 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-48126-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48126-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCX/JCfI6IY+pxs+01v9Z6IGVDlA1NlJF5CunA4mTMSnTzfMADK7OrA3A30Sy9amP5JvPALzaZSwCYn1gFLb0SKYeuyWQg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ds6-20020a0564021cc600b005585701151csi6752500edb.224.2024.02.01.04.29.40 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 04:29:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48126-ouuuleilei=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=Mn2OEGCH; 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-48126-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48126-ouuuleilei=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 70CFB1F24182 for <ouuuleilei@gmail.com>; Thu, 1 Feb 2024 12:29:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 47028160892; Thu, 1 Feb 2024 12:24:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Mn2OEGCH" 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 31DA35F47D; Thu, 1 Feb 2024 12:24:44 +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=1706790285; cv=none; b=V9NSxMQdbG+3s8epdGVrnA5cqRSnD0bxSZ9hgIuIrveuDYlKtCFsXjpqLAuX9BujoEdWrHaQ4TVRJN5kEHzhl+RtyALSs/GvuLZo2J6LRweg7iIbVyvp5JgJ7VSKzV+yMLvCJQRKbyj9+dz1YmFePsw4xNBwdHZzYfycdYJOXvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706790285; c=relaxed/simple; bh=DRgXZrBDaQAbpijEzgcXIBhu1l6MEbkbQ32hkGqS4H4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TwvYhVB/9UMzPibQcTyYxdBKFXnVVXLst5WHZ8nkxgMnUHzdA/Q30WdrjCCl8A8qm4Jl7dvs15m6v15nL3Uetbw2Q5DmiC3VkdDnpadYPJZsvk77zGfOg64f6DtCDcP6hIBzWPXXtA9Fokdb/I2uJkmkvv0JpYCp5e/b9chaaCU= 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=Mn2OEGCH; 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=1706790285; x=1738326285; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DRgXZrBDaQAbpijEzgcXIBhu1l6MEbkbQ32hkGqS4H4=; b=Mn2OEGCHYc8KfseculiWtahpO4NTD1xd+Z3ovEevTP2lx/s85CIf0uRe 6AWzSfxcnRNUTn12kKZV3LVQl04vMR3OBpQx/0zYp/vEyCI3iEGtrLc0N sR8/JKwXzrQRnequHQfsbEYzw0/t4qyj8Mq5jjSLcD2KgtfvXEFTpkCzV Vwui/JUgMJHya9BdXl5RITTep8XPoDPtPiR5kVB+XXvMzOcF+UP3vdR9/ e1wSJzdIaJNyM2lQ+NghnoWQJSloMjDMLpENKrJM/QsxC2i8upjvyKKuL HwuTsobZutkkKg44WmNaWVVysQk/TDVULq/2LCDpQCME2FDPG4WI2aPoW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="3747142" X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="3747142" 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:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="4499131" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orviesa004.jf.intel.com with ESMTP; 01 Feb 2024 04:24:39 -0800 From: Alexander Lobakin <aleksander.lobakin@intel.com> To: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: Alexander Lobakin <aleksander.lobakin@intel.com>, Michal Swiatkowski <michal.swiatkowski@linux.intel.com>, Marcin Szycik <marcin.szycik@linux.intel.com>, Wojciech Drewek <wojciech.drewek@intel.com>, Yury Norov <yury.norov@gmail.com>, Andy Shevchenko <andy@kernel.org>, Rasmus Villemoes <linux@rasmusvillemoes.dk>, Alexander Potapenko <glider@google.com>, Jiri Pirko <jiri@resnulli.us>, Ido Schimmel <idosch@nvidia.com>, Przemek Kitszel <przemyslaw.kitszel@intel.com>, Simon Horman <horms@kernel.org>, 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 14/21] lib/bitmap: add compile-time test for __assign_bit() optimization Date: Thu, 1 Feb 2024 13:22:09 +0100 Message-ID: <20240201122216.2634007-15-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: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789699640025171199 X-GMAIL-MSGID: 1789699640025171199 |
Series |
ice: add PFCP filter support
|
|
Commit Message
Alexander Lobakin
Feb. 1, 2024, 12:22 p.m. UTC
Commit dc34d5036692 ("lib: test_bitmap: add compile-time optimization/evaluations assertions") initially missed __assign_bit(), which led to that quite a time passed before I realized it doesn't get optimized at compilation time. Now that it does, add test for that just to make sure nothing will break one day. To make things more interesting, use bitmap_complement() and bitmap_full(), thus checking their compile-time evaluation as well. And remove the misleading comment mentioning the workaround removed recently in favor of adding the whole file to GCov exceptions. Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com> --- lib/test_bitmap.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
Comments
On Thu, Feb 01, 2024 at 01:22:09PM +0100, Alexander Lobakin wrote: > Commit dc34d5036692 ("lib: test_bitmap: add compile-time > optimization/evaluations assertions") initially missed __assign_bit(), > which led to that quite a time passed before I realized it doesn't get > optimized at compilation time. Now that it does, add test for that just > to make sure nothing will break one day. > To make things more interesting, use bitmap_complement() and > bitmap_full(), thus checking their compile-time evaluation as well. And > remove the misleading comment mentioning the workaround removed recently > in favor of adding the whole file to GCov exceptions. > > Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> > Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com> Signed-off-by: Yury Norov <yury.norov@gmail.com>
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index a6e92cf5266a..4ee1f8ceb51d 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -1204,14 +1204,7 @@ static void __init test_bitmap_const_eval(void) * in runtime. */ - /* - * Equals to `unsigned long bitmap[1] = { GENMASK(6, 5), }`. - * Clang on s390 optimizes bitops at compile-time as intended, but at - * the same time stops treating @bitmap and @bitopvar as compile-time - * constants after regular test_bit() is executed, thus triggering the - * build bugs below. So, call const_test_bit() there directly until - * the compiler is fixed. - */ + /* Equals to `unsigned long bitmap[1] = { GENMASK(6, 5), }` */ bitmap_clear(bitmap, 0, BITS_PER_LONG); if (!test_bit(7, bitmap)) bitmap_set(bitmap, 5, 2); @@ -1243,6 +1236,15 @@ static void __init test_bitmap_const_eval(void) /* ~BIT(25) */ BUILD_BUG_ON(!__builtin_constant_p(~var)); BUILD_BUG_ON(~var != ~BIT(25)); + + /* ~BIT(25) | BIT(25) == ~0UL */ + bitmap_complement(&var, &var, BITS_PER_LONG); + __assign_bit(25, &var, true); + + /* !(~(~0UL)) == 1 */ + res = bitmap_full(&var, BITS_PER_LONG); + BUILD_BUG_ON(!__builtin_constant_p(res)); + BUILD_BUG_ON(!res); } /*