Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Barry Song and committed by
Christoph Hellwig
2281f797 c6303ab9

+5 -5
+2
include/linux/cma.h
··· 18 18 19 19 #endif 20 20 21 + #define CMA_MAX_NAME 64 22 + 21 23 struct cma; 22 24 23 25 extern unsigned long totalcma_pages;
+1 -1
kernel/dma/contiguous.c
··· 119 119 120 120 for_each_online_node(nid) { 121 121 int ret; 122 - char name[20]; 122 + char name[CMA_MAX_NAME]; 123 123 struct cma **cma = &dma_contiguous_pernuma_area[nid]; 124 124 125 125 snprintf(name, sizeof(name), "pernuma%d", nid);
-2
mm/cma.h
··· 4 4 5 5 #include <linux/debugfs.h> 6 6 7 - #define CMA_MAX_NAME 64 8 - 9 7 struct cma { 10 8 unsigned long base_pfn; 11 9 unsigned long count;
+2 -2
mm/hugetlb.c
··· 5683 5683 reserved = 0; 5684 5684 for_each_node_state(nid, N_ONLINE) { 5685 5685 int res; 5686 - char name[20]; 5686 + char name[CMA_MAX_NAME]; 5687 5687 5688 5688 size = min(per_node, hugetlb_cma_size - reserved); 5689 5689 size = round_up(size, PAGE_SIZE << order); 5690 5690 5691 - snprintf(name, 20, "hugetlb%d", nid); 5691 + snprintf(name, sizeof(name), "hugetlb%d", nid); 5692 5692 res = cma_declare_contiguous_nid(0, size, 0, PAGE_SIZE << order, 5693 5693 0, false, name, 5694 5694 &hugetlb_cma[nid], nid);