linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v1 0/4] x86: simpify direct_gbpages setting, add early_param_on_off()
@ 2015-03-05  1:24 Luis R. Rodriguez
  2015-03-05  1:24 ` [RFC v1 1/4] x86: mm: use IS_ENABLED() for direct_gbpages Luis R. Rodriguez
                   ` (7 more replies)
  0 siblings, 8 replies; 19+ messages in thread
From: Luis R. Rodriguez @ 2015-03-05  1:24 UTC (permalink / raw)
  To: gregkh, akpm, tony, tglx, mingo, hpa, jgross, luto, toshi.kani,
	dave.hansen, JBeulich, pavel, qiuxishi, david.vrabel, bp, vbabka,
	iamjoonsoo.kim, decui
  Cc: linux-kernel, x86, julia.lawall, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@suse.com>

While reviewing DIRECT_GBPAGES I noticed some inconsistancies
on when its cached "enable" variable is set and when in reality
its full feature is enabled. There's also some code simplification
possible by simply using Kconfig, so decided to take advantage of
that and then generalize this a bit under a new early_param_on_off()
which makes it easier to associate featureas with respective cached
values and their own feature related Kconfig entries.

In this case in order to use early_param_on_off() given that init.o is
shared with both 32-bit and 64-bit and before the early parameters were
only exposed on 64-bit it does mean we're exposing this kernel
parameter to 32-bit as well now but its not possible to enable it on 32-bit
as its real setting is guarded by ENABLE_DIRECT_GBPAGES.

I was tempted to grep around for this sort of grammar use but couldn't
easily find all uses with Coccinelle / grep due to the #ifder'y
and the code being outside of routines. If the generalization is not
desired we can drop the last two, but would ask that the first two patches
to be considered and reviewed.

Luis R. Rodriguez (4):
  x86: mm: use IS_ENABLED() for direct_gbpages
  x86: mm: simplify enabling direct_gbpages
  init.h: add early_param_on_off()
  x86: mm: use early_param_on_off() for direct_gbpages

 arch/x86/Kconfig       | 18 +++++++++++++-----
 arch/x86/mm/init.c     | 24 +++++++++++-------------
 arch/x86/mm/init_64.c  | 14 --------------
 arch/x86/mm/pageattr.c |  2 --
 include/linux/init.h   | 15 +++++++++++++++
 5 files changed, 39 insertions(+), 34 deletions(-)

-- 
2.2.2


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

* [RFC v1 1/4] x86: mm: use IS_ENABLED() for direct_gbpages
  2015-03-05  1:24 [RFC v1 0/4] x86: simpify direct_gbpages setting, add early_param_on_off() Luis R. Rodriguez
@ 2015-03-05  1:24 ` Luis R. Rodriguez
  2015-03-05 11:49   ` [tip:x86/mm] x86/mm: Use " tip-bot for Luis R. Rodriguez
  2015-03-05  1:24 ` [RFC v1 2/4] x86: mm: simplify enabling direct_gbpages Luis R. Rodriguez
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Luis R. Rodriguez @ 2015-03-05  1:24 UTC (permalink / raw)
  To: gregkh, akpm, tony, tglx, mingo, hpa, jgross, luto, toshi.kani,
	dave.hansen, JBeulich, pavel, qiuxishi, david.vrabel, bp, vbabka,
	iamjoonsoo.kim, decui
  Cc: linux-kernel, x86, julia.lawall, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@suse.com>

Replace #ifdef eyesore with IS_ENABLED() use.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tony Lindgren <tony@atomide.com>
Cc: linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Juergen Gross <jgross@suse.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 arch/x86/mm/init.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 52417e7..b880d06 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -131,11 +131,7 @@ void  __init early_alloc_pgt_buf(void)
 
 int after_bootmem;
 
-int direct_gbpages
-#ifdef CONFIG_DIRECT_GBPAGES
-				= 1
-#endif
-;
+int direct_gbpages = IS_ENABLED(CONFIG_DIRECT_GBPAGES);
 
 static void __init init_gbpages(void)
 {
-- 
2.2.2


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

* [RFC v1 2/4] x86: mm: simplify enabling direct_gbpages
  2015-03-05  1:24 [RFC v1 0/4] x86: simpify direct_gbpages setting, add early_param_on_off() Luis R. Rodriguez
  2015-03-05  1:24 ` [RFC v1 1/4] x86: mm: use IS_ENABLED() for direct_gbpages Luis R. Rodriguez
@ 2015-03-05  1:24 ` Luis R. Rodriguez
  2015-03-05 11:49   ` [tip:x86/mm] x86/mm: Simplify " tip-bot for Luis R. Rodriguez
  2015-03-05  1:24 ` [RFC v1 3/4] init.h: add early_param_on_off() Luis R. Rodriguez
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Luis R. Rodriguez @ 2015-03-05  1:24 UTC (permalink / raw)
  To: gregkh, akpm, tony, tglx, mingo, hpa, jgross, luto, toshi.kani,
	dave.hansen, JBeulich, pavel, qiuxishi, david.vrabel, bp, vbabka,
	iamjoonsoo.kim, decui
  Cc: linux-kernel, x86, julia.lawall, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@suse.com>

direct_gbpages can be force enabled as an early parameter
but not really have taken effect when DEBUG_PAGEALLOC
or KMEMCHECK is enabled. You can also enable direct_gbpages
right now if you have an x86_64 architecture but your CPU
doesn't really have support for this feature. In both cases
PG_LEVEL_1G won't actually be enabled but direct_gbpages is used
in other areas under the assumptions that PG_LEVEL_1G
was set. Fix this by putting together all requirements
which make this feature sensible to enable under, and only
enable both finally flipping on PG_LEVEL_1G and leaving
PG_LEVEL_1G set when this is true.

We only enable this feature then to be possible on sensible
builds defined by the new ENABLE_DIRECT_GBPAGES. If the
CPU has support for it you can either enable this by using
the DIRECT_GBPAGES option or using the early kernel parameter.
If a platform had support for this you can always force disable
it as well.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tony Lindgren <tony@atomide.com>
Cc: linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Juergen Gross <jgross@suse.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 arch/x86/Kconfig       | 18 +++++++++++++-----
 arch/x86/mm/init.c     | 17 +++++++++--------
 arch/x86/mm/pageattr.c |  2 --
 3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index fb8e8cd..f3fd260 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1300,14 +1300,22 @@ config ARCH_DMA_ADDR_T_64BIT
 	def_bool y
 	depends on X86_64 || HIGHMEM64G
 
+config ENABLE_DIRECT_GBPAGES
+	def_bool y
+	depends on X86_64 && !DEBUG_PAGEALLOC && !KMEMCHECK
+
 config DIRECT_GBPAGES
 	bool "Enable 1GB pages for kernel pagetables" if EXPERT
 	default y
-	depends on X86_64
-	---help---
-	  Allow the kernel linear mapping to use 1GB pages on CPUs that
-	  support it. This can improve the kernel's performance a tiny bit by
-	  reducing TLB pressure. If in doubt, say "Y".
+	depends on ENABLE_DIRECT_GBPAGES
+	---help---
+	  Enable by default the kernel linear mapping to use 1GB pages on CPUs
+	  that support it. This can improve the kernel's performance a tiny bit
+	  by reducing TLB pressure. If in doubt, say "Y". If you've disabled
+	  option but your platform is capable of handling support for this
+	  you can use the gbpages kernel parameter. Likewise if you've enabled
+	  this but you'd like to force disable this option you can use the
+	  nogbpages kernel parameter.
 
 # Common NUMA Features
 config NUMA
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index b880d06..8d375ba 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -131,16 +131,21 @@ void  __init early_alloc_pgt_buf(void)
 
 int after_bootmem;
 
+static int page_size_mask;
+
 int direct_gbpages = IS_ENABLED(CONFIG_DIRECT_GBPAGES);
 
 static void __init init_gbpages(void)
 {
-#ifdef CONFIG_X86_64
-	if (direct_gbpages && cpu_has_gbpages)
+	if (!IS_ENABLED(CONFIG_ENABLE_DIRECT_GBPAGES)) {
+		direct_gbpages = 0;
+		return;
+	}
+	if (direct_gbpages && cpu_has_gbpages) {
 		printk(KERN_INFO "Using GB pages for direct mapping\n");
-	else
+		page_size_mask |= 1 << PG_LEVEL_1G;
+	} else
 		direct_gbpages = 0;
-#endif
 }
 
 struct map_range {
@@ -149,8 +154,6 @@ struct map_range {
 	unsigned page_size_mask;
 };
 
-static int page_size_mask;
-
 static void __init probe_page_size_mask(void)
 {
 	init_gbpages();
@@ -161,8 +164,6 @@ static void __init probe_page_size_mask(void)
 	 * This will simplify cpa(), which otherwise needs to support splitting
 	 * large pages into small in interrupt context, etc.
 	 */
-	if (direct_gbpages)
-		page_size_mask |= 1 << PG_LEVEL_1G;
 	if (cpu_has_pse)
 		page_size_mask |= 1 << PG_LEVEL_2M;
 #endif
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 536ea2f..070b7c2 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -81,11 +81,9 @@ void arch_report_meminfo(struct seq_file *m)
 	seq_printf(m, "DirectMap4M:    %8lu kB\n",
 			direct_pages_count[PG_LEVEL_2M] << 12);
 #endif
-#ifdef CONFIG_X86_64
 	if (direct_gbpages)
 		seq_printf(m, "DirectMap1G:    %8lu kB\n",
 			direct_pages_count[PG_LEVEL_1G] << 20);
-#endif
 }
 #else
 static inline void split_page_count(int level) { }
-- 
2.2.2


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

* [RFC v1 3/4] init.h: add early_param_on_off()
  2015-03-05  1:24 [RFC v1 0/4] x86: simpify direct_gbpages setting, add early_param_on_off() Luis R. Rodriguez
  2015-03-05  1:24 ` [RFC v1 1/4] x86: mm: use IS_ENABLED() for direct_gbpages Luis R. Rodriguez
  2015-03-05  1:24 ` [RFC v1 2/4] x86: mm: simplify enabling direct_gbpages Luis R. Rodriguez
@ 2015-03-05  1:24 ` Luis R. Rodriguez
  2015-03-05 11:50   ` [tip:x86/mm] init.h: Add early_param_on_off() tip-bot for Luis R. Rodriguez
  2015-03-05  1:24 ` [RFC v1 4/4] x86: mm: use early_param_on_off() for direct_gbpages Luis R. Rodriguez
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Luis R. Rodriguez @ 2015-03-05  1:24 UTC (permalink / raw)
  To: gregkh, akpm, tony, tglx, mingo, hpa, jgross, luto, toshi.kani,
	dave.hansen, JBeulich, pavel, qiuxishi, david.vrabel, bp, vbabka,
	iamjoonsoo.kim, decui
  Cc: linux-kernel, x86, julia.lawall, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@suse.com>

