From: Yue Hu <zbestahu@gmail.com>
To: akpm@linux-foundation.org, iamjoonsoo.kim@lge.com,
mingo@kernel.org, vbabka@suse.cz, rppt@linux.vnet.ibm.com,
rdunlap@infradead.org
Cc: linux-mm@kvack.org, huyue2@yulong.com
Subject: [PATCH] mm/cma: fix the bitmap status to show failed allocation reason
Date: Wed, 20 Mar 2019 14:08:29 +0800 [thread overview]
Message-ID: <20190320060829.9144-1-zbestahu@gmail.com> (raw)
From: Yue Hu <huyue2@yulong.com>
Currently one bit in cma bitmap represents number of pages rather than
one page, cma->count means cma size in pages. So to find available pages
via find_next_zero_bit()/find_next_bit() we should use cma size not in
pages but in bits although current free pages number is correct due to
zero value of order_per_bit. Once order_per_bit is changed the bitmap
status will be incorrect.
Signed-off-by: Yue Hu <huyue2@yulong.com>
---
mm/cma.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/mm/cma.c b/mm/cma.c
index 5809bbe..6a7aa05 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -367,23 +367,26 @@ int __init cma_declare_contiguous(phys_addr_t base,
#ifdef CONFIG_CMA_DEBUG
static void cma_debug_show_areas(struct cma *cma)
{
- unsigned long next_zero_bit, next_set_bit;
+ unsigned long next_zero_bit, next_set_bit, nr_zero;
unsigned long start = 0;
- unsigned int nr_zero, nr_total = 0;
+ unsigned long nr_part, nr_total = 0;
+ unsigned long nbits = cma_bitmap_maxno(cma);
mutex_lock(&cma->lock);
pr_info("number of available pages: ");
for (;;) {
- next_zero_bit = find_next_zero_bit(cma->bitmap, cma->count, start);
- if (next_zero_bit >= cma->count)
+ next_zero_bit = find_next_zero_bit(cma->bitmap, nbits, start);
+ if (next_zero_bit >= nbits)
break;
- next_set_bit = find_next_bit(cma->bitmap, cma->count, next_zero_bit);
+ next_set_bit = find_next_bit(cma->bitmap, nbits, next_zero_bit);
nr_zero = next_set_bit - next_zero_bit;
- pr_cont("%s%u@%lu", nr_total ? "+" : "", nr_zero, next_zero_bit);
- nr_total += nr_zero;
+ nr_part = nr_zero << cma->order_per_bit;
+ pr_cont("%s%lu@%lu", nr_total ? "+" : "", nr_part,
+ next_zero_bit);
+ nr_total += nr_part;
start = next_zero_bit + nr_zero;
}
- pr_cont("=> %u free of %lu total pages\n", nr_total, cma->count);
+ pr_cont("=> %lu free of %lu total pages\n", nr_total, cma->count);
mutex_unlock(&cma->lock);
}
#else
--
1.9.1
next reply other threads:[~2019-03-20 6:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-20 6:08 Yue Hu [this message]
2019-03-20 22:12 ` [PATCH] mm/cma: fix the bitmap status to show failed allocation reason Andrew Morton
2019-03-21 2:17 ` Yue Hu
2019-03-21 2:58 ` Andrew Morton
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=20190320060829.9144-1-zbestahu@gmail.com \
--to=zbestahu@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=huyue2@yulong.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-mm@kvack.org \
--cc=mingo@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rppt@linux.vnet.ibm.com \
--cc=vbabka@suse.cz \
/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).