From owner-svn-src-all@FreeBSD.ORG Sun Feb 27 12:12:16 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 464B81065670; Sun, 27 Feb 2011 12:12:16 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail01.syd.optusnet.com.au (mail01.syd.optusnet.com.au [211.29.132.182]) by mx1.freebsd.org (Postfix) with ESMTP id A33D88FC0C; Sun, 27 Feb 2011 12:12:15 +0000 (UTC) Received: from c122-107-114-89.carlnfd1.nsw.optusnet.com.au (c122-107-114-89.carlnfd1.nsw.optusnet.com.au [122.107.114.89]) by mail01.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p1RCC3cZ008607 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 27 Feb 2011 23:12:06 +1100 Date: Sun, 27 Feb 2011 23:12:03 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Bruce Cran In-Reply-To: <1298800011.24317.7.camel@core.nessbank> Message-ID: <20110227230553.N10085@besplex.bde.org> References: <201102231028.p1NASbET045275@svn.freebsd.org> <20110224063233.Y1100@besplex.bde.org> <1298499116.9366.3.camel@core.nessbank> <20110224102112.P1871@besplex.bde.org> <1298800011.24317.7.camel@core.nessbank> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Bruce Evans Subject: Re: svn commit: r218966 - head/sys/vm X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Feb 2011 12:12:16 -0000 On Sun, 27 Feb 2011, Bruce Cran wrote: > On Thu, 2011-02-24 at 10:36 +1100, Bruce Evans wrote: >> >> I would cast operand(s) in the expression as necessary to prevent overflow >> of subexpressions. vm_pindex_t would work, but I prefer to use a type >> related to the subexpressions. Not sure what that is. Maybe just >> uintmax_t for safety (even that is not safe if the subexpressions have >> large values). So: >> >> (uintmax_t)swap_bcount * SWAP_META_PAGES * n / mumble. > > Following Alan's suggestion, I've attached an updated patch which uses a > cast to u_long and returns long. I thought he only meant to return long. The units being returned are PAGE_SIZE smaller than the units in the expression. But I don't know exacty how large swp_bcount can be. If everything fits in a single object, then vm_size_t = u_int on 32-bit machines is enough. Bruce