public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Glauber Costa <gcosta@redhat.com>
To: kvm-devel@lists.sourceforge.net
Cc: chrisw@sous-sol.org, avi@qumranet.com, Glauber Costa <gcosta@redhat.com>
Subject: [PATCH 1/2] [PATCH] use per cpu variables instead of a vector
Date: Thu,  6 Mar 2008 11:45:43 -0300	[thread overview]
Message-ID: <1204814744-12595-2-git-send-email-gcosta@redhat.com> (raw)
In-Reply-To: <1204814744-12595-1-git-send-email-gcosta@redhat.com>

replace hv_clock vector in kvmclock with a percpu variable
that is cacheline aligned.

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 arch/x86/kernel/kvmclock.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index 9c4a0f4..7c481a3 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -20,6 +20,7 @@ #include <linux/clocksource.h>
 #include <linux/kvm_para.h>
 #include <asm/arch_hooks.h>
 #include <asm/msr.h>
+#include <linux/percpu.h>
 
 #define KVM_SCALE 22
 
@@ -33,8 +34,8 @@ static int parse_no_kvmclock(char *arg)
 early_param("no-kvmclock", parse_no_kvmclock);
 
 /* The hypervisor will put information about time periodically here */
-static struct kvm_vcpu_time_info hv_clock[NR_CPUS];
-#define get_clock(cpu, field) hv_clock[cpu].field
+static DEFINE_PER_CPU_SHARED_ALIGNED(struct kvm_vcpu_time_info, hv_clock);
+#define get_clock(cpu, field) per_cpu(hv_clock, cpu).field
 
 static inline u64 kvm_get_delta(u64 last_tsc)
 {
@@ -124,8 +125,8 @@ static int kvm_register_clock(void)
 {
 	int cpu = smp_processor_id();
 	int low, high;
-	low = (int)__pa(&hv_clock[cpu]);
-	high = ((u64)__pa(&hv_clock[cpu]) >> 32);
+	low = (int)__pa(&per_cpu(hv_clock, cpu));
+	high = ((u64)__pa(&per_cpu(hv_clock, cpu)) >> 32);
 
 	return native_write_msr_safe(MSR_KVM_SYSTEM_TIME, low, high);
 }
-- 
1.4.2


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

  reply	other threads:[~2008-03-06 14:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-06 14:45 [PATCH 0/2] provide disable clock functionality Glauber Costa
2008-03-06 14:45 ` Glauber Costa [this message]
2008-03-06 14:45   ` [PATCH 2/2] [PATCH] disable kvm clock unless addr's LSB is set Glauber Costa
2008-03-08  3:39     ` Yang, Sheng
2008-03-07  9:05 ` [PATCH 0/2] provide disable clock functionality Avi Kivity

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=1204814744-12595-2-git-send-email-gcosta@redhat.com \
    --to=gcosta@redhat.com \
    --cc=avi@qumranet.com \
    --cc=chrisw@sous-sol.org \
    --cc=kvm-devel@lists.sourceforge.net \
    /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