summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_param.c
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2012-11-29 07:30:42 +0000
committerandre <andre@FreeBSD.org>2012-11-29 07:30:42 +0000
commit051df828de0ee7c6055c650e9ecd53a7d2413e89 (patch)
treedb0ad72c5cb51e20dae6201d488901d1c3ab0f3b /sys/kern/subr_param.c
parent4e7a33716c1179fe69e003004da720fb8e43972f (diff)
downloadFreeBSD-src-051df828de0ee7c6055c650e9ecd53a7d2413e89.zip
FreeBSD-src-051df828de0ee7c6055c650e9ecd53a7d2413e89.tar.gz
Using a long is the wrong type to represent the realmem and maxmbufmem
variable as they may overflow on i386/PAE and i386 with > 2GB RAM. Use 64bit quad_t instead. It has broader kernel infrastructure support with TUNABLE_QUAD_FETCH() and qmin/qmax() than other available types. Pointed out by: alc, bde
Diffstat (limited to 'sys/kern/subr_param.c')
-rw-r--r--sys/kern/subr_param.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c
index f299e08..f8c4fe7 100644
--- a/sys/kern/subr_param.c
+++ b/sys/kern/subr_param.c
@@ -93,7 +93,7 @@ int ncallout; /* maximum # of timer events */
int nbuf;
int ngroups_max; /* max # groups per process */
int nswbuf;
-long maxmbufmem; /* max mbuf memory */
+quad_t maxmbufmem; /* max mbuf memory */
pid_t pid_max = PID_MAX;
long maxswzone; /* max swmeta KVA storage */
long maxbcache; /* max buffer cache KVA storage */
@@ -271,7 +271,7 @@ init_param1(void)
void
init_param2(long physpages)
{
- long realmem;
+ quad_t realmem;
/* Base parameters */
maxusers = MAXUSERS;
@@ -332,10 +332,10 @@ init_param2(long physpages)
* available kernel memory (physical or kmem).
* At most it can be 3/4 of available kernel memory.
*/
- realmem = lmin(physpages * PAGE_SIZE,
+ realmem = qmin(physpages * PAGE_SIZE,
VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS);
maxmbufmem = realmem / 2;
- TUNABLE_LONG_FETCH("kern.maxmbufmem", &maxmbufmem);
+ TUNABLE_QUAD_FETCH("kern.maxmbufmem", &maxmbufmem);
if (maxmbufmem > (realmem / 4) * 3)
maxmbufmem = (realmem / 4) * 3;
OpenPOWER on IntegriCloud