@@ -45,7 +45,10 @@ int hugetlb_max_hstate __read_mostly;
45
45
unsigned int default_hstate_idx ;
46
46
struct hstate hstates [HUGE_MAX_HSTATE ];
47
47
48
+ #ifdef CONFIG_CMA
48
49
static struct cma * hugetlb_cma [MAX_NUMNODES ];
50
+ #endif
51
+ static unsigned long hugetlb_cma_size __initdata ;
49
52
50
53
/*
51
54
* Minimum page order among possible hugepage sizes, set to a proper value
@@ -1235,9 +1238,10 @@ static void free_gigantic_page(struct page *page, unsigned int order)
1235
1238
* If the page isn't allocated using the cma allocator,
1236
1239
* cma_release() returns false.
1237
1240
*/
1238
- if ( IS_ENABLED ( CONFIG_CMA ) &&
1239
- cma_release (hugetlb_cma [page_to_nid (page )], page , 1 << order ))
1241
+ #ifdef CONFIG_CMA
1242
+ if ( cma_release (hugetlb_cma [page_to_nid (page )], page , 1 << order ))
1240
1243
return ;
1244
+ #endif
1241
1245
1242
1246
free_contig_range (page_to_pfn (page ), 1 << order );
1243
1247
}
@@ -1248,7 +1252,8 @@ static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask,
1248
1252
{
1249
1253
unsigned long nr_pages = 1UL << huge_page_order (h );
1250
1254
1251
- if (IS_ENABLED (CONFIG_CMA )) {
1255
+ #ifdef CONFIG_CMA
1256
+ {
1252
1257
struct page * page ;
1253
1258
int node ;
1254
1259
@@ -1262,6 +1267,7 @@ static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask,
1262
1267
return page ;
1263
1268
}
1264
1269
}
1270
+ #endif
1265
1271
1266
1272
return alloc_contig_pages (nr_pages , gfp_mask , nid , nodemask );
1267
1273
}
@@ -2571,7 +2577,7 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h)
2571
2577
2572
2578
for (i = 0 ; i < h -> max_huge_pages ; ++ i ) {
2573
2579
if (hstate_is_gigantic (h )) {
2574
- if (IS_ENABLED ( CONFIG_CMA ) && hugetlb_cma [ 0 ] ) {
2580
+ if (hugetlb_cma_size ) {
2575
2581
pr_warn_once ("HugeTLB: hugetlb_cma is enabled, skip boot time allocation\n" );
2576
2582
break ;
2577
2583
}
@@ -5654,7 +5660,6 @@ void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason)
5654
5660
}
5655
5661
5656
5662
#ifdef CONFIG_CMA
5657
- static unsigned long hugetlb_cma_size __initdata ;
5658
5663
static bool cma_reserve_called __initdata ;
5659
5664
5660
5665
static int __init cmdline_parse_hugetlb_cma (char * p )
0 commit comments