9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] pc *kernelpercent improvement
@ 2010-04-16 14:46 erik quanstrom
  0 siblings, 0 replies; only message in thread
From: erik quanstrom @ 2010-04-16 14:46 UTC (permalink / raw)
  To: 9fans

with some nic drivers (myricom) requiring a vast amount of
buffer space, and the general pc split between user space
and kernel space on a 4gb machine giving only 71mb to
the kernel (1.6%), i find it necessary to set *kernelpercent
on a few machines that have 3-4 nics.  unfortunately, the
kernel is just too smart to allow me to set *kernelpercent
and applies (imho) too much logic, generally defeating
my settings.

this patch allows one to set *kernelprecent to anything
"reasonable".  reasonable means that kernel memory will
fit in the available virtual memory at or above KZERO.
this, kernel memory is capped at 256MB for the standard
KZERO of 0xf0000000.   but if one had KZERO set to
0x80000000, kernel memory would be capped at 2gb.
naturally, the lowest possible KZERO while maintaining
pci(e) space and user memory would be 0x20000000.  but
i haven't been that brave.  i have only tested 0x30000000.

if *kernelpercent is not set, then the logic is unchanged
from before.

/n/sources/plan9//sys/src/9/pc/main.c:397,405 - main.c:397,408
  		 * page list in imagereclaim just takes too long.
  		 */
  		if(kpages > (64*MB + conf.npage*sizeof(Page))/BY2PG){
- 			kpages = (64*MB + conf.npage*sizeof(Page))/BY2PG;
+ 			if(p == nil){
+ 				kpages = (64*MB + conf.npage*sizeof(Page))/BY2PG;
+ 				kpages += (conf.nproc*KSTACK)/BY2PG;
+ 			}else if(kpages > (ulong)-KZERO)
+ 				kpages = (ulong)-KZERO;
  			conf.nimage = 2000;
- 			kpages += (conf.nproc*KSTACK)/BY2PG;
  		}
  	} else {
  		if(userpcnt < 10) {

one thing that could save quite a bit of buffer space for
most drivers that keep a private pool would be a function
allocbpool(uint cnt, uint size, uint align, void (*free)(Block*)).
if size%align < align you can save cnt*(align - size%align) - align
bytes by allocating the buffers seperately from the Block contents,
in large allocations.  or packing the Block header carefully in the slop.
(in addition to Pool overhead.)

for cnt=512, size=16k and align=4k (myricom needs
a power-of-two buffer and has a 9k mtu) this is
	512*(4k - 0) - 4k = 2mb - 4096b (25%).
for cnt=1024, size=12k and align=4k (82563), this is 4mb (25%).
for 4 or 6 interfaces, this really starts to add up.

- erik



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-04-16 14:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-16 14:46 [9fans] pc *kernelpercent improvement erik quanstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).