From owner-svn-src-all@FreeBSD.ORG Mon Dec 17 11:31:58 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E32009AF; Mon, 17 Dec 2012 11:31:58 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 3761E8FC0C; Mon, 17 Dec 2012 11:31:58 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.5/8.14.5) with ESMTP id qBHBVpxl022797; Mon, 17 Dec 2012 13:31:51 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.7.3 kib.kiev.ua qBHBVpxl022797 Received: (from kostik@localhost) by tom.home (8.14.5/8.14.5/Submit) id qBHBVpRH022796; Mon, 17 Dec 2012 13:31:51 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 17 Dec 2012 13:31:51 +0200 From: Konstantin Belousov To: Gabor Kovesdan Subject: Re: svn commit: r244346 - head/usr.bin/sort Message-ID: <20121217113151.GA71906@kib.kiev.ua> References: <201212170936.qBH9ah0V059357@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="2VcK7Ezgm4IMdfSa" Content-Disposition: inline In-Reply-To: <201212170936.qBH9ah0V059357@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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: Mon, 17 Dec 2012 11:31:59 -0000 --2VcK7Ezgm4IMdfSa Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 17, 2012 at 09:36:43AM +0000, Gabor Kovesdan wrote: > Author: gabor > Date: Mon Dec 17 09:36:43 2012 > New Revision: 244346 > URL: http://svnweb.freebsd.org/changeset/base/244346 >=20 > Log: > - Use unsigned int for values obtained with sysctlbyname(). This fixes > sparc64 performance problems. > =20 > Submitted by: Oleg Moskalenko > Tested by: trasz >=20 > Modified: > head/usr.bin/sort/sort.c > head/usr.bin/sort/sort.h >=20 > Modified: head/usr.bin/sort/sort.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.bin/sort/sort.c Mon Dec 17 06:44:16 2012 (r244345) > +++ head/usr.bin/sort/sort.c Mon Dec 17 09:36:43 2012 (r244346) > @@ -103,7 +103,7 @@ bool debug_sort; > bool need_hint; > =20 > #if defined(SORT_THREADS) > -size_t ncpu =3D 1; > +unsigned int ncpu =3D 1; > size_t nthreads =3D 1; > #endif > =20 > @@ -268,14 +268,16 @@ set_hw_params(void) > #if defined(SORT_THREADS) > size_t ncpusz; > #endif > - size_t pages, psize, psz, pszsz; > + unsigned int pages, psize; > + size_t psz, pszsz; > =20 > pages =3D psize =3D 0; > #if defined(SORT_THREADS) > ncpu =3D 1; > ncpusz =3D sizeof(size_t); > #endif > - psz =3D pszsz =3D sizeof(size_t); > + psz =3D sizeof(pages); > + pszsz =3D sizeof(psize); > =20 > if (sysctlbyname("vm.stats.vm.v_free_count", &pages, &psz, > NULL, 0) < 0) { > @@ -299,6 +301,9 @@ set_hw_params(void) > =20 > free_memory =3D (unsigned long long) pages * (unsigned long long) psize; > available_free_memory =3D (free_memory * 9) / 10; > + > + if (available_free_memory < 1024) > + available_free_memory =3D 1024; > } Instead of direct use of sysctl interface for hw.ncpu, use sysconf(_SC_NPROCESSORS_ONLN). The 'query' for the available memory is absolutely wrong and is beyond any repair, it must be removed. > =20 > /* >=20 > Modified: head/usr.bin/sort/sort.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.bin/sort/sort.h Mon Dec 17 06:44:16 2012 (r244345) > +++ head/usr.bin/sort/sort.h Mon Dec 17 09:36:43 2012 (r244346) > @@ -54,7 +54,7 @@ extern const char *nlsstr[]; > =20 > #if defined(SORT_THREADS) > #define MT_SORT_THRESHOLD (10000) > -extern size_t ncpu; > +extern unsigned int ncpu; > extern size_t nthreads; > #endif > =20 --2VcK7Ezgm4IMdfSa Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQIcBAEBAgAGBQJQzwKmAAoJEJDCuSvBvK1Bb+YP/jcn4MhUCyLIxXZVK4TW7cUI 9yTk4jPRJl/pJMIj+oRizANPxGwJBQfDW3h+oCBO5CgwRkfM3vVm/TIs6OKGdNxU utsNQeF17XvtBgoF2sMiff0VcecJgfGKzKve5ffgg8Z82Hvz28ae9/23P5MD5t7P P9gwOsbYjKFdCoYL5ldGZlFJFR48OralcML+f86B7gudWhpU0eNBbAL5cnYGxobe o1j8sS0+aZNQxzjSGnuMyf9t3G5sWpl4aTsbj96ZHYxOd06b6X8UXD+EbOIdSZnX O/BlLkDy+E/nJxqdqk5RVbLE/nUBG9+kUKiptcN+TDVJzo6ctEiAmzFh9XmVuLaB v1XUKt3ZmnOknl8ZiSqXscvBwEGYzKBvz6Dkv72BIvkUVJ0WduloruJne6QvKNSR 6sDx0EFRFZqhYaIX6tgXQMZOAmjcFQUeDcmuAZVaWL/8NEnciC1YViutaZjaT8H4 bZF0vWV43lgQPfveVdBh6lhtdtuxxBDKWeixZZLwVZTU83gPqL2K48KAb0aE0foY ny7QUHXKSObtgEzXriwvYO4eQXWvUYmbWrzH08Aznwg7w04FkKAiYGcEe0OKuNeb d2C6CxS0dWIistK2sRz4hFgS4MgkOzAspTWPI4bJuZuqm76OcNYmxp488y0a0izi UsHrei63BY+k/AK66fqR =yKDY -----END PGP SIGNATURE----- --2VcK7Ezgm4IMdfSa--