linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: stefani@seibold.net
To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	x86@kernel.org, tglx@linutronix.de, mingo@redhat.com,
	hpa@zytor.com, ak@linux.intel.com, aarcange@redhat.com,
	john.stultz@linaro.org, luto@amacapital.net, xemul@parallels.com,
	gorcunov@openvz.org, andriy.shevchenko@linux.intel.com
Cc: Martin.Runge@rohde-schwarz.com, Andreas.Brief@rohde-schwarz.com,
	Stefani Seibold <stefani@seibold.net>
Subject: [PATCH 0/4] Add 32 bit VDSO time function support
Date: Thu, 30 Jan 2014 11:49:09 +0100	[thread overview]
Message-ID: <1391078953-1575-1-git-send-email-stefani@seibold.net> (raw)

From: Stefani Seibold <stefani@seibold.net>

This patch add the functions vdso_gettimeofday(), vdso_clock_gettime()
and vdso_time() to the 32 bit VDSO.

The reason to do this was to get a fast reliable time stamp. Many developers
uses TSC to get a fast time stamp, without knowing the pitfalls. VDSO
time functions a fast and a reliable way, because the kernel knows the
best time source and the P- and C-state of the CPU.

The helper library to use the VDSO functions can be download at
http://http://seibold.net/vdso.c
The libary is very small, only 228 lines of code. Compile it with
gcc -Wall -O3 -fpic vdso.c -lrt -shared -o libvdso.so
and use it with LD_PRELOAD=<path>/libvdso.so

This kind of helper must be integrated into glibc, for x86 64 bit and
PowerPC it is already there.

Some linux 32 bit kernel benchmark results (all measurements are in nano
seconds):

Intel(R) Celeron(TM) CPU 400MHz

Average time kernel call:
 gettimeofday(): 1039
 clock_gettime(): 1578
 time(): 526
Average time VDSO call:
 gettimeofday(): 378
 clock_gettime(): 303
 time(): 60

Celeron(R) Dual-Core CPU T3100 1.90GHz

Average time kernel call:
 gettimeofday(): 209
 clock_gettime(): 406
 time(): 135
Average time VDSO call:
 gettimeofday(): 51
 clock_gettime(): 43
 time(): 10

So you can see a performance increase between 4 and 13, depending on the
CPU and the function.

The address layout of the VDSO has changed, because there is no fixed
address space available on a x86 32 bit kernel, despite the name. Because
someone decided to add an offset to the __FIXADDR_TOP for virtualization.

Also the IA32 Emulation uses the whole 4 GB address space, so there is no
fixed address available.

This was the reason not depend on this kind of address and change the layout
of the VDSO. The VDSO for a 32 bit application has now three pages:

+----------------------------------------+
+ VDSO page (includes code) ro+x         +
+----------------------------------------+
+ VVAR page (export kernel variables) ro +
+----------------------------------------+
+ HPET page (mapped registers) ro 
+----------------------------------------+

The VDSO page for a 32 bit resided now on 0xffffc000, followed by the VVAR and
HPET page.

In the non compat mode the VMA of the VDSO is now 3 pages for a 32 bit kernel.
So this decrease the available logical address room by 2 pages.

The patch is against kernel 3.13 (3aacd625f20129f5a41ea3ff3b5353b0e4dabd01).

Changelog:
25.11.2012 - first release and proof of concept for linux 3.4
11.12.2012 - Port to linux 3.7 and code cleanup
12.12.2012 - fixes suggested by Andy Lutomirski
           - fixes suggested by John Stultz
           - use call VDSO32_vsyscall instead of int 80
           - code cleanup
17.12.2012 - support for IA32_EMULATION, this includes
             - code cleanup
             - include cleanup to fix compile warnings and errors
	     - move out seqcount from seqlock, enable use in VDSO
	     - map FIXMAP and HPET into the 32 bit address space
18.12.2012 - split into separate patches
30.01.2013 - revamp the code
             - code clean up
	     - VDSO layout changed
	     - no fixed addresses
	     - port to 3.13

             reply	other threads:[~2014-01-30 10:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-30 10:49 stefani [this message]
2014-01-30 10:49 ` [PATCH 1/4] Make vsyscall_gtod_data handling x86 generic stefani
2014-01-30 18:05   ` Andy Lutomirski
2014-01-30 19:27     ` Stefani Seibold
2014-01-30 19:51       ` Andy Lutomirski
2014-01-30 20:19         ` Stefani Seibold
2014-01-31  0:10   ` Andi Kleen
2014-02-01 14:51     ` Stefani Seibold
2014-01-30 10:49 ` [PATCH 2/4] Add new func _install_special_mapping() to mmap.c stefani
2014-01-30 10:49 ` [PATCH 3/4] Add 32 bit VDSO support for 32 kernel stefani
2014-01-30 15:30   ` H. Peter Anvin
2014-01-30 15:53     ` Stefani Seibold
2014-01-30 18:17   ` Andy Lutomirski
2014-01-30 19:39     ` Stefani Seibold
2014-01-30 19:50       ` Andy Lutomirski
2014-01-30 10:49 ` [PATCH 4/4] Add 32 bit VDSO support for 64 kernel stefani
2014-01-30 18:21   ` Andy Lutomirski
2014-01-30 19:43     ` Stefani Seibold
2014-01-31 23:12       ` Andy Lutomirski
2014-01-30 15:31 ` [PATCH 0/4] Add 32 bit VDSO time function support H. Peter Anvin
2014-01-30 15:52   ` Stefani Seibold
2014-01-30 15:54     ` H. Peter Anvin
2014-01-30 17:57     ` Andy Lutomirski
2014-01-30 18:03       ` H. Peter Anvin
2014-01-30 18:08         ` Andy Lutomirski
2014-02-01 15:32 stefani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1391078953-1575-1-git-send-email-stefani@seibold.net \
    --to=stefani@seibold.net \
    --cc=Andreas.Brief@rohde-schwarz.com \
    --cc=Martin.Runge@rohde-schwarz.com \
    --cc=aarcange@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gorcunov@openvz.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xemul@parallels.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).