diff options
author | 2004-12-02 19:37:22 +0000 | |
---|---|---|
committer | 2004-12-02 19:37:22 +0000 | |
commit | 6097c6acd8a84b7cd95e25511f7c44e9f7dd44da (patch) | |
tree | 47ba7441170fe2c7394b7c54a0f360b21ffe98fd | |
parent | Fix signal races for isatty(3) (calls ioctl(2)) and printf(3); (diff) | |
download | wireguard-openbsd-6097c6acd8a84b7cd95e25511f7c44e9f7dd44da.tar.xz wireguard-openbsd-6097c6acd8a84b7cd95e25511f7c44e9f7dd44da.zip |
Make BUFCACHEPERCENT adjustable through UKC, like all other arches do.
(This means twice as less buffers on hp300 with unmodified GENERIC kernels
now)
-rw-r--r-- | sys/arch/hp300/hp300/machdep.c | 29 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/machdep.c | 34 | ||||
-rw-r--r-- | sys/arch/sgi/sgi/machdep.c | 25 |
3 files changed, 57 insertions, 31 deletions
diff --git a/sys/arch/hp300/hp300/machdep.c b/sys/arch/hp300/hp300/machdep.c index a5869c12a58..6d358d728f1 100644 --- a/sys/arch/hp300/hp300/machdep.c +++ b/sys/arch/hp300/hp300/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.91 2004/03/10 23:02:53 tom Exp $ */ +/* $OpenBSD: machdep.c,v 1.92 2004/12/02 19:37:22 miod Exp $ */ /* $NetBSD: machdep.c,v 1.121 1999/03/26 23:41:29 mycroft Exp $ */ /* @@ -112,11 +112,18 @@ int nbuf = NBUF; #else int nbuf = 0; #endif + +#ifndef BUFCACHEPERCENT +#define BUFCACHEPERCENT 5 +#endif + #ifdef BUFPAGES int bufpages = BUFPAGES; #else int bufpages = 0; #endif +int bufcachepercent = BUFCACHEPERCENT; + int maxmem; /* max memory per process */ int physmem = MAXMEM; /* max supported memory, changes to actual */ /* @@ -415,19 +422,27 @@ allocsys(v) #endif /* - * Determine how many buffers to allocate. Since HPs tend - * to be long on memory and short on disk speed, we allocate - * more buffer space than the BSD standard of 10% of memory - * for the first 2 Meg, 5% of the remaining. We just allocate - * a flag 10%. Insure a minimum of 16 buffers. + * Determine how many buffers to allocate (enough to + * hold 5% of total physical memory, but at least 16). + * Allocate 1/2 as many swap buffer headers as file i/o buffers. */ if (bufpages == 0) - bufpages = physmem / 10; + bufpages = physmem * bufcachepercent / 100; if (nbuf == 0) { nbuf = bufpages; if (nbuf < 16) nbuf = 16; } + /* Restrict to at most 70% filled kvm */ + if (nbuf * MAXBSIZE > + (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) * 7 / 10) + nbuf = (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / + MAXBSIZE * 7 / 10; + + /* More buffer pages than fits into the buffers is senseless. */ + if (bufpages > nbuf * MAXBSIZE / PAGE_SIZE) + bufpages = nbuf * MAXBSIZE / PAGE_SIZE; + valloc(buf, struct buf, nbuf); return (v); } diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c index b394f5eff9d..a4956902d9d 100644 --- a/sys/arch/mac68k/mac68k/machdep.c +++ b/sys/arch/mac68k/mac68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.113 2004/11/25 18:32:11 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.114 2004/12/02 19:37:25 miod Exp $ */ /* $NetBSD: machdep.c,v 1.207 1998/07/08 04:39:34 thorpej Exp $ */ /* @@ -179,11 +179,17 @@ int nbuf = NBUF; #else int nbuf = 0; #endif + +#ifndef BUFCACHEPERCENT +#define BUFCACHEPERCENT 5 +#endif + #ifdef BUFPAGES int bufpages = BUFPAGES; #else int bufpages = 0; #endif +int bufcachepercent = BUFCACHEPERCENT; int maxmem; /* max memory per process */ int physmem = MAXMEM; /* max supported memory, changes to actual */ @@ -488,23 +494,29 @@ allocsys(v) valloc(msghdrs, struct msg, msginfo.msgtql); valloc(msqids, struct msqid_ds, msginfo.msgmni); #endif + /* - * Determine how many buffers to allocate. - * Use 10% of memory for the first 2 Meg, then 5% of the remaining - * memory. Insure a minimum of 16 buffers. + * Determine how many buffers to allocate (enough to + * hold 5% of total physical memory, but at least 16). + * Allocate 1/2 as many swap buffer headers as file i/o buffers. */ - if (bufpages == 0) { - if (physmem < btoc(2 * 1024 * 1024)) - bufpages = physmem / 10; - else - bufpages = (btoc(2 * 1024 * 1024) + physmem) / 20; - } - + if (bufpages == 0) + bufpages = physmem * bufcachepercent / 100; if (nbuf == 0) { nbuf = bufpages; if (nbuf < 16) nbuf = 16; } + /* Restrict to at most 70% filled kvm */ + if (nbuf * MAXBSIZE > + (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) * 7 / 10) + nbuf = (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / + MAXBSIZE * 7 / 10; + + /* More buffer pages than fits into the buffers is senseless. */ + if (bufpages > nbuf * MAXBSIZE / PAGE_SIZE) + bufpages = nbuf * MAXBSIZE / PAGE_SIZE; + valloc(buf, struct buf, nbuf); return (v); } diff --git a/sys/arch/sgi/sgi/machdep.c b/sys/arch/sgi/sgi/machdep.c index 09b7acb2cdf..85abfdd38a3 100644 --- a/sys/arch/sgi/sgi/machdep.c +++ b/sys/arch/sgi/sgi/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.18 2004/10/22 10:15:42 pefo Exp $ */ +/* $OpenBSD: machdep.c,v 1.19 2004/12/02 19:37:25 miod Exp $ */ /* * Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -113,12 +113,16 @@ int allowaperture = 0; #ifndef NBUF #define NBUF 0 /* Can be changed in config */ #endif +#ifndef BUFCACHEPERCENT +#define BUFCACHEPERCENT 5 /* Can be changed in config */ +#endif #ifndef BUFPAGES #define BUFPAGES 0 /* Can be changed in config */ #endif int nbuf = NBUF; int bufpages = BUFPAGES; +int bufcachepercent = BUFCACHEPERCENT; vm_map_t exec_map; vm_map_t phys_map; @@ -554,30 +558,25 @@ allocsys(caddr_t v) valloc(msqids, struct msqid_ds, msginfo.msgmni); #endif -#ifndef BUFCACHEPERCENT -#define BUFCACHEPERCENT 5 -#endif - /* * Determine how many buffers to allocate. */ - if (bufpages == 0) { - bufpages = (physmem / (100/BUFCACHEPERCENT)); - } + if (bufpages == 0) + bufpages = physmem * bufcachepercent / 100; if (nbuf == 0) { nbuf = bufpages; if (nbuf < 16) nbuf = 16; } /* Restrict to at most 70% filled kvm */ - if (nbuf > (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / MAXBSIZE * 7 / 10) { - nbuf = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / MAXBSIZE * 7 / 10; - } + if (nbuf * MAXBSIZE > + (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) * 7 / 10) + nbuf = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / + MAXBSIZE * 7 / 10; /* More buffer pages than fits into the buffers is senseless. */ - if (bufpages > nbuf * MAXBSIZE / PAGE_SIZE) { + if (bufpages > nbuf * MAXBSIZE / PAGE_SIZE) bufpages = nbuf * MAXBSIZE / PAGE_SIZE; - } valloc(buf, struct buf, nbuf); |