From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (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 64F1A2F25E4 for ; Mon, 8 Jun 2026 19:14:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780946065; cv=none; b=po3DHe7lU4WyVEEnt1lIeXH+RCL7NEab+tT0Qm6z0aMzTCH/9AzAes6eFdpjJIh5WXjwi05lTI1uQ84dbxQViVrDTKGfI+c/Waw2NWynqlRtiktPjhdPpAkEAQSxBbHiAHcp9aNpy4EZQCQ5cor+GIgHSsph842p99YLm9A5SA4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780946065; c=relaxed/simple; bh=/KnMMldv85aV6jspyR1yuS9xoxzr7eG5vj+Rzjdp3ag=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=t0xQeaVus+zDu7u6msSbNXxScUlMawrwCvEQVSLuOjbFBKhDlL7JOic6SinxtnNoSUtnB7hNDqF3xxep5oGJXOwIy4Up9DjDDPu8HCzkgvqm6wS874mcZlCO2KcQszP7tnrFGfbDb3foPULjlZ+YxoUdMkVD0xdzK7gM4BW/ueU= 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=LRTx55TH; arc=none smtp.client-ip=209.85.128.176 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="LRTx55TH" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-7dd3f176f84so55251887b3.0 for ; Mon, 08 Jun 2026 12:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780946063; x=1781550863; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from:from:to :cc:subject:date:message-id:reply-to; bh=q3peHhbNrUfXrWakaajLNjnoQEPZyGdIHLIeVXNGkgM=; b=LRTx55TH+YZVqikioftq6ZbBtrQvo45vWnIRrufIgboVn1RfzHnszV3GGeRUyUoNVN iU/QhJsl1jr3DtS4+3wa1oeB8gEKFA8eJ9lm8Ryec5xkcqGo0rzIWdnQwylFpF/oYBac SNht97pSIxQHXFm/FZ3lRELe48rqyZVKATnRB8CR7jMhsOof32m6rd7p+aQDIahFdLZt P/7AzRi6KL0uaWAWdctGTB599xdQSX2YR6UovTm+Qiz+XI7xJBDbGFXou7o+SR2FJnnD GRwtHL7eotSd5nF63dg+m7E+tINYHt0ZSLOjmbp9XdT5BJsLCgKnL4ynKv44/SdVCDzp 4aeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780946063; x=1781550863; h=in-reply-to:content-transfer-encoding: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=q3peHhbNrUfXrWakaajLNjnoQEPZyGdIHLIeVXNGkgM=; b=nKfD1+J2D/hNCSvNjKzL+T3DHEpeeSOM5osRaHxCDn75EwbRVaiY/0x8YsTt7iepqb vX716GPbUGfUiO7KTvj+cWXDlnIyzZfGih9BC8RMvhLI/1TkqTbwLHED9OHuhuSATPbD w+TbLFxhMILi7oleJZnCThlWesJsflYRvEeQ9EDuAqxGX/aq8k49RhUD0f3wOuvROUPX A4lTCLa7zvPpP8K7Nzk6o4nxRCN69thq4/kWoPdDgHYmfv7sYQ6oZKmKfAVWWFnDV77S hOVVQt7nG57MQKQXetEqtXs5ejyEM6MHzvqMfmQw1ne3bzE32R0yzL7XZyBQop/RHipT Aj9A== X-Forwarded-Encrypted: i=1; AFNElJ8tw3AEQfO1OWhs2uJFkh9JdqXaCaQBpsI9ke2exj/E0aTUM6jpcZZEw0SLatzRdRftGL3Lo3AqMfzICHI=@vger.kernel.org X-Gm-Message-State: AOJu0Yxj4OB+qMjXYFItlIcRgPh0wjvnV59MnitDDjK0tRAExfcjZrU5 XD3qOcUtHsylQ6p5b931Eva9yxxgaAJXU5Ga/saVVWngjrfdRawqIrZU X-Gm-Gg: Acq92OF5/CjzJIST6kan9dBby41tI3gI7Fg4L4z+xSn187ujDg9jhf3F+mAUx0rAUGz HV5p9txTFnUfj9mgSQI6allhF/woLku/N4RcK8sDArE4JsTz7OzjL6kQYVwkCsTjb1F9t3XlKhK LDZrqxIcI8/XbgzS1pqVfRGoc0DUfXMDkqpJr/7dhGzPTa3c4tAGxbFWNSJf9n5D97wFk0j5PCm Sjr/c7oMFEF5jtSDrPkyT7lFRU9Abg4Q8Wn2//Q4wSLIlA13frsqRgdUnOk8OZxGGvswVjXKoNn YW2TKqD50sXyGMEQbAJLehZuA/qblnys5wWWbgq8xr/oNjfyU/0SmxROcYAF+yhl361UNg650b/ TOQRgKpwVzui9HueyS3SNxFN1EpDPOaIQCkScrBRgsZpbR/be13jOHeRXbI7Bj/Ya1A3P5Ly278 1V9p08WBEVaOhzMqwgIfG4ZvUKTol7QlSKXYge2FE= X-Received: by 2002:a05:690c:620a:b0:7ba:a726:57a4 with SMTP id 00721157ae682-7ed0f33acbbmr164623857b3.36.1780946063216; Mon, 08 Jun 2026 12:14:23 -0700 (PDT) Received: from localhost ([50.221.107.122]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7ea23a9a421sm87379207b3.39.2026.06.08.12.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 12:14:22 -0700 (PDT) From: Yury Norov X-Google-Original-From: Yury Norov Date: Mon, 8 Jun 2026 15:14:22 -0400 To: Yi Sun Cc: yury.norov@gmail.com, mnazarewicz@gmail.com, akpm@linux-foundation.org, mina86@mina86.com, akinobu.mita@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/2] lib/bitmap: add tests for bitmap_find_next_zero_area_off() Message-ID: References: <20260601094234.103863-1-yi.sun@unisoc.com> <20260601094234.103863-3-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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260601094234.103863-3-yi.sun@unisoc.com> On Mon, Jun 01, 2026 at 05:42:34PM +0800, Yi Sun wrote: > Add functional and performance tests > for bitmap_find_next_zero_area_off(). > > Signed-off-by: Yi Sun > --- > lib/find_bit_benchmark.c | 17 +++++++++++++++++ > lib/test_bitmap.c | 28 ++++++++++++++++++++++++++++ > 2 files changed, 45 insertions(+) > > diff --git a/lib/find_bit_benchmark.c b/lib/find_bit_benchmark.c > index 00d9dc61cd46..37fe76ad322e 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("bitmap_find_next_zero_area_off: %18llu ns, %6ld iterations\n", time, cnt); > + > + 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..fad2b19760c2 100644 > --- a/lib/test_bitmap.c > +++ b/lib/test_bitmap.c > @@ -234,6 +234,34 @@ static void __init test_find_nth_bit(void) > } > } > > +static void __init > +test_bitmap_find_next_zero_area_off(void) warning: ‘test_bitmap_find_next_zero_area_off’ defined but not used [-Wunused-function] 238 | test_bitmap_find_next_zero_area_off(void) > +{ > + int bmap_len = 64 * 3; > + DECLARE_BITMAP(bmap, bmap_len); I believe, everyone can realize that 64*3 == 192, and we don't need a variable for it. > + bitmap_set(bmap, 0, bmap_len); > + > + bitmap_clear(bmap, 0, 8); > + __clear_bit(50, bmap); > + bitmap_clear(bmap, 60, 10); > + __clear_bit(80, bmap); > + bitmap_clear(bmap, 100, 10); > + __clear_bit(120, bmap); > + bitmap_clear(bmap, 160, 32); Can you also test a 'dirty' region: bitmap_clear(60, 18); __set_bit(69); // find nothing bitmap_find_next_zero_area_off(bmap, bmap_len, 0, 10, 0, 0)); > + > + expect_eq_uint(0, > + bitmap_find_next_zero_area_off(bmap, bmap_len, 0, 8, 0, 0)); > + expect_eq_uint(60, > + bitmap_find_next_zero_area_off(bmap, bmap_len, 1, 8, 0, 0)); > + expect_eq_uint(60, > + bitmap_find_next_zero_area_off(bmap, bmap_len, 0, 10, 0, 0)); > + expect_eq_uint(160, > + bitmap_find_next_zero_area_off(bmap, bmap_len, 0, 32, 0, 0)); > + expect_eq_uint(1, > + !!(bitmap_find_next_zero_area_off(bmap, bmap_len, 0, 33, 0, 0) > bmap_len)); Two last parameters are zero in all cases. Doesn't sound like an exhaustive testing. Real users provide non-zero alignments, so please you do. > +} > + > static void __init test_fill_set(void) > { > DECLARE_BITMAP(bmap, 1024); > -- > 2.34.1