summaryrefslogtreecommitdiff
path: root/sys/src/9/pc64
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-06-01 06:31:50 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2014-06-01 06:31:50 +0200
commitfb97665a14c347657e03f07d72098d2c9f76a65d (patch)
tree3417b2a996d0a509138385e2244c1c77446f75e6 /sys/src/9/pc64
parentc9f91d50154015ef31b6e63131847742893ffc91 (diff)
pc64: use 2MB pages for preallocpages()
Diffstat (limited to 'sys/src/9/pc64')
-rw-r--r--sys/src/9/pc64/main.c17
-rw-r--r--sys/src/9/pc64/mem.h1
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; i<nelem(palloc.mem); i++){
pm = &palloc.mem[i];
- if((pm->base + 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)