From owner-svn-src-head@FreeBSD.ORG Sun Feb 27 09:47:10 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 808F4106566C; Sun, 27 Feb 2011 09:47:10 +0000 (UTC) (envelope-from bruce@cran.org.uk) Received: from muon.cran.org.uk (unknown [IPv6:2a01:348:0:15:5d59:5c40:0:1]) by mx1.freebsd.org (Postfix) with ESMTP id 0B1E38FC12; Sun, 27 Feb 2011 09:47:10 +0000 (UTC) Received: from muon.cran.org.uk (localhost [127.0.0.1]) by muon.cran.org.uk (Postfix) with ESMTP id 51A84E8CA6; Sun, 27 Feb 2011 09:47:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cran.org.uk; h=subject :from:to:cc:in-reply-to:references:content-type:date:message-id :mime-version; s=mail; bh=twLZl7JPImyla/TbGjpeaKVtM1k=; b=y6x+4t +OXllOYaST8PZePymF1UCeS23kWofEtWO32SO+evF/OXqNABq2C0dwho+pbRhCF8 Q4evV2FbBdy8UezepGZqMJPGKN/f0YG+cAcC1wHlkyPwtse+mgP2r34Vwxh+6ceA vupw8ZpDiDZrbxAc3/G7u00pqhnJosofSLwMo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=cran.org.uk; h=subject:from :to:cc:in-reply-to:references:content-type:date:message-id :mime-version; q=dns; s=mail; b=aYqdREe93f/B/eHZej27N3b/YD2iInfH u+JrBtsZl7QgtZTtr+FUW1AsY1Ot52qJV4ITL3KLvqes+btqhCKwlfb6GFj4U1xA PtoNxHjY3l/0cgHgbpk3ogGq35JDc3+GdI4pGpHzhO8DgOJNBibQFFSWRXY1n6fy BLhvYw+8w/k= Received: from [192.168.0.10] (client-86-31-236-253.oxfd.adsl.virginmedia.com [86.31.236.253]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by muon.cran.org.uk (Postfix) with ESMTPSA id EEE21E8C98; Sun, 27 Feb 2011 09:47:06 +0000 (GMT) From: Bruce Cran To: Bruce Evans In-Reply-To: <20110224102112.P1871@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> Content-Type: multipart/mixed; boundary="=-j8MDx4GezBwO3yPa/kG/" Date: Sun, 27 Feb 2011 09:46:51 +0000 Message-ID: <1298800011.24317.7.camel@core.nessbank> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r218966 - head/sys/vm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Feb 2011 09:47:10 -0000 --=-j8MDx4GezBwO3yPa/kG/ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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. -- Bruce Cran --=-j8MDx4GezBwO3yPa/kG/ Content-Disposition: attachment; filename="vm.diff" Content-Type: text/x-patch; name="vm.diff"; charset="us-ascii" Content-Transfer-Encoding: 7bit Index: vm_map.h =================================================================== --- vm_map.h (revision 219050) +++ vm_map.h (working copy) @@ -380,6 +380,6 @@ int flags); int vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags); -vm_offset_t vmspace_swap_count(struct vmspace *vmspace); +long vmspace_swap_count(struct vmspace *vmspace); #endif /* _KERNEL */ #endif /* _VM_MAP_ */ Index: swap_pager.c =================================================================== --- swap_pager.c (revision 219050) +++ swap_pager.c (working copy) @@ -2420,13 +2420,13 @@ * if the VM object has any swap use at all the associated map entries * count for at least 1 swap page. */ -vm_offset_t +long vmspace_swap_count(struct vmspace *vmspace) { vm_map_t map; vm_map_entry_t cur; vm_object_t object; - vm_offset_t count, n; + long count, n; map = &vmspace->vm_map; count = 0; @@ -2438,7 +2438,7 @@ if (object->type == OBJT_SWAP && object->un_pager.swp.swp_bcount != 0) { n = (cur->end - cur->start) / PAGE_SIZE; - count += object->un_pager.swp.swp_bcount * + count += (u_long)object->un_pager.swp.swp_bcount * SWAP_META_PAGES * n / object->size + 1; } VM_OBJECT_UNLOCK(object); --=-j8MDx4GezBwO3yPa/kG/--