From 632cfe6c226ee356d6e3440ab0dc64e78cf30a9a Mon Sep 17 00:00:00 2001 From: Yury Norov Date: Fri, 11 May 2018 16:01:39 -0700 Subject: [PATCH] lib/find_bit_benchmark.c: avoid soft lockup in test_find_first_bit() BugLink: http://bugs.launchpad.net/bugs/1794889 [ Upstream commit 4ba281d5bd9907355e6b79fb72049c9ed50cc670 ] 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. Link: http://lkml.kernel.org/r/20180420171949.15710-1-ynorov@caviumnetworks.com Fixes: 4441fca0a27f5 ("lib: test module for find_*_bit() functions") Signed-off-by: Yury Norov Reviewed-by: Andrew Morton Reported-by: Fengguang Wu Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman Signed-off-by: Kamal Mostafa Signed-off-by: Stefan Bader --- lib/test_find_bit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/test_find_bit.c b/lib/test_find_bit.c index f4394a36f9aa..44ceda470a2a 100644 --- a/lib/test_find_bit.c +++ b/lib/test_find_bit.c @@ -118,7 +118,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); pr_err("\nStart testing find_bit() with sparse bitmap\n"); -- 2.39.2