linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hugetlb, x86: register 1G page size if we can allocate them runtime
@ 2015-02-04 11:54 Kirill A. Shutemov
  2015-02-04 17:47 ` Luiz Capitulino
  0 siblings, 1 reply; 2+ messages in thread
From: Kirill A. Shutemov @ 2015-02-04 11:54 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, linux-kernel, Kirill A. Shutemov, Luiz Capitulino,
	Naoya Horiguchi, Andi Kleen, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin

After commit 944d9fec8d7a we can allocate 1G pages runtime if CMA is
enabled.

Let's register 1G pages into hugetlb even if user hasn't requested them
explicitly at boot time with hugepagesz=1G.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/mm/hugetlbpage.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
index 9161f764121e..42982b26e32b 100644
--- a/arch/x86/mm/hugetlbpage.c
+++ b/arch/x86/mm/hugetlbpage.c
@@ -172,4 +172,15 @@ static __init int setup_hugepagesz(char *opt)
 	return 1;
 }
 __setup("hugepagesz=", setup_hugepagesz);
+
+#ifdef CONFIG_CMA
+static __init int gigantic_pages_init(void)
+{
+	/* With CMA we can allocate gigantic pages at runtime */
+	if (cpu_has_gbpages && !size_to_hstate(1UL << PUD_SHIFT))
+		hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
+	return 0;
+}
+arch_initcall(gigantic_pages_init);
+#endif
 #endif
-- 
2.1.4


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

* Re: [PATCH] hugetlb, x86: register 1G page size if we can allocate them runtime
  2015-02-04 11:54 [PATCH] hugetlb, x86: register 1G page size if we can allocate them runtime Kirill A. Shutemov
@ 2015-02-04 17:47 ` Luiz Capitulino
  0 siblings, 0 replies; 2+ messages in thread
From: Luiz Capitulino @ 2015-02-04 17:47 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Andrew Morton, linux-mm, linux-kernel, Naoya Horiguchi,
	Andi Kleen, Thomas Gleixner, Ingo Molnar, H. Peter Anvin

On Wed,  4 Feb 2015 13:54:31 +0200
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> wrote:

> After commit 944d9fec8d7a we can allocate 1G pages runtime if CMA is
> enabled.
> 
> Let's register 1G pages into hugetlb even if user hasn't requested them
> explicitly at boot time with hugepagesz=1G.
> 
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Luiz Capitulino <lcapitulino@redhat.com>
> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Cc: Andi Kleen <ak@linux.intel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> ---
>  arch/x86/mm/hugetlbpage.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
> index 9161f764121e..42982b26e32b 100644
> --- a/arch/x86/mm/hugetlbpage.c
> +++ b/arch/x86/mm/hugetlbpage.c
> @@ -172,4 +172,15 @@ static __init int setup_hugepagesz(char *opt)
>  	return 1;
>  }
>  __setup("hugepagesz=", setup_hugepagesz);
> +
> +#ifdef CONFIG_CMA
> +static __init int gigantic_pages_init(void)
> +{
> +	/* With CMA we can allocate gigantic pages at runtime */
> +	if (cpu_has_gbpages && !size_to_hstate(1UL << PUD_SHIFT))
> +		hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
> +	return 0;
> +}
> +arch_initcall(gigantic_pages_init);
> +#endif
>  #endif

Very nice! I was thinking about this for a long time but I don't
think my implementation would be that simple:

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>

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

end of thread, other threads:[~2015-02-04 17:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-04 11:54 [PATCH] hugetlb, x86: register 1G page size if we can allocate them runtime Kirill A. Shutemov
2015-02-04 17:47 ` Luiz Capitulino

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