summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-02-07 02:52:23 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2015-02-07 02:52:23 +0100
commitb8cf3cb879a19c001796329ebe266104d13e63be (patch)
tree745534899e603d5336347c846ad286c3535c43fc /sys
parentf215b660b30cc5e5d318922f545441b4ac14b200 (diff)
kernel: reduce Page structure size by changing Page.cachectl[]
there are no kernels currently that do page coloring, so the only use of cachectl[] is flushing the icache (on arm and ppc). on pc64, cachectl consumes 32 bytes in each page resulting in over 200 megabytes of overhead for 32gb of ram with 4K pages. this change removes cachectl[] and adds txtflush ulong that is set to ~0 by pio() to instruct putmmu() to flush the icache.
Diffstat (limited to 'sys')
-rw-r--r--sys/src/9/alphapc/main.c2
-rw-r--r--sys/src/9/bcm/main.c2
-rw-r--r--sys/src/9/bcm/mmu.c5
-rw-r--r--sys/src/9/bitsy/main.c2
-rw-r--r--sys/src/9/bitsy/mmu.c5
-rw-r--r--sys/src/9/kw/main.c2
-rw-r--r--sys/src/9/kw/mmu.c5
-rw-r--r--sys/src/9/mtx/main.c2
-rw-r--r--sys/src/9/mtx/mmu.c14
-rw-r--r--sys/src/9/omap/main.c2
-rw-r--r--sys/src/9/omap/mmu.c5
-rw-r--r--sys/src/9/omap4/main.c2
-rw-r--r--sys/src/9/pc/main.c2
-rw-r--r--sys/src/9/pc64/main.c2
-rw-r--r--sys/src/9/port/devproc.c10
-rw-r--r--sys/src/9/port/fault.c4
-rw-r--r--sys/src/9/port/page.c9
-rw-r--r--sys/src/9/port/portdat.h7
-rw-r--r--sys/src/9/port/segment.c2
-rw-r--r--sys/src/9/ppc/main.c2
-rw-r--r--sys/src/9/ppc/mmu.c15
-rw-r--r--sys/src/9/teg2/main.c2
-rw-r--r--sys/src/9/teg2/mmu.c5
-rw-r--r--sys/src/9/xen/main.c2
-rw-r--r--sys/src/9/zynq/main.c2
-rw-r--r--sys/src/9/zynq/mmu.c6
26 files changed, 41 insertions, 77 deletions
diff --git a/sys/src/9/alphapc/main.c b/sys/src/9/alphapc/main.c
index 0ac133dfe..ac123ea9f 100644
--- a/sys/src/9/alphapc/main.c
+++ b/sys/src/9/alphapc/main.c
@@ -255,7 +255,7 @@ userinit(void)
s->flushme++;
p->seg[TSEG] = s;
pg = newpage(1, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
memmove((uchar*)VA(k), initcode, sizeof initcode);
diff --git a/sys/src/9/bcm/main.c b/sys/src/9/bcm/main.c
index d5fbdd1ee..1746a5279 100644
--- a/sys/src/9/bcm/main.c
+++ b/sys/src/9/bcm/main.c
@@ -413,7 +413,7 @@ userinit(void)
s = newseg(SG_TEXT, UTZERO, 1);
p->seg[TSEG] = s;
pg = newpage(1, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
memmove(UINT2PTR(VA(k)), initcode, sizeof initcode);
diff --git a/sys/src/9/bcm/mmu.c b/sys/src/9/bcm/mmu.c
index 439f2edba..f068b387c 100644
--- a/sys/src/9/bcm/mmu.c
+++ b/sys/src/9/bcm/mmu.c
@@ -265,10 +265,9 @@ putmmu(uintptr va, uintptr pa, Page* page)
* rather than direct mapped.
*/
cachedwbinv();
- if(page->cachectl[0] == PG_TXTFLUSH){
- /* pio() sets PG_TXTFLUSH whenever a text pg has been written */
+ if(page->txtflush){
cacheiinv();
- page->cachectl[0] = PG_NOFLUSH;
+ page->txtflush = 0;
}
checkmmu(va, PPN(pa));
}
diff --git a/sys/src/9/bitsy/main.c b/sys/src/9/bitsy/main.c
index e36610927..03f496286 100644
--- a/sys/src/9/bitsy/main.c
+++ b/sys/src/9/bitsy/main.c
@@ -225,7 +225,7 @@ userinit(void)
s = newseg(SG_TEXT, UTZERO, 1);
p->seg[TSEG] = s;
pg = newpage(1, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
memmove((ulong*)VA(k), initcode, sizeof initcode);
diff --git a/sys/src/9/bitsy/mmu.c b/sys/src/9/bitsy/mmu.c
index d3812941b..9d420fd06 100644
--- a/sys/src/9/bitsy/mmu.c
+++ b/sys/src/9/bitsy/mmu.c
@@ -406,10 +406,9 @@ putmmu(uintptr va, uintptr pa, Page *pg)
* rather than direct mapped.
*/
cachewb();
- if(pg->cachectl[0] == PG_TXTFLUSH){
- /* pio() sets PG_TXTFLUSH whenever a text page has been written */
+ if(pg->txtflush){
icacheinvalidate();
- pg->cachectl[0] = PG_NOFLUSH;
+ pg->txtflush = 0;
}
splx(s);
diff --git a/sys/src/9/kw/main.c b/sys/src/9/kw/main.c
index aa722a0eb..8b2080ef7 100644
--- a/sys/src/9/kw/main.c
+++ b/sys/src/9/kw/main.c
@@ -587,7 +587,7 @@ userinit(void)
s->flushme++;
p->seg[TSEG] = s;
pg = newpage(1, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
memmove(UINT2PTR(VA(k)), initcode, sizeof initcode);
diff --git a/sys/src/9/kw/mmu.c b/sys/src/9/kw/mmu.c
index 2557ff59b..5128e2cee 100644
--- a/sys/src/9/kw/mmu.c
+++ b/sys/src/9/kw/mmu.c
@@ -353,10 +353,9 @@ putmmu(uintptr va, uintptr pa, Page* page)
* rather than direct mapped.
*/
cachedwbinv();
- if(page->cachectl[0] == PG_TXTFLUSH){
- /* pio() sets PG_TXTFLUSH whenever a text pg has been written */
+ if(page->txtflush){
cacheiinv();
- page->cachectl[0] = PG_NOFLUSH;
+ page->txtflush = 0;
}
//print("putmmu %#p %#p %#p\n", va, pa, PPN(pa)|x);
}
diff --git a/sys/src/9/mtx/main.c b/sys/src/9/mtx/main.c
index 7cb1bad16..491580101 100644
--- a/sys/src/9/mtx/main.c
+++ b/sys/src/9/mtx/main.c
@@ -198,7 +198,7 @@ userinit(void)
s->flushme++;
p->seg[TSEG] = s;
pg = newpage(1, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
memmove((ulong*)VA(k), initcode, sizeof initcode);
diff --git a/sys/src/9/mtx/mmu.c b/sys/src/9/mtx/mmu.c
index 255cf5f5a..791c968da 100644
--- a/sys/src/9/mtx/mmu.c
+++ b/sys/src/9/mtx/mmu.c
@@ -179,7 +179,6 @@ void
putmmu(uintptr va, uintptr pa, Page *pg)
{
int mp;
- char *ctl;
ulong *p, *ep, *q, pteg;
ulong vsid, ptehi, x, hash;
@@ -218,19 +217,10 @@ putmmu(uintptr va, uintptr pa, Page *pg)
q[1] = pa;
sync();
- ctl = &pg->cachectl[m->machno];
- switch(*ctl) {
- case PG_NEWCOL:
- default:
- panic("putmmu: %d\n", *ctl);
- break;
- case PG_NOFLUSH:
- break;
- case PG_TXTFLUSH:
+ if(pg->txtflush & (1<<m->machno)){
dcflush((void*)pg->va, BY2PG);
icflush((void*)pg->va, BY2PG);
- *ctl = PG_NOFLUSH;
- break;
+ pg->txtflush &= ~(1<<m->machno);
}
}
diff --git a/sys/src/9/omap/main.c b/sys/src/9/omap/main.c
index b54a08d52..818da7276 100644
--- a/sys/src/9/omap/main.c
+++ b/sys/src/9/omap/main.c
@@ -565,7 +565,7 @@ userinit(void)
s = newseg(SG_TEXT, UTZERO, 1);
p->seg[TSEG] = s;
pg = newpage(1, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
memmove(UINT2PTR(VA(k)), initcode, sizeof initcode);
diff --git a/sys/src/9/omap/mmu.c b/sys/src/9/omap/mmu.c
index 05b4dc38c..f54359ff6 100644
--- a/sys/src/9/omap/mmu.c
+++ b/sys/src/9/omap/mmu.c
@@ -330,10 +330,9 @@ putmmu(uintptr va, uintptr pa, Page* page)
* rather than direct mapped.
*/
cachedwbinv();
- if(page->cachectl[0] == PG_TXTFLUSH){
- /* pio() sets PG_TXTFLUSH whenever a text pg has been written */
+ if(page->txtflush){
cacheiinv();
- page->cachectl[0] = PG_NOFLUSH;
+ page->txtflush = 0;
}
//print("putmmu %#p %#p %#p\n", va, pa, PPN(pa)|x);
}
diff --git a/sys/src/9/omap4/main.c b/sys/src/9/omap4/main.c
index f8e75ce94..bb3de759e 100644
--- a/sys/src/9/omap4/main.c
+++ b/sys/src/9/omap4/main.c
@@ -134,7 +134,7 @@ userinit(void)
s->flushme++;
p->seg[TSEG] = s;
pg = newpage(0, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
segpage(s, pg);
v = vmap(pg->pa, BY2PG);
memset(v, 0, BY2PG);
diff --git a/sys/src/9/pc/main.c b/sys/src/9/pc/main.c
index 9d95c9f8a..f049c49ab 100644
--- a/sys/src/9/pc/main.c
+++ b/sys/src/9/pc/main.c
@@ -307,7 +307,7 @@ userinit(void)
s->flushme++;
p->seg[TSEG] = s;
pg = newpage(0, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
segpage(s, pg);
v = tmpmap(pg);
memset(v, 0, BY2PG);
diff --git a/sys/src/9/pc64/main.c b/sys/src/9/pc64/main.c
index 087450c55..5dcf3da48 100644
--- a/sys/src/9/pc64/main.c
+++ b/sys/src/9/pc64/main.c
@@ -461,7 +461,7 @@ userinit(void)
s->flushme++;
p->seg[TSEG] = s;
pg = newpage(0, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
segpage(s, pg);
v = kmap(pg);
memset(v, 0, BY2PG);
diff --git a/sys/src/9/port/devproc.c b/sys/src/9/port/devproc.c
index dc378e499..566d81740 100644
--- a/sys/src/9/port/devproc.c
+++ b/sys/src/9/port/devproc.c
@@ -1580,12 +1580,12 @@ procctlmemio(Proc *p, uintptr offset, int n, void *va, int read)
memmove(b, a, n);
kunmap(k);
- /* Ensure the process sees text page changes */
- if(s->flushme)
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
-
- if(!read)
+ if(!read){
+ /* Ensure the process sees text page changes */
+ if(s->flushme)
+ pg->txtflush = ~0;
p->newtlb = 1;
+ }
qunlock(s);
poperror();
diff --git a/sys/src/9/port/fault.c b/sys/src/9/port/fault.c
index 45c3959b3..d77894641 100644
--- a/sys/src/9/port/fault.c
+++ b/sys/src/9/port/fault.c
@@ -187,7 +187,7 @@ retry:
done:
putpage(new);
if(s->flushme)
- memset((*p)->cachectl, PG_TXTFLUSH, sizeof((*p)->cachectl));
+ (*p)->txtflush = ~0;
}
void (*checkaddr)(uintptr, Segment *, Page *);
@@ -263,6 +263,8 @@ fixfault(Segment *s, uintptr addr, int read, int doputmmu)
new = newpage(0, &s, addr);
if(s == nil)
return -1;
+ if(s->flushme)
+ new->txtflush = ~0;
*pg = new;
copypage(old, *pg);
putpage(old);
diff --git a/sys/src/9/port/page.c b/sys/src/9/port/page.c
index f3397c4fa..c33b1ec6b 100644
--- a/sys/src/9/port/page.c
+++ b/sys/src/9/port/page.c
@@ -145,8 +145,7 @@ newpage(int clear, Segment **s, uintptr va)
{
Page *p, **l;
KMap *k;
- uchar ct;
- int i, color;
+ int color;
color = getpgcolor(va);
lock(&palloc);
@@ -195,12 +194,9 @@ newpage(int clear, Segment **s, uintptr va)
l = &p->next;
}
- ct = PG_NOFLUSH;
if(p == nil) {
l = &palloc.head;
p = *l;
- p->color = color;
- ct = PG_NEWCOL;
}
*l = p->next;
@@ -211,8 +207,7 @@ newpage(int clear, Segment **s, uintptr va)
p->ref = 1;
p->va = va;
p->modref = 0;
- for(i = 0; i < MAXMACH; i++)
- p->cachectl[i] = ct;
+ p->txtflush = 0;
if(clear) {
k = kmap(p);
diff --git a/sys/src/9/port/portdat.h b/sys/src/9/port/portdat.h
index af33ea8a1..96e823766 100644
--- a/sys/src/9/port/portdat.h
+++ b/sys/src/9/port/portdat.h
@@ -292,11 +292,6 @@ struct Note
enum
{
- PG_NOFLUSH = 0,
- PG_TXTFLUSH = 1, /* flush dcache and invalidate icache */
- PG_DATFLUSH = 2, /* flush both i & d caches (UNUSED) */
- PG_NEWCOL = 3, /* page has been recolored */
-
PG_MOD = 0x01, /* software modified bit */
PG_REF = 0x02, /* software referenced bit */
};
@@ -309,10 +304,10 @@ struct Page
uintptr va; /* Virtual address for user */
uintptr daddr; /* Disc address on swap */
Image *image; /* Associated text or swap image */
+ ulong txtflush; /* Flush icache for putmmu */
ushort refage; /* Swap reference age */
char modref; /* Simulated modify/reference bits */
char color; /* Cache coloring */
- char cachectl[MAXMACH]; /* Cache flushing control for putmmu */
};
struct Swapalloc
diff --git a/sys/src/9/port/segment.c b/sys/src/9/port/segment.c
index 2b45af88d..5bafd0c36 100644
--- a/sys/src/9/port/segment.c
+++ b/sys/src/9/port/segment.c
@@ -669,7 +669,7 @@ pteflush(Pte *pte, int s, int e)
for(i = s; i < e; i++) {
pg = pte->pages[i];
if(!pagedout(pg))
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
}
}
diff --git a/sys/src/9/ppc/main.c b/sys/src/9/ppc/main.c
index a77f31127..e0badeb57 100644
--- a/sys/src/9/ppc/main.c
+++ b/sys/src/9/ppc/main.c
@@ -233,7 +233,7 @@ userinit(void)
s->flushme++;
p->seg[TSEG] = s;
pg = newpage(1, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
memmove((ulong*)VA(k), initcode, sizeof initcode);
diff --git a/sys/src/9/ppc/mmu.c b/sys/src/9/ppc/mmu.c
index 94dbeb03c..a47bf2d56 100644
--- a/sys/src/9/ppc/mmu.c
+++ b/sys/src/9/ppc/mmu.c
@@ -199,7 +199,6 @@ void
putmmu(uintptr va, uintptr pa, Page *pg)
{
int mp;
- char *ctl;
ulong *p, *ep, *q, pteg;
ulong vsid, hash;
ulong ptehi, x;
@@ -244,21 +243,11 @@ putmmu(uintptr va, uintptr pa, Page *pg)
q[0] = ptehi;
q[1] = pa;
- ctl = &pg->cachectl[m->machno];
- switch(*ctl) {
- case PG_NEWCOL:
- default:
- panic("putmmu: %d\n", *ctl);
- break;
- case PG_TXTFLUSH:
+ if(pg->txtflush & (1<<m->machno)){
dcflush((void*)pg->va, BY2PG);
icflush((void*)pg->va, BY2PG);
- *ctl = PG_NOFLUSH;
- break;
- case PG_NOFLUSH:
- break;
+ pg->txtflush &= ~(1<<m->machno);
}
-
}
void
diff --git a/sys/src/9/teg2/main.c b/sys/src/9/teg2/main.c
index 7b6aa92b1..c8e511d19 100644
--- a/sys/src/9/teg2/main.c
+++ b/sys/src/9/teg2/main.c
@@ -792,7 +792,7 @@ userinit(void)
s = newseg(SG_TEXT, UTZERO, 1);
p->seg[TSEG] = s;
pg = newpage(1, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
memmove(UINT2PTR(VA(k)), initcode, sizeof initcode);
diff --git a/sys/src/9/teg2/mmu.c b/sys/src/9/teg2/mmu.c
index 19065fd6a..de6c819b8 100644
--- a/sys/src/9/teg2/mmu.c
+++ b/sys/src/9/teg2/mmu.c
@@ -582,10 +582,9 @@ putmmu(uintptr va, uintptr pa, Page* page)
*/
l1cache->wb();
- if(page->cachectl[0] == PG_TXTFLUSH){
- /* pio() sets PG_TXTFLUSH whenever a text pg has been written */
+ if(page->txtflush & (1<<m->machno)){
cacheiinv();
- page->cachectl[0] = PG_NOFLUSH;
+ page->txtflush &= ~(1<<m->machno);
}
if (Debug)
iprint("putmmu %#p %#p %#p\n", va, pa, PPN(pa)|x);
diff --git a/sys/src/9/xen/main.c b/sys/src/9/xen/main.c
index 2cc4e2ca6..9888af3ce 100644
--- a/sys/src/9/xen/main.c
+++ b/sys/src/9/xen/main.c
@@ -245,7 +245,7 @@ userinit(void)
s->flushme++;
p->seg[TSEG] = s;
pg = newpage(1, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
memmove((ulong*)VA(k), initcode, sizeof initcode);
diff --git a/sys/src/9/zynq/main.c b/sys/src/9/zynq/main.c
index c27879f75..f8a103b11 100644
--- a/sys/src/9/zynq/main.c
+++ b/sys/src/9/zynq/main.c
@@ -306,7 +306,7 @@ userinit(void)
s->flushme++;
p->seg[TSEG] = s;
pg = newpage(0, 0, UTZERO);
- memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
+ pg->txtflush = ~0;
segpage(s, pg);
v = tmpmap(pg->pa);
diff --git a/sys/src/9/zynq/mmu.c b/sys/src/9/zynq/mmu.c
index 54f6a17d6..66816225f 100644
--- a/sys/src/9/zynq/mmu.c
+++ b/sys/src/9/zynq/mmu.c
@@ -140,7 +140,6 @@ putmmu(uintptr va, uintptr pa, Page *pg)
ulong *e;
ulong *l2;
PTE old;
- char *ctl;
uintptr l2p;
int s;
@@ -180,11 +179,10 @@ putmmu(uintptr va, uintptr pa, Page *pg)
splx(s);
if((old & L2VALID) != 0)
flushpg((void *) va);
- ctl = &pg->cachectl[m->machno];
- if(*ctl == PG_TXTFLUSH){
+ if(pg->txtflush & (1<<m->machno)){
cleandse((void *) va, (void *) (va + BY2PG));
invalise((void *) va, (void *) (va + BY2PG));
- *ctl = PG_NOFLUSH;
+ pg->txtflush &= ~(1<<m->machno);
}
}