linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib: avoid soft lockup in test_find_first_bit()
@ 2018-04-20 17:19 Yury Norov
  0 siblings, 0 replies; only message in thread
From: Yury Norov @ 2018-04-20 17:19 UTC (permalink / raw)
  To: Fengguang Wu, Dmitry Vyukov, Kefeng Wang, Andrew Morton,
	Clement Courbet, Arnd Bergmann, Geert Uytterhoeven, linux-kernel,
	lkp
  Cc: Yury Norov

test_find_first_bit() is intentionally sub-optimal,
and may cause soft lockup due to long time of run on some systems.
So decrease length of bitmap to traverse to avoid lockup.

With the change below, time of test execution doesn't exceed 0.2
seconds on my testing system.

Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Fixes: 4441fca0a27f5 ("lib: test module for find_*_bit() functions")
---
 lib/find_bit_benchmark.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/find_bit_benchmark.c b/lib/find_bit_benchmark.c
index 5985a25e6cbc..5367ffa5c18f 100644
--- a/lib/find_bit_benchmark.c
+++ b/lib/find_bit_benchmark.c
@@ -132,7 +132,12 @@ static int __init find_bit_test(void)
 	test_find_next_bit(bitmap, BITMAP_LEN);
 	test_find_next_zero_bit(bitmap, BITMAP_LEN);
 	test_find_last_bit(bitmap, BITMAP_LEN);
-	test_find_first_bit(bitmap, BITMAP_LEN);
+
+	/*
+	 * test_find_first_bit() may take some time, so
+	 * traverse only part of bitmap to avoid soft lockup.
+	 */
+	test_find_first_bit(bitmap, BITMAP_LEN / 10);
 	test_find_next_and_bit(bitmap, bitmap2, BITMAP_LEN);
 
 	pr_err("\nStart testing find_bit() with sparse bitmap\n");
-- 
2.14.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-04-20 17:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-20 17:19 [PATCH] lib: avoid soft lockup in test_find_first_bit() Yury Norov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).