At times all you need is a kconfig variable to enable a feature,
by default but you may want to also enable / disable it through
a kernel parameter. In such cases the parameter routines to turn
the thing on / off are really simple. Just use a wrapper for
this, it lets us generalize the code and makes it easier to
associate parameters with related kernel configuration options.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tony Lindgren <tony@atomide.com>
Cc: linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Juergen Gross <jgross@suse.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 include/linux/init.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/init.h b/include/linux/init.h
index 2df8e8d..bc11ff9 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -268,6 +268,21 @@ struct obs_kernel_param {
 #define early_param(str, fn)					\
 	__setup_param(str, fn, fn, 1)
 
+#define early_param_on_off(str_on, str_off, var, config)			\
+	int var = IS_ENABLED(config);				\
+	static int __init parse_##var##_on(char *arg)		\
+	{							\
+		var = 1;					\
+		return 0;					\
+	}							\
+	static int __init parse_##var##_off(char *arg)		\
+	{							\
+		var = 0;					\
+		return 0;					\
+	}							\
+	__setup_param(str_on, parse_##var##_on, parse_##var##_on, 1); \
+	__setup_param(str_off, parse_##var##_off, parse_##var##_off, 1)
+
 /* Relies on boot_command_line being set */
 void __init parse_early_param(void);
 void __init parse_early_options(char *cmdline);
-- 
2.2.2


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

* [RFC v1 4/4] x86: mm: use early_param_on_off() for direct_gbpages
  2015-03-05  1:24 [RFC v1 0/4] x86: simpify direct_gbpages setting, add early_param_on_off() Luis R. Rodriguez
                   ` (2 preceding siblings ...)
  2015-03-05  1:24 ` [RFC v1 3/4] init.h: add early_param_on_off() Luis R. Rodriguez
@ 2015-03-05  1:24 ` Luis R. Rodriguez
  2015-03-05 11:50   ` [tip:x86/mm] x86/mm: Use " tip-bot for Luis R. Rodriguez
  2015-03-05  7:23 ` [PATCH 5/4] x86/mm: Further simplify 1 GB kernel linear mappings handling Ingo Molnar
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Luis R. Rodriguez @ 2015-03-05  1:24 UTC (permalink / raw)
  To: gregkh, akpm, tony, tglx, mingo, hpa, jgross, luto, toshi.kani,
	dave.hansen, JBeulich, pavel, qiuxishi, david.vrabel, bp, vbabka,
	iamjoonsoo.kim, decui
  Cc: linux-kernel, x86, julia.lawall, Luis R. Rodriguez

From: "Luis R. Rodriguez" <mcgrof@suse.com>

The enabler / disabler is pretty simple, just use the
provided wrappers, this lets us easily relate the variable
to the associated Kconfig entry.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tony Lindgren <tony@atomide.com>
Cc: linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Juergen Gross <jgross@suse.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
 arch/x86/mm/init.c    |  3 ++-
 arch/x86/mm/init_64.c | 14 --------------
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 8d375ba..ce5db80 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -133,7 +133,8 @@ int after_bootmem;
 
 static int page_size_mask;
 
-int direct_gbpages = IS_ENABLED(CONFIG_DIRECT_GBPAGES);
+early_param_on_off("gbpages", "nogbpages",
+		   direct_gbpages, CONFIG_DIRECT_GBPAGES);
 
 static void __init init_gbpages(void)
 {
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 30eb05a..3fba623 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -130,20 +130,6 @@ int kernel_ident_mapping_init(struct x86_mapping_info *info, pgd_t *pgd_page,
 	return 0;
 }
 
-static int __init parse_direct_gbpages_off(char *arg)
-{
-	direct_gbpages = 0;
-	return 0;
-}
-early_param("nogbpages", parse_direct_gbpages_off);
-
-static int __init parse_direct_gbpages_on(char *arg)
-{
-	direct_gbpages = 1;
-	return 0;
-}
-early_param("gbpages", parse_direct_gbpages_on);
-
 /*
  * NOTE: pagetable_init alloc all the fixmap pagetables contiguous on the
  * physical space so we can cache the place of the first one and move
-- 
2.2.2


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

* [PATCH 5/4] x86/mm: Further simplify 1 GB kernel linear mappings handling
  2015-03-05  1:24 [RFC v1 0/4] x86: simpify direct_gbpages setting, add early_param_on_off() Luis R. Rodriguez
                   ` (3 preceding siblings ...)
  2015-03-05  1:24 ` [RFC v1 4/4] x86: mm: use early_param_on_off() for direct_gbpages Luis R. Rodriguez
@ 2015-03-05  7:23 ` Ingo Molnar
  2015-03-05  8:05   ` Jan Beulich
  2015-03-05  7:27 ` [PATCH 6/4] x86/mm: Simplify probe_page_size_mask() Ingo Molnar
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Ingo Molnar @ 2015-03-05  7:23 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: gregkh, akpm, tony, tglx, mingo, hpa, jgross, luto, toshi.kani,
	dave.hansen, JBeulich, pavel, qiuxishi, david.vrabel, bp, vbabka,
	iamjoonsoo.kim, decui, linux-kernel, x86, julia.lawall,
	Luis R. Rodriguez


It's a bit pointless to allow Kconfig configuration for 1GB kernel
mappings, it's already hidden behind a 'default y' and CONFIG_EXPERT.

Remove this complication and simplify the code by renaming
CONFIG_ENABLE_DIRECT_GBPAGES to CONFIG_X86_DIRECT_GBPAGES and
document the DEBUG_PAGE_ALLOC and KMEMCHECK quirks.

Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: JBeulich@suse.com
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: julia.lawall@lip6.fr
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/Kconfig   | 23 +++++++----------------
 arch/x86/mm/init.c |  7 +------
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 4d06e1c8294a..54d528a37ff4 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1299,22 +1299,13 @@ config ARCH_DMA_ADDR_T_64BIT
 	def_bool y
 	depends on X86_64 || HIGHMEM64G
 
-config ENABLE_DIRECT_GBPAGES
-	def_bool y
-	depends on X86_64 && !DEBUG_PAGEALLOC && !KMEMCHECK
-
-config DIRECT_GBPAGES
-	bool "Enable 1GB pages for kernel pagetables" if EXPERT
-	default y
-	depends on ENABLE_DIRECT_GBPAGES
-	---help---
-	  Enable by default the kernel linear mapping to use 1GB pages on CPUs
-	  that support it. This can improve the kernel's performance a tiny bit
-	  by reducing TLB pressure. If in doubt, say "Y". If you've disabled
-	  option but your platform is capable of handling support for this
-	  you can use the gbpages kernel parameter. Likewise if you've enabled
-	  this but you'd like to force disable this option you can use the
-	  nogbpages kernel parameter.
+config X86_DIRECT_GBPAGES
+	def_bool (X86_64 && !DEBUG_PAGEALLOC && !KMEMCHECK)
+	---help---
+	  Certain kernel features effectively disable kernel
+	  linear 1 GB mappings (even if the CPU otherwise
+	  supports them), so don't confuse the user by printing
+	  that we have them enabled.
 
 # Common NUMA Features
 config NUMA
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index c35ba8bce7cb..8704153f2675 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -133,15 +133,10 @@ int after_bootmem;
 
 static int page_size_mask;
 
-early_param_on_off("gbpages", "nogbpages",
-		   direct_gbpages, CONFIG_DIRECT_GBPAGES);
+early_param_on_off("gbpages", "nogbpages", direct_gbpages, CONFIG_X86_DIRECT_GBPAGES);
 
 static void __init init_gbpages(void)
 {
-	if (!IS_ENABLED(CONFIG_ENABLE_DIRECT_GBPAGES)) {
-		direct_gbpages = 0;
-		return;
-	}
 	if (direct_gbpages && cpu_has_gbpages) {
 		printk(KERN_INFO "Using GB pages for direct mapping\n");
 		page_size_mask |= 1 << PG_LEVEL_1G;

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

* [PATCH 6/4] x86/mm: Simplify probe_page_size_mask()
  2015-03-05  1:24 [RFC v1 0/4] x86: simpify direct_gbpages setting, add early_param_on_off() Luis R. Rodriguez
                   ` (4 preceding siblings ...)
  2015-03-05  7:23 ` [PATCH 5/4] x86/mm: Further simplify 1 GB kernel linear mappings handling Ingo Molnar
@ 2015-03-05  7:27 ` Ingo Molnar
  2015-03-05  8:38   ` Juergen Gross
  2015-03-05  7:44 ` [PATCH 7/4] init.h: Clean up the __setup()/early_param() macros Ingo Molnar
  2015-03-05  8:21 ` [PATCH] x86/mm/pat: Initialize __cachemode2pte_tbl[] and __pte2cachemode_tbl[] in a bit more readable fashion Ingo Molnar
  7 siblings, 1 reply; 19+ messages in thread
From: Ingo Molnar @ 2015-03-05  7:27 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: gregkh, akpm, tony, tglx, mingo, hpa, jgross, luto, toshi.kani,
	dave.hansen, JBeulich, pavel, qiuxishi, david.vrabel, bp, vbabka,
	iamjoonsoo.kim, decui, linux-kernel, x86, julia.lawall,
	Luis R. Rodriguez


Now that we've simplified the gbpages config space, move the 
'page_size_mask' initialization into probe_page_size_mask(), right 
next to the PSE and PGE enablement lines.

Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: JBeulich@suse.com
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: julia.lawall@lip6.fr
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/mm/init.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 8704153f2675..6dc85d51cd98 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -131,29 +131,18 @@ void  __init early_alloc_pgt_buf(void)
 
 int after_bootmem;
 
-static int page_size_mask;
-
 early_param_on_off("gbpages", "nogbpages", direct_gbpages, CONFIG_X86_DIRECT_GBPAGES);
 
-static void __init init_gbpages(void)
-{
-	if (direct_gbpages && cpu_has_gbpages) {
-		printk(KERN_INFO "Using GB pages for direct mapping\n");
-		page_size_mask |= 1 << PG_LEVEL_1G;
-	} else
-		direct_gbpages = 0;
-}
-
 struct map_range {
 	unsigned long start;
 	unsigned long end;
 	unsigned page_size_mask;
 };
 
+static int page_size_mask;
+
 static void __init probe_page_size_mask(void)
 {
-	init_gbpages();
-
 #if !defined(CONFIG_DEBUG_PAGEALLOC) && !defined(CONFIG_KMEMCHECK)
 	/*
 	 * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
@@ -173,6 +162,14 @@ static void __init probe_page_size_mask(void)
 		cr4_set_bits_and_update_boot(X86_CR4_PGE);
 		__supported_pte_mask |= _PAGE_GLOBAL;
 	}
+
+	/* Enable 1 GB linear kernel mappings if available: */
+	if (direct_gbpages && cpu_has_gbpages) {
+		printk(KERN_INFO "Using GB pages for direct mapping\n");
+		page_size_mask |= 1 << PG_LEVEL_1G;
+	} else {
+		direct_gbpages = 0;
+	}
 }
 
 #ifdef CONFIG_X86_32

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

* [PATCH 7/4] init.h: Clean up the __setup()/early_param() macros
  2015-03-05  1:24 [RFC v1 0/4] x86: simpify direct_gbpages setting, add early_param_on_off() Luis R. Rodriguez
                   ` (5 preceding siblings ...)
  2015-03-05  7:27 ` [PATCH 6/4] x86/mm: Simplify probe_page_size_mask() Ingo Molnar
@ 2015-03-05  7:44 ` Ingo Molnar
  2015-03-05  8:21 ` [PATCH] x86/mm/pat: Initialize __cachemode2pte_tbl[] and __pte2cachemode_tbl[] in a bit more readable fashion Ingo Molnar
  7 siblings, 0 replies; 19+ messages in thread
From: Ingo Molnar @ 2015-03-05  7:44 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: gregkh, akpm, tony, tglx, mingo, hpa, jgross, luto, toshi.kani,
	dave.hansen, JBeulich, pavel, qiuxishi, david.vrabel, bp, vbabka,
	iamjoonsoo.kim, decui, linux-kernel, x86, julia.lawall,
	Luis R. Rodriguez


Make it all a bit easier on the eyes:

 - Move the __setup_param() lines right after their init functions
 - Use consistent vertical spacing
 - Use more horizontal spacing to make it look like regular C code
 - Use standard comment style

Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: julia.lawall@lip6.fr
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/init.h | 49 +++++++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/include/linux/init.h b/include/linux/init.h
index bc11ff96f336..21b6d768edd7 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -253,34 +253,39 @@ struct obs_kernel_param {
  * obs_kernel_param "array" too far apart in .init.setup.
  */
 #define __setup_param(str, unique_id, fn, early)			\
-	static const char __setup_str_##unique_id[] __initconst	\
-		__aligned(1) = str; \
-	static struct obs_kernel_param __setup_##unique_id	\
-		__used __section(.init.setup)			\
-		__attribute__((aligned((sizeof(long)))))	\
+	static const char __setup_str_##unique_id[] __initconst		\
+		__aligned(1) = str; 					\
+	static struct obs_kernel_param __setup_##unique_id		\
+		__used __section(.init.setup)				\
+		__attribute__((aligned((sizeof(long)))))		\
 		= { __setup_str_##unique_id, fn, early }
 
-#define __setup(str, fn)					\
+#define __setup(str, fn)						\
 	__setup_param(str, fn, fn, 0)
 
-/* NOTE: fn is as per module_param, not __setup!  Emits warning if fn
- * returns non-zero. */
-#define early_param(str, fn)					\
+/*
+ * NOTE: fn is as per module_param, not __setup!
+ * Emits warning if fn returns non-zero.
+ */
+#define early_param(str, fn)						\
 	__setup_param(str, fn, fn, 1)
 
-#define early_param_on_off(str_on, str_off, var, config)			\
-	int var = IS_ENABLED(config);				\
-	static int __init parse_##var##_on(char *arg)		\
-	{							\
-		var = 1;					\
-		return 0;					\
-	}							\
-	static int __init parse_##var##_off(char *arg)		\
-	{							\
-		var = 0;					\
-		return 0;					\
-	}							\
-	__setup_param(str_on, parse_##var##_on, parse_##var##_on, 1); \
+#define early_param_on_off(str_on, str_off, var, config)		\
+									\
+	int var = IS_ENABLED(config);					\
+									\
+	static int __init parse_##var##_on(char *arg)			\
+	{								\
+		var = 1;						\
+		return 0;						\
+	}								\
+	__setup_param(str_on, parse_##var##_on, parse_##var##_on, 1);	\
+									\
+	static int __init parse_##var##_off(char *arg)			\
+	{								\
+		var = 0;						\
+		return 0;						\
+	}								\
 	__setup_param(str_off, parse_##var##_off, parse_##var##_off, 1)
 
 /* Relies on boot_command_line being set */

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

* Re: [PATCH 5/4] x86/mm: Further simplify 1 GB kernel linear mappings handling
  2015-03-05  7:23 ` [PATCH 5/4] x86/mm: Further simplify 1 GB kernel linear mappings handling Ingo Molnar
@ 2015-03-05  8:05   ` Jan Beulich
  2015-03-05  8:23     ` Ingo Molnar
  0 siblings, 1 reply; 19+ messages in thread
From: Jan Beulich @ 2015-03-05  8:05 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: luto, tony, david.vrabel, Luis R. Rodriguez, toshi.kani,
	qiuxishi, x86, iamjoonsoo.kim, tglx, akpm, dave.hansen, gregkh,
	julia.lawall, decui, mingo, Juergen Gross, Luis Rodriguez,
	vbabka, bp, pavel, linux-kernel, hpa

>>> On 05.03.15 at 08:23, <mingo@kernel.org> wrote:

> It's a bit pointless to allow Kconfig configuration for 1GB kernel
> mappings, it's already hidden behind a 'default y' and CONFIG_EXPERT.
> 
> Remove this complication and simplify the code by renaming
> CONFIG_ENABLE_DIRECT_GBPAGES to CONFIG_X86_DIRECT_GBPAGES and
> document the DEBUG_PAGE_ALLOC and KMEMCHECK quirks.
> 
> Cc: Luis R. Rodriguez <mcgrof@suse.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Andy Lutomirski <luto@amacapital.net>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: David Vrabel <david.vrabel@citrix.com>
> Cc: Dexuan Cui <decui@microsoft.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: JBeulich@suse.com 
> Cc: Jan Beulich <JBeulich@suse.com>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> Cc: Juergen Gross <jgross@suse.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Toshi Kani <toshi.kani@hp.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: Xishi Qiu <qiuxishi@huawei.com>
> Cc: julia.lawall@lip6.fr 
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> ---
>  arch/x86/Kconfig   | 23 +++++++----------------
>  arch/x86/mm/init.c |  7 +------
>  2 files changed, 8 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 4d06e1c8294a..54d528a37ff4 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -1299,22 +1299,13 @@ config ARCH_DMA_ADDR_T_64BIT
>  	def_bool y
>  	depends on X86_64 || HIGHMEM64G
>  
> -config ENABLE_DIRECT_GBPAGES
> -	def_bool y
> -	depends on X86_64 && !DEBUG_PAGEALLOC && !KMEMCHECK
> -
> -config DIRECT_GBPAGES
> -	bool "Enable 1GB pages for kernel pagetables" if EXPERT
> -	default y
> -	depends on ENABLE_DIRECT_GBPAGES
> -	---help---
> -	  Enable by default the kernel linear mapping to use 1GB pages on CPUs
> -	  that support it. This can improve the kernel's performance a tiny bit
> -	  by reducing TLB pressure. If in doubt, say "Y". If you've disabled
> -	  option but your platform is capable of handling support for this
> -	  you can use the gbpages kernel parameter. Likewise if you've enabled
> -	  this but you'd like to force disable this option you can use the
> -	  nogbpages kernel parameter.
> +config X86_DIRECT_GBPAGES
> +	def_bool (X86_64 && !DEBUG_PAGEALLOC && !KMEMCHECK)

config X86_DIRECT_GBPAGES
	def_bool y
	depends on X86_64 && !DEBUG_PAGEALLOC && !KMEMCHECK

or else it'll leave a pointless

# CONFIG_X86_DIRECT_GBPAGES is not set

in .config-s where the dependencies are not met.

Jan


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

* [PATCH] x86/mm/pat: Initialize __cachemode2pte_tbl[] and __pte2cachemode_tbl[] in a bit more readable fashion
  2015-03-05  1:24 [RFC v1 0/4] x86: simpify direct_gbpages setting, add early_param_on_off() Luis R. Rodriguez
                   ` (6 preceding siblings ...)
  2015-03-05  7:44 ` [PATCH 7/4] init.h: Clean up the __setup()/early_param() macros Ingo Molnar
@ 2015-03-05  8:21 ` Ingo Molnar
  2015-03-05  8:42   ` Juergen Gross
  2015-03-05 11:51   ` [tip:x86/mm] " tip-bot for Ingo Molnar
  7 siblings, 2 replies; 19+ messages in thread
From: Ingo Molnar @ 2015-03-05  8:21 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: gregkh, akpm, tony, tglx, mingo, hpa, jgross, luto, toshi.kani,
	dave.hansen, JBeulich, pavel, qiuxishi, david.vrabel, bp, vbabka,
	iamjoonsoo.kim, decui, linux-kernel, x86, julia.lawall,
	Luis R. Rodriguez


( So this patch is not directly related to gbpages, but while reading 
  arch/x86/mm/init.c I could not resist ... )

=======================>

The initialization of these two arrays is a bit difficult to follow:
restructure it optically so that a 2D structure shows which bit in
the PTE is set and which not.

Also improve on comments a bit.

No code or data changed:

  # arch/x86/mm/init.o:

   text    data     bss     dec     hex filename
   4585     424   29776   34785    87e1 init.o.before
   4585     424   29776   34785    87e1 init.o.after

md5:
   a82e11ff58bcfd0af3a94662a701f65d  init.o.before.asm
   a82e11ff58bcfd0af3a94662a701f65d  init.o.after.asm

Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/mm/init.c | 40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 6dc85d51cd98..4469563f8c3b 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -29,29 +29,33 @@
 
 /*
  * Tables translating between page_cache_type_t and pte encoding.
- * Minimal supported modes are defined statically, modified if more supported
- * cache modes are available.
- * Index into __cachemode2pte_tbl is the cachemode.
- * Index into __pte2cachemode_tbl are the caching attribute bits of the pte
- * (_PAGE_PWT, _PAGE_PCD, _PAGE_PAT) at index bit positions 0, 1, 2.
+ *
+ * Minimal supported modes are defined statically, they are modified
+ * during bootup if more supported cache modes are available.
+ *
+ *   Index into __cachemode2pte_tbl[] is the cachemode.
+ *
+ *   Index into __pte2cachemode_tbl[] are the caching attribute bits of the pte
+ *   (_PAGE_PWT, _PAGE_PCD, _PAGE_PAT) at index bit positions 0, 1, 2.
  */
 uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM] = {
-	[_PAGE_CACHE_MODE_WB]		= 0,
-	[_PAGE_CACHE_MODE_WC]		= _PAGE_PWT,
-	[_PAGE_CACHE_MODE_UC_MINUS]	= _PAGE_PCD,
-	[_PAGE_CACHE_MODE_UC]		= _PAGE_PCD | _PAGE_PWT,
-	[_PAGE_CACHE_MODE_WT]		= _PAGE_PCD,
-	[_PAGE_CACHE_MODE_WP]		= _PAGE_PCD,
+	[_PAGE_CACHE_MODE_WB      ]	= 0         | 0        ,
+	[_PAGE_CACHE_MODE_WC      ]	= _PAGE_PWT | 0        ,
+	[_PAGE_CACHE_MODE_UC_MINUS]	= 0         | _PAGE_PCD,
+	[_PAGE_CACHE_MODE_UC      ]	= _PAGE_PWT | _PAGE_PCD,
+	[_PAGE_CACHE_MODE_WT      ]	= 0         | _PAGE_PCD,
+	[_PAGE_CACHE_MODE_WP      ]	= 0         | _PAGE_PCD,
 };
 EXPORT_SYMBOL(__cachemode2pte_tbl);
+
 uint8_t __pte2cachemode_tbl[8] = {
-	[__pte2cm_idx(0)] = _PAGE_CACHE_MODE_WB,
-	[__pte2cm_idx(_PAGE_PWT)] = _PAGE_CACHE_MODE_WC,
-	[__pte2cm_idx(_PAGE_PCD)] = _PAGE_CACHE_MODE_UC_MINUS,
-	[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD)] = _PAGE_CACHE_MODE_UC,
-	[__pte2cm_idx(_PAGE_PAT)] = _PAGE_CACHE_MODE_WB,
-	[__pte2cm_idx(_PAGE_PWT | _PAGE_PAT)] = _PAGE_CACHE_MODE_WC,
-	[__pte2cm_idx(_PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC_MINUS,
+	[__pte2cm_idx( 0        | 0         | 0        )] = _PAGE_CACHE_MODE_WB,
+	[__pte2cm_idx(_PAGE_PWT | 0         | 0        )] = _PAGE_CACHE_MODE_WC,
+	[__pte2cm_idx( 0        | _PAGE_PCD | 0        )] = _PAGE_CACHE_MODE_UC_MINUS,
+	[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | 0        )] = _PAGE_CACHE_MODE_UC,
+	[__pte2cm_idx( 0        | 0         | _PAGE_PAT)] = _PAGE_CACHE_MODE_WB,
+	[__pte2cm_idx(_PAGE_PWT | 0         | _PAGE_PAT)] = _PAGE_CACHE_MODE_WC,
+	[__pte2cm_idx(0         | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC_MINUS,
 	[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC,
 };
 EXPORT_SYMBOL(__pte2cachemode_tbl);

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

* Re: [PATCH 5/4] x86/mm: Further simplify 1 GB kernel linear mappings handling
  2015-03-05  8:05   ` Jan Beulich
@ 2015-03-05  8:23     ` Ingo Molnar
  0 siblings, 0 replies; 19+ messages in thread
From: Ingo Molnar @ 2015-03-05  8:23 UTC (permalink / raw)
  To: Jan Beulich
  Cc: luto, tony, david.vrabel, Luis R. Rodriguez, toshi.kani,
	qiuxishi, x86, iamjoonsoo.kim, tglx, akpm, dave.hansen, gregkh,
	julia.lawall, decui, mingo, Juergen Gross, Luis Rodriguez,
	vbabka, bp, pavel, linux-kernel, hpa


* Jan Beulich <JBeulich@suse.com> wrote:

> > +config X86_DIRECT_GBPAGES
> > +	def_bool (X86_64 && !DEBUG_PAGEALLOC && !KMEMCHECK)
> 
> config X86_DIRECT_GBPAGES
> 	def_bool y
> 	depends on X86_64 && !DEBUG_PAGEALLOC && !KMEMCHECK
> 
> or else it'll leave a pointless
> 
> # CONFIG_X86_DIRECT_GBPAGES is not set
> 
> in .config-s where the dependencies are not met.

Ok, fixed - thanks!

	Ingo

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

* Re: [PATCH 6/4] x86/mm: Simplify probe_page_size_mask()
  2015-03-05  7:27 ` [PATCH 6/4] x86/mm: Simplify probe_page_size_mask() Ingo Molnar
@ 2015-03-05  8:38   ` Juergen Gross
  2015-03-05  8:47     ` Ingo Molnar
  0 siblings, 1 reply; 19+ messages in thread
From: Juergen Gross @ 2015-03-05  8:38 UTC (permalink / raw)
  To: Ingo Molnar, Luis R. Rodriguez
  Cc: gregkh, akpm, tony, tglx, mingo, hpa, luto, toshi.kani,
	dave.hansen, JBeulich, pavel, qiuxishi, david.vrabel, bp, vbabka,
	iamjoonsoo.kim, decui, linux-kernel, x86, julia.lawall,
	Luis R. Rodriguez

On 03/05/2015 08:27 AM, Ingo Molnar wrote:
>
> Now that we've simplified the gbpages config space, move the
> 'page_size_mask' initialization into probe_page_size_mask(), right
> next to the PSE and PGE enablement lines.
>
> Cc: Luis R. Rodriguez <mcgrof@suse.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Andy Lutomirski <luto@amacapital.net>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: David Vrabel <david.vrabel@citrix.com>
> Cc: Dexuan Cui <decui@microsoft.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: JBeulich@suse.com
> Cc: Jan Beulich <JBeulich@suse.com>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> Cc: Juergen Gross <jgross@suse.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Toshi Kani <toshi.kani@hp.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: Xishi Qiu <qiuxishi@huawei.com>
> Cc: julia.lawall@lip6.fr
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> ---
>   arch/x86/mm/init.c | 23 ++++++++++-------------
>   1 file changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
> index 8704153f2675..6dc85d51cd98 100644
> --- a/arch/x86/mm/init.c
> +++ b/arch/x86/mm/init.c
> @@ -131,29 +131,18 @@ void  __init early_alloc_pgt_buf(void)
>
>   int after_bootmem;
>
> -static int page_size_mask;
> -
>   early_param_on_off("gbpages", "nogbpages", direct_gbpages, CONFIG_X86_DIRECT_GBPAGES);
>
> -static void __init init_gbpages(void)
> -{
> -	if (direct_gbpages && cpu_has_gbpages) {
> -		printk(KERN_INFO "Using GB pages for direct mapping\n");
> -		page_size_mask |= 1 << PG_LEVEL_1G;
> -	} else
> -		direct_gbpages = 0;
> -}
> -
>   struct map_range {
>   	unsigned long start;
>   	unsigned long end;
>   	unsigned page_size_mask;
>   };
>
> +static int page_size_mask;
> +
>   static void __init probe_page_size_mask(void)
>   {
> -	init_gbpages();
> -
>   #if !defined(CONFIG_DEBUG_PAGEALLOC) && !defined(CONFIG_KMEMCHECK)
>   	/*
>   	 * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
> @@ -173,6 +162,14 @@ static void __init probe_page_size_mask(void)
>   		cr4_set_bits_and_update_boot(X86_CR4_PGE);
>   		__supported_pte_mask |= _PAGE_GLOBAL;
>   	}
> +
> +	/* Enable 1 GB linear kernel mappings if available: */
> +	if (direct_gbpages && cpu_has_gbpages) {
> +		printk(KERN_INFO "Using GB pages for direct mapping\n");

pr_info()?

> +		page_size_mask |= 1 << PG_LEVEL_1G;
> +	} else {
> +		direct_gbpages = 0;
> +	}
>   }
>
>   #ifdef CONFIG_X86_32
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>


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

* Re: [PATCH] x86/mm/pat: Initialize __cachemode2pte_tbl[] and __pte2cachemode_tbl[] in a bit more readable fashion
  2015-03-05  8:21 ` [PATCH] x86/mm/pat: Initialize __cachemode2pte_tbl[] and __pte2cachemode_tbl[] in a bit more readable fashion Ingo Molnar
@ 2015-03-05  8:42   ` Juergen Gross
  2015-03-05 11:51   ` [tip:x86/mm] " tip-bot for Ingo Molnar
  1 sibling, 0 replies; 19+ messages in thread
From: Juergen Gross @ 2015-03-05  8:42 UTC (permalink / raw)
  To: Ingo Molnar, Luis R. Rodriguez
  Cc: gregkh, akpm, tony, tglx, mingo, hpa, luto, toshi.kani,
	dave.hansen, JBeulich, pavel, qiuxishi, david.vrabel, bp, vbabka,
	iamjoonsoo.kim, decui, linux-kernel, x86, julia.lawall,
	Luis R. Rodriguez

On 03/05/2015 09:21 AM, Ingo Molnar wrote:
>
> ( So this patch is not directly related to gbpages, but while reading
>    arch/x86/mm/init.c I could not resist ... )
>
> =======================>
>
> The initialization of these two arrays is a bit difficult to follow:
> restructure it optically so that a 2D structure shows which bit in
> the PTE is set and which not.
>
> Also improve on comments a bit.
>
> No code or data changed:
>
>    # arch/x86/mm/init.o:
>
>     text    data     bss     dec     hex filename
>     4585     424   29776   34785    87e1 init.o.before
>     4585     424   29776   34785    87e1 init.o.after
>
> md5:
>     a82e11ff58bcfd0af3a94662a701f65d  init.o.before.asm
>     a82e11ff58bcfd0af3a94662a701f65d  init.o.after.asm
>
> Cc: Andy Lutomirski <luto@amacapital.net>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Jan Beulich <JBeulich@suse.com>
> Cc: Juergen Gross <jgross@suse.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Luis R. Rodriguez <mcgrof@suse.com>
> Cc: Toshi Kani <toshi.kani@hp.com>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Ingo Molnar <mingo@kernel.org>

Reviewed-by: Juergen Gross <jgross@suse.com>

> ---
>   arch/x86/mm/init.c | 40 ++++++++++++++++++++++------------------
>   1 file changed, 22 insertions(+), 18 deletions(-)
>
> diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
> index 6dc85d51cd98..4469563f8c3b 100644
> --- a/arch/x86/mm/init.c
> +++ b/arch/x86/mm/init.c
> @@ -29,29 +29,33 @@
>
>   /*
>    * Tables translating between page_cache_type_t and pte encoding.
> - * Minimal supported modes are defined statically, modified if more supported
> - * cache modes are available.
> - * Index into __cachemode2pte_tbl is the cachemode.
> - * Index into __pte2cachemode_tbl are the caching attribute bits of the pte
> - * (_PAGE_PWT, _PAGE_PCD, _PAGE_PAT) at index bit positions 0, 1, 2.
> + *
> + * Minimal supported modes are defined statically, they are modified
> + * during bootup if more supported cache modes are available.
> + *
> + *   Index into __cachemode2pte_tbl[] is the cachemode.
> + *
> + *   Index into __pte2cachemode_tbl[] are the caching attribute bits of the pte
> + *   (_PAGE_PWT, _PAGE_PCD, _PAGE_PAT) at index bit positions 0, 1, 2.
>    */
>   uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM] = {
> -	[_PAGE_CACHE_MODE_WB]		= 0,
> -	[_PAGE_CACHE_MODE_WC]		= _PAGE_PWT,
> -	[_PAGE_CACHE_MODE_UC_MINUS]	= _PAGE_PCD,
> -	[_PAGE_CACHE_MODE_UC]		= _PAGE_PCD | _PAGE_PWT,
> -	[_PAGE_CACHE_MODE_WT]		= _PAGE_PCD,
> -	[_PAGE_CACHE_MODE_WP]		= _PAGE_PCD,
> +	[_PAGE_CACHE_MODE_WB      ]	= 0         | 0        ,
> +	[_PAGE_CACHE_MODE_WC      ]	= _PAGE_PWT | 0        ,
> +	[_PAGE_CACHE_MODE_UC_MINUS]	= 0         | _PAGE_PCD,
> +	[_PAGE_CACHE_MODE_UC      ]	= _PAGE_PWT | _PAGE_PCD,
> +	[_PAGE_CACHE_MODE_WT      ]	= 0         | _PAGE_PCD,
> +	[_PAGE_CACHE_MODE_WP      ]	= 0         | _PAGE_PCD,
>   };
>   EXPORT_SYMBOL(__cachemode2pte_tbl);
> +
>   uint8_t __pte2cachemode_tbl[8] = {
> -	[__pte2cm_idx(0)] = _PAGE_CACHE_MODE_WB,
> -	[__pte2cm_idx(_PAGE_PWT)] = _PAGE_CACHE_MODE_WC,
> -	[__pte2cm_idx(_PAGE_PCD)] = _PAGE_CACHE_MODE_UC_MINUS,
> -	[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD)] = _PAGE_CACHE_MODE_UC,
> -	[__pte2cm_idx(_PAGE_PAT)] = _PAGE_CACHE_MODE_WB,
> -	[__pte2cm_idx(_PAGE_PWT | _PAGE_PAT)] = _PAGE_CACHE_MODE_WC,
> -	[__pte2cm_idx(_PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC_MINUS,
> +	[__pte2cm_idx( 0        | 0         | 0        )] = _PAGE_CACHE_MODE_WB,
> +	[__pte2cm_idx(_PAGE_PWT | 0         | 0        )] = _PAGE_CACHE_MODE_WC,
> +	[__pte2cm_idx( 0        | _PAGE_PCD | 0        )] = _PAGE_CACHE_MODE_UC_MINUS,
> +	[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | 0        )] = _PAGE_CACHE_MODE_UC,
> +	[__pte2cm_idx( 0        | 0         | _PAGE_PAT)] = _PAGE_CACHE_MODE_WB,
> +	[__pte2cm_idx(_PAGE_PWT | 0         | _PAGE_PAT)] = _PAGE_CACHE_MODE_WC,
> +	[__pte2cm_idx(0         | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC_MINUS,
>   	[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC,
>   };
>   EXPORT_SYMBOL(__pte2cachemode_tbl);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>


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

* Re: [PATCH 6/4] x86/mm: Simplify probe_page_size_mask()
  2015-03-05  8:38   ` Juergen Gross
@ 2015-03-05  8:47     ` Ingo Molnar
  0 siblings, 0 replies; 19+ messages in thread
From: Ingo Molnar @ 2015-03-05  8:47 UTC (permalink / raw)
  To: Juergen Gross
  Cc: Luis R. Rodriguez, gregkh, akpm, tony, tglx, mingo, hpa, luto,
	toshi.kani, dave.hansen, JBeulich, pavel, qiuxishi, david.vrabel,
	bp, vbabka, iamjoonsoo.kim, decui, linux-kernel, x86,
	julia.lawall, Luis R. Rodriguez


* Juergen Gross <jgross@suse.com> wrote:

> On 03/05/2015 08:27 AM, Ingo Molnar wrote:
> >
> >Now that we've simplified the gbpages config space, move the
> >'page_size_mask' initialization into probe_page_size_mask(), right
> >next to the PSE and PGE enablement lines.
> >
> >Cc: Luis R. Rodriguez <mcgrof@suse.com>
> >Cc: Andrew Morton <akpm@linux-foundation.org>
> >Cc: Andy Lutomirski <luto@amacapital.net>
> >Cc: Borislav Petkov <bp@alien8.de>
> >Cc: Borislav Petkov <bp@suse.de>
> >Cc: Dave Hansen <dave.hansen@linux.intel.com>
> >Cc: David Vrabel <david.vrabel@citrix.com>
> >Cc: Dexuan Cui <decui@microsoft.com>
> >Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >Cc: H. Peter Anvin <hpa@zytor.com>
> >Cc: JBeulich@suse.com
> >Cc: Jan Beulich <JBeulich@suse.com>
> >Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> >Cc: Juergen Gross <jgross@suse.com>
> >Cc: Linus Torvalds <torvalds@linux-foundation.org>
> >Cc: Pavel Machek <pavel@ucw.cz>
> >Cc: Thomas Gleixner <tglx@linutronix.de>
> >Cc: Tony Lindgren <tony@atomide.com>
> >Cc: Toshi Kani <toshi.kani@hp.com>
> >Cc: Vlastimil Babka <vbabka@suse.cz>
> >Cc: Xishi Qiu <qiuxishi@huawei.com>
> >Cc: julia.lawall@lip6.fr
> >Signed-off-by: Ingo Molnar <mingo@kernel.org>
> >---
> >  arch/x86/mm/init.c | 23 ++++++++++-------------
> >  1 file changed, 10 insertions(+), 13 deletions(-)
> >
> >diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
> >index 8704153f2675..6dc85d51cd98 100644
> >--- a/arch/x86/mm/init.c
> >+++ b/arch/x86/mm/init.c
> >@@ -131,29 +131,18 @@ void  __init early_alloc_pgt_buf(void)
> >
> >  int after_bootmem;
> >
> >-static int page_size_mask;
> >-
> >  early_param_on_off("gbpages", "nogbpages", direct_gbpages, CONFIG_X86_DIRECT_GBPAGES);
> >
> >-static void __init init_gbpages(void)
> >-{
> >-	if (direct_gbpages && cpu_has_gbpages) {
> >-		printk(KERN_INFO "Using GB pages for direct mapping\n");
> >-		page_size_mask |= 1 << PG_LEVEL_1G;
> >-	} else
> >-		direct_gbpages = 0;
> >-}
> >-
> >  struct map_range {
> >  	unsigned long start;
> >  	unsigned long end;
> >  	unsigned page_size_mask;
> >  };
> >
> >+static int page_size_mask;
> >+
> >  static void __init probe_page_size_mask(void)
> >  {
> >-	init_gbpages();
> >-
> >  #if !defined(CONFIG_DEBUG_PAGEALLOC) && !defined(CONFIG_KMEMCHECK)
> >  	/*
> >  	 * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
> >@@ -173,6 +162,14 @@ static void __init probe_page_size_mask(void)
> >  		cr4_set_bits_and_update_boot(X86_CR4_PGE);
> >  		__supported_pte_mask |= _PAGE_GLOBAL;
> >  	}
> >+
> >+	/* Enable 1 GB linear kernel mappings if available: */
> >+	if (direct_gbpages && cpu_has_gbpages) {
> >+		printk(KERN_INFO "Using GB pages for direct mapping\n");
> 
> pr_info()?

Yeah - probably in a separate patch, as there's three other KERN_ 
users in arch/x86/mm/init.c.

Thanks,

	Ingo

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

* [tip:x86/mm] x86/mm: Use IS_ENABLED() for direct_gbpages
  2015-03-05  1:24 ` [RFC v1 1/4] x86: mm: use IS_ENABLED() for direct_gbpages Luis R. Rodriguez
@ 2015-03-05 11:49   ` tip-bot for Luis R. Rodriguez
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Luis R. Rodriguez @ 2015-03-05 11:49 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: JBeulich, hpa, toshi.kani, david.vrabel, tony, pavel,
	dave.hansen, bp, bp, vbabka, luto, gregkh, iamjoonsoo.kim,
	linux-kernel, tglx, mcgrof, torvalds, jgross, decui, akpm, mingo,
	qiuxishi

Commit-ID:  d9fd579c218e22c897f0f1b9e132af9b436cf445
Gitweb:     http://git.kernel.org/tip/d9fd579c218e22c897f0f1b9e132af9b436cf445
Author:     Luis R. Rodriguez <mcgrof@suse.com>
AuthorDate: Wed, 4 Mar 2015 17:24:11 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 5 Mar 2015 08:02:11 +0100

x86/mm: Use IS_ENABLED() for direct_gbpages

Replace #ifdef eyesore with IS_ENABLED() use.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: JBeulich@suse.com
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: julia.lawall@lip6.fr
Link: http://lkml.kernel.org/r/1425518654-3403-2-git-send-email-mcgrof@do-not-panic.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/mm/init.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index a110efc..74f2b37 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -131,11 +131,7 @@ void  __init early_alloc_pgt_buf(void)
 
 int after_bootmem;
 
-int direct_gbpages
-#ifdef CONFIG_DIRECT_GBPAGES
-				= 1
-#endif
-;
+int direct_gbpages = IS_ENABLED(CONFIG_DIRECT_GBPAGES);
 
 static void __init init_gbpages(void)
 {

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

* [tip:x86/mm] x86/mm: Simplify enabling direct_gbpages
  2015-03-05  1:24 ` [RFC v1 2/4] x86: mm: simplify enabling direct_gbpages Luis R. Rodriguez
@ 2015-03-05 11:49   ` tip-bot for Luis R. Rodriguez
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Luis R. Rodriguez @ 2015-03-05 11:49 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, gregkh, toshi.kani, mingo, akpm, qiuxishi, bp, vbabka,
	iamjoonsoo.kim, JBeulich, linux-kernel, decui, tony, dave.hansen,
	mcgrof, jgross, tglx, bp, torvalds, pavel, luto, david.vrabel

Commit-ID:  e5008abe929c160d36e44b8c2b644d4330d2e389
Gitweb:     http://git.kernel.org/tip/e5008abe929c160d36e44b8c2b644d4330d2e389
Author:     Luis R. Rodriguez <mcgrof@suse.com>
AuthorDate: Wed, 4 Mar 2015 17:24:12 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 5 Mar 2015 08:02:12 +0100

x86/mm: Simplify enabling direct_gbpages

direct_gbpages can be force enabled as an early parameter
but not really have taken effect when DEBUG_PAGEALLOC
or KMEMCHECK is enabled. You can also enable direct_gbpages
right now if you have an x86_64 architecture but your CPU
doesn't really have support for this feature. In both cases
PG_LEVEL_1G won't actually be enabled but direct_gbpages is used
in other areas under the assumptions that PG_LEVEL_1G
was set. Fix this by putting together all requirements
which make this feature sensible to enable under, and only
enable both finally flipping on PG_LEVEL_1G and leaving
PG_LEVEL_1G set when this is true.

We only enable this feature then to be possible on sensible
builds defined by the new ENABLE_DIRECT_GBPAGES. If the
CPU has support for it you can either enable this by using
the DIRECT_GBPAGES option or using the early kernel parameter.
If a platform had support for this you can always force disable
it as well.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: JBeulich@suse.com
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: julia.lawall@lip6.fr
Link: http://lkml.kernel.org/r/1425518654-3403-3-git-send-email-mcgrof@do-not-panic.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/Kconfig       | 18 +++++++++++++-----
 arch/x86/mm/init.c     | 17 +++++++++--------
 arch/x86/mm/pageattr.c |  2 --
 3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index c2fb8a8..4d06e1c 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1299,14 +1299,22 @@ config ARCH_DMA_ADDR_T_64BIT
 	def_bool y
 	depends on X86_64 || HIGHMEM64G
 
+config ENABLE_DIRECT_GBPAGES
+	def_bool y
+	depends on X86_64 && !DEBUG_PAGEALLOC && !KMEMCHECK
+
 config DIRECT_GBPAGES
 	bool "Enable 1GB pages for kernel pagetables" if EXPERT
 	default y
-	depends on X86_64
-	---help---
-	  Allow the kernel linear mapping to use 1GB pages on CPUs that
-	  support it. This can improve the kernel's performance a tiny bit by
-	  reducing TLB pressure. If in doubt, say "Y".
+	depends on ENABLE_DIRECT_GBPAGES
+	---help---
+	  Enable by default the kernel linear mapping to use 1GB pages on CPUs
+	  that support it. This can improve the kernel's performance a tiny bit
+	  by reducing TLB pressure. If in doubt, say "Y". If you've disabled
+	  option but your platform is capable of handling support for this
+	  you can use the gbpages kernel parameter. Likewise if you've enabled
+	  this but you'd like to force disable this option you can use the
+	  nogbpages kernel parameter.
 
 # Common NUMA Features
 config NUMA
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 74f2b37..2ce2c8e 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -131,16 +131,21 @@ void  __init early_alloc_pgt_buf(void)
 
 int after_bootmem;
 
+static int page_size_mask;
+
 int direct_gbpages = IS_ENABLED(CONFIG_DIRECT_GBPAGES);
 
 static void __init init_gbpages(void)
 {
-#ifdef CONFIG_X86_64
-	if (direct_gbpages && cpu_has_gbpages)
+	if (!IS_ENABLED(CONFIG_ENABLE_DIRECT_GBPAGES)) {
+		direct_gbpages = 0;
+		return;
+	}
+	if (direct_gbpages && cpu_has_gbpages) {
 		printk(KERN_INFO "Using GB pages for direct mapping\n");
-	else
+		page_size_mask |= 1 << PG_LEVEL_1G;
+	} else
 		direct_gbpages = 0;
-#endif
 }
 
 struct map_range {
@@ -149,8 +154,6 @@ struct map_range {
 	unsigned page_size_mask;
 };
 
-static int page_size_mask;
-
 static void __init probe_page_size_mask(void)
 {
 	init_gbpages();
@@ -161,8 +164,6 @@ static void __init probe_page_size_mask(void)
 	 * This will simplify cpa(), which otherwise needs to support splitting
 	 * large pages into small in interrupt context, etc.
 	 */
-	if (direct_gbpages)
-		page_size_mask |= 1 << PG_LEVEL_1G;
 	if (cpu_has_pse)
 		page_size_mask |= 1 << PG_LEVEL_2M;
 #endif
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 81e8282..89af288 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -81,11 +81,9 @@ void arch_report_meminfo(struct seq_file *m)
 	seq_printf(m, "DirectMap4M:    %8lu kB\n",
 			direct_pages_count[PG_LEVEL_2M] << 12);
 #endif
-#ifdef CONFIG_X86_64
 	if (direct_gbpages)
 		seq_printf(m, "DirectMap1G:    %8lu kB\n",
 			direct_pages_count[PG_LEVEL_1G] << 20);
-#endif
 }
 #else
 static inline void split_page_count(int level) { }

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

* [tip:x86/mm] init.h: Add early_param_on_off()
  2015-03-05  1:24 ` [RFC v1 3/4] init.h: add early_param_on_off() Luis R. Rodriguez
@ 2015-03-05 11:50   ` tip-bot for Luis R. Rodriguez
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Luis R. Rodriguez @ 2015-03-05 11:50 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, david.vrabel, iamjoonsoo.kim, linux-kernel, vbabka, bp,
	torvalds, JBeulich, jgross, tony, mcgrof, tglx, bp, qiuxishi,
	gregkh, dave.hansen, luto, hpa, akpm, decui, pavel, toshi.kani

Commit-ID:  bfb33bad83f650f265ed65cbfe8352b7c3ce8c76
Gitweb:     http://git.kernel.org/tip/bfb33bad83f650f265ed65cbfe8352b7c3ce8c76
Author:     Luis R. Rodriguez <mcgrof@suse.com>
AuthorDate: Wed, 4 Mar 2015 17:24:13 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 5 Mar 2015 08:02:12 +0100

init.h: Add early_param_on_off()

At times all you need is a kconfig variable to enable a feature,
by default but you may want to also enable / disable it through
a kernel parameter. In such cases the parameter routines to turn
the thing on / off are really simple. Just use a wrapper for
this, it lets us generalize the code and makes it easier to
associate parameters with related kernel configuration options.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: JBeulich@suse.com
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: julia.lawall@lip6.fr
Link: http://lkml.kernel.org/r/1425518654-3403-4-git-send-email-mcgrof@do-not-panic.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/init.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/init.h b/include/linux/init.h
index 2df8e8d..bc11ff9 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -268,6 +268,21 @@ struct obs_kernel_param {
 #define early_param(str, fn)					\
 	__setup_param(str, fn, fn, 1)
 
+#define early_param_on_off(str_on, str_off, var, config)			\
+	int var = IS_ENABLED(config);				\
+	static int __init parse_##var##_on(char *arg)		\
+	{							\
+		var = 1;					\
+		return 0;					\
+	}							\
+	static int __init parse_##var##_off(char *arg)		\
+	{							\
+		var = 0;					\
+		return 0;					\
+	}							\
+	__setup_param(str_on, parse_##var##_on, parse_##var##_on, 1); \
+	__setup_param(str_off, parse_##var##_off, parse_##var##_off, 1)
+
 /* Relies on boot_command_line being set */
 void __init parse_early_param(void);
 void __init parse_early_options(char *cmdline);

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

* [tip:x86/mm] x86/mm: Use early_param_on_off() for direct_gbpages
  2015-03-05  1:24 ` [RFC v1 4/4] x86: mm: use early_param_on_off() for direct_gbpages Luis R. Rodriguez
@ 2015-03-05 11:50   ` tip-bot for Luis R. Rodriguez
  0 siblings, 0 replies; 19+ messages in thread
From: tip-bot for Luis R. Rodriguez @ 2015-03-05 11:50 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tony, JBeulich, gregkh, decui, toshi.kani, david.vrabel, pavel,
	bp, luto, iamjoonsoo.kim, linux-kernel, mingo, qiuxishi, bp,
	vbabka, akpm, hpa, jgross, dave.hansen, mcgrof, torvalds, tglx

Commit-ID:  73c8c861dc5bddf1b24c6aeffee2292c96cf8db2
Gitweb:     http://git.kernel.org/tip/73c8c861dc5bddf1b24c6aeffee2292c96cf8db2
Author:     Luis R. Rodriguez <mcgrof@suse.com>
AuthorDate: Wed, 4 Mar 2015 17:24:14 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 5 Mar 2015 08:02:12 +0100

x86/mm: Use early_param_on_off() for direct_gbpages

The enabler / disabler is pretty simple, just use the
provided wrappers, this lets us easily relate the variable
to the associated Kconfig entry.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: JBeulich@suse.com
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: julia.lawall@lip6.fr
Link: http://lkml.kernel.org/r/1425518654-3403-5-git-send-email-mcgrof@do-not-panic.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/mm/init.c    |  3 ++-
 arch/x86/mm/init_64.c | 14 --------------
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 2ce2c8e..c35ba8b 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -133,7 +133,8 @@ int after_bootmem;
 
 static int page_size_mask;
 
-int direct_gbpages = IS_ENABLED(CONFIG_DIRECT_GBPAGES);
+early_param_on_off("gbpages", "nogbpages",
+		   direct_gbpages, CONFIG_DIRECT_GBPAGES);
 
 static void __init init_gbpages(void)
 {
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 30eb05a..3fba623 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -130,20 +130,6 @@ int kernel_ident_mapping_init(struct x86_mapping_info *info, pgd_t *pgd_page,
 	return 0;
 }
 
-static int __init parse_direct_gbpages_off(char *arg)
-{
-	direct_gbpages = 0;
-	return 0;
-}
-early_param("nogbpages", parse_direct_gbpages_off);
-
-static int __init parse_direct_gbpages_on(char *arg)
-{
-	direct_gbpages = 1;
-	return 0;
-}
-early_param("gbpages", parse_direct_gbpages_on);
-
 /*
  * NOTE: pagetable_init alloc all the fixmap pagetables contiguous on the
  * physical space so we can cache the place of the first one and move

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

* [tip:x86/mm] x86/mm/pat: Initialize __cachemode2pte_tbl[] and __pte2cachemode_tbl[] in a bit more readable fashion
  2015-03-05  8:21 ` [PATCH] x86/mm/pat: Initialize __cachemode2pte_tbl[] and __pte2cachemode_tbl[] in a bit more readable fashion Ingo Molnar
  2015-03-05  8:42   ` Juergen Gross
@ 2015-03-05 11:51   ` tip-bot for Ingo Molnar
  1 sibling, 0 replies; 19+ messages in thread
From: tip-bot for Ingo Molnar @ 2015-03-05 11:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: luto, hpa, linux-kernel, jgross, mcgrof, torvalds, tglx,
	dave.hansen, toshi.kani, mingo, JBeulich

Commit-ID:  c709feda56886c38af3116254f84cbe6a78b3a5d
Gitweb:     http://git.kernel.org/tip/c709feda56886c38af3116254f84cbe6a78b3a5d
Author:     Ingo Molnar <mingo@kernel.org>
AuthorDate: Thu, 5 Mar 2015 08:58:44 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 5 Mar 2015 09:48:17 +0100

x86/mm/pat: Initialize __cachemode2pte_tbl[] and __pte2cachemode_tbl[] in a bit more readable fashion

The initialization of these two arrays is a bit difficult to follow:
restructure it optically so that a 2D structure shows which bit in
the PTE is set and which not.

Also improve on comments a bit.

No code or data changed:

  # arch/x86/mm/init.o:

   text    data     bss     dec     hex filename
   4585     424   29776   34785    87e1 init.o.before
   4585     424   29776   34785    87e1 init.o.after

md5:
   a82e11ff58bcfd0af3a94662a701f65d  init.o.before.asm
   a82e11ff58bcfd0af3a94662a701f65d  init.o.after.asm

Reviewed-by: Juergen Gross <jgross@suse.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/20150305082135.GB5969@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/mm/init.c | 40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 6dc85d5..4469563 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -29,29 +29,33 @@
 
 /*
  * Tables translating between page_cache_type_t and pte encoding.
- * Minimal supported modes are defined statically, modified if more supported
- * cache modes are available.
- * Index into __cachemode2pte_tbl is the cachemode.
- * Index into __pte2cachemode_tbl are the caching attribute bits of the pte
- * (_PAGE_PWT, _PAGE_PCD, _PAGE_PAT) at index bit positions 0, 1, 2.
+ *
+ * Minimal supported modes are defined statically, they are modified
+ * during bootup if more supported cache modes are available.
+ *
+ *   Index into __cachemode2pte_tbl[] is the cachemode.
+ *
+ *   Index into __pte2cachemode_tbl[] are the caching attribute bits of the pte
+ *   (_PAGE_PWT, _PAGE_PCD, _PAGE_PAT) at index bit positions 0, 1, 2.
  */
 uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM] = {
-	[_PAGE_CACHE_MODE_WB]		= 0,
-	[_PAGE_CACHE_MODE_WC]		= _PAGE_PWT,
-	[_PAGE_CACHE_MODE_UC_MINUS]	= _PAGE_PCD,
-	[_PAGE_CACHE_MODE_UC]		= _PAGE_PCD | _PAGE_PWT,
-	[_PAGE_CACHE_MODE_WT]		= _PAGE_PCD,
-	[_PAGE_CACHE_MODE_WP]		= _PAGE_PCD,
+	[_PAGE_CACHE_MODE_WB      ]	= 0         | 0        ,
+	[_PAGE_CACHE_MODE_WC      ]	= _PAGE_PWT | 0        ,
+	[_PAGE_CACHE_MODE_UC_MINUS]	= 0         | _PAGE_PCD,
+	[_PAGE_CACHE_MODE_UC      ]	= _PAGE_PWT | _PAGE_PCD,
+	[_PAGE_CACHE_MODE_WT      ]	= 0         | _PAGE_PCD,
+	[_PAGE_CACHE_MODE_WP      ]	= 0         | _PAGE_PCD,
 };
 EXPORT_SYMBOL(__cachemode2pte_tbl);
+
 uint8_t __pte2cachemode_tbl[8] = {
-	[__pte2cm_idx(0)] = _PAGE_CACHE_MODE_WB,
-	[__pte2cm_idx(_PAGE_PWT)] = _PAGE_CACHE_MODE_WC,
-	[__pte2cm_idx(_PAGE_PCD)] = _PAGE_CACHE_MODE_UC_MINUS,
-	[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD)] = _PAGE_CACHE_MODE_UC,
-	[__pte2cm_idx(_PAGE_PAT)] = _PAGE_CACHE_MODE_WB,
-	[__pte2cm_idx(_PAGE_PWT | _PAGE_PAT)] = _PAGE_CACHE_MODE_WC,
-	[__pte2cm_idx(_PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC_MINUS,
+	[__pte2cm_idx( 0        | 0         | 0        )] = _PAGE_CACHE_MODE_WB,
+	[__pte2cm_idx(_PAGE_PWT | 0         | 0        )] = _PAGE_CACHE_MODE_WC,
+	[__pte2cm_idx( 0        | _PAGE_PCD | 0        )] = _PAGE_CACHE_MODE_UC_MINUS,
+	[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | 0        )] = _PAGE_CACHE_MODE_UC,
+	[__pte2cm_idx( 0        | 0         | _PAGE_PAT)] = _PAGE_CACHE_MODE_WB,
+	[__pte2cm_idx(_PAGE_PWT | 0         | _PAGE_PAT)] = _PAGE_CACHE_MODE_WC,
+	[__pte2cm_idx(0         | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC_MINUS,
 	[__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC,
 };
 EXPORT_SYMBOL(__pte2cachemode_tbl);

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

end of thread, other threads:[~2015-03-05 11:52 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-05  1:24 [RFC v1 0/4] x86: simpify direct_gbpages setting, add early_param_on_off() Luis R. Rodriguez
2015-03-05  1:24 ` [RFC v1 1/4] x86: mm: use IS_ENABLED() for direct_gbpages Luis R. Rodriguez
2015-03-05 11:49   ` [tip:x86/mm] x86/mm: Use " tip-bot for Luis R. Rodriguez
2015-03-05  1:24 ` [RFC v1 2/4] x86: mm: simplify enabling direct_gbpages Luis R. Rodriguez
2015-03-05 11:49   ` [tip:x86/mm] x86/mm: Simplify " tip-bot for Luis R. Rodriguez
2015-03-05  1:24 ` [RFC v1 3/4] init.h: add early_param_on_off() Luis R. Rodriguez
2015-03-05 11:50   ` [tip:x86/mm] init.h: Add early_param_on_off() tip-bot for Luis R. Rodriguez
2015-03-05  1:24 ` [RFC v1 4/4] x86: mm: use early_param_on_off() for direct_gbpages Luis R. Rodriguez
2015-03-05 11:50   ` [tip:x86/mm] x86/mm: Use " tip-bot for Luis R. Rodriguez
2015-03-05  7:23 ` [PATCH 5/4] x86/mm: Further simplify 1 GB kernel linear mappings handling Ingo Molnar
2015-03-05  8:05   ` Jan Beulich
2015-03-05  8:23     ` Ingo Molnar
2015-03-05  7:27 ` [PATCH 6/4] x86/mm: Simplify probe_page_size_mask() Ingo Molnar
2015-03-05  8:38   ` Juergen Gross
2015-03-05  8:47     ` Ingo Molnar
2015-03-05  7:44 ` [PATCH 7/4] init.h: Clean up the __setup()/early_param() macros Ingo Molnar
2015-03-05  8:21 ` [PATCH] x86/mm/pat: Initialize __cachemode2pte_tbl[] and __pte2cachemode_tbl[] in a bit more readable fashion Ingo Molnar
2015-03-05  8:42   ` Juergen Gross
2015-03-05 11:51   ` [tip:x86/mm] " tip-bot for Ingo Molnar

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).