aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/xen/time.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /arch/x86/xen/time.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'arch/x86/xen/time.c')
-rw-r--r--arch/x86/xen/time.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 0a5aa44299a5..32764b8880b5 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -13,6 +13,7 @@
13#include <linux/clockchips.h> 13#include <linux/clockchips.h>
14#include <linux/kernel_stat.h> 14#include <linux/kernel_stat.h>
15#include <linux/math64.h> 15#include <linux/math64.h>
16#include <linux/gfp.h>
16 17
17#include <asm/pvclock.h> 18#include <asm/pvclock.h>
18#include <asm/xen/hypervisor.h> 19#include <asm/xen/hypervisor.h>
@@ -31,14 +32,14 @@
31#define NS_PER_TICK (1000000000LL / HZ) 32#define NS_PER_TICK (1000000000LL / HZ)
32 33
33/* runstate info updated by Xen */ 34/* runstate info updated by Xen */
34static DEFINE_PER_CPU(struct vcpu_runstate_info, runstate); 35static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate);
35 36
36/* snapshots of runstate info */ 37/* snapshots of runstate info */
37static DEFINE_PER_CPU(struct vcpu_runstate_info, runstate_snapshot); 38static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate_snapshot);
38 39
39/* unused ns of stolen and blocked time */ 40/* unused ns of stolen and blocked time */
40static DEFINE_PER_CPU(u64, residual_stolen); 41static DEFINE_PER_CPU(u64, xen_residual_stolen);
41static DEFINE_PER_CPU(u64, residual_blocked); 42static DEFINE_PER_CPU(u64, xen_residual_blocked);
42 43
43/* return an consistent snapshot of 64-bit time/counter value */ 44/* return an consistent snapshot of 64-bit time/counter value */
44static u64 get64(const u64 *p) 45static u64 get64(const u64 *p)
@@ -79,7 +80,7 @@ static void get_runstate_snapshot(struct vcpu_runstate_info *res)
79 80
80 BUG_ON(preemptible()); 81 BUG_ON(preemptible());
81 82
82 state = &__get_cpu_var(runstate); 83 state = &__get_cpu_var(xen_runstate);
83 84
84 /* 85 /*
85 * The runstate info is always updated by the hypervisor on 86 * The runstate info is always updated by the hypervisor on
@@ -97,14 +98,14 @@ static void get_runstate_snapshot(struct vcpu_runstate_info *res)
97/* return true when a vcpu could run but has no real cpu to run on */ 98/* return true when a vcpu could run but has no real cpu to run on */
98bool xen_vcpu_stolen(int vcpu) 99bool xen_vcpu_stolen(int vcpu)
99{ 100{
100 return per_cpu(runstate, vcpu).state == RUNSTATE_runnable; 101 return per_cpu(xen_runstate, vcpu).state == RUNSTATE_runnable;
101} 102}
102 103
103static void setup_runstate_info(int cpu) 104void xen_setup_runstate_info(int cpu)
104{ 105{
105 struct vcpu_register_runstate_memory_area area; 106 struct vcpu_register_runstate_memory_area area;
106 107
107 area.addr.v = &per_cpu(runstate, cpu); 108 area.addr.v = &per_cpu(xen_runstate, cpu);
108 109
109 if (HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area, 110 if (HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area,
110 cpu, &area)) 111 cpu, &area))
@@ -122,7 +123,7 @@ static void do_stolen_accounting(void)
122 123
123 WARN_ON(state.state != RUNSTATE_running); 124 WARN_ON(state.state != RUNSTATE_running);
124 125
125 snap = &__get_cpu_var(runstate_snapshot); 126 snap = &__get_cpu_var(xen_runstate_snapshot);
126 127
127 /* work out how much time the VCPU has not been runn*ing* */ 128 /* work out how much time the VCPU has not been runn*ing* */
128 blocked = state.time[RUNSTATE_blocked] - snap->time[RUNSTATE_blocked]; 129 blocked = state.time[RUNSTATE_blocked] - snap->time[RUNSTATE_blocked];
@@ -133,24 +134,24 @@ static void do_stolen_accounting(void)
133 134
134 /* Add the appropriate number of ticks of stolen time, 135 /* Add the appropriate number of ticks of stolen time,
135 including any left-overs from last time. */ 136 including any left-overs from last time. */
136 stolen = runnable + offline + __get_cpu_var(residual_stolen); 137 stolen = runnable + offline + __get_cpu_var(xen_residual_stolen);
137 138
138 if (stolen < 0) 139 if (stolen < 0)
139 stolen = 0; 140 stolen = 0;
140 141
141 ticks = iter_div_u64_rem(stolen, NS_PER_TICK, &stolen); 142 ticks = iter_div_u64_rem(stolen, NS_PER_TICK, &stolen);
142 __get_cpu_var(residual_stolen) = stolen; 143 __get_cpu_var(xen_residual_stolen) = stolen;
143 account_steal_ticks(ticks); 144 account_steal_ticks(ticks);
144 145
145 /* Add the appropriate number of ticks of blocked time, 146 /* Add the appropriate number of ticks of blocked time,
146 including any left-overs from last time. */ 147 including any left-overs from last time. */
147 blocked += __get_cpu_var(residual_blocked); 148 blocked += __get_cpu_var(xen_residual_blocked);
148 149
149 if (blocked < 0) 150 if (blocked < 0)
150 blocked = 0; 151 blocked = 0;
151 152
152 ticks = iter_div_u64_rem(blocked, NS_PER_TICK, &blocked); 153 ticks = iter_div_u64_rem(blocked, NS_PER_TICK, &blocked);
153 __get_cpu_var(residual_blocked) = blocked; 154 __get_cpu_var(xen_residual_blocked) = blocked;
154 account_idle_ticks(ticks); 155 account_idle_ticks(ticks);
155} 156}
156 157
@@ -434,7 +435,7 @@ void xen_setup_timer(int cpu)
434 name = "<timer kasprintf failed>"; 435 name = "<timer kasprintf failed>";
435 436
436 irq = bind_virq_to_irqhandler(VIRQ_TIMER, cpu, xen_timer_interrupt, 437 irq = bind_virq_to_irqhandler(VIRQ_TIMER, cpu, xen_timer_interrupt,
437 IRQF_DISABLED|IRQF_PERCPU|IRQF_NOBALANCING, 438 IRQF_DISABLED|IRQF_PERCPU|IRQF_NOBALANCING|IRQF_TIMER,
438 name, NULL); 439 name, NULL);
439 440
440 evt = &per_cpu(xen_clock_events, cpu); 441 evt = &per_cpu(xen_clock_events, cpu);
@@ -442,8 +443,6 @@ void xen_setup_timer(int cpu)
442 443
443 evt->cpumask = cpumask_of(cpu); 444 evt->cpumask = cpumask_of(cpu);
444 evt->irq = irq; 445 evt->irq = irq;
445
446 setup_runstate_info(cpu);
447} 446}
448 447
449void xen_teardown_timer(int cpu) 448void xen_teardown_timer(int cpu)
@@ -494,6 +493,7 @@ __init void xen_time_init(void)
494 493
495 setup_force_cpu_cap(X86_FEATURE_TSC); 494 setup_force_cpu_cap(X86_FEATURE_TSC);
496 495
496 xen_setup_runstate_info(cpu);
497 xen_setup_timer(cpu); 497 xen_setup_timer(cpu);
498 xen_setup_cpu_clockevents(); 498 xen_setup_cpu_clockevents();
499} 499}