aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/venti/srv/icache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/venti/srv/icache.c')
-rw-r--r--src/cmd/venti/srv/icache.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/cmd/venti/srv/icache.c b/src/cmd/venti/srv/icache.c
index 3055b981..3663345d 100644
--- a/src/cmd/venti/srv/icache.c
+++ b/src/cmd/venti/srv/icache.c
@@ -60,14 +60,14 @@ mkihash(int size1)
u32int size;
int bits;
IHash *ih;
-
+
bits = 0;
size = 1;
while(size < size1){
bits++;
size <<= 1;
}
-
+
ih = vtmallocz(sizeof(IHash)+size*sizeof(ih->table[0]));
ih->table = (IEntry**)(ih+1);
ih->bits = bits;
@@ -80,7 +80,7 @@ ihashlookup(IHash *ih, u8int score[VtScoreSize], int type)
{
u32int h;
IEntry *ie;
-
+
h = hashbits(score, ih->bits);
for(ie=ih->table[h]; ie; ie=ie->nexthash)
if((type == -1 || type == ie->ia.type) && scorecmp(score, ie->score) == 0)
@@ -93,7 +93,7 @@ ihashdelete(IHash *ih, IEntry *ie, char *what)
{
u32int h;
IEntry **l;
-
+
h = hashbits(ie->score, ih->bits);
for(l=&ih->table[h]; *l; l=&(*l)->nexthash)
if(*l == ie){
@@ -107,7 +107,7 @@ static void
ihashinsert(IHash *ih, IEntry *ie)
{
u32int h;
-
+
h = hashbits(ie->score, ih->bits);
ie->nexthash = ih->table[h];
ih->table[h] = ie;
@@ -203,7 +203,7 @@ scacheevict(void)
{
ISum *s;
int i;
-
+
for(i=icache.nsum-1; i>=0; i--){
s = icache.sum[i];
if(canqlock(&s->lock)){
@@ -281,7 +281,7 @@ scachemiss(u64int addr)
qunlock(&s->lock);
return nil;
}
-
+
return s; /* locked */
}
@@ -294,7 +294,7 @@ initicache(u32int mem0)
{
u32int mem;
int i, entries, scache;
-
+
icache.full.l = &icache.lock;
mem = mem0;
@@ -312,7 +312,7 @@ fprint(2, "icache %,d bytes = %,d entries; %d scache\n", mem0, entries, scache);
icache.clean.prev = icache.clean.next = &icache.clean;
icache.dirty.prev = icache.dirty.next = &icache.dirty;
icache.free.prev = icache.free.next = (IEntry*)&icache.free;
-
+
icache.hash = mkihash(entries);
icache.nentries = entries;
setstat(StatIcacheSize, entries);
@@ -338,7 +338,7 @@ static IEntry*
evictlru(void)
{
IEntry *ie;
-
+
ie = poplast(&icache.clean);
if(ie == nil)
return nil;
@@ -356,7 +356,7 @@ icacheinsert(u8int score[VtScoreSize], IAddr *ia, int state)
while((ie = poplast(&icache.free)) == nil && (ie = evictlru()) == nil){
// Could safely return here if state == IEClean.
// But if state == IEDirty, have to wait to make
- // sure we don't lose an index write.
+ // sure we don't lose an index write.
// Let's wait all the time.
flushdcache();
kickicache();
@@ -444,7 +444,7 @@ insertscore(u8int score[VtScoreSize], IAddr *ia, int state, AState *as)
scacheload(toload);
qunlock(&toload->lock);
}
-
+
if(icache.ndirty >= icache.maxdirty)
kickicache();
@@ -483,7 +483,7 @@ lookupscore(u8int score[VtScoreSize], int type, IAddr *ia)
addstat2(StatIcacheRead, 1, StatIcacheReadTime, msec() - ms);
return ret;
}
-
+
u32int
hashbits(u8int *sc, int bits)
{
@@ -550,7 +550,7 @@ void
icacheclean(IEntry *ie)
{
IEntry *next;
-
+
trace(TraceProc, "icacheclean enter");
qlock(&icache.lock);
for(; ie; ie=next){
@@ -574,7 +574,7 @@ emptyicache(void)
int i;
IEntry *ie;
ISum *s;
-
+
qlock(&icache.lock);
while((ie = evictlru()) != nil)
pushfirst(&icache.free, ie);
@@ -586,4 +586,3 @@ emptyicache(void)
}
qunlock(&icache.lock);
}
-