linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390)
@ 2016-02-03  8:39 Christian Borntraeger
  2016-02-03  8:39 ` [PATCH v4 1/4] mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC Christian Borntraeger
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Christian Borntraeger @ 2016-02-03  8:39 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, linux-mm, x86, Thomas Gleixner, David Rientjes,
	Christian Borntraeger

Andrew, here is a resend as these patches were dropped as I also 
had them on my linux-next branch (instead of a private one)

As CONFIG_DEBUG_PAGEALLOC can be enabled/disabled via kernel
parameters we can optimize some cases by checking the enablement
state.

I have done s390 and x86. Other architecture can follow as necessary.

Christian Borntraeger (4):
  mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC
  x86: query dynamic DEBUG_PAGEALLOC setting
  s390: query dynamic DEBUG_PAGEALLOC setting
  x86: also use debug_pagealloc_enabled() for free_init_pages

 arch/s390/kernel/dumpstack.c |  6 +++---
 arch/s390/mm/vmem.c          | 10 ++++------
 arch/x86/kernel/dumpstack.c  |  5 ++---
 arch/x86/mm/init.c           | 36 +++++++++++++++++++-----------------
 arch/x86/mm/pageattr.c       | 14 ++++----------
 include/linux/mm.h           |  9 +++++++--
 6 files changed, 39 insertions(+), 41 deletions(-)

-- 
2.3.0

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v4 1/4] mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC
  2016-02-03  8:39 [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger
@ 2016-02-03  8:39 ` Christian Borntraeger
  2016-02-03  8:39 ` [PATCH v4 2/4] x86: query dynamic DEBUG_PAGEALLOC setting Christian Borntraeger
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Christian Borntraeger @ 2016-02-03  8:39 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, linux-mm, x86, Thomas Gleixner, David Rientjes,
	Christian Borntraeger

We can provide debug_pagealloc_enabled() also if CONFIG_DEBUG_PAGEALLOC
is not set. It will return false in that case.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/mm.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index f1cd22f..ae84716 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2194,13 +2194,18 @@ kernel_map_pages(struct page *page, int numpages, int enable)
 #ifdef CONFIG_HIBERNATION
 extern bool kernel_page_present(struct page *page);
 #endif /* CONFIG_HIBERNATION */
-#else
+#else  /* CONFIG_DEBUG_PAGEALLOC */
+static inline bool debug_pagealloc_enabled(void)
+{
+	return false;
+}
+
 static inline void
 kernel_map_pages(struct page *page, int numpages, int enable) {}
 #ifdef CONFIG_HIBERNATION
 static inline bool kernel_page_present(struct page *page) { return true; }
 #endif /* CONFIG_HIBERNATION */
-#endif
+#endif /* CONFIG_DEBUG_PAGEALLOC */
 
 #ifdef __HAVE_ARCH_GATE_AREA
 extern struct vm_area_struct *get_gate_vma(struct mm_struct *mm);
-- 
2.3.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 2/4] x86: query dynamic DEBUG_PAGEALLOC setting
  2016-02-03  8:39 [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger
  2016-02-03  8:39 ` [PATCH v4 1/4] mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC Christian Borntraeger
