Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1325045 > unrolled thread
| Started by | Christian Borntraeger <borntraeger@de.ibm.com> |
|---|---|
| First post | 2016-02-03 09:40 +0100 |
| Last post | 2016-02-03 23:50 +0100 |
| Articles | 10 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger <borntraeger@de.ibm.com> - 2016-02-03 09:40 +0100
[PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) Christian Borntraeger <borntraeger@de.ibm.com> - 2016-02-03 09:50 +0100
[PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages Christian Borntraeger <borntraeger@de.ibm.com> - 2016-02-03 09:50 +0100
Re: [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages Thomas Gleixner <tglx@linutronix.de> - 2016-02-03 11:50 +0100
Re: [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages David Rientjes <rientjes@google.com> - 2016-02-04 00:00 +0100
[PATCH v4 1/4] mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC Christian Borntraeger <borntraeger@de.ibm.com> - 2016-02-03 09:50 +0100
[PATCH v4 2/4] x86: query dynamic DEBUG_PAGEALLOC setting Christian Borntraeger <borntraeger@de.ibm.com> - 2016-02-03 09:50 +0100
[PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages Christian Borntraeger <borntraeger@de.ibm.com> - 2016-02-03 09:50 +0100
[PATCH v4 3/4] s390: query dynamic DEBUG_PAGEALLOC setting Christian Borntraeger <borntraeger@de.ibm.com> - 2016-02-03 09:50 +0100
Re: [PATCH v4 3/4] s390: query dynamic DEBUG_PAGEALLOC setting David Rientjes <rientjes@google.com> - 2016-02-03 23:50 +0100
| From | Christian Borntraeger <borntraeger@de.ibm.com> |
|---|---|
| Date | 2016-02-03 09:40 +0100 |
| Subject | [PATCH v4 0/4 (resend)] Optimize CONFIG_DEBUG_PAGEALLOC (x86 and s390) |
| Message-ID | <qY18J-7WJ-7@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Christian Borntraeger <borntraeger@de.ibm.com> |
|---|---|
| Date | 2016-02-03 09:50 +0100 |
| Message-ID | <qY1iq-80l-21@gated-at.bofh.it> |
| In reply to | #1325045 |
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
[toc] | [prev] | [next] | [standalone]
| From | Christian Borntraeger <borntraeger@de.ibm.com> |
|---|---|
| Date | 2016-02-03 09:50 +0100 |
| Subject | [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages |
| Message-ID | <qY1iq-80l-27@gated-at.bofh.it> |
| In reply to | #1325045 |
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
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2016-02-03 11:50 +0100 |
| Subject | Re: [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages |
| Message-ID | <qY3ay-Nu-13@gated-at.bofh.it> |
| In reply to | #1325052 |
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>
[toc] | [prev] | [next] | [standalone]
| From | David Rientjes <rientjes@google.com> |
|---|---|
| Date | 2016-02-04 00:00 +0100 |
| Subject | Re: [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages |
| Message-ID | <qYez2-8kz-81@gated-at.bofh.it> |
| In reply to | #1325052 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Christian Borntraeger <borntraeger@de.ibm.com> |
|---|---|
| Date | 2016-02-03 09:50 +0100 |
| Subject | [PATCH v4 1/4] mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC |
| Message-ID | <qY1iq-80l-25@gated-at.bofh.it> |
| In reply to | #1325045 |
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
[toc] | [prev] | [next] | [standalone]
| From | Christian Borntraeger <borntraeger@de.ibm.com> |
|---|---|
| Date | 2016-02-03 09:50 +0100 |
| Subject | [PATCH v4 2/4] x86: query dynamic DEBUG_PAGEALLOC setting |
| Message-ID | <qY1iq-80l-39@gated-at.bofh.it> |
| In reply to | #1325045 |
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
[toc] | [prev] | [next] | [standalone]
| From | Christian Borntraeger <borntraeger@de.ibm.com> |
|---|---|
| Date | 2016-02-03 09:50 +0100 |
| Subject | [PATCH v4 4/4] x86: also use debug_pagealloc_enabled() for free_init_pages |
| Message-ID | <qY1ir-80l-43@gated-at.bofh.it> |
| In reply to | #1325045 |
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
[toc] | [prev] | [next] | [standalone]
| From | Christian Borntraeger <borntraeger@de.ibm.com> |
|---|---|
| Date | 2016-02-03 09:50 +0100 |
| Subject | [PATCH v4 3/4] s390: query dynamic DEBUG_PAGEALLOC setting |
| Message-ID | <qY1ir-80l-45@gated-at.bofh.it> |
| In reply to | #1325045 |
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
[toc] | [prev] | [next] | [standalone]
| From | David Rientjes <rientjes@google.com> |
|---|---|
| Date | 2016-02-03 23:50 +0100 |
| Subject | Re: [PATCH v4 3/4] s390: query dynamic DEBUG_PAGEALLOC setting |
| Message-ID | <qYepm-8ec-61@gated-at.bofh.it> |
| In reply to | #1325061 |
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>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web