linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Andy Lutomirski <luto@kernel.org>,
	x86@kernel.org, Marcelo Tosatti <mtosatti@redhat.com>,
	Radim Krcmar <rkrcmar@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	Alexander Graf <agraf@suse.de>
Subject: Re: [PATCH 5/5] x86/vdso: Enable vdso pvclock access on all vdso variants
Date: Thu, 10 Dec 2015 10:10:09 +0100	[thread overview]
Message-ID: <56694171.6000202@redhat.com> (raw)
In-Reply-To: <a7ef693b7a4c88dd2173dc1d4bf6bc27023626eb.1449702533.git.luto@kernel.org>



On 10/12/2015 00:12, Andy Lutomirski wrote:
> Now that pvclock doesn't require access to the fixmap, all vdso
> variants can use it.
> 
> The kernel side isn't wired up for 32-bit kernels yet, but this
> covers 32-bit and x32 userspace on 64-bit kernels.
> 
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
>  arch/x86/entry/vdso/vclock_gettime.c | 91 ++++++++++++++++--------------------
>  1 file changed, 40 insertions(+), 51 deletions(-)
> 
> diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/vclock_gettime.c
> index 59a98c25bde7..8602f06c759f 100644
> --- a/arch/x86/entry/vdso/vclock_gettime.c
> +++ b/arch/x86/entry/vdso/vclock_gettime.c
> @@ -17,8 +17,10 @@
>  #include <asm/vvar.h>
>  #include <asm/unistd.h>
>  #include <asm/msr.h>
> +#include <asm/pvclock.h>
>  #include <linux/math64.h>
>  #include <linux/time.h>
> +#include <linux/kernel.h>
>  
>  #define gtod (&VVAR(vsyscall_gtod_data))
>  
> @@ -43,10 +45,6 @@ extern u8 pvclock_page
>  
>  #ifndef BUILD_VDSO32
>  
> -#include <linux/kernel.h>
> -#include <asm/vsyscall.h>
> -#include <asm/pvclock.h>
> -
>  notrace static long vdso_fallback_gettime(long clock, struct timespec *ts)
>  {
>  	long ret;
> @@ -64,8 +62,42 @@ notrace static long vdso_fallback_gtod(struct timeval *tv, struct timezone *tz)
>  	return ret;
>  }
>  
> -#ifdef CONFIG_PARAVIRT_CLOCK
>  
> +#else
> +
> +notrace static long vdso_fallback_gettime(long clock, struct timespec *ts)
> +{
> +	long ret;
> +
> +	asm(
> +		"mov %%ebx, %%edx \n"
> +		"mov %2, %%ebx \n"
> +		"call __kernel_vsyscall \n"
> +		"mov %%edx, %%ebx \n"
> +		: "=a" (ret)
> +		: "0" (__NR_clock_gettime), "g" (clock), "c" (ts)
> +		: "memory", "edx");
> +	return ret;
> +}
> +
> +notrace static long vdso_fallback_gtod(struct timeval *tv, struct timezone *tz)
> +{
> +	long ret;
> +
> +	asm(
> +		"mov %%ebx, %%edx \n"
> +		"mov %2, %%ebx \n"
> +		"call __kernel_vsyscall \n"
> +		"mov %%edx, %%ebx \n"
> +		: "=a" (ret)
> +		: "0" (__NR_gettimeofday), "g" (tv), "c" (tz)
> +		: "memory", "edx");
> +	return ret;
> +}
> +
> +#endif
> +
> +#ifdef CONFIG_PARAVIRT_CLOCK
>  static notrace const struct pvclock_vsyscall_time_info *get_pvti0(void)
>  {
>  	return (const struct pvclock_vsyscall_time_info *)&pvclock_page;
> @@ -109,9 +141,9 @@ static notrace cycle_t vread_pvclock(int *mode)
>  	do {
>  		version = pvti->version;
>  
> -		/* This is also a read barrier, so we'll read version first. */
> -		tsc = rdtsc_ordered();
> +		smp_rmb();
>  
> +		tsc = rdtsc_ordered();
>  		pvti_tsc_to_system_mul = pvti->tsc_to_system_mul;
>  		pvti_tsc_shift = pvti->tsc_shift;
>  		pvti_system_time = pvti->system_time;
> @@ -126,7 +158,7 @@ static notrace cycle_t vread_pvclock(int *mode)
>  		pvclock_scale_delta(delta, pvti_tsc_to_system_mul,
>  				    pvti_tsc_shift);
>  
> -	/* refer to tsc.c read_tsc() comment for rationale */
> +	/* refer to vread_tsc() comment for rationale */
>  	last = gtod->cycle_last;
>  
>  	if (likely(ret >= last))
> @@ -136,49 +168,6 @@ static notrace cycle_t vread_pvclock(int *mode)
>  }
>  #endif
>  
> -#else
> -
> -notrace static long vdso_fallback_gettime(long clock, struct timespec *ts)
> -{
> -	long ret;
> -
> -	asm(
> -		"mov %%ebx, %%edx \n"
> -		"mov %2, %%ebx \n"
> -		"call __kernel_vsyscall \n"
> -		"mov %%edx, %%ebx \n"
> -		: "=a" (ret)
> -		: "0" (__NR_clock_gettime), "g" (clock), "c" (ts)
> -		: "memory", "edx");
> -	return ret;
> -}
> -
> -notrace static long vdso_fallback_gtod(struct timeval *tv, struct timezone *tz)
> -{
> -	long ret;
> -
> -	asm(
> -		"mov %%ebx, %%edx \n"
> -		"mov %2, %%ebx \n"
> -		"call __kernel_vsyscall \n"
> -		"mov %%edx, %%ebx \n"
> -		: "=a" (ret)
> -		: "0" (__NR_gettimeofday), "g" (tv), "c" (tz)
> -		: "memory", "edx");
> -	return ret;
> -}
> -
> -#ifdef CONFIG_PARAVIRT_CLOCK
> -
> -static notrace cycle_t vread_pvclock(int *mode)
> -{
> -	*mode = VCLOCK_NONE;
> -	return 0;
> -}
> -#endif
> -
> -#endif
> -
>  notrace static cycle_t vread_tsc(void)
>  {
>  	cycle_t ret = (cycle_t)rdtsc_ordered();
> 

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

  reply	other threads:[~2015-12-10  9:10 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09 23:12 [PATCH 0/5] x86: KVM vdso and clock improvements Andy Lutomirski
2015-12-09 23:12 ` [PATCH 1/5] x86/kvm: On KVM re-enable (e.g. after suspend), update clocks Andy Lutomirski
2015-12-14  8:16   ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-12-14 10:18     ` Paolo Bonzini
2016-03-16 22:06   ` [PATCH 1/5] " Radim Krcmar
2016-03-16 22:15     ` Andy Lutomirski
2016-03-16 22:59       ` Radim Krcmar
2016-03-16 23:07         ` Andy Lutomirski
2016-03-17 15:10           ` Radim Krcmar
2016-03-17 18:22             ` Andy Lutomirski
2016-03-17 19:58               ` Radim Krcmar
2015-12-09 23:12 ` [PATCH 2/5] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader Andy Lutomirski
2015-12-10  9:09   ` Paolo Bonzini
2015-12-11  7:52     ` Ingo Molnar
2015-12-11  8:42       ` Paolo Bonzini
2015-12-11 18:03         ` Andy Lutomirski
2015-12-14  8:16   ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-12-09 23:12 ` [PATCH 3/5] x86/vdso: Get pvclock data from the vvar VMA instead of the fixmap Andy Lutomirski
2015-12-10  9:09   ` Paolo Bonzini
2015-12-14  8:17   ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-12-09 23:12 ` [PATCH 4/5] x86/vdso: Remove pvclock fixmap machinery Andy Lutomirski
2015-12-10  9:09   ` Paolo Bonzini
2015-12-11  8:06   ` [PATCH] x86/platform/uv: Include clocksource.h for clocksource_touch_watchdog() Ingo Molnar
2015-12-11 17:33     ` Andy Lutomirski
2015-12-14  8:17   ` [tip:x86/asm] x86/vdso: Remove pvclock fixmap machinery tip-bot for Andy Lutomirski
2015-12-09 23:12 ` [PATCH 5/5] x86/vdso: Enable vdso pvclock access on all vdso variants Andy Lutomirski
2015-12-10  9:10   ` Paolo Bonzini [this message]
2015-12-14  8:17   ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2015-12-11  3:21 ` [PATCH 0/5] x86: KVM vdso and clock improvements Andy Lutomirski

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=56694171.6000202@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=agraf@suse.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=x86@kernel.org \
    /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).