ref: 330465b3190f2298cdf82fbe2bcd817591b781e4
parent: 2da6980e793f66dfc81257d0557e27137730a900
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Nov 5 16:05:40 EDT 2016
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.
--- a/sys/lib/acid/kernel
+++ b/sys/lib/acid/kernel
@@ -55,6 +55,16 @@
}
}
+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
defn chan(c) {local d, q;
--- a/sys/src/9/port/allocb.c
+++ b/sys/src/9/port/allocb.c
@@ -8,15 +8,10 @@
enum
{Hdrspc = 64, /* leave room for high-level headers */
+ Tlrspc = 16, /* extra room at the end for pad/crc/mac */
Bdead = 0x51494F42, /* "QIOB" */
};
-struct
-{- Lock;
- ulong bytes;
-} ialloc;
-
static Block*
_allocb(int size)
{@@ -23,6 +18,7 @@
Block *b;
uintptr addr;
+ size += Tlrspc;
if((b = mallocz(sizeof(Block)+size+Hdrspc, 0)) == nil)
return nil;
@@ -58,7 +54,6 @@
/*
* Check in a process and wait until successful.
- * Can still error out of here, though.
*/
if(up == nil)
panic("allocb without up: %#p", getcallerpc(&size));@@ -82,24 +77,16 @@
iallocb(int size)
{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((m2++%10000)==0){- if(mp++ > 1000)
- panic("iallocb: out of memory");- iprint("iallocb: no memory %lud/%lud\n",- ialloc.bytes, conf.ialloc);
+ static ulong nerr;
+ if((nerr++%10000)==0){+ if(nerr > 10000000){+ xsummary();
+ mallocsummary();
+ panic("iallocb: out of memory")+ }
+ iprint("iallocb: no memory for %d bytes\n", size);}
return nil;
}
@@ -106,10 +93,6 @@
setmalloctag(b, getcallerpc(&size));
b->flag = BINTR;
- ilock(&ialloc);
- ialloc.bytes += b->lim - b->base;
- iunlock(&ialloc);
-
return b;
}
@@ -129,11 +112,6 @@
b->free(b);
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 */
b->next = dead;
@@ -170,10 +148,4 @@
panic("checkb 3 %s %#p %#p", msg, b->rp, b->lim);if(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);}
--- a/sys/src/9/port/portfns.h
+++ b/sys/src/9/port/portfns.h
@@ -129,7 +129,6 @@
void (*hwrandbuf)(void*, ulong);
void hzsched(void);
Block* iallocb(int);
-void iallocsummary(void);
uintptr ibrk(uintptr, int);
void ilock(Lock*);
void interrupted(void);
@@ -143,7 +142,6 @@
int islo(void);
Segment* isoverlap(uintptr, uintptr);
Physseg* findphysseg(char*);
-void ixsummary(void);
void kickpager(void);
void killbig(char*);
void kproc(char*, void(*)(void*), void*);
--- a/sys/src/9/port/qio.c
+++ b/sys/src/9/port/qio.c
@@ -13,8 +13,6 @@
static ulong producecnt;
static ulong qcopycnt;
-static int debugging;
-
#define QDEBUG if(0)
/*
@@ -55,17 +53,6 @@
};
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
--
⑨