mm/cma: ise for_each_clear_bitrange() where appropriate
Subsystems (2)
cover mm/cma: ise for_each_clear_bitrange() where appropriate
From: Yury Norov (NVIDIA) <[email protected]>
Hi Andrew,
Pleas pull a couple of simplifications for mm/cma.
Thanks,
Yury
Yury Norov (NVIDIA) (2):
mm: cma: simplify cma_debug_show_areas()
mm: cma: simplify cma_maxchunk_get()
mm/cma.c | 19 ++++--------------- mm/cma_debug.c | 10 +--------- 2 files changed, 5 insertions(+), 24 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 mm: cma: simplify cma_debug_show_areas()
From: Yury Norov (NVIDIA) <[email protected]>
The function opencodes for_each_clear_bitrange(). Fix that and drop most of housekeeping code.
--- mm/cma.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
mm/cma.c +4 -15
@@ -739,8 +739,7 @@ static int __init __cma_declare_contiguous_nid(phys_addr_t *basep,static void cma_debug_show_areas (struct cma *cma) { -unsigned long next_zero_bit, next_set_bit, nr_zero; -unsigned long start; +unsigned long start, end;unsigned long nr_part;unsigned long nbits;int r;
@@ -751,22 +750,12 @@ static void cma_debug_show_areas(struct cma *cma)for (r =0 ; r < cma->nranges; r++) { cmr = &cma->ranges[r]; - start =0 ; nbits =cma_bitmap_maxno (cma, cmr);pr_info ("range %d: " , r); -for (;;) { - next_zero_bit =find_next_zero_bit (cmr->bitmap, - nbits, start); -if (next_zero_bit >= nbits) -break ; - next_set_bit =find_next_bit (cmr->bitmap, nbits, - next_zero_bit); - nr_zero = next_set_bit - next_zero_bit; - nr_part = nr_zero << cma->order_per_bit; -pr_cont ("%s%lu@%lu" , start ?"+" :"" , nr_part, - next_zero_bit); - start = next_zero_bit + nr_zero; +for_each_clear_bitrange (start, end, cmr->bitmap, nbits) { + nr_part = (end - start) << cma->order_per_bit; +pr_cont ("%s%lu@%lu" , start ?"+" :"" , nr_part, start); }pr_info ("\n" ); }
Signature · 1 line
2.43.0
Re: [PATCH 1/2] mm: cma: simplify cma_debug_show_areas()
Quoted 4 lines · Yury Norov
From: Yury Norov (NVIDIA) <[email protected]>
The function opencodes
for_each_clear_bitrange(). Fix that and drop most of housekeeping code.
Same comment regarding "fix" as for patch #2
Signature · 3 lines
Cheers, David / dhildenb
PATCH 2/2 mm: cma: simplify cma_maxchunk_get()
In reply to Yury NorovFrom: Yury Norov (NVIDIA) <[email protected]>
The function opencodes for_each_clear_bitrange(). Fix that and drop most of housekeeping code.
--- mm/cma_debug.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
mm/cma_debug.c +1 -9
@@ -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;
Signature · 1 line
2.43.0
Re: [PATCH 2/2] mm: cma: simplify cma_maxchunk_get()
Quoted 4 lines · Yury Norov
From: Yury Norov (NVIDIA) <[email protected]>
The function opencodes
for_each_clear_bitrange(). Fix that and drop most of housekeeping code.
Not sure if talking about a "fix" it the right word here.
Quoted 28 lines
Signed-off-by Yury Norov (NVIDIA) <[email protected]>--- mm/cma_debug.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)mm/cma_debug.c +1
-9@@ -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;
Signature · 3 lines
Cheers, David / dhildenb