@ 2016-02-03  8:39 ` Christian Borntraeger
  2016-02-03 22:48   ` David Rientjes
  2016-02-03  8:39 ` [PATCH v4 3/4] s390: " Christian Borntraeger
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Christian Borntraeger @ 2016-02-03  8:39 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, linux-mm, x86, Thomas Gleixner, David Rientjes,
	Christian Borntraeger

We can use debug_pagealloc_enabled() to check if we can map
the identity mapping with 2MB pages. We can also add the state
into the dump_stack output.

The patch does not touch the code for the 1GB pages, which ignored
CONFIG_DEBUG_PAGEALLOC. Do we need to fence this as well?

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/dumpstack.c |  5 ++---
 arch/x86/mm/init.c          |  7 ++++---
 arch/x86/mm/pageattr.c      | 14 ++++----------
 3 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 9c30acf..32e5699 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -265,9 +265,8 @@ int __die(const char *str, struct pt_regs *regs, long err)
 #ifdef CONFIG_SMP
 	printk("SMP ");
 #endif
-#ifdef CONFIG_DEBUG_PAGEALLOC
-	printk("DEBUG_PAGEALLOC ");
-#endif
+	if (debug_pagealloc_enabled())
+		printk("DEBUG_PAGEALLOC ");
 #ifdef CONFIG_KASAN
 	printk("KASAN");
 #endif
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 493f541..39823fd 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -150,13 +150,14 @@ static int page_size_mask;
 
 static void __init probe_page_size_mask(void)
 {
-#if !defined(CONFIG_DEBUG_PAGEALLOC) && !defined(CONFIG_KMEMCHECK)
+#if !defined(CONFIG_KMEMCHECK)
 	/*
-	 * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
+	 * For CONFIG_KMEMCHECK or pagealloc debugging, identity mapping will
+	 * use small pages.
 	 * This will simplify cpa(), which otherwise needs to support splitting
 	 * large pages into small in interrupt context, etc.
 	 */
-	if (cpu_has_pse)
+	if (cpu_has_pse && !debug_pagealloc_enabled())
 		page_size_mask |= 1 << PG_LEVEL_2M;
 #endif
 
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 2440814..1ef9c2c 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -106,12 +106,6 @@ static inline unsigned long highmap_end_pfn(void)
 
 #endif
 
-#ifdef CONFIG_DEBUG_PAGEALLOC
-# define debug_pagealloc 1
-#else
-# define debug_pagealloc 0
-#endif
-
 static inline int
 within(unsigned long addr, unsigned long start, unsigned long end)
 {
@@ -708,10 +702,10 @@ static int split_large_page(struct cpa_data *cpa, pte_t *kpte,
 {
 	struct page *base;
 
-	if (!debug_pagealloc)
+	if (!debug_pagealloc_enabled())
 		spin_unlock(&cpa_lock);
 	base = alloc_pages(GFP_KERNEL | __GFP_NOTRACK, 0);
-	if (!debug_pagealloc)
+	if (!debug_pagealloc_enabled())
 		spin_lock(&cpa_lock);
 	if (!base)
 		return -ENOMEM;
@@ -1331,10 +1325,10 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
 		if (cpa->flags & (CPA_ARRAY | CPA_PAGES_ARRAY))
 			cpa->numpages = 1;
 
-		if (!debug_pagealloc)
+		if (!debug_pagealloc_enabled())
 			spin_lock(&cpa_lock);
 		ret = __change_page_attr(cpa, checkalias);
-		if (!debug_pagealloc)
+		if (!debug_pagealloc_enabled())
 			spin_unlock(&cpa_lock);
 		if (ret)
 			return ret;
-- 
2.3.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 3/4] s390: query dynamic DEBUG_PAGEALLOC setting
  2016-02-03  8:39 [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger
  2016-02-03  8:39 ` [PATCH v4 1/4] mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC Christian Borntraeger
  2016-02-03  8:39 ` [PATCH v4 2/4] x86: query dynamic DEBUG_PAGEALLOC setting Christian Borntraeger
@ 2016-02-03  8:39 ` Christian Borntraeger
  2016-02-03 22:48   ` David Rientjes
  2016-02-03  8:39 ` [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages Christian Borntraeger
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Christian Borntraeger @ 2016-02-03  8:39 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, linux-mm, x86, Thomas Gleixner, David Rientjes,
	Christian Borntraeger

We can use debug_pagealloc_enabled() to check if we can map
the identity mapping with 1MB/2GB pages as well as to print
the current setting in dump_stack.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 arch/s390/kernel/dumpstack.c |  6 +++---
 arch/s390/mm/vmem.c          | 10 ++++------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/s390/kernel/dumpstack.c b/arch/s390/kernel/dumpstack.c
index 02bd02f..14c1ed3 100644
--- a/arch/s390/kernel/dumpstack.c
+++ b/arch/s390/kernel/dumpstack.c
@@ -11,6 +11,7 @@
 #include <linux/export.h>
 #include <linux/kdebug.h>
 #include <linux/ptrace.h>
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <asm/processor.h>
@@ -184,9 +185,8 @@ void die(struct pt_regs *regs, const char *str)
 #ifdef CONFIG_SMP
 	printk("SMP ");
 #endif
-#ifdef CONFIG_DEBUG_PAGEALLOC
-	printk("DEBUG_PAGEALLOC");
-#endif
+	if (debug_pagealloc_enabled())
+		printk("DEBUG_PAGEALLOC");
 	printk("\n");
 	notify_die(DIE_OOPS, str, regs, 0, regs->int_code & 0xffff, SIGSEGV);
 	print_modules();
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
index ef7d6c8..d27fccba 100644
--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -94,16 +94,15 @@ static int vmem_add_mem(unsigned long start, unsigned long size, int ro)
 			pgd_populate(&init_mm, pg_dir, pu_dir);
 		}
 		pu_dir = pud_offset(pg_dir, address);
