pc64: use 2MB pages for preallocpages()
This commit is contained in:
parent
c9f91d5015
commit
fb97665a14
2 changed files with 9 additions and 9 deletions
|
@ -259,7 +259,7 @@ static void
|
||||||
preallocpages(void)
|
preallocpages(void)
|
||||||
{
|
{
|
||||||
Pallocmem *pm;
|
Pallocmem *pm;
|
||||||
uintptr va;
|
uintptr va, base, top;
|
||||||
vlong size;
|
vlong size;
|
||||||
ulong np;
|
ulong np;
|
||||||
int i;
|
int i;
|
||||||
|
@ -272,17 +272,18 @@ preallocpages(void)
|
||||||
size = (uvlong)np * BY2PG;
|
size = (uvlong)np * BY2PG;
|
||||||
size += sizeof(Page) + BY2PG; /* round up */
|
size += sizeof(Page) + BY2PG; /* round up */
|
||||||
size = (size / (sizeof(Page) + BY2PG)) * sizeof(Page);
|
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++){
|
for(i=0; i<nelem(palloc.mem); i++){
|
||||||
pm = &palloc.mem[i];
|
pm = &palloc.mem[i];
|
||||||
if((pm->base + size) <= VMAPSIZE && pm->npage >= np){
|
base = ROUND(pm->base, PGLSZ(1));
|
||||||
va = VMAP + pm->base;
|
top = pm->base + (uvlong)pm->npage * BY2PG;
|
||||||
pmap(m->pml4, pm->base | PTEGLOBAL|PTEWRITE|PTEVALID, va, size);
|
if((base + size) <= VMAPSIZE && (top - base) >= size){
|
||||||
|
va = base + VMAP;
|
||||||
|
pmap(m->pml4, base | PTEGLOBAL|PTEWRITE|PTEVALID, va, size);
|
||||||
palloc.pages = (Page*)va;
|
palloc.pages = (Page*)va;
|
||||||
pm->base += size;
|
pm->base = base + size;
|
||||||
pm->npage -= np;
|
pm->npage = (top - pm->base)/BY2PG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#define BY2V 8 /* bytes per double word */
|
#define BY2V 8 /* bytes per double word */
|
||||||
#define BY2PG (0x1000ull) /* bytes per page */
|
#define BY2PG (0x1000ull) /* bytes per page */
|
||||||
#define WD2PG (BY2PG/BY2WD) /* words per page */
|
#define WD2PG (BY2PG/BY2WD) /* words per page */
|
||||||
#define BY2XPG (2*MiB) /* bytes per big page */
|
|
||||||
#define PGSHIFT 12 /* log(BY2PG) */
|
#define PGSHIFT 12 /* log(BY2PG) */
|
||||||
#define ROUND(s, sz) (((s)+((sz)-1))&~((sz)-1))
|
#define ROUND(s, sz) (((s)+((sz)-1))&~((sz)-1))
|
||||||
#define PGROUND(s) ROUND(s, BY2PG)
|
#define PGROUND(s) ROUND(s, BY2PG)
|
||||||
|
|
Loading…
Reference in a new issue