From owner-svn-src-head@FreeBSD.ORG Thu Jun 28 07:53:10 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1AA191065673; Thu, 28 Jun 2012 07:53: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 A79D18FC08; Thu, 28 Jun 2012 07:53:09 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q5S7r2dh036045; Thu, 28 Jun 2012 10:53:02 +0300 (EEST) (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.5/8.14.5) with ESMTP id q5S7r22R099779; Thu, 28 Jun 2012 10:53:02 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q5S7r2QR099778; Thu, 28 Jun 2012 10:53:02 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 28 Jun 2012 10:53:01 +0300 From: Konstantin Belousov To: davidxu@freebsd.org Message-ID: <20120628075301.GS2337@deviant.kiev.zoral.com.ua> References: <201206272032.q5RKWjvt031174@svn.freebsd.org> <4FEBB8C9.8070006@gmail.com> <4FEBC0A2.3010708@gmail.com> <4FEBC70F.40408@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YD+BIkcXU0IoTTos" Content-Disposition: inline In-Reply-To: <4FEBC70F.40408@gmail.com> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: Attilio Rao , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r237660 - head/lib/libc/gen 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: Thu, 28 Jun 2012 07:53:10 -0000 --YD+BIkcXU0IoTTos Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 28, 2012 at 10:53:03AM +0800, David Xu wrote: > On 2012/6/28 10:32, Attilio Rao wrote: > >2012/6/28, David Xu: > >>On 2012/6/28 10:21, Attilio Rao wrote: > >>>2012/6/28, David Xu: > >>>>On 2012/6/28 4:32, Konstantin Belousov wrote: > >>>>>Author: kib > >>>>>Date: Wed Jun 27 20:32:45 2012 > >>>>>New Revision: 237660 > >>>>>URL: http://svn.freebsd.org/changeset/base/237660 > >>>>> > >>>>>Log: > >>>>> Optimize the handling of SC_NPROCESSORS_CONF, by using auxv=20 > >>>>> AT_NCPU > >>>>> value if present. > >>>>> > >>>>> MFC after: 1 week > >>>>> > >>>>>Modified: > >>>>> head/lib/libc/gen/sysconf.c > >>>>> > >>>>>Modified: head/lib/libc/gen/sysconf.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/lib/libc/gen/sysconf.c Wed Jun 27 20:24:25 2012 (r237659) > >>>>>+++ head/lib/libc/gen/sysconf.c Wed Jun 27 20:32:45 2012 (r237660) > >>>>>@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); > >>>>> #include > >>>>> #include > >>>>> > >>>>>+#include > >>>>> #include > >>>>> #include > >>>>> #include > >>>>>@@ -51,6 +52,7 @@ __FBSDID("$FreeBSD$"); > >>>>> > >>>>> #include "../stdlib/atexit.h" > >>>>> #include "tzfile.h" /* from=20 > >>>>> ../../../contrib/tzcode/stdtime */ > >>>>>+#include "libc_private.h" > >>>>> > >>>>> #define _PATH_ZONEINFO TZDIR /* from tzfile.h */ > >>>>> > >>>>>@@ -585,6 +587,8 @@ yesno: > >>>>> > >>>>> case _SC_NPROCESSORS_CONF: > >>>>> case _SC_NPROCESSORS_ONLN: > >>>>>+ if (_elf_aux_info(AT_NCPUS,&value, sizeof(value)) =3D=3D 0) > >>>>>+ return ((long)value); > >>>>> mib[0] =3D CTL_HW; > >>>>> mib[1] =3D HW_NCPU; > >>>>> break; > >>>>> > >>>>Will this make controlling the number of CPU online or CPU hotplug > >>>>be impossible on FreeBSD ? > >>>If I think about hotplug CPUs I can think of other 1000 > >>>problems/races/bad situations to be fixed before this one, really. > >>These are problems only in kernel, but kib's change is about ABI > >>between userland and kernel, I hope we don't introduce an ABI which > >>is not extendable road stone. > >I'm not entirely sure I see the ABI breakage here. > It is not breakage, it is the ABI thinks number of online cpu is fixed, > obviously, it is not the case in future unless FreeBSD won't support > dynamic number of online cpus. >=20 >=20 > >If the AT_NCPUS > >becames unconvenient and not correct at some point we can just fix > >sysconf() to not look into the aux vector anymoe. > If you already know this will be a problem, why do you introduce it > and later need to fix it ? >=20 > > Please note that > >AT_NCPUS is already exported nowadays. I think this is instead a > >clever optimization to avoid the sysctl() (usual way to retrieve the > >number of CPUs). > But why don't you cache it in libc ? following code is enough: >=20 > static int online_cpu; > if (online_cpu =3D=3D 0) > online_cpu =3D sysctl > return online_cpu; >=20 Thread did evolved somewhat while I was AFK. First, please note that the ABI which I designed there is fixable: if kernel does not export AT_NCPUS at all, then auxv correctly handles the situation returning an error, and libc falls back to sysctl(2). Second, sysconf(3) is very weird API. Note the following statement from SUSv4: "The value shall not change during the lifetime of the calling process, [XSI] [Option Start] except that sysconf(_SC_OPEN_MAX) may return different values before and after a call to setrlimit() which changes the RLIMIT_NOFILE soft limit." Corresponding comment is also present in sysconf.c. So I do not see an issue there, esp. for advisory value which NCPUS is anyway. --YD+BIkcXU0IoTTos Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/sDV0ACgkQC3+MBN1Mb4jAxwCeOOJVbcfvLsTXSgOupccMhLDZ OmgAnie0Etxxw62u1QPnCI0lCNYFOKez =jhGE -----END PGP SIGNATURE----- --YD+BIkcXU0IoTTos--