kernel: avoid padblock copying for devtls/devssl/esp, cleanup debugging

to avoid copying in padblock() when adding cryptographics macs to a block
in devtls/devssl/esp we reserve 16 extra bytes to the allocation.

remove qio ixsummary() function and add acid function qiostats() to
/sys/lib/acid/kernel

simplify iallocb(), remove iallocsummary() statitics.
This commit is contained in:
cinap_lenrek 2016-11-05 20:05:40 +01:00
parent 240590ab0a
commit 963497f06b
4 changed files with 20 additions and 53 deletions

View file

@ -55,6 +55,16 @@ defn imagecache() {
} }
} }
defn qiostats() {
print ("padblockcnt=", *padblockcnt\D, "\n");
print ("concatblockcnt=", *concatblockcnt\D, "\n");
print ("pullupblockcnt=", *pullupblockcnt\D, "\n");
print ("copyblockcnt=", *copyblockcnt\D, "\n");
print ("consumecnt=", *consumecnt\D, "\n");
print ("producecnt=", *producecnt\D, "\n");
print ("qcopycnt=", *qcopycnt\D, "\n");
}
// dump channels // dump channels
defn chan(c) { defn chan(c) {
local d, q; local d, q;

View file

@ -8,21 +8,17 @@
enum enum
{ {
Hdrspc = 64, /* leave room for high-level headers */ Hdrspc = 64, /* leave room for high-level headers */
Tlrspc = 16, /* extra room at the end for pad/crc/mac */
Bdead = 0x51494F42, /* "QIOB" */ Bdead = 0x51494F42, /* "QIOB" */
}; };
struct
{
Lock;
ulong bytes;
} ialloc;
static Block* static Block*
_allocb(int size) _allocb(int size)
{ {
Block *b; Block *b;
uintptr addr; uintptr addr;
size += Tlrspc;
if((b = mallocz(sizeof(Block)+size+Hdrspc, 0)) == nil) if((b = mallocz(sizeof(Block)+size+Hdrspc, 0)) == nil)
return nil; return nil;
@ -58,7 +54,6 @@ allocb(int size)
/* /*
* Check in a process and wait until successful. * Check in a process and wait until successful.
* Can still error out of here, though.
*/ */
if(up == nil) if(up == nil)
panic("allocb without up: %#p", getcallerpc(&size)); panic("allocb without up: %#p", getcallerpc(&size));
@ -82,34 +77,22 @@ Block*
iallocb(int size) iallocb(int size)
{ {
Block *b; Block *b;
static int m1, m2, mp;
if(ialloc.bytes > conf.ialloc){
if((m1++%10000)==0){
if(mp++ > 1000)
panic("iallocb: out of memory");
iprint("iallocb: limited %lud/%lud\n",
ialloc.bytes, conf.ialloc);
}
return nil;
}
if((b = _allocb(size)) == nil){ if((b = _allocb(size)) == nil){
if((m2++%10000)==0){ static ulong nerr;
if(mp++ > 1000) if((nerr++%10000)==0){
panic("iallocb: out of memory"); if(nerr > 10000000){
iprint("iallocb: no memory %lud/%lud\n", xsummary();
ialloc.bytes, conf.ialloc); mallocsummary();
panic("iallocb: out of memory")
}
iprint("iallocb: no memory for %d bytes\n", size);
} }
return nil; return nil;
} }
setmalloctag(b, getcallerpc(&size)); setmalloctag(b, getcallerpc(&size));
b->flag = BINTR; b->flag = BINTR;
ilock(&ialloc);
ialloc.bytes += b->lim - b->base;
iunlock(&ialloc);
return b; return b;
} }
@ -129,11 +112,6 @@ freeb(Block *b)
b->free(b); b->free(b);
return; return;
} }
if(b->flag & BINTR) {
ilock(&ialloc);
ialloc.bytes -= b->lim - b->base;
iunlock(&ialloc);
}
/* poison the block in case someone is still holding onto it */ /* poison the block in case someone is still holding onto it */
b->next = dead; b->next = dead;
@ -171,9 +149,3 @@ checkb(Block *b, char *msg)
if(b->wp > b->lim) if(b->wp > b->lim)
panic("checkb 4 %s %#p %#p", msg, b->wp, b->lim); panic("checkb 4 %s %#p %#p", msg, b->wp, b->lim);
} }
void
iallocsummary(void)
{
print("ialloc %lud/%lud\n", ialloc.bytes, conf.ialloc);
}

View file

@ -129,7 +129,6 @@ long hostownerwrite(char*, int);
void (*hwrandbuf)(void*, ulong); void (*hwrandbuf)(void*, ulong);
void hzsched(void); void hzsched(void);
Block* iallocb(int); Block* iallocb(int);
void iallocsummary(void);
uintptr ibrk(uintptr, int); uintptr ibrk(uintptr, int);
void ilock(Lock*); void ilock(Lock*);
void interrupted(void); void interrupted(void);
@ -143,7 +142,6 @@ int iseve(void);
int islo(void); int islo(void);
Segment* isoverlap(uintptr, uintptr); Segment* isoverlap(uintptr, uintptr);
Physseg* findphysseg(char*); Physseg* findphysseg(char*);
void ixsummary(void);
void kickpager(void); void kickpager(void);
void killbig(char*); void killbig(char*);
void kproc(char*, void(*)(void*), void*); void kproc(char*, void(*)(void*), void*);

View file

@ -13,8 +13,6 @@ static ulong consumecnt;
static ulong producecnt; static ulong producecnt;
static ulong qcopycnt; static ulong qcopycnt;
static int debugging;
#define QDEBUG if(0) #define QDEBUG if(0)
/* /*
@ -56,17 +54,6 @@ enum
uint qiomaxatomic = Maxatomic; uint qiomaxatomic = Maxatomic;
void
ixsummary(void)
{
debugging ^= 1;
iallocsummary();
print("pad %lud, concat %lud, pullup %lud, copy %lud\n",
padblockcnt, concatblockcnt, pullupblockcnt, copyblockcnt);
print("consume %lud, produce %lud, qcopy %lud\n",
consumecnt, producecnt, qcopycnt);
}
/* /*
* free a list of blocks * free a list of blocks
*/ */