summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorBarry Song <song.bao.hua@hisilicon.com>2020-08-24 01:03:09 +0200
committerChristoph Hellwig <hch@lst.de>2020-09-01 09:19:43 +0200
commit2281f797f5524abb8fff66bf8540b4f4687332a2 (patch)
tree13ce4ce2bf6a70c115809e883e5c5e6f10f9e58a /mm
parentarm64: mm: reserve per-numa CMA to localize coherent dma buffers (diff)
downloadlinux-2281f797f5524abb8fff66bf8540b4f4687332a2.tar.xz
linux-2281f797f5524abb8fff66bf8540b4f4687332a2.zip
mm: cma: use CMA_MAX_NAME to define the length of cma name array
CMA_MAX_NAME should be visible to CMA's users as they might need it to set the name of CMA areas and avoid hardcoding the size locally. So this patch moves CMA_MAX_NAME from local header file to include/linux header file and removes the hardcode in both hugetlb.c and contiguous.c. Signed-off-by: Barry Song <song.bao.hua@hisilicon.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'mm')
-rw-r--r--mm/cma.h2
-rw-r--r--mm/hugetlb.c4
2 files changed, 2 insertions, 4 deletions
diff --git a/mm/cma.h b/mm/cma.h
index 20f6e24bc477..42ae082cb067 100644
--- a/mm/cma.h
+++ b/mm/cma.h
@@ -4,8 +4,6 @@
#include <linux/debugfs.h>
-#define CMA_MAX_NAME 64
-
struct cma {
unsigned long base_pfn;
unsigned long count;
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a301c2d672bf..9eec0ea9ba68 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5683,12 +5683,12 @@ void __init hugetlb_cma_reserve(int order)
reserved = 0;
for_each_node_state(nid, N_ONLINE) {
int res;
- char name[20];
+ char name[CMA_MAX_NAME];
size = min(per_node, hugetlb_cma_size - reserved);
size = round_up(size, PAGE_SIZE << order);
- snprintf(name, 20, "hugetlb%d", nid);
+ snprintf(name, sizeof(name), "hugetlb%d", nid);
res = cma_declare_contiguous_nid(0, size, 0, PAGE_SIZE << order,
0, false, name,
&hugetlb_cma[nid], nid);