-#ifndef CONFIG_DEBUG_PAGEALLOC
 		if (MACHINE_HAS_EDAT2 && pud_none(*pu_dir) && address &&
-		    !(address & ~PUD_MASK) && (address + PUD_SIZE <= end)) {
+		    !(address & ~PUD_MASK) && (address + PUD_SIZE <= end) &&
+		     !debug_pagealloc_enabled()) {
 			pud_val(*pu_dir) = __pa(address) |
 				_REGION_ENTRY_TYPE_R3 | _REGION3_ENTRY_LARGE |
 				(ro ? _REGION_ENTRY_PROTECT : 0);
 			address += PUD_SIZE;
 			continue;
 		}
-#endif
 		if (pud_none(*pu_dir)) {
 			pm_dir = vmem_pmd_alloc();
 			if (!pm_dir)
@@ -111,9 +110,9 @@ static int vmem_add_mem(unsigned long start, unsigned long size, int ro)
 			pud_populate(&init_mm, pu_dir, pm_dir);
 		}
 		pm_dir = pmd_offset(pu_dir, address);
-#ifndef CONFIG_DEBUG_PAGEALLOC
 		if (MACHINE_HAS_EDAT1 && pmd_none(*pm_dir) && address &&
-		    !(address & ~PMD_MASK) && (address + PMD_SIZE <= end)) {
+		    !(address & ~PMD_MASK) && (address + PMD_SIZE <= end) &&
+		    !debug_pagealloc_enabled()) {
 			pmd_val(*pm_dir) = __pa(address) |
 				_SEGMENT_ENTRY | _SEGMENT_ENTRY_LARGE |
 				_SEGMENT_ENTRY_YOUNG |
@@ -121,7 +120,6 @@ static int vmem_add_mem(unsigned long start, unsigned long size, int ro)
 			address += PMD_SIZE;
 			continue;
 		}
