From: Paolo Bonzini <pbonzini@redhat.com>
To: Tiejun Chen <tiejun.chen@intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] kvm: kvmclock: use get_cpu() and put_cpu()
Date: Fri, 31 Oct 2014 16:11:06 +0100 [thread overview]
Message-ID: <5453A68A.9030606@redhat.com> (raw)
In-Reply-To: <1411711204-8892-1-git-send-email-tiejun.chen@intel.com>
On 26/09/2014 08:00, Tiejun Chen wrote:
> We can use get_cpu() and put_cpu() to replace
> preempt_disable()/cpu = smp_processor_id() and
> preempt_enable() for slightly better code.
>
> Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
> ---
> arch/x86/kernel/kvmclock.c | 19 ++++++++-----------
> 1 file changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
> index d9156ce..0bf3467 100644
> --- a/arch/x86/kernel/kvmclock.c
> +++ b/arch/x86/kernel/kvmclock.c
> @@ -59,13 +59,12 @@ static void kvm_get_wallclock(struct timespec *now)
>
> native_write_msr(msr_kvm_wall_clock, low, high);
>
> - preempt_disable();
> - cpu = smp_processor_id();
> + cpu = get_cpu();
>
> vcpu_time = &hv_clock[cpu].pvti;
> pvclock_read_wallclock(&wall_clock, vcpu_time, now);
>
> - preempt_enable();
> + put_cpu();
> }
>
> static int kvm_set_wallclock(const struct timespec *now)
> @@ -107,11 +106,10 @@ static unsigned long kvm_get_tsc_khz(void)
> int cpu;
> unsigned long tsc_khz;
>
> - preempt_disable();
> - cpu = smp_processor_id();
> + cpu = get_cpu();
> src = &hv_clock[cpu].pvti;
> tsc_khz = pvclock_tsc_khz(src);
> - preempt_enable();
> + put_cpu();
> return tsc_khz;
> }
>
> @@ -284,23 +282,22 @@ int __init kvm_setup_vsyscall_timeinfo(void)
>
> size = PAGE_ALIGN(sizeof(struct pvclock_vsyscall_time_info)*NR_CPUS);
>
> - preempt_disable();
> - cpu = smp_processor_id();
> + cpu = get_cpu();
>
> vcpu_time = &hv_clock[cpu].pvti;
> flags = pvclock_read_flags(vcpu_time);
>
> if (!(flags & PVCLOCK_TSC_STABLE_BIT)) {
> - preempt_enable();
> + put_cpu();
> return 1;
> }
>
> if ((ret = pvclock_init_vsyscall(hv_clock, size))) {
> - preempt_enable();
> + put_cpu();
> return ret;
> }
>
> - preempt_enable();
> + put_cpu();
>
> kvm_clock.archdata.vclock_mode = VCLOCK_PVCLOCK;
> #endif
>
Thanks, applied at last.
Paolo
prev parent reply other threads:[~2014-10-31 16:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-26 6:00 [PATCH] kvm: kvmclock: use get_cpu() and put_cpu() Tiejun Chen
2014-09-26 8:23 ` Paolo Bonzini
2014-10-31 15:11 ` Paolo Bonzini [this message]
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=5453A68A.9030606@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=tiejun.chen@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.