From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010055.outbound.protection.outlook.com [52.101.46.55]) (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 F2D52254B1F for ; Sat, 10 Jan 2026 02:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.55 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768011942; cv=fail; b=gYktYe2lWzWEB2KQlf4FKToR+ekkmLrJv7Wv7FcdILof1qgol1OmumW6lXUfbfJ81jeQFHFFUe0Xf9x9WAdafFE14Wz9UkRVJkgEzi+ITYR5f1yF7ie0VUc53DuOIFP221k9afGqj7+d4ASVw4E3klqKk+Vu3h/RQ90TobDqcdk= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768011942; c=relaxed/simple; bh=AUvpIwP4xjgdGrkHAxkRuYyuMjiX7h5hv7AGvJmYlTA=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=YZLXsb9KtAg0Ws4Ai9VJNWPDFz+DSJ7E0y4OCUZEzvFE073MPRNbEk2S4N2ZVP6adqwT+FK0pCvEkneTEG9zd2YpVfPO1Xp/P38ukT58Xj874H9H5qTKv1yDzzrvVwYlsL5f/zNxEASuK9Ka5KzOVx7s6DbMTi2Sn/u2+pKE2sY= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=jOFWUTk8; arc=fail smtp.client-ip=52.101.46.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="jOFWUTk8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wBSI0iWzAq491nSTFNxBVY0W19u7oJ/iwLyxz4ctoyO/+a0+MkRFH9YOjKCP/ZHbUq7tf1VTMKUX6LcYIi60SmtSktq6/ed+GC0Go2X9C1NfM834qOIxutlRiVnT6MLIUmbrjyQZW5TlMUmxICDjwGwQbBxpLqdp+nBfeLUvIbstf0eLDYXjJTclnQahPvojH5tlfQcPuocjadIHOqQwLEbv9R8FtC/ws8lYta0wR62G+iOe9FOc5xisEEep5nLG+19AAFvRRH6EotXQdr+qHaB7X3X4ika84NijYBkwrmaqYS1sQLzFeTEz5nj6io6T172eP0W56+QJH07mhXbIPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=57OM4bUeqbMNjzOKVqmgXeNFixMNxdnkH8h6I3pnjQ8=; b=YALGL48IiPFudITpfBGsxV0gg4E9S0D6AIwUiPmZ6AbTo3R3m8Nw/TIcSqMzXMIFhvF8MIsMfSEA7dRQLW5X1TDtTrQLKYn2G3AN4EcavPerORfF4KXc9rLUNoHa85/dBpBTeJqEfK+v8AJSyJQyEF4euG2bbcBXKhuPXWcICb7LDFG2xCwiGEcs9sUzbe7xiWUedSa0LP+LHVkmbmlwR9Jwo2LlFCIM0F8GGRiReOckRKPOVZ02vZEVS/wzOhwnnVVJSl0AkFtujxUJzqslMahivNbXMUPmu0FVE7CQZQ+7mghwq+XBBSOMm8Tvrhw0Gfzq3DIg2Kt590jIN2xx6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=57OM4bUeqbMNjzOKVqmgXeNFixMNxdnkH8h6I3pnjQ8=; b=jOFWUTk8OjQqIBNT741S4/GouDT8Tr1uQmyVkQHa9COoV6zaeBbcRykX/xj1HCzG3tNcpMBErsERvO/QRYDUzGZ+sQEI1tGcnNr2b1hu5ilRnGW+nVGh7UOHbA0bd/zRhq/r47rALwwqghSEgtQe2uNeKt4RBT7Jb62euTOZQhEoN3xmFupb1BYt3Q7f+36DqZ/d1OAgt7Vchs4r62fwNoAtxq+0JbkqzfYNfGDTydUcKUIDclexO/5E9BRIph7FVwV/C/6xOHHTHQHRPyNow03hotZFqFwK1KNqdKEAk2aWpAojTTTrm1KHggEJvK93nAJfll48qwpfFol9K0Kb3Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from PH0PR12MB8800.namprd12.prod.outlook.com (2603:10b6:510:26f::12) by DS2PR12MB9685.namprd12.prod.outlook.com (2603:10b6:8:27a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9499.5; Sat, 10 Jan 2026 02:25:39 +0000 Received: from PH0PR12MB8800.namprd12.prod.outlook.com ([fe80::bdb6:e12f:18b6:2b77]) by PH0PR12MB8800.namprd12.prod.outlook.com ([fe80::bdb6:e12f:18b6:2b77%5]) with mapi id 15.20.9499.003; Sat, 10 Jan 2026 02:25:38 +0000 Date: Fri, 9 Jan 2026 21:25:36 -0500 From: Yury Norov To: Ryota Sakamoto Cc: Andrew Morton , Yury Norov , Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: Re: [PATCH] lib/tests: add KUnit test for bitops Message-ID: References: <20260110-kunit-bitops-v1-1-fe39a1ff1a02@gmail.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260110-kunit-bitops-v1-1-fe39a1ff1a02@gmail.com> X-ClientProxiedBy: BN9PR03CA0676.namprd03.prod.outlook.com (2603:10b6:408:10e::21) To PH0PR12MB8800.namprd12.prod.outlook.com (2603:10b6:510:26f::12) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR12MB8800:EE_|DS2PR12MB9685:EE_ X-MS-Office365-Filtering-Correlation-Id: ef374bb1-a317-4909-aeb8-08de4fef8b1b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|366016|376014|1800799024|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?R/QqJ2oXOCIerL5F9RFsRp+b7w2HkXK2QmqWkzgmiFtc8zkujvWPpJ1bq/YV?= =?us-ascii?Q?QnKw8o4Gt0vWoJc3JN496N27IpylhdoJG3n3qMViGu8z8XGKEyttwwyXdFGg?= =?us-ascii?Q?Cik54hdeo6FttW9weT03hYhXagf7q5Ou2V9Wtz6Aii5qeoxG9IO+AGoW+JET?= =?us-ascii?Q?7pTHOwmj31P7pknfum1xMeibK5AjLPBCp4c0MkmWETPjMoyQQdAgAhI28a5z?= =?us-ascii?Q?2u9N3rzv/qz5h9C/ds3jDI5Fm1SvDwvPOIePwWPMqPddVtfdA7hYeWPiUC9M?= =?us-ascii?Q?+hVOgEzerbBRoYWzn7AZAFFMf92JCqOHwl4Fys+lIzcHB5+RI6qEY9V/i6Dd?= =?us-ascii?Q?NSPdkCaMdcl+crcWFIHGgdhVvD7TiZ0YAeeymjN7Gls5s+/AMEdrimPGlxus?= =?us-ascii?Q?wuMh8WoVkmqhiyP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=?us-ascii?Q?hp4BJjSB1kp9J8ZkH0+TnoYT6kJTOkYeL/Ss12sp+BAJ5FUxW4gfekbm2UBA?= =?us-ascii?Q?mfkXLI+JKIUndVV28al9BZDEjBJhX6bE/yfjVBMf+GPMgeWiwCeF+zeoDuYg?= =?us-ascii?Q?BDZd0vYgwkz8/+DtOrPXEBLboSvFpeWR?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR12MB8800.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(366016)(376014)(1800799024)(7053199007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?zENPEQ9D+N/52u0UcGrLpyfqo9yB14jXbGNIt8aIVRWUVGZ84LsdqpqvvU7v?= =?us-ascii?Q?gz1JkEJvkeqndk5+ypDHZh7fMDtoV/LrsmWTUD0yaBuhqNHGRKHoq1pfDrD5?= =?us-ascii?Q?kt3WZJ6WJE1B9Q2P4IfkpgXb0ZNtTZL3FPTG+2BtO3sNV/5zPK+dIihM1utM?= =?us-ascii?Q?7/ajMfcfheixc2j9ZLIsfmVjnCO6Oh7Zg2D6NCnFzX8Th+XPmyD5e+UtwbpP?= =?us-ascii?Q?ZhUXMm2XSOCzYht2ngjL0bBVCyuCuBjb21qMeaV2BPYtryA2xg7r4pxDiLVD?= =?us-ascii?Q?R0Wj9JN/CC7apwpO940KO+jer++2EwEoAKB2VI+z/SfUv2M270sq7sv92yO1?= =?us-ascii?Q?XBHiI3cXwCDVknF1psyns5+4b9lKINpNbIK+XDptmk3xOgG4v9aA5BK3xYZc?= =?us-ascii?Q?RHRm9oK8FrSWPwG/E4YRhdWbb/+/hoBjXNKsyr7tnmR7i4A0IDNhoDXhASi8?= =?us-ascii?Q?BadmihhT4Io2OxMw0dj3bXCfflm9QXsj+KktNXFBwhWiVTJx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ROiK8liApZi+lgtnw2ZyHcJhNz0fxHNpaTmdUmFRv1yoXQ6uaa?= =?us-ascii?Q?aVCKvi8jmxd/64xdjqytSoUzivEGrk1JnUu5OrnBKMNP+ZTV8ftdTdySrOgp?= =?us-ascii?Q?WlmrMK5aE55i9riEFzMyQRPvizDkiUdQniTWR9yoer0nShfuMGt2Tjsmjukg?= =?us-ascii?Q?2sHFp7EZ5fstXgxcEpLRnHe884zeRx+Gz1ipblG/LnyHQIAMAxjQCMIH91pp?= =?us-ascii?Q?ddaaqBiCYbCFRngz1/vpXuOXbLw7dYqdA9z+3/37WmK9LSDPBh5EDLbe4ii9?= =?us-ascii?Q?slAn89/ZpkGmCIJ7IvX4eMYIOi0+IkSayvd/uEurszLd9xk4Ya2+btgawWSr?= =?us-ascii?Q?ODXgWfcUeohVbtjH0jVYVCbGW+vFrhHpRuV3LpBtwXM4k2qZUxly?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef374bb1-a317-4909-aeb8-08de4fef8b1b X-MS-Exchange-CrossTenant-AuthSource: PH0PR12MB8800.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2026 02:25:38.4160 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: K1FZZDWA+IKffnsn9MmxJkzvS8ur0l9lr6C0CTAokCKO2XB+GiT20offl3umGLWYD6y9c5neImBxbvFUXMQFEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS2PR12MB9685 Hi Ryota, Is this your first commitment? If so - congrats and welcome to the community! On Sat, Jan 10, 2026 at 03:42:21AM +0900, Ryota Sakamoto wrote: > Add a KUnit test suite for the bitops API. > > The existing 'lib/test_bitops.c' is preserved as-is because it contains > ad-hoc micro-benchmarks 'test_fns' and is intended to ensure no compiler > warnings from C=1 sparse checker or -Wextra compilations. > > Introduce 'lib/tests/bitops_kunit.c' for functional regression testing. It > ports the test logic and data patterns from 'lib/test_bitops.c' to KUnit, 'ports' her is an euphemism for copy-pasting? > verifying correct behavior across various input patterns and > architecture-specific edge cases using isolated stack-allocated bitmaps. > > Also improve the find_first_bit() test to check the full bitmap length > (BITOPS_LENGTH) instead of omitting the last bit, ensuring the bitmap is > completely empty after cleanup. > > Verified on x86_64, i386, and arm64 architectures. > > Signed-off-by: Ryota Sakamoto OK, it doesn't look like a pure duplicate. I'm not a user of kunit, but some people are. And seemingly it would help to improve testing coverage through those enabling KUNIT_ALL_TESTS. So I don't object against this test. Can you please resend this patch, and in commit message list all the tests from the original lib/test_bitops? Please mention those you move to the new test. Is there any new coverage in your version? Please attach whatever it prints as an output, if any. > --- > MAINTAINERS | 1 + > lib/Kconfig.debug | 17 ++++++ > lib/tests/Makefile | 1 + > lib/tests/bitops_kunit.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 161 insertions(+) > > diff --git a/MAINTAINERS b/MAINTAINERS > index a0dd762f5648b7e4e6fc62560662e43720422e01..ad978698deedca3e6acdf62145a48d45b579cec2 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -4468,6 +4468,7 @@ F: include/asm-generic/bitops.h > F: include/linux/bitops.h > F: lib/hweight.c > F: lib/test_bitops.c > +F: lib/tests/bitops_kunit.c > F: tools/*/bitops* > > BITOPS API BINDINGS [RUST] > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index ba36939fda79bf890834b586c366a28acd434ef9..3d7fdea11354a421ac5b7283a14f0752261d4a63 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -2652,6 +2652,23 @@ config TEST_SYSCTL > > If unsure, say N. > > +config BITOPS_KUNIT > + tristate "KUnit test bitops functions at runtime" if !KUNIT_ALL_TESTS > + depends on KUNIT > + default KUNIT_ALL_TESTS > + help > + Enable this option to test the bitops functions at boot. It's tested at boot only if 'y'. If 'm' - it's not. > + > + KUnit tests run during boot and output the results to the debug log > + in TAP format (http://testanything.org/). Only useful for kernel devs > + running the KUnit test harness, and not intended for inclusion into a > + production build. > + > + For more information on KUnit and unit tests in general please refer > + to the KUnit documentation in Documentation/dev-tools/kunit/. Those 2 paragraphs don't relate to the new test, don't even mention it. Please drop them. I would add a note that this is a partial copy of test_bitops, and in case of _any_ doubt, one could enable config TEST_BITOPS and run the original test. > + > + If unsure, say N. > + > config BITFIELD_KUNIT > tristate "KUnit test bitfield functions at runtime" if !KUNIT_ALL_TESTS > depends on KUNIT > diff --git a/lib/tests/Makefile b/lib/tests/Makefile > index 601dba4b7d966d568d0bb6671dffaf4d68489549..0f24048f36845b13daebcb504e182f738e0a807f 100644 > --- a/lib/tests/Makefile > +++ b/lib/tests/Makefile > @@ -5,6 +5,7 @@ > # KUnit tests > CFLAGS_bitfield_kunit.o := $(DISABLE_STRUCTLEAK_PLUGIN) > obj-$(CONFIG_BASE64_KUNIT) += base64_kunit.o > +obj-$(CONFIG_BITOPS_KUNIT) += bitops_kunit.o > obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o > obj-$(CONFIG_BITS_TEST) += test_bits.o > obj-$(CONFIG_BLACKHOLE_DEV_KUNIT_TEST) += blackhole_dev_kunit.o > diff --git a/lib/tests/bitops_kunit.c b/lib/tests/bitops_kunit.c > new file mode 100644 > index 0000000000000000000000000000000000000000..5c47a12760611a0445feb37c252d00f3bf73f6a1 > --- /dev/null > +++ b/lib/tests/bitops_kunit.c > @@ -0,0 +1,142 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (C) 2020 Intel Corporation > + * Copyright (C) 2026 Ryota Sakamoto > + */ > + > +#include > +#include > +#include > + > +/* use an enum because that's the most common BITMAP usage */ > +enum bitops_fun { > + BITOPS_4 = 4, > + BITOPS_7 = 7, > + BITOPS_11 = 11, > + BITOPS_31 = 31, > + BITOPS_88 = 88, > + BITOPS_LENGTH = 256 > +}; > + > +struct bitops_test_case { > + const char *str; > + const long nr; > +}; > + > +static struct bitops_test_case bitops_cases[] = { > + { > + .str = "BITOPS_4", > + .nr = BITOPS_4, > + }, > + { > + .str = "BITOPS_7", > + .nr = BITOPS_7, > + }, > + { > + .str = "BITOPS_11", > + .nr = BITOPS_11, > + }, > + { > + .str = "BITOPS_31", > + .nr = BITOPS_31, > + }, > + { > + .str = "BITOPS_88", > + .nr = BITOPS_88, > + }, > +}; > + > +KUNIT_ARRAY_PARAM_DESC(bitops, bitops_cases, str); > + > +static void test_set_bit_clear_bit(struct kunit *test) > +{ > + const struct bitops_test_case *params = test->param_value; > + DECLARE_BITMAP(bitmap, BITOPS_LENGTH); > + int bit_set; > + > + bitmap_zero(bitmap, BITOPS_LENGTH); > + > + set_bit(params->nr, bitmap); > + KUNIT_EXPECT_TRUE(test, test_bit(params->nr, bitmap)); > + > + clear_bit(params->nr, bitmap); > + KUNIT_EXPECT_FALSE(test, test_bit(params->nr, bitmap)); > + > + bit_set = find_first_bit(bitmap, BITOPS_LENGTH); > + KUNIT_EXPECT_EQ(test, bit_set, BITOPS_LENGTH); > +} > + > +struct order_test_case { > + const char *str; > + const unsigned int count; > + const int expected; > +}; > + > +static struct order_test_case order_test_cases[] = { > + {"0x00000003", 0x00000003, 2}, > + {"0x00000004", 0x00000004, 2}, > + {"0x00001fff", 0x00001fff, 13}, > + {"0x00002000", 0x00002000, 13}, > + {"0x50000000", 0x50000000, 31}, > + {"0x80000000", 0x80000000, 31}, > + {"0x80003000", 0x80003000, 32}, > +}; > + > +KUNIT_ARRAY_PARAM_DESC(order, order_test_cases, str); > + > +static void test_get_count_order(struct kunit *test) > +{ > + const struct order_test_case *params = test->param_value; > + > + KUNIT_EXPECT_EQ(test, get_count_order(params->count), params->expected); > + KUNIT_EXPECT_EQ(test, get_count_order_long(params->count), params->expected); > +} > + > +#ifdef CONFIG_64BIT > +struct order_long_test_case { > + const char *str; > + const unsigned long count; > + const int expected; > +}; > + > +static struct order_long_test_case order_long_test_cases[] = { > + {"0x0000000300000000", 0x0000000300000000, 34}, > + {"0x0000000400000000", 0x0000000400000000, 34}, > + {"0x00001fff00000000", 0x00001fff00000000, 45}, > + {"0x0000200000000000", 0x0000200000000000, 45}, > + {"0x5000000000000000", 0x5000000000000000, 63}, > + {"0x8000000000000000", 0x8000000000000000, 63}, > + {"0x8000300000000000", 0x8000300000000000, 64}, > +}; > + > +KUNIT_ARRAY_PARAM_DESC(order_long, order_long_test_cases, str); > + > +static void test_get_count_order_long(struct kunit *test) > +{ > + const struct order_long_test_case *params = test->param_value; > + > + KUNIT_EXPECT_EQ(test, get_count_order_long(params->count), params->expected); > +} > +#endif > + > +static struct kunit_case bitops_test_cases[] = { > + KUNIT_CASE_PARAM(test_set_bit_clear_bit, bitops_gen_params), > + KUNIT_CASE_PARAM(test_get_count_order, order_gen_params), > +#ifdef CONFIG_64BIT > + KUNIT_CASE_PARAM(test_get_count_order_long, order_long_gen_params), > +#endif > + {}, > +}; > + > +static struct kunit_suite bitops_test_suite = { > + .name = "bitops", > + .test_cases = bitops_test_cases, > +}; > + > +kunit_test_suite(bitops_test_suite); > + > +MODULE_AUTHOR("Jesse Brandeburg "); > +MODULE_AUTHOR("Wei Yang "); Those gentlemen are not even in CC. Are you sure they agree to be in this list? Thanks, Yury > +MODULE_AUTHOR("Ryota Sakamoto "); > +MODULE_LICENSE("GPL"); > +MODULE_DESCRIPTION("Bit testing module"); > > --- > base-commit: 79b95d74470dd97d7d0908d5a3c0734a23e51aa4 > change-id: 20260109-kunit-bitops-9abb5cac8cba > > Best regards, > -- > Ryota Sakamoto