LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: tglx@linutronix.de, mingo@elte.hu, linux-kernel@vger.kernel.org
Subject: [PATCH] [11/12] GBPAGES: Do kernel direct mapping at boot using GB pages
Date: Fri,  1 Feb 2008 10:53:24 +0100 (CET)	[thread overview]
Message-ID: <20080201095324.5F1FF1B416F@basil.firstfloor.org> (raw)
In-Reply-To: <200802011053.107168490@suse.de>


The AMD Fam10h CPUs support new Gigabyte page table entry for 
mapping 1GB at a time. Use this for the kernel direct mapping. 

Only done for 64bit because i386 does not support GB page tables.

This only applies to the data portion of the direct mapping; the
kernel text mapping stays with 2MB pages because the AMD Fam10h
microarchitecture does not support GB ITLBs and AMD recommends 
against using GB mappings for code.

GBpage are disabled when DEBUG_PAGEALLOC is enabled, because
DEBUG_PAGEALLOC causes recursion in cpa() and with gbpages
the potential max recursion depth is much deeper. 

Can be disabled with direct_gbpages=off

Signed-off-by: Andi Kleen <ak@suse.de>

---
 arch/x86/mm/init_64.c |   35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

Index: linux/arch/x86/mm/init_64.c
===================================================================
--- linux.orig/arch/x86/mm/init_64.c
+++ linux/arch/x86/mm/init_64.c
@@ -339,7 +339,14 @@ phys_pud_init(pud_t *pud_page, unsigned 
 		}
 
 		if (pud_val(*pud)) {
-			phys_pmd_update(pud, addr, end);
+			if (!pud_large(*pud))
+				phys_pmd_update(pud, addr, end);
+			continue;
+		}
+
+		if (direct_gbpages == GBP_ON) {
+			set_pte((pte_t *)pud,
+				pfn_pte(addr >> PAGE_SHIFT, PAGE_KERNEL_LARGE));
 			continue;
 		}
 
@@ -360,9 +367,11 @@ static void __init find_early_table_spac
 	unsigned long puds, pmds, tables, start;
 
 	puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
-	pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
-	tables = round_up(puds * sizeof(pud_t), PAGE_SIZE) +
-		 round_up(pmds * sizeof(pmd_t), PAGE_SIZE);
+	tables = round_up(puds * sizeof(pud_t), PAGE_SIZE);
+	if (direct_gbpages == GBP_ON) {
+		pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
+		tables += round_up(pmds * sizeof(pmd_t), PAGE_SIZE);
+	}
 
 	/*
 	 * RED-PEN putting page tables only on node 0 could
@@ -389,6 +398,20 @@ static void __init find_early_table_spac
 		(table_start << PAGE_SHIFT) + tables);
 }
 
+static void __init init_gbpages(void)
+{
+#ifdef CONFIG_DEBUG_PAGEALLOC
+	/* debug pagealloc causes too much recursion with gbpages */
+	if (direct_gbpages != GBP_DEFAULT)
+		return;
+#endif
+	if (direct_gbpages != GBP_OFF && cpu_has_gbpages) {
+		printk(KERN_INFO "Using GB pages for direct mapping\n");
+		direct_gbpages = GBP_ON;
+	} else
+		direct_gbpages = GBP_OFF;
+}
+
 /*
  * Setup the direct mapping of the physical memory at PAGE_OFFSET.
  * This runs before bootmem is initialized and gets pages directly from
@@ -407,8 +430,10 @@ void __init_refok init_memory_mapping(un
 	 * memory mapped. Unfortunately this is done currently before the
 	 * nodes are discovered.
 	 */
-	if (!after_bootmem)
+	if (!after_bootmem) {
+		init_gbpages();
 		find_early_table_space(end);
+	}
 
 	start = (unsigned long)__va(start);
 	end = (unsigned long)__va(end);

  parent reply	other threads:[~2008-02-01  9:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-01  9:53 [PATCH] [0/12] GBPAGES patchkit for 2.6.25 v3 Andi Kleen
2008-02-01  9:53 ` [PATCH] [1/12] GBPAGES: Add feature macros for the gbpages cpuid bit Andi Kleen
2008-02-01  9:53 ` [PATCH] [2/12] GBPAGES: Rename LARGE_PAGE_SIZE to PMD_PAGE_SIZE Andi Kleen
2008-02-01  9:53 ` [PATCH] [3/12] GBPAGES: Add PUD_PAGE_SIZE Andi Kleen
2008-02-01  9:53 ` [PATCH] [4/12] Add pgtable accessor functions for GB pages Andi Kleen
2008-02-01  9:53 ` [PATCH] [5/12] GBPAGES: Support gbpages in pagetable dump Andi Kleen
2008-02-01  9:53 ` [PATCH] [6/12] GBPAGES: Add gbpages support to lookup_address Andi Kleen
2008-02-01  9:53 ` [PATCH] [7/12] GBPAGES: Add an option to disable direct mapping gbpages and a global variable Andi Kleen
2008-02-05 22:41   ` Randy Dunlap
2008-02-01  9:53 ` [PATCH] [8/12] GBPAGES: Implement gbpages support in change_page_attr() Andi Kleen
2008-02-01  9:53 ` [PATCH] [9/12] GBPAGES: Switch pci-gart over to using cpa instead of clear_kernel_mapping Andi Kleen
2008-02-01  9:53 ` [PATCH] [10/12] GBPAGES: Remove now unused clear_kernel_mapping Andi Kleen
2008-02-01  9:53 ` Andi Kleen [this message]
2008-02-01  9:53 ` [PATCH] [12/12] GBPAGES: Switch direct mapping setup over to set_pte Andi Kleen
2008-02-01 17:37   ` Jeremy Fitzhardinge
2008-02-01 17:58     ` Andi Kleen
2008-02-01 19:16       ` Jeremy Fitzhardinge
2008-02-01 12:25 ` [PATCH] [0/12] GBPAGES patchkit for 2.6.25 v3 Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080201095324.5F1FF1B416F@basil.firstfloor.org \
    --to=ak@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --subject='Re: [PATCH] [11/12] GBPAGES: Do kernel direct mapping at boot using GB pages' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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