From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 BD1F223370F for ; Mon, 22 Jun 2026 10:05:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782122761; cv=none; b=HfOiHPWYdRF/iIJfh30IpgQNZnoi9hxZdWEQwPKMSGZKtlq3Mo7zAbDkYvwo5FfFlaGMRAfzBQLoz+IZi1YUSeKxaAGiW+Z2cTWKlJhGh9KJklGQzKD6YqAHoAnRIB7y9WLEKaOSlTmNEvVuPncmJ2xg+Cqng2eeSu+4jHhug4E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782122761; c=relaxed/simple; bh=YlIv1GjdkYTk+tJ+eEQjFHjq5ucWsoiQbEJgSbS8suQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=dxpN4pjeSxYB0mg4qSQStBVSKI7WKercr+o0JcRndQur047swTx06DgysANy2RZFl9J3178Q9wA2KH4MB900tPsEqfIR06uFLq/OLKLw1x4EaP5x3SrnuuzmHOEYLQshvhMEsC+734ADEIIZZgwNQJG6oeQyAofsuOZ+KySR4nA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=mina86.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PMBfaoKe; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=mina86.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="PMBfaoKe" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-6976b0c5adbso4515323a12.2 for ; Mon, 22 Jun 2026 03:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782122758; x=1782727558; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=ptKIOW+ISuDnFARsXo7WCl1PRzftPF0fTxka2t7XOyk=; b=PMBfaoKeIxebeap/QgoNkFYqNMlRaSG7SkgqyajDGj72w1r45700vCSAKz7QE+Eb9k +b6BZ47fzkLMsGOk7HciqWi8FSYKjBTTG7u8YycxnZwKOg5ppvdWLwCdzDyTPFkWDEYN J4WL4wJFFmcSV+tJFOEOrpEKlfALtgFMK0fmeojCoZBibPlANufI2QDJvuSs1lGzKw+W uPSHHNZYXHyP0kA7+Pk3NetknIxRea+KjLKOgmtTRMCfUa7CBeypsPwRRv38Wm5gYDz2 +cCIaP+zaj3bA6/KSuh/lxv24vcMFk0XKJ37QG+PIvqwvXxPVUsO4sUk9+S60zT3t8hh DfWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782122758; x=1782727558; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:sender:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ptKIOW+ISuDnFARsXo7WCl1PRzftPF0fTxka2t7XOyk=; b=CwiGUjrrlHxYkbN29e8zF8MlVz1rTRXsGr+1+qMetcxNgQ0lxdvpBECwIIofIC8TA+ 6f/pD127vxndu6i2UFyD6WEsBAqfScd8xSg6LIbOy15k36t++Ldiz6Z9YbX8/KI7Aads P1WwVYN81qakgggUTo8a+vj2uUuda/2nqdrHRIAlX9f37sloI/5hurvcnd6MhTwpbJjj 5OjOHv1HF0CFO/POX5VU0INkcvY+K/b1TigoeuH3Y4z+p/xPHHTeA1XJjY6Uo0CfWX8n IgltZ88b35iPZiXcmH1Qsr8jX7vGihuSGyyAtFZPlaHyCTUI/17xuIg/22zlW8wpXORz fSXQ== X-Forwarded-Encrypted: i=1; AFNElJ/be3F/in57eFCTxD2BDeDlVG7MXHg3R0rPiEINhE7jY6tcpYU8RGmvGKexoLG7+tubh3BreV/VM3QC12I=@vger.kernel.org X-Gm-Message-State: AOJu0YwJ4QyFsppttZsJlSp2zYbWfgpcbJ2f7CeoqT4igelk+doMmp8m 7iq8nlPNGpC/vxaTISzyQ8+nivI8waX+26h1AqJJ3H6IQzeLT6ggqKto X-Gm-Gg: AfdE7cn/VknuUbZB9SRtpu1BQMl1Z/932jYbyupLIa1Ckew+vVG0TqLrP/hFbsQCrKs f8/DsXT2LjDndF8y+7ppsMEl2jH99Dq3NWpFLXIKYXdKzFzRQ55lDhNk/kgwMI/7AFfi1717wSl OKih2Jr0lst8aso3/1PyfsrU+O23/Gs3KbxAGQ31DxmL0PjNm35uMhz9+jv0LmoD1tN2wGjA8oL MgffRvMMSmUao6dqidPbMVn6PyQujfTBCgy3NH8R2FZKo6fFhY2KcfujtGUV3B0eH34s8jskeTD bUgg57iXW46pTxE6BPEa09BPh4XiQ+KyvVmydnJAwutZs3ThxW1opBdNwZPG39WxHHKL5Rj5mPr 25iWm6ikjO+j04U7KrH1diJymuSHDvK32R9HwF4DN+UuBYgtuQ7/FBLTAJVeUyWaBsXbvaJAU8t /Sd3JqWnPu83l//SHL74sdtKDyiFekB6WPU79HNGE= X-Received: by 2002:a05:6402:354f:b0:697:76d6:5e76 with SMTP id 4fb4d7f45d1cf-69776d65f93mr4034808a12.9.1782122757878; Mon, 22 Jun 2026 03:05:57 -0700 (PDT) Received: from erwin (109241130011.warszawa.vectranet.pl. [109.241.130.11]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6977b86de31sm2706392a12.12.2026.06.22.03.05.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2026 03:05:57 -0700 (PDT) Sender: =?UTF-8?Q?Micha=C5=82_Nazarewicz?= From: =?utf-8?Q?Micha=C5=82?= Nazarewicz To: Yi Sun , yury.norov@gmail.com Cc: yi.sun@unisoc.com, 279644543@qq.com, akpm@linux-foundation.org, akinobu.mita@gmail.com, linux-kernel@vger.kernel.org, tjmercier@google.com, fvdl@google.com, tglx@kernel.org, song@kernel.org, hch@lst.de, minchan@kernel.org, jstultz@google.com Subject: Re: [PATCH v7 1/2] lib: bitmap: add tests for bitmap_find_next_zero_area_off() In-Reply-To: <20260622030036.1744080-2-yi.sun@unisoc.com> References: <20260622030036.1744080-1-yi.sun@unisoc.com> <20260622030036.1744080-2-yi.sun@unisoc.com> Date: Mon, 22 Jun 2026 12:05:56 +0200 Message-ID: <6sfwcijc0ud502lapi52xvgs@mina86.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=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Jun 22 2026, 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 iteratio= ns > [ 0.311435] find_next_bit: 1356654 ns, 163975 iteratio= ns > Start testing find_bit() with sparse bitmap > [ 0.316267] bitmap_find_next_zero_area_off:4426808 ns, 322479 iteratio= ns > [ 0.316292] find_next_bit: 15154 ns, 656 iteratio= ns > > Signed-off-by: Yi Sun Acked-by: Micha=C5=82 Nazarewicz > --- > lib/find_bit_benchmark.c | 17 +++++++++++++++++ > lib/test_bitmap.c | 38 ++++++++++++++++++++++++++++++++++++++ > 2 files changed, 55 insertions(+) > > diff --git a/lib/find_bit_benchmark.c b/lib/find_bit_benchmark.c > index 00d9dc61cd46..05305e655f99 100644 > --- a/lib/find_bit_benchmark.c > +++ b/lib/find_bit_benchmark.c > @@ -149,6 +149,21 @@ static int __init test_find_next_and_bit(const void = *bitmap, > return 0; > } >=20=20 > +static int __init > +test_bitmap_find_next_zero_area_off(unsigned long *bitmap, unsigned long= len) > +{ > + unsigned long i, cnt; > + ktime_t time; > + > + time =3D ktime_get(); > + for (cnt =3D i =3D 0; i < BITMAP_LEN; cnt++) > + i =3D bitmap_find_next_zero_area_off(bitmap, BITMAP_LEN, i, 8, 0, 0) += 1; > + time =3D ktime_get() - time; > + pr_err("bitmap_find_next_zero_area_off:%7llu ns, %6ld iterations\n", ti= me, cnt); > + > + return 0; > +} > + > static int __init find_bit_test(void) > { > unsigned long nbits =3D BITMAP_LEN / SPARSE; > @@ -158,6 +173,7 @@ static int __init find_bit_test(void) > get_random_bytes(bitmap, sizeof(bitmap)); > get_random_bytes(bitmap2, sizeof(bitmap2)); >=20=20 > + 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); > } >=20=20 > + 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) > } > } >=20=20 > +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) >=3D 192)); In C `x >=3D y` yields 0 or 1. There=E2=80=99s no need for `!!`. About `>` vs `>=3D`, the original code returns `> 192` (because it returns `end` when it exceeds `size`). The new code returns `192` (because it returns `size` if loop fails to find an area). If that=E2=80=99s the case,= this patch, PATCH 1/2, should have `>` and PATCH 2/2 should change it to `expect_eq_uint(192, =E2=80=A6)` to reflect change in the API. =20 > +} > + > 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(); > } >=20=20 > KSTM_MODULE_LOADERS(test_bitmap); --=20 Best regards =E3=83=9F=E3=83=8F=E3=82=A6 =E2=80=9C=F0=9D=93=B6=F0=9D=93=B2=F0=9D=93=B7= =F0=9D=93=AA86=E2=80=9D =E3=83=8A=E3=82=B6=E3=83=AC=E3=83=B4=E3=82=A3=E3=83= =84 =C2=ABIf at first you don=E2=80=99t succeed, give up skydiving=C2=BB