From owner-cvs-src@FreeBSD.ORG Wed Jun 30 00:19:31 2004 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A64C316A4CE; Wed, 30 Jun 2004 00:19:31 +0000 (GMT) Received: from mailout1.pacific.net.au (mailout1.pacific.net.au [61.8.0.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 28BAB43D1D; Wed, 30 Jun 2004 00:19:31 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.0.86])i5U0J34u029050; Wed, 30 Jun 2004 10:19:03 +1000 Received: from gamplex.bde.org (katana.zip.com.au [61.8.7.246]) i5U0Irao025398; Wed, 30 Jun 2004 10:19:02 +1000 Date: Wed, 30 Jun 2004 10:18:53 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Andrew Gallatin In-Reply-To: <16609.23767.245708.270218@grasshopper.cs.duke.edu> Message-ID: <20040630095111.U2619@gamplex.bde.org> References: <200406281915.i5SJFeaV060231@repoman.freebsd.org> <20040628193858.GG5635@green.homeunix.org> <20040629114614.T2908@gamplex.bde.org> <16609.23767.245708.270218@grasshopper.cs.duke.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: Brian Fundakowski Feldman cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org cc: cvs-src@FreeBSD.org Subject: Re: cvs commit: src/sys/vm vm_map.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jun 2004 00:19:31 -0000 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