Date: Thu, 29 Nov 2012 00:15:46 +0100 From: Andre Oppermann <andre@freebsd.org> To: Bruce Evans <brde@optusnet.com.au> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Alan Cox <alc@rice.edu> Subject: Re: svn commit: r243631 - in head/sys: kern sys Message-ID: <50B69B22.80706@freebsd.org> In-Reply-To: <20121129072617.T1123@besplex.bde.org> References: <201211272119.qARLJxXV061083@svn.freebsd.org> <50B64BE8.3040708@rice.edu> <20121129072617.T1123@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 28.11.2012 22:45, Bruce Evans wrote: > On Wed, 28 Nov 2012, Alan Cox wrote: > >> I'm pretty sure that the "realmem" calculation is going to overflow on >> i386/PAE, where the number of bytes of physical memory is greater than >> the type long can represent. > > It overflows on i386 even without PAE, where the number of bytes of > physical memory is greater than the type long can represent (2GB). This is the usual case for new > hardware. Please have a look at the attached patch. Is quad_t the appropriate type to use? If not, which is the right one? > I think it changes the defaults for machines with small amounts of > memory (say 32MB) in dangerous ways. > > Reserving half of kva for mbufs is network-centric. I reserve more > than half of kva for the buffer cache in some configurations > (VM_BCACHE_SIZE_MAX defaults too 200 MB, but I use 512 MB), and in the > old scheme where the default for mbufs was under-sized, this may even > have fitted without separate tuning for mbufs. Please note that NO *reservations* are made for mbufs. It's only *limits* that are enforced. For example stand-alone mbufs were not limited at all previously and could completely exhaust all available kernel memory. > The code has lots of style bugs. Thank you for your detailed input. I'll handle that after the "long" overflow issue is solved. -- Andre Index: kern/subr_param.c =================================================================== --- kern/subr_param.c (revision 243631) +++ kern/subr_param.c (working copy) @@ -271,7 +271,7 @@ void init_param2(long physpages) { - long realmem; + quad_t realmem; /* Base parameters */ maxusers = MAXUSERS; @@ -332,10 +332,10 @@ * 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; Index: sys/mbuf.h =================================================================== --- sys/mbuf.h (revision 243631) +++ sys/mbuf.h (working copy) @@ -395,7 +395,7 @@ * * The rest of it is defined in kern/kern_mbuf.c */ -extern long maxmbufmem; +extern quad_t maxmbufmem; extern uma_zone_t zone_mbuf; extern uma_zone_t zone_clust; extern uma_zone_t zone_pack;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50B69B22.80706>