From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD1AB31F9AA for ; Thu, 18 Jun 2026 17:31:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781803877; cv=none; b=bQNB2Digt5YhiLMcMn87R2QGAqculU9EhzEBra7b/XoUtCvc/SoHLMLTjebbR67ZWcqUo4hYj71PojqW/eQMl+AozeE69BiMPSNN9VfZRjrMOcdgpJ9U9T7N/oCtfCqC6x+4lmZKoK5jwPYXdiHj/KxdQuCFA2iEK1buJZDwDm0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781803877; c=relaxed/simple; bh=ozM1Fm6vB+Mz1lTpDx2gJYIaU4yKJaESeleQ7Q3kgxs=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Tf0qP11eAl1zrHvGEQO71csCwWiXYYSI1BlHsP7Q6Ha4A9vwGy2NgTp1sbjt+Co5KQRmM/ETNIBdmDZxilaUwuDr/CQZqZEbq0RkZG9gB1xUe3a90aDPf3CI71RZmoY2/rU1G9OzZT2J24du0Xd/9/aEoziGjCIv6jdwY6TnT0k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VZi3v7PX; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VZi3v7PX" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-7fd8446a1cdso13691647b3.1 for ; Thu, 18 Jun 2026 10:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781803875; x=1782408675; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=2Ez8dICsmGiuTmNeGh5fp1CLmzA+XSDL39+PAOpdO14=; b=VZi3v7PX+fhbXcQV+BuHNR5UpnfVGjqUYqOsa03WwrWRxO4AJMQkum+FKp0aZqy5S7 UYxbWzHvGwSv20GnC+Ux4eQrAUMe1E7oE9sFr3MQldnMymGedOG/zn6egDXlJHTdgq6N TNdYb7JxbzZGsENq87JAiaZuILkNXtKYkb0Dom3otxnhe95WllBR1Mzjfabq3F8abbfX GjWchaYNJhvUDkTRBNhv1IrarxH1tRtdN01mzC8YrPAdUTeGsAmCw7WQrvWC5yNCUCs0 bist1MEyinjSfscC1PfP7rWnojnzxx90klIlOgtjHVGXJWWrtYpyM6tYi8frZ/dS/ecN MNAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781803875; x=1782408675; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2Ez8dICsmGiuTmNeGh5fp1CLmzA+XSDL39+PAOpdO14=; b=WsAeKzauNxa7gSYGkxxHflnzM6DGWPPSD3WTZcp/peFXFuHh+E9cywji+fXcW5+ySz RFpZckLO85BaD+RKnebMXIF/E5fbqWvHRpaN7BgvTtvcBXjJ3qAvX3KKgCdfG/3Okk8h SkWzhh8hkjYslLf79ewfjXILjoeHtiWKvcmLqMkS6Pj2ARay7L0KyzAuhvUIaQ+ldChe I118ezRA8x6tCm4ee95CYu1p7EsIhJb57M5y7oSTdZANX/8dI/QDAR3nLjUyFk0BaEiF 5dMiJWnbYtSUhfYrFPBpT0UHthU5l/R2ZL48I4Iicp/6BLxq0mrIvb+WuXELcnGMBeGb 2Gwg== X-Forwarded-Encrypted: i=1; AFNElJ81creJiUCpg05Wf3sLjXqAJUKLndjbvTZewIlzp4mfEGQh9XCoUc9CEUXVzuWhmYX5dp013p+qJ6NXGEU=@vger.kernel.org X-Gm-Message-State: AOJu0YxukmFP7bgc+mbxeKN+zFMI7y1QMb4b9vh9LlZZvS4CjX6Duxv0 Gff4pqR3aSn0S9CRL1GMeKwyuNz5UZ7S2mRGq4l+gvY/38/qETQiha7S X-Gm-Gg: AfdE7clU20UKwAd6v6uGK2dItGOUeDyLeNmbsUJlub5Xs6CM0T02NCwNM8A/pw1HL3g t4thDj9oKX6vmjSVZRxgjehTMxCXGIb74IBj1uy9FVnhRPA17nawqXU+8/Wl12QA417pdY7m8Xj UkLmsOGg2QMbnL5rZwbduwlsDegqcmp7Es56+WW4IMKIAWWG5uU8NNYDKYB8PcNMmUm8w1iSPFN A73EY0H8AH9TlXZsB4agQWi7SnUSJ5PTIbt6MPMtQ1l8nO4yWR8sycTMyP64ItjEc17dqZ6ih2R oEvYZGw0O84JFaiZggGxOxiwBgX/HYEYdqBOIS0P+9SX8nNtqaVvD7ILVsdjuYY9avpngVEkUiL zomykx7CiQ4qbbv7nItflj1I6cHgMgKM93BqerswWILGO/NNNi0QWmbtNwzfKEb2qyoA7/sZ9zM 0qR6vKeqAH8AwwBVk5PmpH1UZJwkr9sixYk0sfIUVrpd7OYA== X-Received: by 2002:a05:690c:4906:b0:7db:bff4:f086 with SMTP id 00721157ae682-7fe5b7dc8aemr115231057b3.12.1781803874665; Thu, 18 Jun 2026 10:31:14 -0700 (PDT) Received: from localhost (syn-035-130-123-074.biz.spectrum.com. [35.130.123.74]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8011d507cecsm102867b3.33.2026.06.18.10.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 10:31:14 -0700 (PDT) From: Yury Norov X-Google-Original-From: Yury Norov Date: Thu, 18 Jun 2026 13:31:13 -0400 To: Yi Sun Cc: yury.norov@gmail.com, 279644543@qq.com, mina86@mina86.com, mnazarewicz@gmail.com, akpm@linux-foundation.org, akinobu.mita@gmail.com, linux-kernel@vger.kernel.org, tjmercier@google.com, qiang.zhao@freescale.com, scottwood@freescale.com, fvdl@google.com, tglx@kernel.org, song@kernel.org, hch@lst.de, minchan@kernel.org, jstultz@google.com Subject: Re: [PATCH v6 1/2] lib: bitmap: add tests for bitmap_find_next_zero_area_off() Message-ID: References: <20260618133518.4079981-1-yi.sun@unisoc.com> <20260618133518.4079981-2-yi.sun@unisoc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260618133518.4079981-2-yi.sun@unisoc.com> On Thu, Jun 18, 2026 at 09:35:17PM +0800, Yi Sun wrote: > Add functional and performance tests > for bitmap_find_next_zero_area_off(). > > performance tests partial output: > Start testing find_bit() with random-filled bitmap > [ 0.310073] bitmap_find_next_zero_area_off: 852731 ns, 1154 iterations > [ 0.311435] find_next_bit: 1356654 ns, 163975 iterations > Start testing find_bit() with sparse bitmap > [ 0.316267] bitmap_find_next_zero_area_off: 4426808 ns, 322479 iterations > [ 0.316292] find_next_bit: 15154 ns, 656 iterations > > Signed-off-by: Yi Sun > --- > lib/find_bit_benchmark.c | 31 ++++++++++++++++++++++++------- > lib/test_bitmap.c | 38 ++++++++++++++++++++++++++++++++++++++ > 2 files changed, 62 insertions(+), 7 deletions(-) > > diff --git a/lib/find_bit_benchmark.c b/lib/find_bit_benchmark.c > index 00d9dc61cd46..cde7c09de05c 100644 > --- a/lib/find_bit_benchmark.c > +++ b/lib/find_bit_benchmark.c > @@ -46,7 +46,7 @@ static int __init test_find_first_bit(const void *bitmap, unsigned long len) > __clear_bit(i, cp); > } > time = ktime_get() - time; > - pr_err("find_first_bit: %18llu ns, %6ld iterations\n", time, cnt); > + pr_err("find_first_bit: %14llu ns, %6ld iterations\n", time, cnt); No need to change the existing code. Just add your test and make sure it looks aligned with the existing format. > > return 0; > } > @@ -66,7 +66,7 @@ static int __init test_find_first_and_bit(const void *bitmap, const void *bitmap > __clear_bit(i, cp); > } > time = ktime_get() - time; > - pr_err("find_first_and_bit: %18llu ns, %6ld iterations\n", time, cnt); > + pr_err("find_first_and_bit: %14llu ns, %6ld iterations\n", time, cnt); > > return 0; > } > @@ -80,7 +80,7 @@ static int __init test_find_next_bit(const void *bitmap, unsigned long len) > for (cnt = i = 0; i < BITMAP_LEN; cnt++) > i = find_next_bit(bitmap, BITMAP_LEN, i) + 1; > time = ktime_get() - time; > - pr_err("find_next_bit: %18llu ns, %6ld iterations\n", time, cnt); > + pr_err("find_next_bit: %14llu ns, %6ld iterations\n", time, cnt); > > return 0; > } > @@ -94,7 +94,7 @@ static int __init test_find_next_zero_bit(const void *bitmap, unsigned long len) > for (cnt = i = 0; i < BITMAP_LEN; cnt++) > i = find_next_zero_bit(bitmap, len, i) + 1; > time = ktime_get() - time; > - pr_err("find_next_zero_bit: %18llu ns, %6ld iterations\n", time, cnt); > + pr_err("find_next_zero_bit: %14llu ns, %6ld iterations\n", time, cnt); > > return 0; > } > @@ -113,7 +113,7 @@ static int __init test_find_last_bit(const void *bitmap, unsigned long len) > len = l; > } while (len); > time = ktime_get() - time; > - pr_err("find_last_bit: %18llu ns, %6ld iterations\n", time, cnt); > + pr_err("find_last_bit: %14llu ns, %6ld iterations\n", time, cnt); > > return 0; > } > @@ -129,7 +129,7 @@ static int __init test_find_nth_bit(const unsigned long *bitmap, unsigned long l > WARN_ON(l >= len); > } > time = ktime_get() - time; > - pr_err("find_nth_bit: %18llu ns, %6ld iterations\n", time, w); > + pr_err("find_nth_bit: %14llu ns, %6ld iterations\n", time, w); > > return 0; > } > @@ -144,7 +144,22 @@ static int __init test_find_next_and_bit(const void *bitmap, > for (cnt = i = 0; i < BITMAP_LEN; cnt++) > i = find_next_and_bit(bitmap, bitmap2, BITMAP_LEN, i + 1); > time = ktime_get() - time; > - pr_err("find_next_and_bit: %18llu ns, %6ld iterations\n", time, cnt); > + pr_err("find_next_and_bit: %14llu ns, %6ld iterations\n", time, cnt); > + > + return 0; > +} > + > +static int __init > +test_bitmap_find_next_zero_area_off(unsigned long *bitmap, unsigned long len) > +{ > + unsigned long i, cnt; > + ktime_t time; > + > + time = ktime_get(); > + for (cnt = i = 0; i < BITMAP_LEN; cnt++) > + i = bitmap_find_next_zero_area_off(bitmap, BITMAP_LEN, i, 8, 0, 0) + 1; > + time = ktime_get() - time; > + pr_err("bitmap_find_next_zero_area_off: %14llu ns, %6ld iterations\n", time, cnt); > > return 0; > } > @@ -158,6 +173,7 @@ static int __init find_bit_test(void) > get_random_bytes(bitmap, sizeof(bitmap)); > get_random_bytes(bitmap2, sizeof(bitmap2)); > > + test_bitmap_find_next_zero_area_off(bitmap, BITMAP_LEN); > test_find_next_bit(bitmap, BITMAP_LEN); > test_find_next_zero_bit(bitmap, BITMAP_LEN); > test_find_last_bit(bitmap, BITMAP_LEN); > @@ -181,6 +197,7 @@ static int __init find_bit_test(void) > __set_bit(get_random_u32_below(BITMAP_LEN), bitmap2); > } > > + test_bitmap_find_next_zero_area_off(bitmap, BITMAP_LEN); > test_find_next_bit(bitmap, BITMAP_LEN); > test_find_next_zero_bit(bitmap, BITMAP_LEN); > test_find_last_bit(bitmap, BITMAP_LEN); > diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c > index 69813c10e6c0..8665df77c960 100644 > --- a/lib/test_bitmap.c > +++ b/lib/test_bitmap.c > @@ -234,6 +234,43 @@ static void __init test_find_nth_bit(void) > } > } > > +static void __init > +test_bitmap_find_next_zero_area_off(void) > +{ > + DECLARE_BITMAP(bmap, 192); > + > + bitmap_set(bmap, 0, 192); > + > + bitmap_clear(bmap, 0, 8); > + __clear_bit(50, bmap); > + bitmap_clear(bmap, 60, 18); > + __set_bit(69, bmap); > + __clear_bit(80, bmap); > + bitmap_clear(bmap, 100, 10); > + __clear_bit(120, bmap); > + bitmap_clear(bmap, 145, 8); > + bitmap_clear(bmap, 160, 32); > + > + expect_eq_uint(0, > + bitmap_find_next_zero_area_off(bmap, 192, 0, 8, 0, 0)); > + expect_eq_uint(0, > + bitmap_find_next_zero_area_off(bmap, 192, 0, 8, 3, 0)); > + expect_eq_uint(163, > + bitmap_find_next_zero_area_off(bmap, 192, 0, 8, 3, 1)); > + expect_eq_uint(60, > + bitmap_find_next_zero_area_off(bmap, 192, 1, 8, 0, 0)); > + expect_eq_uint(160, > + bitmap_find_next_zero_area_off(bmap, 192, 1, 8, 7, 0)); > + expect_eq_uint(60, > + bitmap_find_next_zero_area_off(bmap, 192, 1, 8, 7, 4)); > + expect_eq_uint(100, > + bitmap_find_next_zero_area_off(bmap, 192, 0, 10, 0, 0)); > + expect_eq_uint(160, > + bitmap_find_next_zero_area_off(bmap, 192, 0, 32, 0, 0)); > + expect_eq_uint(1, > + !!(bitmap_find_next_zero_area_off(bmap, 192, 0, 33, 0, 0) >= 192)); > +} > + > static void __init test_fill_set(void) > { > DECLARE_BITMAP(bmap, 1024); > @@ -1559,6 +1596,7 @@ static void __init selftest(void) > test_for_each_clear_bitrange_from(); > test_for_each_set_clump8(); > test_for_each_set_bit_wrap(); > + test_bitmap_find_next_zero_area_off(); > } > > KSTM_MODULE_LOADERS(test_bitmap); > -- > 2.34.1