[PATCH 10 of 11] x86: allocate and initialize unshared pmds

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Ingo Molnar <mingo@...>
Cc: LKML <linux-kernel@...>, Andi Kleen <ak@...>, Jan Beulich <jbeulich@...>, Eduardo Pereira Habkost <ehabkost@...>, Ian Campbell <ijc@...>, H Peter Anvin <hpa@...>
Date: Friday, January 25, 2008 - 5:23 pm

If SHARED_KERNEL_PMD is false, then we need to allocate and initialize
the kernel pmd.  We can easily piggy-back this onto the existing pmd
prepopulation code.

Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
---
 arch/x86/mm/pgtable_32.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
--- a/arch/x86/mm/pgtable_32.c
+++ b/arch/x86/mm/pgtable_32.c
@@ -269,7 +269,7 @@ static void pgd_mop_up_pmds(pgd_t *pgdp)
 {
 	int i;
 
-	for(i = 0; i < USER_PTRS_PER_PGD; i++) {
+	for(i = 0; i < UNSHARED_PTRS_PER_PGD; i++) {
 		pgd_t pgd = pgdp[i];
 
 		if (pgd_val(pgd) != 0) {
@@ -289,6 +289,10 @@ static void pgd_mop_up_pmds(pgd_t *pgdp)
  * processor notices the update.  Since this is expensive, and
  * all 4 top-level entries are used almost immediately in a
  * new process's life, we just pre-populate them here.
+ *
+ * Also, if we're in a paravirt environment where the kernel pmd is
+ * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
+ * and initialize the kernel pmds here.
  */
 static int pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd)
 {
@@ -297,13 +301,18 @@ static int pgd_prepopulate_pmd(struct mm
 	int i;
 
 	pud = pud_offset(pgd, 0);
- 	for (addr = i = 0; i < USER_PTRS_PER_PGD; i++, pud++, addr += PUD_SIZE) {
+ 	for (addr = i = 0; i < UNSHARED_PTRS_PER_PGD;
+	     i++, pud++, addr += PUD_SIZE) {
 		pmd_t *pmd = pmd_alloc_one(mm, addr);
 
 		if (!pmd) {
 			pgd_mop_up_pmds(pgd);
 			return 0;
 		}
+
+		if (i >= USER_PTRS_PER_PGD)
+			memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
+			       sizeof(pmd_t) * PTRS_PER_PMD);
 
 		pud_populate(mm, pud, pmd);
 	}
@@ -346,4 +355,3 @@ void check_pgt_cache(void)
 {
 	quicklist_trim(0, pgd_dtor, 25, 16);
 }
-


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00 of 11] x86: separate pmd lifetime from pgd, Jeremy Fitzhardinge, (Fri Jan 25, 5:23 pm)
Re: [PATCH 00 of 11] x86: separate pmd lifetime from pgd, Jeremy Fitzhardinge, (Mon Jan 28, 12:20 pm)
Re: [PATCH 00 of 11] x86: separate pmd lifetime from pgd, Jeremy Fitzhardinge, (Mon Jan 28, 11:39 am)
[PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear(), Jeremy Fitzhardinge, (Fri Jan 25, 5:23 pm)
[PATCH 09 of 11] x86: preallocate pmds at pgd creation time, Jeremy Fitzhardinge, (Fri Jan 25, 5:23 pm)
[PATCH 08 of 11] xen: deal with pmd being allocated/freed, Jeremy Fitzhardinge, (Fri Jan 25, 5:23 pm)
[PATCH 05 of 11] x86: demacro asm-x86/pgalloc_32.h, Jeremy Fitzhardinge, (Fri Jan 25, 5:23 pm)
[PATCH 10 of 11] x86: allocate and initialize unshared pmds, Jeremy Fitzhardinge, (Fri Jan 25, 5:23 pm)
[PATCH 07 of 11] x86: don't special-case pmd allocations as ..., Jeremy Fitzhardinge, (Fri Jan 25, 5:23 pm)
[PATCH 02 of 11] x86: use the same pgd_list for PAE and 64-bit, Jeremy Fitzhardinge, (Fri Jan 25, 5:23 pm)
[PATCH 03 of 11] x86: add mm parameter to paravirt_alloc_pd, Jeremy Fitzhardinge, (Fri Jan 25, 5:23 pm)
[PATCH 01 of 11] xen: fix mismerge in masking pte flags, Jeremy Fitzhardinge, (Fri Jan 25, 5:23 pm)
[PATCH 04 of 11] x86: fix early_ioremap pagetable ops, Jeremy Fitzhardinge, (Fri Jan 25, 5:23 pm)
Re: [PATCH 04 of 11] x86: fix early_ioremap pagetable ops, Jeremy Fitzhardinge, (Thu Jan 31, 4:41 pm)
Re: [PATCH 04 of 11] x86: fix early_ioremap pagetable ops, Jeremy Fitzhardinge, (Thu Jan 31, 3:52 pm)
[PATCH 06 of 11] x86: unify PAE/non-PAE pgd_ctor, Jeremy Fitzhardinge, (Fri Jan 25, 5:23 pm)