From: Yury Norov <yury.norov@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Yury Norov <yury.norov@gmail.com>
Subject: [PATCH 1/2] mm: cma: simplify cma_debug_show_areas()
Date: Sat, 19 Jul 2025 16:53:59 -0400 [thread overview]
Message-ID: <20250719205401.399475-2-yury.norov@gmail.com> (raw)
In-Reply-To: <20250719205401.399475-1-yury.norov@gmail.com>
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
next prev parent reply other threads:[~2025-07-19 20:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-07-21 11:01 ` [PATCH 1/2] mm: cma: simplify cma_debug_show_areas() 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250719205401.399475-2-yury.norov@gmail.com \
--to=yury.norov@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).