kernel: add support for sticky segments (cached, preallocated, never paged)
This commit is contained in:
parent
fb165d6a54
commit
2723c9fc77
7 changed files with 24 additions and 1 deletions
|
@ -138,7 +138,7 @@ Cmdtab proccmd[] = {
|
|||
};
|
||||
|
||||
/* Segment type from portdat.h */
|
||||
static char *sname[]={ "Text", "Data", "Bss", "Stack", "Shared", "Phys", "Fixed", };
|
||||
static char *sname[]={ "Text", "Data", "Bss", "Stack", "Shared", "Phys", "Fixed", "Sticky" };
|
||||
|
||||
/*
|
||||
* Qids are, in path:
|
||||
|
|
|
@ -284,6 +284,8 @@ segmentread(Chan *c, void *a, long n, vlong voff)
|
|||
if((g->s->type&SG_TYPE) == SG_FIXED)
|
||||
snprint(buf, sizeof(buf), "va %#p %#p fixed %#p\n", g->s->base, g->s->top-g->s->base,
|
||||
g->s->map[0]->pages[0]->pa);
|
||||
else if((g->s->type&SG_TYPE) == SG_STICKY)
|
||||
snprint(buf, sizeof(buf), "va %#p %#p sticky\n", g->s->base, g->s->top-g->s->base);
|
||||
else
|
||||
snprint(buf, sizeof(buf), "va %#p %#p\n", g->s->base, g->s->top-g->s->base);
|
||||
return readstr(voff, a, n, buf);
|
||||
|
@ -331,6 +333,20 @@ segmentwrite(Chan *c, void *a, long n, vlong voff)
|
|||
if(!iseve())
|
||||
error(Eperm);
|
||||
g->s = fixedseg(va, len/BY2PG);
|
||||
} else if(cb->nf >= 4 && strcmp(cb->f[3], "sticky") == 0){
|
||||
Segment *s;
|
||||
|
||||
if(!iseve())
|
||||
error(Eperm);
|
||||
s = newseg(SG_STICKY, va, len/BY2PG);
|
||||
if(waserror()){
|
||||
putseg(s);
|
||||
nexterror();
|
||||
}
|
||||
for(; va < s->top; va += BY2PG)
|
||||
segpage(s, newpage(1, nil, va));
|
||||
poperror();
|
||||
g->s = s;
|
||||
} else
|
||||
g->s = newseg(SG_SHARED, va, len/BY2PG);
|
||||
} else
|
||||
|
|
|
@ -270,6 +270,8 @@ fixfault(Segment *s, uintptr addr, int read)
|
|||
copypage(old, *pg);
|
||||
putpage(old);
|
||||
}
|
||||
/* wet floor */
|
||||
case SG_STICKY: /* Never paged out */
|
||||
mmuphys = PPN((*pg)->pa) | PTEWRITE | PTEVALID;
|
||||
(*pg)->modref = PG_MOD|PG_REF;
|
||||
break;
|
||||
|
|
|
@ -368,6 +368,7 @@ enum
|
|||
SG_SHARED = 04,
|
||||
SG_PHYSICAL = 05,
|
||||
SG_FIXED = 06,
|
||||
SG_STICKY = 07,
|
||||
|
||||
SG_RONLY = 0040, /* Segment is read only */
|
||||
SG_CEXEC = 0100, /* Detach at exec */
|
||||
|
|
|
@ -1595,6 +1595,7 @@ killbig(char *why)
|
|||
case SG_SHARED:
|
||||
case SG_PHYSICAL:
|
||||
case SG_FIXED:
|
||||
case SG_STICKY:
|
||||
continue;
|
||||
}
|
||||
qlock(s);
|
||||
|
|
|
@ -155,6 +155,7 @@ dupseg(Segment **seg, int segno, int share)
|
|||
case SG_SHARED:
|
||||
case SG_PHYSICAL:
|
||||
case SG_FIXED:
|
||||
case SG_STICKY:
|
||||
goto sameseg;
|
||||
|
||||
case SG_STACK:
|
||||
|
@ -499,6 +500,7 @@ mfreeseg(Segment *s, uintptr start, ulong pages)
|
|||
switch(s->type&SG_TYPE){
|
||||
case SG_PHYSICAL:
|
||||
case SG_FIXED:
|
||||
case SG_STICKY:
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -773,6 +773,7 @@ syssegbrk(va_list list)
|
|||
case SG_STACK:
|
||||
case SG_PHYSICAL:
|
||||
case SG_FIXED:
|
||||
case SG_STICKY:
|
||||
error(Ebadarg);
|
||||
default:
|
||||
return ibrk(va_arg(list, uintptr), i);
|
||||
|
|
Loading…
Reference in a new issue