* [PATCH 0/2] mm/cma: ise for_each_clear_bitrange() where appropriate @ 2025-07-19 20:53 Yury Norov 2025-07-19 20:53 ` [PATCH 1/2] mm: cma: simplify cma_debug_show_areas() Yury Norov 2025-07-19 20:54 ` [PATCH 2/2] mm: cma: simplify cma_maxchunk_get() Yury Norov 0 siblings, 2 replies; 5+ messages in thread From: Yury Norov @ 2025-07-19 20:53 UTC (permalink / raw) To: Andrew Morton, linux-mm, linux-kernel; +Cc: Yury Norov From: Yury Norov (NVIDIA) <yury.norov@gmail.com> 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(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] mm: cma: simplify cma_debug_show_areas() 2025-07-19 20:53 [PATCH 0/2] mm/cma: ise for_each_clear_bitrange() where appropriate Yury Norov @ 2025-07-19 20:53 ` Yury Norov 2025-07-21 11:01 ` David Hildenbrand 2025-07-19 20:54 ` [PATCH 2/2] mm: cma: simplify cma_maxchunk_get() Yury Norov 1 sibling, 1 reply; 5+ messages in thread From: Yury Norov @ 2025-07-19 20:53 UTC (permalink / raw) To: Andrew Morton, linux-mm, linux-kernel; +Cc: Yury Norov From: Yury Norov (NVIDIA) <yury.norov@gmail.com> The function opencodes for_each_clear_bitrange(). Fix that and drop most of housekeeping code. Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com> --- mm/cma.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/mm/cma.c b/mm/cma.c index 397567883a10..adc57bf7c68c 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -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"); } -- 2.43.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mm: cma: simplify cma_debug_show_areas() 2025-07-19 20:53 ` [PATCH 1/2] mm: cma: simplify cma_debug_show_areas() Yury Norov @ 2025-07-21 11:01 ` David Hildenbrand 0 siblings, 0 replies; 5+ messages in thread From: David Hildenbrand @ 2025-07-21 11:01 UTC (permalink / raw) To: Yury Norov, Andrew Morton, linux-mm, linux-kernel On 19.07.25 22:53, Yury Norov wrote: > From: Yury Norov (NVIDIA) <yury.norov@gmail.com> > > The function opencodes for_each_clear_bitrange(). Fix that and drop most > of housekeeping code. Same comment regarding "fix" as for patch #2 Acked-by: David Hildenbrand <david@redhat.com> -- Cheers, David / dhildenb ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] mm: cma: simplify cma_maxchunk_get() 2025-07-19 20:53 [PATCH 0/2] mm/cma: ise for_each_clear_bitrange() where appropriate Yury Norov 2025-07-19 20:53 ` [PATCH 1/2] mm: cma: simplify cma_debug_show_areas() Yury Norov @ 2025-07-19 20:54 ` Yury Norov 2025-07-21 10:59 ` David Hildenbrand 1 sibling, 1 reply; 5+ messages in thread From: Yury Norov @ 2025-07-19 20:54 UTC (permalink / raw) To: Andrew Morton, linux-mm, linux-kernel; +Cc: Yury Norov From: Yury Norov (NVIDIA) <yury.norov@gmail.com> The function opencodes for_each_clear_bitrange(). Fix that and drop most of housekeeping code. Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com> --- mm/cma_debug.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/mm/cma_debug.c b/mm/cma_debug.c index fdf899532ca0..8c7d7f8e8fbd 100644 --- a/mm/cma_debug.c +++ b/mm/cma_debug.c @@ -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; -- 2.43.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] mm: cma: simplify cma_maxchunk_get() 2025-07-19 20:54 ` [PATCH 2/2] mm: cma: simplify cma_maxchunk_get() Yury Norov @ 2025-07-21 10:59 ` David Hildenbrand 0 siblings, 0 replies; 5+ messages in thread From: David Hildenbrand @ 2025-07-21 10:59 UTC (permalink / raw) To: Yury Norov, Andrew Morton, linux-mm, linux-kernel On 19.07.25 22:54, Yury Norov wrote: > From: Yury Norov (NVIDIA) <yury.norov@gmail.com> > > 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. Acked-by: David Hildenbrand <david@redhat.com> > > Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com> > --- > mm/cma_debug.c | 10 +--------- > 1 file changed, 1 insertion(+), 9 deletions(-) > > diff --git a/mm/cma_debug.c b/mm/cma_debug.c > index fdf899532ca0..8c7d7f8e8fbd 100644 > --- a/mm/cma_debug.c > +++ b/mm/cma_debug.c > @@ -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; -- Cheers, David / dhildenb ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-21 11:01 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-07-19 20:53 [PATCH 0/2] mm/cma: ise for_each_clear_bitrange() where appropriate Yury Norov 2025-07-19 20:53 ` [PATCH 1/2] mm: cma: simplify cma_debug_show_areas() Yury Norov 2025-07-21 11:01 ` David Hildenbrand 2025-07-19 20:54 ` [PATCH 2/2] mm: cma: simplify cma_maxchunk_get() Yury Norov 2025-07-21 10:59 ` David Hildenbrand
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox