From owner-freebsd-arch@FreeBSD.ORG Thu Jun 7 22:43:11 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 87CE1106564A; Thu, 7 Jun 2012 22:43:11 +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 04F768FC0C; Thu, 7 Jun 2012 22:43: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 q57Mh24b033391; Fri, 8 Jun 2012 01:43: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 q57Mh1XM031780; Fri, 8 Jun 2012 01:43:01 +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 q57Mh18n031779; Fri, 8 Jun 2012 01:43: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: Fri, 8 Jun 2012 01:43:01 +0300 From: Konstantin Belousov To: Peter Wemm Message-ID: <20120607224301.GB85127@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="ds9maZbwT7uk2FVi" Content-Disposition: inline In-Reply-To: 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: Gianni , Alan Cox , Alexander Kabaev , Attilio Rao , freebsd-arch@freebsd.org, Dag-Erling Sm?rgrav 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 22:43:11 -0000 --ds9maZbwT7uk2FVi Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 07, 2012 at 03:30:54PM -0700, Peter Wemm wrote: > On Thu, Jun 7, 2012 at 1:26 AM, Dag-Erling Sm?rgrav wrote: > > Bruce Evans writes: > >> Now 2.44 nsec/call makes sense, but you really should add some volatil= es > >> here to ensure that getpid() is not optimized away. > > > > As you can see from the disassembly I provided, it isn't. > > > >> SO it loops OK, but we can't see what getpid() does. =9AIt must not be > >> doing much. > > > > Umm, yes, that's the whole point of this conversation. =9ALinux's getpi= d() > > is not a syscall, but a library function that returns a constant from a > > page shared by the kernel. >=20 > It might be worth taking a peek at what they do before going too far > down the rabbit hole. They've had to deal with the whole ABI > stability vs kernel layout thing already. >=20 > As I recall, they literally embed a userland style .so shared object > into the kernel and make it available to the user. The dynamic linker > "finds" it via elf auxinfo and inserts it into the symbol search > order. >=20 > That way, the shared page layout is kernel specific. If they chose to > provide getpid() or gettimeofday() or whatever, its a matter of > adjusting the shared page and inserting code into the .so file. If > the page changes, the code changes. >=20 > Think of what we do with signal trampolines except in a way > ld-elf.so.1 can pull it into user space and gdb "sees" it as a .so > file with debug info. >=20 > I think I remember that they did the shared page thing and then > switched to providing a stub .so file. Yes, this is the thing called VDSO in the thread discussion. --ds9maZbwT7uk2FVi Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/RLnUACgkQC3+MBN1Mb4hULgCg6R/ekHO3tW9BYjjiMafdKXmR gccAoLWFdYgh2qDFvMB7fGpWn1myusKE =HShI -----END PGP SIGNATURE----- --ds9maZbwT7uk2FVi--