BACKPORT: FROMGIT: mm: vmstat: add cma statistics
Since CMA is used more widely, it's worth to have CMA allocation statistics into vmstat. With it, we could know how agressively system uses cma allocation and how often it fails. Link: https://lkml.kernel.org/r/20210302183346.3707237-1-minchan@kernel.org Signed-off-by: Minchan Kim <minchan@kernel.org> Reviewed-by: John Hubbard <jhubbard@nvidia.com> Cc: John Dias <joaodias@google.com> Cc: Suren Baghdasaryan <surenb@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Bug: 181887812 Signed-off-by: Minchan Kim <minchan@google.com> (cherry picked from https://lore.kernel.org/mm-commits/20210302232736.Dy5dxmWpK%25akpm@linux-foundation.org/) [minchan: Resolved minor bailout path in mm/cma.c ] Change-Id: Ib5a8cfd0944689e84c8bbf136d215981e956b82f
This commit is contained in:
committed by
Suren Baghdasaryan
parent
cd6aa9911d
commit
0fb3917d8a
@@ -70,6 +70,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
|
||||
#endif
|
||||
#ifdef CONFIG_HUGETLB_PAGE
|
||||
HTLB_BUDDY_PGALLOC, HTLB_BUDDY_PGALLOC_FAIL,
|
||||
#endif
|
||||
#ifdef CONFIG_CMA
|
||||
CMA_ALLOC_SUCCESS,
|
||||
CMA_ALLOC_FAIL,
|
||||
#endif
|
||||
UNEVICTABLE_PGCULLED, /* culled to noreclaim list */
|
||||
UNEVICTABLE_PGSCANNED, /* scanned for reclaimability */
|
||||
|
||||
12
mm/cma.c
12
mm/cma.c
@@ -441,13 +441,13 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
|
||||
int max_retries = 5;
|
||||
|
||||
if (!cma || !cma->count || !cma->bitmap)
|
||||
return NULL;
|
||||
goto out;
|
||||
|
||||
pr_debug("%s(cma %p, count %zu, align %d gfp_mask 0x%x)\n", __func__,
|
||||
(void *)cma, count, align, gfp_mask);
|
||||
|
||||
if (!count)
|
||||
return NULL;
|
||||
goto out;
|
||||
|
||||
mask = cma_bitmap_aligned_mask(cma, align);
|
||||
offset = cma_bitmap_aligned_offset(cma, align);
|
||||
@@ -455,7 +455,7 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
|
||||
bitmap_count = cma_bitmap_pages_to_bits(cma, count);
|
||||
|
||||
if (bitmap_count > bitmap_maxno)
|
||||
return NULL;
|
||||
goto out;
|
||||
|
||||
for (;;) {
|
||||
mutex_lock(&cma->lock);
|
||||
@@ -530,6 +530,12 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
|
||||
}
|
||||
|
||||
pr_debug("%s(): returned %p\n", __func__, page);
|
||||
out:
|
||||
if (page)
|
||||
count_vm_event(CMA_ALLOC_SUCCESS);
|
||||
else
|
||||
count_vm_event(CMA_ALLOC_FAIL);
|
||||
|
||||
return page;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cma_alloc);
|
||||
|
||||
@@ -1295,6 +1295,10 @@ const char * const vmstat_text[] = {
|
||||
#ifdef CONFIG_HUGETLB_PAGE
|
||||
"htlb_buddy_alloc_success",
|
||||
"htlb_buddy_alloc_fail",
|
||||
#endif
|
||||
#ifdef CONFIG_CMA
|
||||
"cma_alloc_success",
|
||||
"cma_alloc_fail",
|
||||
#endif
|
||||
"unevictable_pgs_culled",
|
||||
"unevictable_pgs_scanned",
|
||||
|
||||
Reference in New Issue
Block a user