-#endif
 		if (pmd_none(*pm_dir)) {
 			pt_dir = vmem_pte_alloc(address);
 			if (!pt_dir)
-- 
2.3.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages
  2016-02-03  8:39 [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger
                   ` (2 preceding siblings ...)
  2016-02-03  8:39 ` [PATCH v4 3/4] s390: " Christian Borntraeger
@ 2016-02-03  8:39 ` Christian Borntraeger
  2016-02-03 10:43   ` Thomas Gleixner
  2016-02-03 22:50   ` David Rientjes
  2016-02-03  8:39 ` [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger
                   ` (4 subsequent siblings)
  8 siblings, 2 replies; 14+ messages in thread
From: Christian Borntraeger @ 2016-02-03  8:39 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, linux-mm, x86, Thomas Gleixner, David Rientjes,
	Christian Borntraeger

we want to couple all debugging features with debug_pagealloc_enabled()
and not with the config option CONFIG_DEBUG_PAGEALLOC.

Suggested-by: David Rientjes <rientjes@google.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/x86/mm/init.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 39823fd..9d56f27 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -667,21 +667,22 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
 	 * mark them not present - any buggy init-section access will
 	 * create a kernel page fault:
 	 */
-#ifdef CONFIG_DEBUG_PAGEALLOC
-	printk(KERN_INFO "debug: unmapping init [mem %#010lx-%#010lx]\n",
-		begin, end - 1);
-	set_memory_np(begin, (end - begin) >> PAGE_SHIFT);
-#else
-	/*
-	 * We just marked the kernel text read only above, now that
-	 * we are going to free part of that, we need to make that
-	 * writeable and non-executable first.
-	 */
-	set_memory_nx(begin, (end - begin) >> PAGE_SHIFT);
-	set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);
+	if (debug_pagealloc_enabled()) {
+		pr_info("debug: unmapping init [mem %#010lx-%#010lx]\n",
+			begin, end - 1);
+		set_memory_np(begin, (end - begin) >> PAGE_SHIFT);
+	} else {
+		/*
+		 * We just marked the kernel text read only above, now that
+		 * we are going to free part of that, we need to make that
+		 * writeable and non-executable first.
+		 */
+		set_memory_nx(begin, (end - begin) >> PAGE_SHIFT);
+		set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);
 
-	free_reserved_area((void *)begin, (void *)end, POISON_FREE_INITMEM, what);
-#endif
+		free_reserved_area((void *)begin, (void *)end,
+				   POISON_FREE_INITMEM, what);
+	}
 }
 
 void free_initmem(void)
-- 
2.3.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390)
  2016-02-03  8:39 [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger
                   ` (3 preceding siblings ...)
  2016-02-03  8:39 ` [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages Christian Borntraeger
@ 2016-02-03  8:39 ` Christian Borntraeger
  2016-02-03  8:39 ` [PATCH v4 1/4] mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC Christian Borntraeger
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Christian Borntraeger @ 2016-02-03  8:39 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, linux-mm, x86, Thomas Gleixner, David Rientjes,
	Christian Borntraeger

Andrew, here is a resend as these patches were dropped as I also 
had them on my linux-next branch (instead of a private one)

As CONFIG_DEBUG_PAGEALLOC can be enabled/disabled via kernel
parameters we can optimize some cases by checking the enablement
state.

I have done s390 and x86. Other architecture can follow as necessary.

Christian Borntraeger (4):
  mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC
  x86: query dynamic DEBUG_PAGEALLOC setting
  s390: query dynamic DEBUG_PAGEALLOC setting
  x86: also use debug_pagealloc_enabled() for free_init_pages

 arch/s390/kernel/dumpstack.c |  6 +++---
 arch/s390/mm/vmem.c          | 10 ++++------
 arch/x86/kernel/dumpstack.c  |  5 ++---
 arch/x86/mm/init.c           | 36 +++++++++++++++++++-----------------
 arch/x86/mm/pageattr.c       | 14 ++++----------
 include/linux/mm.h           |  9 +++++++--
 6 files changed, 39 insertions(+), 41 deletions(-)

-- 
2.3.0

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v4 1/4] mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC
  2016-02-03  8:39 [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger
                   ` (4 preceding siblings ...)
  2016-02-03  8:39 ` [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger
@ 2016-02-03  8:39 ` Christian Borntraeger
  2016-02-03  8:39 ` [PATCH v4 2/4] x86: query dynamic DEBUG_PAGEALLOC setting Christian Borntraeger
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Christian Borntraeger @ 2016-02-03  8:39 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, linux-mm, x86, Thomas Gleixner, David Rientjes,
	Christian Borntraeger

We can provide debug_pagealloc_enabled() also if CONFIG_DEBUG_PAGEALLOC
is not set. It will return false in that case.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/mm.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index f1cd22f..ae84716 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2194,13 +2194,18 @@ kernel_map_pages(struct page *page, int numpages, int enable)
 #ifdef CONFIG_HIBERNATION
 extern bool kernel_page_present(struct page *page);
 #endif /* CONFIG_HIBERNATION */
-#else
+#else  /* CONFIG_DEBUG_PAGEALLOC */
+static inline bool debug_pagealloc_enabled(void)
+{
+	return false;
+}
+
 static inline void
 kernel_map_pages(struct page *page, int numpages, int enable) {}
 #ifdef CONFIG_HIBERNATION
 static inline bool kernel_page_present(struct page *page) { return true; }
 #endif /* CONFIG_HIBERNATION */
-#endif
+#endif /* CONFIG_DEBUG_PAGEALLOC */
 
 #ifdef __HAVE_ARCH_GATE_AREA
 extern struct vm_area_struct *get_gate_vma(struct mm_struct *mm);
-- 
2.3.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 2/4] x86: query dynamic DEBUG_PAGEALLOC setting
  2016-02-03  8:39 [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger
                   ` (5 preceding siblings ...)
  2016-02-03  8:39 ` [PATCH v4 1/4] mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC Christian Borntraeger
@ 2016-02-03  8:39 ` Christian Borntraeger
  2016-02-03  8:39 ` [PATCH v4 3/4] s390: " Christian Borntraeger
  2016-02-03  8:39 ` [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages Christian Borntraeger
  8 siblings, 0 replies; 14+ messages in thread
From: Christian Borntraeger @ 2016-02-03  8:39 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, linux-mm, x86, Thomas Gleixner, David Rientjes,
	Christian Borntraeger

We can use debug_pagealloc_enabled() to check if we can map
the identity mapping with 2MB pages. We can also add the state
into the dump_stack output.

The patch does not touch the code for the 1GB pages, which ignored
CONFIG_DEBUG_PAGEALLOC. Do we need to fence this as well?

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/dumpstack.c |  5 ++---
 arch/x86/mm/init.c          |  7 ++++---
 arch/x86/mm/pageattr.c      | 14 ++++----------
 3 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 9c30acf..32e5699 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -265,9 +265,8 @@ int __die(const char *str, struct pt_regs *regs, long err)
 #ifdef CONFIG_SMP
 	printk("SMP ");
 #endif
-#ifdef CONFIG_DEBUG_PAGEALLOC
-	printk("DEBUG_PAGEALLOC ");
-#endif
+	if (debug_pagealloc_enabled())
+		printk("DEBUG_PAGEALLOC ");
 #ifdef CONFIG_KASAN
 	printk("KASAN");
 #endif
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 493f541..39823fd 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -150,13 +150,14 @@ static int page_size_mask;
 
 static void __init probe_page_size_mask(void)
 {
-#if !defined(CONFIG_DEBUG_PAGEALLOC) && !defined(CONFIG_KMEMCHECK)
+#if !defined(CONFIG_KMEMCHECK)
 	/*
-	 * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
+	 * For CONFIG_KMEMCHECK or pagealloc debugging, identity mapping will
+	 * use small pages.
 	 * This will simplify cpa(), which otherwise needs to support splitting
 	 * large pages into small in interrupt context, etc.
 	 */
-	if (cpu_has_pse)
+	if (cpu_has_pse && !debug_pagealloc_enabled())
 		page_size_mask |= 1 << PG_LEVEL_2M;
 #endif
 
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 2440814..1ef9c2c 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -106,12 +106,6 @@ static inline unsigned long highmap_end_pfn(void)
 
 #endif
 
-#ifdef CONFIG_DEBUG_PAGEALLOC
-# define debug_pagealloc 1
-#else
-# define debug_pagealloc 0
-#endif
-
 static inline int
 within(unsigned long addr, unsigned long start, unsigned long end)
 {
@@ -708,10 +702,10 @@ static int split_large_page(struct cpa_data *cpa, pte_t *kpte,
 {
 	struct page *base;
 
-	if (!debug_pagealloc)
+	if (!debug_pagealloc_enabled())
 		spin_unlock(&cpa_lock);
 	base = alloc_pages(GFP_KERNEL | __GFP_NOTRACK, 0);
-	if (!debug_pagealloc)
+	if (!debug_pagealloc_enabled())
 		spin_lock(&cpa_lock);
 	if (!base)
 		return -ENOMEM;
@@ -1331,10 +1325,10 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
 		if (cpa->flags & (CPA_ARRAY | CPA_PAGES_ARRAY))
 			cpa->numpages = 1;
 
-		if (!debug_pagealloc)
+		if (!debug_pagealloc_enabled())
 			spin_lock(&cpa_lock);
 		ret = __change_page_attr(cpa, checkalias);
-		if (!debug_pagealloc)
+		if (!debug_pagealloc_enabled())
 			spin_unlock(&cpa_lock);
 		if (ret)
 			return ret;
-- 
2.3.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 3/4] s390: query dynamic DEBUG_PAGEALLOC setting
  2016-02-03  8:39 [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger
                   ` (6 preceding siblings ...)
  2016-02-03  8:39 ` [PATCH v4 2/4] x86: query dynamic DEBUG_PAGEALLOC setting Christian Borntraeger
@ 2016-02-03  8:39 ` Christian Borntraeger
  2016-02-03  8:39 ` [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages Christian Borntraeger
  8 siblings, 0 replies; 14+ messages in thread
From: Christian Borntraeger @ 2016-02-03  8:39 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, linux-mm, x86, Thomas Gleixner, David Rientjes,
	Christian Borntraeger

We can use debug_pagealloc_enabled() to check if we can map
the identity mapping with 1MB/2GB pages as well as to print
the current setting in dump_stack.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 arch/s390/kernel/dumpstack.c |  6 +++---
 arch/s390/mm/vmem.c          | 10 ++++------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/s390/kernel/dumpstack.c b/arch/s390/kernel/dumpstack.c
index 02bd02f..14c1ed3 100644
--- a/arch/s390/kernel/dumpstack.c
+++ b/arch/s390/kernel/dumpstack.c
@@ -11,6 +11,7 @@
 #include <linux/export.h>
 #include <linux/kdebug.h>
 #include <linux/ptrace.h>
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <asm/processor.h>
@@ -184,9 +185,8 @@ void die(struct pt_regs *regs, const char *str)
 #ifdef CONFIG_SMP
 	printk("SMP ");
 #endif
-#ifdef CONFIG_DEBUG_PAGEALLOC
-	printk("DEBUG_PAGEALLOC");
-#endif
+	if (debug_pagealloc_enabled())
+		printk("DEBUG_PAGEALLOC");
 	printk("\n");
 	notify_die(DIE_OOPS, str, regs, 0, regs->int_code & 0xffff, SIGSEGV);
 	print_modules();
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
index ef7d6c8..d27fccba 100644
--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -94,16 +94,15 @@ static int vmem_add_mem(unsigned long start, unsigned long size, int ro)
 			pgd_populate(&init_mm, pg_dir, pu_dir);
 		}
 		pu_dir = pud_offset(pg_dir, address);
-#ifndef CONFIG_DEBUG_PAGEALLOC
 		if (MACHINE_HAS_EDAT2 && pud_none(*pu_dir) && address &&
-		    !(address & ~PUD_MASK) && (address + PUD_SIZE <= end)) {
+		    !(address & ~PUD_MASK) && (address + PUD_SIZE <= end) &&
+		     !debug_pagealloc_enabled()) {
 			pud_val(*pu_dir) = __pa(address) |
 				_REGION_ENTRY_TYPE_R3 | _REGION3_ENTRY_LARGE |
 				(ro ? _REGION_ENTRY_PROTECT : 0);
 			address += PUD_SIZE;
 			continue;
 		}
-#endif
 		if (pud_none(*pu_dir)) {
 			pm_dir = vmem_pmd_alloc();
 			if (!pm_dir)
@@ -111,9 +110,9 @@ static int vmem_add_mem(unsigned long start, unsigned long size, int ro)
 			pud_populate(&init_mm, pu_dir, pm_dir);
 		}
 		pm_dir = pmd_offset(pu_dir, address);
-#ifndef CONFIG_DEBUG_PAGEALLOC
 		if (MACHINE_HAS_EDAT1 && pmd_none(*pm_dir) && address &&
-		    !(address & ~PMD_MASK) && (address + PMD_SIZE <= end)) {
+		    !(address & ~PMD_MASK) && (address + PMD_SIZE <= end) &&
+		    !debug_pagealloc_enabled()) {
 			pmd_val(*pm_dir) = __pa(address) |
 				_SEGMENT_ENTRY | _SEGMENT_ENTRY_LARGE |
 				_SEGMENT_ENTRY_YOUNG |
@@ -121,7 +120,6 @@ static int vmem_add_mem(unsigned long start, unsigned long size, int ro)
 			address += PMD_SIZE;
 			continue;
 		}
-#endif
 		if (pmd_none(*pm_dir)) {
 			pt_dir = vmem_pte_alloc(address);
 			if (!pt_dir)
-- 
2.3.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages
  2016-02-03  8:39 [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger
                   ` (7 preceding siblings ...)
  2016-02-03  8:39 ` [PATCH v4 3/4] s390: " Christian Borntraeger
@ 2016-02-03  8:39 ` Christian Borntraeger
  8 siblings, 0 replies; 14+ messages in thread
From: Christian Borntraeger @ 2016-02-03  8:39 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, linux-mm, x86, Thomas Gleixner, David Rientjes,
	Christian Borntraeger

we want to couple all debugging features with debug_pagealloc_enabled()
and not with the config option CONFIG_DEBUG_PAGEALLOC.

Suggested-by: David Rientjes <rientjes@google.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/x86/mm/init.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 39823fd..9d56f27 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -667,21 +667,22 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
 	 * mark them not present - any buggy init-section access will
 	 * create a kernel page fault:
 	 */
-#ifdef CONFIG_DEBUG_PAGEALLOC
-	printk(KERN_INFO "debug: unmapping init [mem %#010lx-%#010lx]\n",
-		begin, end - 1);
-	set_memory_np(begin, (end - begin) >> PAGE_SHIFT);
-#else
-	/*
-	 * We just marked the kernel text read only above, now that
-	 * we are going to free part of that, we need to make that
-	 * writeable and non-executable first.
-	 */
-	set_memory_nx(begin, (end - begin) >> PAGE_SHIFT);
-	set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);
+	if (debug_pagealloc_enabled()) {
+		pr_info("debug: unmapping init [mem %#010lx-%#010lx]\n",
+			begin, end - 1);
+		set_memory_np(begin, (end - begin) >> PAGE_SHIFT);
+	} else {
+		/*
+		 * We just marked the kernel text read only above, now that
+		 * we are going to free part of that, we need to make that
+		 * writeable and non-executable first.
+		 */
+		set_memory_nx(begin, (end - begin) >> PAGE_SHIFT);
+		set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);
 
-	free_reserved_area((void *)begin, (void *)end, POISON_FREE_INITMEM, what);
-#endif
+		free_reserved_area((void *)begin, (void *)end,
+				   POISON_FREE_INITMEM, what);
+	}
 }
 
 void free_initmem(void)
-- 
2.3.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages
  2016-02-03  8:39 ` [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages Christian Borntraeger
@ 2016-02-03 10:43   ` Thomas Gleixner
  2016-02-03 22:50   ` David Rientjes
  1 sibling, 0 replies; 14+ messages in thread
From: Thomas Gleixner @ 2016-02-03 10:43 UTC (permalink / raw)
  To: Christian Borntraeger; +Cc: akpm, linux-kernel, linux-mm, x86, David Rientjes

On Wed, 3 Feb 2016, Christian Borntraeger wrote:

> we want to couple all debugging features with debug_pagealloc_enabled()
> and not with the config option CONFIG_DEBUG_PAGEALLOC.
> 
> Suggested-by: David Rientjes <rientjes@google.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4 2/4] x86: query dynamic DEBUG_PAGEALLOC setting
  2016-02-03  8:39 ` [PATCH v4 2/4] x86: query dynamic DEBUG_PAGEALLOC setting Christian Borntraeger
@ 2016-02-03 22:48   ` David Rientjes
  0 siblings, 0 replies; 14+ messages in thread
From: David Rientjes @ 2016-02-03 22:48 UTC (permalink / raw)
  To: Christian Borntraeger; +Cc: akpm, linux-kernel, linux-mm, x86, Thomas Gleixner

On Wed, 3 Feb 2016, Christian Borntraeger wrote:

> We can use debug_pagealloc_enabled() to check if we can map
> the identity mapping with 2MB pages. We can also add the state
> into the dump_stack output.
> 
> The patch does not touch the code for the 1GB pages, which ignored
> CONFIG_DEBUG_PAGEALLOC. Do we need to fence this as well?
> 

I think it would be an extension of the debug_pagealloc= functionality and 
can certainly be introduced if someone is inclined.

> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

Acked-by: David Rientjes <rientjes@google.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4 3/4] s390: query dynamic DEBUG_PAGEALLOC setting
  2016-02-03  8:39 ` [PATCH v4 3/4] s390: " Christian Borntraeger
@ 2016-02-03 22:48   ` David Rientjes
  0 siblings, 0 replies; 14+ messages in thread
From: David Rientjes @ 2016-02-03 22:48 UTC (permalink / raw)
  To: Christian Borntraeger; +Cc: akpm, linux-kernel, linux-mm, x86, Thomas Gleixner

On Wed, 3 Feb 2016, Christian Borntraeger wrote:

> We can use debug_pagealloc_enabled() to check if we can map
> the identity mapping with 1MB/2GB pages as well as to print
> the current setting in dump_stack.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>

Acked-by: David Rientjes <rientjes@google.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages
  2016-02-03  8:39 ` [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages Christian Borntraeger
  2016-02-03 10:43   ` Thomas Gleixner
@ 2016-02-03 22:50   ` David Rientjes
  1 sibling, 0 replies; 14+ messages in thread
From: David Rientjes @ 2016-02-03 22:50 UTC (permalink / raw)
  To: Christian Borntraeger, Joonsoo Kim
  Cc: Andrew Morton, linux-kernel, linux-mm, x86, Thomas Gleixner

On Wed, 3 Feb 2016, Christian Borntraeger wrote:

> we want to couple all debugging features with debug_pagealloc_enabled()
> and not with the config option CONFIG_DEBUG_PAGEALLOC.
> 
> Suggested-by: David Rientjes <rientjes@google.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>

Acked-by: David Rientjes <rientjes@google.com>

[+Joonsoo]

Joonso has indicated that he will work on converting other code using 
CONFIG_DEBUG_PAGEALLOC to instead consider debug_pagealloc_enabled(), so 
more work in this area will probably be forthcoming.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-02-03 22:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-03  8:39 [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger
2016-02-03  8:39 ` [PATCH v4 1/4] mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC Christian Borntraeger
2016-02-03  8:39 ` [PATCH v4 2/4] x86: query dynamic DEBUG_PAGEALLOC setting Christian Borntraeger
2016-02-03 22:48   ` David Rientjes
2016-02-03  8:39 ` [PATCH v4 3/4] s390: " Christian Borntraeger
2016-02-03 22:48   ` David Rientjes
2016-02-03  8:39 ` [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages Christian Borntraeger
2016-02-03 10:43   ` Thomas Gleixner
2016-02-03 22:50   ` David Rientjes
2016-02-03  8:39 ` [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger
2016-02-03  8:39 ` [PATCH v4 1/4] mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC Christian Borntraeger
2016-02-03  8:39 ` [PATCH v4 2/4] x86: query dynamic DEBUG_PAGEALLOC setting Christian Borntraeger
2016-02-03  8:39 ` [PATCH v4 3/4] s390: " Christian Borntraeger
2016-02-03  8:39 ` [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages Christian Borntraeger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).