From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (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 5EEC522F388 for ; Thu, 18 Jun 2026 05:48:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781761683; cv=none; b=BeZVED5rAI+Bbqewr4MVg1FX1qbhPvMg30tnflbN4E7Xr8rMq0rG9wBukvhJ/baM2RsjoI+GHkYNSADHnE6xezjpCDV3IBdl2m6O0grmHl6vehfhGC4qd+us4pVNTFIvBTLvQfgcbQC+FdEa5uG7pn7SUEUjOLtGhpXVRPR/+p8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781761683; c=relaxed/simple; bh=KX14Sp3OeNI3dmbRqsO2ILAnVM+byyTHpK+JYney2d8=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=E5rRT54OrcqXaVZKv5PwkEV6qgSAYq94gjfCtLisZN88IaxjcsZrDCca9fclVnR31bbGJ2yhE0kX4ZujtqdrX8BAp6B+slsFy0J86tXedABfatLvMnw/3958MMCn1W8Zc/fijWgRuW9MFYd883p2L4MY1zgGK0gUIqbAs4bymjs= 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=ol/Npg9K; arc=none smtp.client-ip=209.85.128.172 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="ol/Npg9K" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-7fe8bc0a01bso5730967b3.1 for ; Wed, 17 Jun 2026 22:48:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781761681; x=1782366481; 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=KBRUik/UKx4C3ajGGJ1T1fBUTpbTQN67cOuQbzIYN8s=; b=ol/Npg9KZdUPMe/3em3EMVO67rmt0ibOKjTBhyakznFsnzrGk08JM4sjxrO0KGWw8L yfqo64gvsjY6mEJZ0jI1nf6JV/8CC4PJZMOklcLiv5earh4EySfQVkP4GPDPQ/4S3rPb ZNPzFlu9ZtBxe4f31a5cbQIvG1G2Ax30s68wheWgoKDmJvGQL0eMlUxiPblmDK+0RPtK ZRCFACFbs7k9IONJXPzQuSlbrJdZ7YKJs2E/vJajwIPWfEUT7NHZ3C0+dQndXdIbXh4n hxuT8geUlKySqF1cixDOaZIGC2xnZ3okTiUZv+e6nIY5Lbkkpf72IEw2OsT5gn1+ZgNQ Qfqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781761681; x=1782366481; 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=KBRUik/UKx4C3ajGGJ1T1fBUTpbTQN67cOuQbzIYN8s=; b=BezRPcjNz4Wy7RCRubpe4XSKJuWiNLANlar/kDfN0CHpxNWCb9oZbdbGWy2M0MN72E 2OB25vZOgnRvU2cyyL+ALJtbfOWM5el7BPjiXn4fXeRO1iFWMLmimNnLY9O1fxyisbpm AB6eFDb1yInzNgrZawbMBdo3/4phBDxgAc9adTejJa2daVPLiaABliC3vNpyqM11vm7Z t478NyYNKgTaSzuWfh+OIzGYRSaBXqmGK9bSHtbYu3Iu95O+bfgVnRkCxZcF4TrJfiQV GynGjuD5ZXJ8jlowI3AtmmM92Z2GiZzEhbpzB2h5WOgQ22rDkk8PUMBt7dfRJ90MjYUn BONA== X-Forwarded-Encrypted: i=1; AFNElJ9F6La4Pzl3/0zZMwtZzr1p46u0iga/98apiusmP2J9mEWmoihPMTJoccAFVb74EDzaQ36ooazEeR2FWNg=@vger.kernel.org X-Gm-Message-State: AOJu0YxufLtN6etSTU1m5BLRLXr2/jbPbFCTA+79ssWyHfU/MBAm1F0m ePOyfK9WYw/Owyh5GZcMCtNISJRF1DeIDEmmUTYOQ9VJepqY/X1MCHBI X-Gm-Gg: AfdE7cka8S2Ot/0RifKzLfrzWo2OCa4QYgZ74Qhu19xkH7a4eG63Xd8Ha7pQnwqeNtB LtXdTpSrsqMrR2WK950FG6T6IHQL3ex73ZqVR6dJAFi2Rxch3yW26ni1guC+wE9pJMkXr3VRyQC i7iPyg0YFG+47fCpr1W5J/UU25NSNzoASHFn7OFRumS1lH93L3H8zG01eqUqbD+pA6HYmxxNZvG k7X839xzAnwlvCCPjJhR4L5KOwFOLuCja48yC7RxpBrjNxD2p7XNBQWTHiUC4PPCWUvnQavjXVV 4keWNurQNQW7pBIZlpWEp/uUWjtC1etiZIlzIY+oxxH8XN7fCQ5uxgTvZM/JodOXdsNEudGTPdg tUUFTAeNMVtXo6P1qVoxnQW1VyDSX4IVGHCyAaHP8rMrzPNbdRRJ6kdQq5KXy3GzekfmTNr2bFt JwnVu1Dms9wt95izVuZA+RqhVzuU+tEK6GWWSjSubXvBL43Q== X-Received: by 2002:a05:690c:6c86:b0:7d1:c256:b5a8 with SMTP id 00721157ae682-7ffc793a52fmr20685987b3.40.1781761681339; Wed, 17 Jun 2026 22:48:01 -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-7fcd00da747sm63396577b3.7.2026.06.17.22.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 22:48:00 -0700 (PDT) From: Yury Norov X-Google-Original-From: Yury Norov Date: Thu, 18 Jun 2026 01:48:00 -0400 To: Yi Sun Cc: yury.norov@gmail.com, mina86@mina86.com, 279644543@qq.com, mnazarewicz@gmail.com, akpm@linux-foundation.org, akinobu.mita@gmail.com, linux-kernel@vger.kernel.org, john.stultz@linaro.org, tjmercier@google.com, qiang.zhao@freescale.com, scottwood@freescale.com, benjamin.gaignard@linaro.org, fvdl@google.com, tglx@kernel.org, andreas.herrmann@calxeda.com, song@kernel.org, hch@lst.de, sasha.levin@oracle.com, minchan@kernel.org Subject: Re: [PATCH v5 1/2] lib: bitmap: add tests for bitmap_find_next_zero_area_off() Message-ID: References: <20260618015252.3601554-1-yi.sun@unisoc.com> <20260618015252.3601554-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: <20260618015252.3601554-2-yi.sun@unisoc.com> On Thu, Jun 18, 2026 at 09:52:51AM +0800, Yi Sun wrote: > Add functional and performance tests > for bitmap_find_next_zero_area_off(). > > To maintain consistent output format, > use "find_next_0_area" instead of > "bitmap_find_next_zero_area_off". > > performance tests partial output: > Start testing find_bit() with random-filled bitmap > [ 0.191166] find_next_0_area: 1521308 ns, 1326 iterations > [ 0.192552] find_next_bit: 1382385 ns, 163724 iterations > Start testing find_bit() with sparse bitmap > [ 0.196835] find_next_0_area: 4250307 ns, 322497 iterations > [ 0.196853] find_next_bit: 15077 ns, 656 iterations > > Signed-off-by: Yi Sun > --- > 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..062a69930d83 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; > } > > +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("find_next_0_area: %18llu ns, %6ld iterations\n", time, cnt); Change %18llu to %14llu (or whatever), and keep the name as it should. > + > + return 0; > +} > + > static int __init find_bit_test(void) > { > unsigned long nbits = 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)); > > + 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..12aa2ca37fe1 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)); It should be >= here. > +} > + > 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