mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [4/7] hugetlb: internalize hugetlb init
@ 2002-11-06  2:29 William Lee Irwin III
  0 siblings, 0 replies; only message in thread
From: William Lee Irwin III @ 2002-11-06  2:29 UTC (permalink / raw)
  To: linux-kernel

This patch internalizes hugetlb initialization, implementing a command-line
option in the process.

 hugetlbpage.c |   40 ++++++++++++++++++++++++++++++++++++----
 init.c        |   31 -------------------------------
 2 files changed, 36 insertions(+), 35 deletions(-)


diff -urpN hugetlbfs-2.5.46-2/arch/i386/mm/hugetlbpage.c hugetlbfs-2.5.46-3/arch/i386/mm/hugetlbpage.c
--- hugetlbfs-2.5.46-2/arch/i386/mm/hugetlbpage.c	2002-11-05 11:07:53.000000000 -0800
+++ hugetlbfs-2.5.46-3/arch/i386/mm/hugetlbpage.c	2002-11-05 17:27:30.000000000 -0800
@@ -12,16 +12,19 @@
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
-
+#include <linux/module.h>
 #include <asm/mman.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
 
+long    htlbpagemem = 0;
+int     htlbpage_max;
+long    htlbzone_pages;
+
 struct vm_operations_struct hugetlb_vm_ops;
-struct list_head htlbpage_freelist;
-spinlock_t htlbpage_lock = SPIN_LOCK_UNLOCKED;
-extern long htlbpagemem;
+static LIST_HEAD(htlbpage_freelist);
+static spinlock_t htlbpage_lock = SPIN_LOCK_UNLOCKED;
 
 #define MAX_ID 	32
 struct htlbpagekey {
@@ -510,6 +513,35 @@ int set_hugetlb_mem_size(int count)
 	return (int) htlbzone_pages;
 }
 
+static int __init hugetlb_setup(char *s)
+{
+	if (sscanf(s, "%d", &htlbpage_max) <= 0)
+		htlbpage_max = 0;
+	return 1;
+}
+__setup("hugepages=", hugetlb_setup);
+
+static int __init hugetlb_init(void)
+{
+	int i, j;
+	struct page *page;
+
+	for (i = 0; i < htlbpage_max; ++i) {
+		page = alloc_pages(__GFP_HIGHMEM, HUGETLB_PAGE_ORDER);
+		if (!page)
+			break;
+		for (j = 0; j < HPAGE_SIZE/PAGE_SIZE; ++j)
+			SetPageReserved(&page[j]);
+		spin_lock(&htlbpage_lock);
+		list_add(&page->list, &htlbpage_freelist);
+		spin_unlock(&htlbpage_lock);
+	}
+	htlbpage_max = htlbpagemem = htlbzone_pages = i;
+	printk("Total HugeTLB memory allocated, %ld\n", htlbpagemem);
+	return 0;
+}
+module_init(hugetlb_init);
+
 static struct page * hugetlb_nopage(struct vm_area_struct * area, unsigned long address, int unused)
 {
 	BUG();
diff -urpN hugetlbfs-2.5.46-2/arch/i386/mm/init.c hugetlbfs-2.5.46-3/arch/i386/mm/init.c
--- hugetlbfs-2.5.46-2/arch/i386/mm/init.c	2002-11-04 14:30:46.000000000 -0800
+++ hugetlbfs-2.5.46-3/arch/i386/mm/init.c	2002-11-05 11:30:45.000000000 -0800
@@ -422,13 +422,6 @@ static void __init set_max_mapnr_init(vo
 extern void set_max_mapnr_init(void);
 #endif /* !CONFIG_DISCONTIGMEM */
 
-#ifdef CONFIG_HUGETLB_PAGE
-long    htlbpagemem = 0;
-int     htlbpage_max;
-long    htlbzone_pages;
-extern struct list_head htlbpage_freelist;
-#endif
-
 void __init mem_init(void)
 {
 	extern int ppro_with_ram_bug(void);
@@ -497,30 +490,6 @@ void __init mem_init(void)
 #ifndef CONFIG_SMP
 	zap_low_mappings();
 #endif
-#ifdef CONFIG_HUGETLB_PAGE
-	{
-		long	i, j;
-		struct	page	*page, *map;
-		/*For now reserve quarter for hugetlb_pages.*/
-		htlbzone_pages = (max_low_pfn >> ((HPAGE_SHIFT - PAGE_SHIFT) + 2)) ;
-		/*Will make this kernel command line. */
-		INIT_LIST_HEAD(&htlbpage_freelist);
-		for (i=0; i<htlbzone_pages; i++) {
-			page = alloc_pages(__GFP_HIGHMEM, HUGETLB_PAGE_ORDER);
-			if (page == NULL)
-				break;
-			map = page;
-			for (j=0; j<(HPAGE_SIZE/PAGE_SIZE); j++) {
-				SetPageReserved(map);
-				map++;
-			}
-			list_add(&page->list, &htlbpage_freelist);
-		}
-		printk("Total Huge_TLB_Page memory pages allocated %ld\n", i);
-		htlbzone_pages = htlbpagemem = i;
-		htlbpage_max = i;
-	}
-#endif
 }
 
 #if CONFIG_X86_PAE

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-11-06  2:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-06  2:29 [4/7] hugetlb: internalize hugetlb init William Lee Irwin III

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®