]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm: cma: simplify cma_maxchunk_get()
authorYury Norov (NVIDIA) <yury.norov@gmail.com>
Sat, 19 Jul 2025 20:54:00 +0000 (16:54 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 25 Jul 2025 02:12:36 +0000 (19:12 -0700)
The function opencodes for_each_clear_bitrange().  Fix that and drop most
of housekeeping code.

Link: https://lkml.kernel.org/r/20250719205401.399475-3-yury.norov@gmail.com
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
Acked-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/cma_debug.c

index fdf899532ca02fd80e5657f10388a8caeffffc41..8c7d7f8e8fbd004ce2003f46ace84ff9bba7a95c 100644 (file)
@@ -56,16 +56,8 @@ static int cma_maxchunk_get(void *data, u64 *val)
        for (r = 0; r < cma->nranges; r++) {
                cmr = &cma->ranges[r];
                bitmap_maxno = cma_bitmap_maxno(cma, cmr);
-               end = 0;
-               for (;;) {
-                       start = find_next_zero_bit(cmr->bitmap,
-                                                  bitmap_maxno, end);
-                       if (start >= bitmap_maxno)
-                               break;
-                       end = find_next_bit(cmr->bitmap, bitmap_maxno,
-                                           start);
+               for_each_clear_bitrange(start, end, cmr->bitmap, bitmap_maxno)
                        maxchunk = max(end - start, maxchunk);
-               }
        }
        spin_unlock_irq(&cma->lock);
        *val = (u64)maxchunk << cma->order_per_bit;