Merge tag 'drm-misc-fixes-2022-03-03' of git://anongit.freedesktop.org/drm/drm-misc...
[linux-2.6-microblaze.git] / lib / find_bit_benchmark.c
index 5637c57..db904b5 100644 (file)
@@ -49,6 +49,25 @@ static int __init test_find_first_bit(void *bitmap, unsigned long len)
        return 0;
 }
 
+static int __init test_find_first_and_bit(void *bitmap, const void *bitmap2, unsigned long len)
+{
+       static DECLARE_BITMAP(cp, BITMAP_LEN) __initdata;
+       unsigned long i, cnt;
+       ktime_t time;
+
+       bitmap_copy(cp, bitmap, BITMAP_LEN);
+
+       time = ktime_get();
+       for (cnt = i = 0; i < len; cnt++) {
+               i = find_first_and_bit(cp, bitmap2, len);
+               __clear_bit(i, cp);
+       }
+       time = ktime_get() - time;
+       pr_err("find_first_and_bit: %18llu ns, %6ld iterations\n", time, cnt);
+
+       return 0;
+}
+
 static int __init test_find_next_bit(const void *bitmap, unsigned long len)
 {
        unsigned long i, cnt;
@@ -129,6 +148,7 @@ static int __init find_bit_test(void)
         * traverse only part of bitmap to avoid soft lockup.
         */
        test_find_first_bit(bitmap, BITMAP_LEN / 10);
+       test_find_first_and_bit(bitmap, bitmap2, BITMAP_LEN / 2);
        test_find_next_and_bit(bitmap, bitmap2, BITMAP_LEN);
 
        pr_err("\nStart testing find_bit() with sparse bitmap\n");
@@ -145,6 +165,7 @@ static int __init find_bit_test(void)
        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_and_bit(bitmap, bitmap2, BITMAP_LEN);
        test_find_next_and_bit(bitmap, bitmap2, BITMAP_LEN);
 
        /*