Skip to content

Commit 031bc57

Browse files
JoonsooKimtorvalds
authored andcommitted
mm/debug-pagealloc: make debug-pagealloc boottime configurable
Now, we have prepared to avoid using debug-pagealloc in boottime. So introduce new kernel-parameter to disable debug-pagealloc in boottime, and makes related functions to be disabled in this case. Only non-intuitive part is change of guard page functions. Because guard page is effective only if debug-pagealloc is enabled, turning off according to debug-pagealloc is reasonable thing to do. Signed-off-by: Joonsoo Kim <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Michal Nazarewicz <[email protected]> Cc: Jungsoo Son <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Joonsoo Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent e30825f commit 031bc57

File tree

9 files changed

+57
-7
lines changed

9 files changed

+57
-7
lines changed

Documentation/kernel-parameters.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,15 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
829829
CONFIG_DEBUG_PAGEALLOC, hence this option will not help
830830
tracking down these problems.
831831

832+
debug_pagealloc=
833+
[KNL] When CONFIG_DEBUG_PAGEALLOC is set, this
834+
parameter enables the feature at boot time. In
835+
default, it is disabled. We can avoid allocating huge
836+
chunk of memory for debug pagealloc if we don't enable
837+
it at boot time and the system will work mostly same
838+
with the kernel built without CONFIG_DEBUG_PAGEALLOC.
839+
on: enable the feature
840+
832841
debugpat [X86] Enable PAT debugging
833842

834843
decnet.addr= [HW,NET]

arch/powerpc/mm/hash_utils_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi)
15141514
mmu_kernel_ssize, 0);
15151515
}
15161516

1517-
void kernel_map_pages(struct page *page, int numpages, int enable)
1517+
void __kernel_map_pages(struct page *page, int numpages, int enable)
15181518
{
15191519
unsigned long flags, vaddr, lmi;
15201520
int i;

arch/powerpc/mm/pgtable_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ static int change_page_attr(struct page *page, int numpages, pgprot_t prot)
429429
}
430430

431431

432-
void kernel_map_pages(struct page *page, int numpages, int enable)
432+
void __kernel_map_pages(struct page *page, int numpages, int enable)
433433
{
434434
if (PageHighMem(page))
435435
return;

arch/s390/mm/pageattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static void ipte_range(pte_t *pte, unsigned long address, int nr)
120120
}
121121
}
122122

123-
void kernel_map_pages(struct page *page, int numpages, int enable)
123+
void __kernel_map_pages(struct page *page, int numpages, int enable)
124124
{
125125
unsigned long address;
126126
int nr, i, j;

arch/sparc/mm/init_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ static void __init kernel_physical_mapping_init(void)
16211621
}
16221622

16231623
#ifdef CONFIG_DEBUG_PAGEALLOC
1624-
void kernel_map_pages(struct page *page, int numpages, int enable)
1624+
void __kernel_map_pages(struct page *page, int numpages, int enable)
16251625
{
16261626
unsigned long phys_start = page_to_pfn(page) << PAGE_SHIFT;
16271627
unsigned long phys_end = phys_start + (numpages * PAGE_SIZE);

arch/x86/mm/pageattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ static int __set_pages_np(struct page *page, int numpages)
18171817
return __change_page_attr_set_clr(&cpa, 0);
18181818
}
18191819

1820-
void kernel_map_pages(struct page *page, int numpages, int enable)
1820+
void __kernel_map_pages(struct page *page, int numpages, int enable)
18211821
{
18221822
if (PageHighMem(page))
18231823
return;

include/linux/mm.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2061,7 +2061,22 @@ static inline void vm_stat_account(struct mm_struct *mm,
20612061
#endif /* CONFIG_PROC_FS */
20622062

20632063
#ifdef CONFIG_DEBUG_PAGEALLOC
2064-
extern void kernel_map_pages(struct page *page, int numpages, int enable);
2064+
extern bool _debug_pagealloc_enabled;
2065+
extern void __kernel_map_pages(struct page *page, int numpages, int enable);
2066+
2067+
static inline bool debug_pagealloc_enabled(void)
2068+
{
2069+
return _debug_pagealloc_enabled;
2070+
}
2071+
2072+
static inline void
2073+
kernel_map_pages(struct page *page, int numpages, int enable)
2074+
{
2075+
if (!debug_pagealloc_enabled())
2076+
return;
2077+
2078+
__kernel_map_pages(page, numpages, enable);
2079+
}
20652080
#ifdef CONFIG_HIBERNATION
20662081
extern bool kernel_page_present(struct page *page);
20672082
#endif /* CONFIG_HIBERNATION */

mm/debug-pagealloc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ static bool page_poisoning_enabled __read_mostly;
1010

1111
static bool need_page_poisoning(void)
1212
{
13+
if (!debug_pagealloc_enabled())
14+
return false;
15+
1316
return true;
1417
}
1518

1619
static void init_page_poisoning(void)
1720
{
21+
if (!debug_pagealloc_enabled())
22+
return;
23+
1824
page_poisoning_enabled = true;
1925
}
2026

@@ -119,7 +125,7 @@ static void unpoison_pages(struct page *page, int n)
119125
unpoison_page(page + i);
120126
}
121127

122-
void kernel_map_pages(struct page *page, int numpages, int enable)
128+
void __kernel_map_pages(struct page *page, int numpages, int enable)
123129
{
124130
if (!page_poisoning_enabled)
125131
return;

mm/page_alloc.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,35 @@ static inline void prep_zero_page(struct page *page, unsigned int order,
425425

426426
#ifdef CONFIG_DEBUG_PAGEALLOC
427427
unsigned int _debug_guardpage_minorder;
428+
bool _debug_pagealloc_enabled __read_mostly;
428429
bool _debug_guardpage_enabled __read_mostly;
429430

431+
static int __init early_debug_pagealloc(char *buf)
432+
{
433+
if (!buf)
434+
return -EINVAL;
435+
436+
if (strcmp(buf, "on") == 0)
437+
_debug_pagealloc_enabled = true;
438+
439+
return 0;
440+
}
441+
early_param("debug_pagealloc", early_debug_pagealloc);
442+
430443
static bool need_debug_guardpage(void)
431444
{
445+
/* If we don't use debug_pagealloc, we don't need guard page */
446+
if (!debug_pagealloc_enabled())
447+
return false;
448+
432449
return true;
433450
}
434451

435452
static void init_debug_guardpage(void)
436453
{
454+
if (!debug_pagealloc_enabled())
455+
return;
456+
437457
_debug_guardpage_enabled = true;
438458
}
439459

0 commit comments

Comments
 (0)