From owner-freebsd-arch@FreeBSD.ORG Thu Jun 7 10:04:22 2012 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4D1D8106567F; Thu, 7 Jun 2012 10:04:22 +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 DBBFA8FC1F; Thu, 7 Jun 2012 10:04:21 +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 q57A42Q5072985; Thu, 7 Jun 2012 13:04: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 q57A42K6028244; Thu, 7 Jun 2012 13:04: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 q57A41Lb028243; Thu, 7 Jun 2012 13:04:01 +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, 7 Jun 2012 13:04:01 +0300 From: Konstantin Belousov To: Dag-Erling Sm??rgrav Message-ID: <20120607100401.GW85127@deviant.kiev.zoral.com.ua> References: <201206051008.29568.jhb@freebsd.org> <86haupvk4a.fsf@ds4.des.no> <201206051222.12627.jhb@freebsd.org> <20120605171446.GA28387@onelab2.iet.unipi.it> <20120606040931.F1050@besplex.bde.org> <864nqovoek.fsf@ds4.des.no> <20120607064951.C1106@besplex.bde.org> <86sje7sf31.fsf@ds4.des.no> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PoKbPPFu8MuDl6RC" Content-Disposition: inline In-Reply-To: <86sje7sf31.fsf@ds4.des.no> 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: John Baldwin , freebsd-arch@FreeBSD.org Subject: Re: Fast vs slow syscalls (Re: Fwd: [RFC] Kernel shared variables) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jun 2012 10:04:22 -0000 --PoKbPPFu8MuDl6RC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 07, 2012 at 10:26:10AM +0200, Dag-Erling Sm??rgrav wrote: > Bruce Evans writes: > > Now 2.44 nsec/call makes sense, but you really should add some volatiles > > here to ensure that getpid() is not optimized away. >=20 > As you can see from the disassembly I provided, it isn't. >=20 > > SO it loops OK, but we can't see what getpid() does. It must not be > > doing much. >=20 > Umm, yes, that's the whole point of this conversation. Linux's getpid() > is not a syscall, but a library function that returns a constant from a > page shared by the kernel. >=20 > > 5.4104 nsec/call for gettimeofday() is impossible if there is any > > rdtsc() hardware call or much layering. >=20 > It's gettimeofday(0, 0), actually, so it doesn't need to read the clock. > If I pass a struct timeval as the first argument - so it *does* need to > read the clock - it's a little bit slower but still faster than an > actual system call. Here's another run that demonstrates this - a > little bit slower than previous runs because I have other processes > running: >=20 > getpid(): 10,000,000 iterations in 30,377 us > gettimeofday(0, 0): 10,000,000 iterations in 55,571 us > gettimeofday(&tv, 0): 10,000,000 iterations in 302,634 us So this timing seems to be approximately same by the order of magnitude as the times I get for the patch, around 25 vs. 30ns/per gettimeofday() call. Linux seems slower probably due to slower CPU ? Mine is 3.4Ghz, while des used 3.1Ghz for Linux box. > kill(pid, 0): 10,000,000 iterations in 1,291,793 us >=20 > I can't test a static build since RHEL6 does not provide a static libc. >=20 > DES > --=20 > Dag-Erling Sm??rgrav - des@des.no --PoKbPPFu8MuDl6RC Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/QfJEACgkQC3+MBN1Mb4itsgCgsxTeKDTcDUfT3Q8hK0aYFBDs 0+sAoMzkk9S8GR9ivMLh2+70M0nWjqOz =tk9Z -----END PGP SIGNATURE----- --PoKbPPFu8MuDl6RC--