mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
mm: cma: add CmaAllocated/CmaReleased info for meminfo node
Show the CMA pages used by cma_alloc in meminfo node. Tested on RV1126 EVB DDR3: CmaTotal: 270336 kB CmaAllocated: 44408 kB CmaReleased: 225928 kB CmaFree: 0 kB The CmaTotal = CmaAllocated + CmaReleased, and the CmaFree is pages under cma area unused by system. The CmaAllocated can be calculated by CMA_DEBUGFS. Tested on RV1126 EVB DDR3: cat /sys/kernel/debug/cma/*/used 10756 346 The results from cma used is in page count, 1 page = 4kByte CmaAllocated = 44408kB = 10756 + 346 pages Change-Id: Ib79001367562c968e6432816b158cba551978173 Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
This commit is contained in:
@@ -144,6 +144,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
|
||||
|
||||
#ifdef CONFIG_CMA
|
||||
show_val_kb(m, "CmaTotal: ", totalcma_pages);
|
||||
show_val_kb(m, "CmaAllocated: ", cma_used_pages());
|
||||
show_val_kb(m, "CmaReleased: ", totalcma_pages - cma_used_pages());
|
||||
show_val_kb(m, "CmaFree: ",
|
||||
global_zone_page_state(NR_FREE_CMA_PAGES));
|
||||
#endif
|
||||
|
||||
@@ -35,6 +35,7 @@ extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
|
||||
extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
|
||||
bool no_warn);
|
||||
extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count);
|
||||
extern unsigned long cma_used_pages(void);
|
||||
|
||||
extern int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data);
|
||||
|
||||
|
||||
18
mm/cma.c
18
mm/cma.c
@@ -555,6 +555,24 @@ bool cma_release(struct cma *cma, const struct page *pages, unsigned int count)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cma_release);
|
||||
|
||||
unsigned long cma_used_pages(void)
|
||||
{
|
||||
struct cma *cma;
|
||||
unsigned long used;
|
||||
unsigned long val = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < cma_area_count; i++) {
|
||||
cma = &cma_areas[i];
|
||||
mutex_lock(&cma->lock);
|
||||
used = bitmap_weight(cma->bitmap, (int)cma_bitmap_maxno(cma));
|
||||
mutex_unlock(&cma->lock);
|
||||
val += used << cma->order_per_bit;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cma_used_pages);
|
||||
|
||||
int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data)
|
||||
{
|
||||
int i;
|
||||
|
||||
Reference in New Issue
Block a user