* [PATCH] lib/show_mem.c: correct reserved memory calculation
@ 2015-07-20 9:14 Vishnu Pratap Singh
2015-07-20 22:48 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Vishnu Pratap Singh @ 2015-07-20 9:14 UTC (permalink / raw)
To: akpm, linux, riel, isimatu.yasuaki, aquini, linux-kernel
Cc: cpgs, vishu13285, pintu.k, rohit.kr, Vishnu Pratap Singh
CMA reserved memory is not part of total reserved memory.
Currently when we print the total reserve memory it considers
cma as part of reserve memory and do minus of totalcma_pages
from reserved, which is wrong. In cases where total reserved
is less than cma reserved we will get negative values & while
printing we print as unsigned and we will get a very large value.
Below is the show mem output on X86 ubuntu based system where
CMA reserved is 100MB (25600 pages) & total reserved is ~40MB(10316 pages).
And reserve memory shows a large value because of this bug.
Before:
[ 127.066430] 898908 pages RAM
[ 127.066432] 671682 pages HighMem/MovableOnly
[ 127.066434] 4294952012 pages reserved
[ 127.066436] 25600 pages cma reserved
After:
[ 44.663129] 898908 pages RAM
[ 44.663130] 671682 pages HighMem/MovableOnly
[ 44.663130] 10316 pages reserved
[ 44.663131] 25600 pages cma reserved
Also this patch change printk to pr_info.
Signed-off-by: Vishnu Pratap Singh <vishnu.ps@samsung.com>
---
lib/show_mem.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/lib/show_mem.c b/lib/show_mem.c
index adc98e18..0af5ede 100644
--- a/lib/show_mem.c
+++ b/lib/show_mem.c
@@ -14,7 +14,7 @@ void show_mem(unsigned int filter)
pg_data_t *pgdat;
unsigned long total = 0, reserved = 0, highmem = 0;
- printk("Mem-Info:\n");
+ pr_info("Mem-Info:\n");
show_free_areas(filter);
for_each_online_pgdat(pgdat) {
@@ -36,19 +36,18 @@ void show_mem(unsigned int filter)
pgdat_resize_unlock(pgdat, &flags);
}
- printk("%lu pages RAM\n", total);
- printk("%lu pages HighMem/MovableOnly\n", highmem);
+ pr_info("%lu pages RAM\n", total);
+ pr_info("%lu pages HighMem/MovableOnly\n", highmem);
+ pr_info("%lu pages reserved\n", reserved);
#ifdef CONFIG_CMA
- printk("%lu pages reserved\n", (reserved - totalcma_pages));
- printk("%lu pages cma reserved\n", totalcma_pages);
-#else
- printk("%lu pages reserved\n", reserved);
+ pr_info("%lu pages cma reserved\n", totalcma_pages);
#endif
#ifdef CONFIG_QUICKLIST
- printk("%lu pages in pagetable cache\n",
+ pr_info("%lu pages in pagetable cache\n",
quicklist_total_size());
#endif
#ifdef CONFIG_MEMORY_FAILURE
- printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
+ pr_info("%lu pages hwpoisoned\n",
+ atomic_long_read(&num_poisoned_pages));
#endif
}
--
1.7.9.5
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] lib/show_mem.c: correct reserved memory calculation
2015-07-20 9:14 [PATCH] lib/show_mem.c: correct reserved memory calculation Vishnu Pratap Singh
@ 2015-07-20 22:48 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2015-07-20 22:48 UTC (permalink / raw)
To: Vishnu Pratap Singh
Cc: linux, riel, isimatu.yasuaki, aquini, linux-kernel, cpgs,
vishu13285, pintu.k, rohit.kr
On Mon, 20 Jul 2015 14:44:25 +0530 Vishnu Pratap Singh <vishnu.ps@samsung.com> wrote:
> CMA reserved memory is not part of total reserved memory.
> Currently when we print the total reserve memory it considers
> cma as part of reserve memory and do minus of totalcma_pages
> from reserved, which is wrong. In cases where total reserved
> is less than cma reserved we will get negative values & while
> printing we print as unsigned and we will get a very large value.
>
> Below is the show mem output on X86 ubuntu based system where
> CMA reserved is 100MB (25600 pages) & total reserved is ~40MB(10316 pages).
> And reserve memory shows a large value because of this bug.
>
> Before:
> [ 127.066430] 898908 pages RAM
> [ 127.066432] 671682 pages HighMem/MovableOnly
> [ 127.066434] 4294952012 pages reserved
> [ 127.066436] 25600 pages cma reserved
>
> After:
> [ 44.663129] 898908 pages RAM
> [ 44.663130] 671682 pages HighMem/MovableOnly
> [ 44.663130] 10316 pages reserved
> [ 44.663131] 25600 pages cma reserved
>
> Also this patch change printk to pr_info.
The pr_info change was irritating - it makes it quite hard to see the
functional change. Please don't mix changes like this, unless the
unrelated changes are trivial and don't hamper review.
This is what the patch actually does:
--- a/lib/show_mem.c~lib-show_memc-correct-reserved-memory-calculation
+++ a/lib/show_mem.c
@@ -38,11 +38,9 @@ void show_mem(unsigned int filter)
printk("%lu pages RAM\n", total);
printk("%lu pages HighMem/MovableOnly\n", highmem);
+ printk("%lu pages reserved\n", reserved);
#ifdef CONFIG_CMA
- printk("%lu pages reserved\n", (reserved - totalcma_pages));
printk("%lu pages cma reserved\n", totalcma_pages);
-#else
- printk("%lu pages reserved\n", reserved);
#endif
#ifdef CONFIG_QUICKLIST
printk("%lu pages in pagetable cache\n",
_
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-07-20 22:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-20 9:14 [PATCH] lib/show_mem.c: correct reserved memory calculation Vishnu Pratap Singh
2015-07-20 22:48 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®