x86: add hugepagesz option on 64-bit
authorAndi Kleen <ak@suse.de>
Thu, 24 Jul 2008 04:27:51 +0000 (21:27 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 24 Jul 2008 17:47:19 +0000 (10:47 -0700)
Add an hugepagesz=...  option similar to IA64, PPC etc.  to x86-64.

This finally allows to select GB pages for hugetlbfs in x86 now that all
the infrastructure is in place.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Documentation/kernel-parameters.txt
arch/x86/mm/hugetlbpage.c
include/asm-x86/page.h

index 5e20ccb5a736efdfa7b0e59cc92596057640346d..d55fd88fd0a94c0c469c7aecb98debf3cb90523f 100644 (file)
@@ -774,8 +774,15 @@ and is between 256 and 4096 characters. It is defined in the file
        hisax=          [HW,ISDN]
                        See Documentation/isdn/README.HiSax.
 
-       hugepages=      [HW,X86-32,IA-64] Maximal number of HugeTLB pages.
-       hugepagesz=     [HW,IA-64,PPC] The size of the HugeTLB pages.
+       hugepages=      [HW,X86-32,IA-64] HugeTLB pages to allocate at boot.
+       hugepagesz=     [HW,IA-64,PPC,X86-64] The size of the HugeTLB pages.
+                       On x86 this option can be specified multiple times
+                       interleaved with hugepages= to reserve huge pages
+                       of different sizes. Valid pages sizes on x86-64
+                       are 2M (when the CPU supports "pse") and 1G (when the
+                       CPU supports the "pdpe1gb" cpuinfo flag)
+                       Note that 1GB pages can only be allocated at boot time
+                       using hugepages= and not freed afterwards.
 
        i8042.direct    [HW] Put keyboard port into non-translated mode
        i8042.dumbkbd   [HW] Pretend that controller can only read data from
index b7a65a07af033ffea28f101f5a9cf4c6cc19f18e..8f307d914c2ec860c3b9093796362e9c4719ab41 100644 (file)
@@ -425,3 +425,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
 
 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
 
+#ifdef CONFIG_X86_64
+static __init int setup_hugepagesz(char *opt)
+{
+       unsigned long ps = memparse(opt, &opt);
+       if (ps == PMD_SIZE) {
+               hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT);
+       } else if (ps == PUD_SIZE && cpu_has_gbpages) {
+               hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
+       } else {
+               printk(KERN_ERR "hugepagesz: Unsupported page size %lu M\n",
+                       ps >> 20);
+               return 0;
+       }
+       return 1;
+}
+__setup("hugepagesz=", setup_hugepagesz);
+#endif
index 6c846228948d54f739ca59385ea647b521e39f32..6e02098b160527aa28415520ec4590ff3cab7898 100644 (file)
@@ -32,6 +32,8 @@
 #define HPAGE_MASK             (~(HPAGE_SIZE - 1))
 #define HUGETLB_PAGE_ORDER     (HPAGE_SHIFT - PAGE_SHIFT)
 
+#define HUGE_MAX_HSTATE 2
+
 /* to align the pointer to the (next) page boundary */
 #define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)