Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jun 2012 15:30:54 -0700
From:      Peter Wemm <peter@wemm.org>
To:        =?ISO-8859-1?Q?Dag=2DErling_Sm=F8rgrav?= <des@des.no>
Cc:        Gianni <gianni@freebsd.org>, Alan Cox <alc@rice.edu>, Alexander Kabaev <kan@freebsd.org>, Attilio Rao <attilio@freebsd.org>, Konstantin Belousov <kib@freebsd.org>, freebsd-arch@freebsd.org, Konstantin Belousov <kostikbel@gmail.com>
Subject:   Re: Fast vs slow syscalls (Re: Fwd: [RFC] Kernel shared variables)
Message-ID:  <CAGE5yCp0VUwcPh1_L2uU=wmCh96pkrrpuZWNMNw6RuMnYPyXQw@mail.gmail.com>
In-Reply-To: <86sje7sf31.fsf@ds4.des.no>
References:  <CACfq090r1tWhuDkxdSZ24fwafbVKU0yduu1yV2%2BoYo%2BwwT4ipA@mail.gmail.com> <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>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jun 7, 2012 at 1:26 AM, Dag-Erling Sm=F8rgrav <des@des.no> wrote:
> Bruce Evans <brde@optusnet.com.au> writes:
>> Now 2.44 nsec/call makes sense, but you really should add some volatiles
>> 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. =A0It must not be
>> doing much.
>
> Umm, yes, that's the whole point of this conversation. =A0Linux's getpid(=
)
> is not a syscall, but a library function that returns a constant from a
> page shared by the kernel.

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.

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.

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.

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.

I think I remember that they did the shared page thing and then
switched to providing a stub .so file.

--=20
Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com; KI6FJV
"All of this is for nothing if we don't go to the stars" - JMS/B5
"If Java had true garbage collection, most programs would delete
themselves upon execution." -- Robert Sewell



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGE5yCp0VUwcPh1_L2uU=wmCh96pkrrpuZWNMNw6RuMnYPyXQw>