Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp132673rdb; Thu, 1 Feb 2024 04:29:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHns6zA5pEAU+igbYQZ3DJvJAn5vfDxKzgq7pV93oTRo4m5GWBUu7y9IfAhk89cbRuSac/G X-Received: by 2002:a05:6214:29ce:b0:68c:61fc:680a with SMTP id gh14-20020a05621429ce00b0068c61fc680amr5747810qvb.25.1706790569643; Thu, 01 Feb 2024 04:29:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706790569; cv=pass; d=google.com; s=arc-20160816; b=gdMSaK3vdWaGXgYk73efSI3z7JX5fyQbEW8DAsFBJklVjxmGjM6utIErtYH4S4OIIy u3z8jMcZlkZrRXbAbZwvRZMKKJftPy7nmmbveKlv4a1ObCZ4La3PA1FGrGPRLDYYolCW iK5ev+eAOiE6RfmU9qcFLluJaX1SDcCtkv0Ud18YZeMekmEWpAqOKyD683aGZVccZySF pZZXyZKm5K09EtPtxrDGA7Du2Pv5bJKOyhz3DME8vdfohLATvpAJcjwt0SAzpE7pbVmX bUKGZ6EyQVQpy6c/Dm01ePexaHQonBHjkaGCu5t08O+WjKPcW5+BShphcQZt/xyv0xXE MEDA== 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=hsAjCKK+Kem1cKMltHh1xgaunakds7EpJfnzSOLnkHs=; b=CWM17zxr2R9OU4M+y2/2H0bXuYBiu1aChF+NNFnlqzrJxAVnC9XaG7I0lDyv73VpTF o+tDSNpnpg9NY4SyrdxHOHWCR1MNcuSuUmoyjYtu3cao7kG64SysshJwzoRmmuTPaHH3 eAZmBAfIifey9D6Yk/fFt+G/AuvDWo4Zc0CFXWxp3hnWYe5gx3TQDv6yhd3BspIkoVC0 99pL0gz1rO8vzPCYItyoRkHG26MTXaNflZvUFVUXlqmBy225sPO/5iMf9CNA2ihpqXow aY4dCgNFlhTzZgnI8kn33iPAQStR4Pcq8g4yDtszqiFQc2QD6ICHwOeloXZNnEG3riZL JoeQ==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48126-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; AJvYcCVCqgSn1TEpOvHcbfESq83GXsawgiZfJY/kRqGYbiwMaVdJinIi6O10dY3jiG1gqbBlag87qdkwNtMJoFslduQlWpxHvp50Kjw9tGT4Ww== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i3-20020ad45c63000000b0067f931f6bf8si14211486qvh.122.2024.02.01.04.29.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 04:29:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48126-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48126-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 660571C24E6E for ; Thu, 1 Feb 2024 12:29:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 743B95F49C; Thu, 1 Feb 2024 12:24:46 +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 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 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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Alexander Lobakin --- lib/test_bitmap.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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); } /* -- 2.43.0