Date: Wed, 30 Jun 2004 10:18:53 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Andrew Gallatin <gallatin@cs.duke.edu> Cc: cvs-src@FreeBSD.org Subject: Re: cvs commit: src/sys/vm vm_map.c Message-ID: <20040630095111.U2619@gamplex.bde.org> In-Reply-To: <16609.23767.245708.270218@grasshopper.cs.duke.edu> References: <200406281915.i5SJFeaV060231@repoman.freebsd.org> <20040628193858.GG5635@green.homeunix.org> <20040629114614.T2908@gamplex.bde.org> <16609.23767.245708.270218@grasshopper.cs.duke.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 29 Jun 2004, Andrew Gallatin wrote: > Bruce Evans writes: > > On Mon, 28 Jun 2004, Andrew Gallatin wrote: > > > > > > Log: > > > > > > Fix alpha - the use of min() on longs was loosing the high bits and > > > > > > returning wrong answers, leading to strange values vm2->vm_{s,t,d}size. > > > > MIN() and MAX() should not be used in the kernel. 4.4BSD removed them in > > the kernel, but FreeBSD broke this in rev.1.141 of sys/param.h. They > > remain removed in RELENG_4. > > OK. Then what's the correct fix? ulmin()? Fixing min() to handle all unsigned types is probably best. Some not-quite correct fixes: 1. Just use ulmin(). It would work on all supported machines because vm_offset_t is smaller than u_long (actually the same). This is fragile. 2. (1) plus a compile-time assertion that sizeof(vm_offset_t) <= sizeof(u_long). This is quite practical. There are only a few min()'s in all of vm, and only the 2 that you fixed seem to need special handling (the others are mainly for page counts, and 2^32 pages should be enough for anyone). 3. (1) plus a runtime assertion... 4. (3) with calls to uqmin() instead of failing assertions for larger vm_offset_t's. 5. (4) plus support for uintmax_t's. 6. Support for uintmax_t's, and just use uimax_min(). 7. (6), plus wait for gcc to optimize uimax_min(). gcc currently always widens the args before comparing them, even with -O3. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040630095111.U2619>