From fb97665a14c347657e03f07d72098d2c9f76a65d Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 1 Jun 2014 06:31:50 +0200 Subject: [PATCH] pc64: use 2MB pages for preallocpages() --- sys/src/9/pc64/main.c | 17 +++++++++-------- sys/src/9/pc64/mem.h | 1 - 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/src/9/pc64/main.c b/sys/src/9/pc64/main.c index 8b5b45338..47b5e1c85 100644 --- a/sys/src/9/pc64/main.c +++ b/sys/src/9/pc64/main.c @@ -259,7 +259,7 @@ static void preallocpages(void) { Pallocmem *pm; - uintptr va; + uintptr va, base, top; vlong size; ulong np; int i; @@ -272,17 +272,18 @@ preallocpages(void) size = (uvlong)np * BY2PG; size += sizeof(Page) + BY2PG; /* round up */ size = (size / (sizeof(Page) + BY2PG)) * sizeof(Page); - size = PGROUND(size); + size = ROUND(size, PGLSZ(1)); - np = size/BY2PG; for(i=0; ibase + size) <= VMAPSIZE && pm->npage >= np){ - va = VMAP + pm->base; - pmap(m->pml4, pm->base | PTEGLOBAL|PTEWRITE|PTEVALID, va, size); + base = ROUND(pm->base, PGLSZ(1)); + top = pm->base + (uvlong)pm->npage * BY2PG; + if((base + size) <= VMAPSIZE && (top - base) >= size){ + va = base + VMAP; + pmap(m->pml4, base | PTEGLOBAL|PTEWRITE|PTEVALID, va, size); palloc.pages = (Page*)va; - pm->base += size; - pm->npage -= np; + pm->base = base + size; + pm->npage = (top - pm->base)/BY2PG; break; } } diff --git a/sys/src/9/pc64/mem.h b/sys/src/9/pc64/mem.h index 595ade9e3..9ec07363a 100644 --- a/sys/src/9/pc64/mem.h +++ b/sys/src/9/pc64/mem.h @@ -22,7 +22,6 @@ #define BY2V 8 /* bytes per double word */ #define BY2PG (0x1000ull) /* bytes per page */ #define WD2PG (BY2PG/BY2WD) /* words per page */ -#define BY2XPG (2*MiB) /* bytes per big page */ #define PGSHIFT 12 /* log(BY2PG) */ #define ROUND(s, sz) (((s)+((sz)-1))&~((sz)-1)) #define PGROUND(s) ROUND(s, BY2PG)