From owner-svn-src-head@FreeBSD.ORG Sun Feb 27 13:19: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 73C49106566C; Sun, 27 Feb 2011 13:19:10 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id DEF288FC0C; Sun, 27 Feb 2011 13:19:09 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p1RDJ4rr035403 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 27 Feb 2011 15:19:04 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p1RDJ4wM007338; Sun, 27 Feb 2011 15:19:04 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p1RDJ3cF007337; Sun, 27 Feb 2011 15:19:03 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 27 Feb 2011 15:19:03 +0200 From: Kostik Belousov To: Bruce Evans Message-ID: <20110227131903.GE78089@deviant.kiev.zoral.com.ua> 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> <20110227230553.N10085@besplex.bde.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="uZAQk/nhVDxpDIck" Content-Disposition: inline In-Reply-To: <20110227230553.N10085@besplex.bde.org> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: Bruce Cran , 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 13:19:10 -0000 --uZAQk/nhVDxpDIck Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Feb 27, 2011 at 11:12:03PM +1100, Bruce Evans wrote: > On Sun, 27 Feb 2011, Bruce Cran wrote: >=20 > >On Thu, 2011-02-24 at 10:36 +1100, Bruce Evans wrote: > >> > >>I would cast operand(s) in the expression as necessary to prevent overf= low > >>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. >=20 > 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 =3D u_int on 32-bit machines is enough. I think that return type should be left as vm_offset_t. The calculation basically returns some quantity of type vm_offset_t, divided by PAGE_SIZE. This validates the new return type. The calculation could use vm_offset_t, or uintmax_t cast, probably vm_offset_t is preferred for the same reason. --uZAQk/nhVDxpDIck Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk1qT0cACgkQC3+MBN1Mb4jZ3wCgzOYhyMq3VyMFcNZ8wBa5bQue o+MAn0I0IQTEWaTiTPuJ6hLddDyQYFoM =nIGG -----END PGP SIGNATURE----- --uZAQk/nhVDxpDIck--