]> Pileus Git - ~andy/linux/blobdiff - arch/x86/xen/time.c
Merge tag 'iio-fixes-for-3.11b' of git://git.kernel.org/pub/scm/linux/kernel/git...
[~andy/linux] / arch / x86 / xen / time.c
index 7a5671b4fec6b8c0fc53675d153ddc155c4b68ab..ee365895b06bb431a2f56e1f940119a9c0cc5ef1 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/math64.h>
 #include <linux/gfp.h>
+#include <linux/slab.h>
 #include <linux/pvclock_gtod.h>
 
 #include <asm/pvclock.h>
@@ -37,9 +38,8 @@ static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate);
 /* snapshots of runstate info */
 static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate_snapshot);
 
-/* unused ns of stolen and blocked time */
+/* unused ns of stolen time */
 static DEFINE_PER_CPU(u64, xen_residual_stolen);
-static DEFINE_PER_CPU(u64, xen_residual_blocked);
 
 /* return an consistent snapshot of 64-bit time/counter value */
 static u64 get64(const u64 *p)
@@ -116,7 +116,7 @@ static void do_stolen_accounting(void)
 {
        struct vcpu_runstate_info state;
        struct vcpu_runstate_info *snap;
-       s64 blocked, runnable, offline, stolen;
+       s64 runnable, offline, stolen;
        cputime_t ticks;
 
        get_runstate_snapshot(&state);
@@ -126,7 +126,6 @@ static void do_stolen_accounting(void)
        snap = &__get_cpu_var(xen_runstate_snapshot);
 
        /* work out how much time the VCPU has not been runn*ing*  */
-       blocked = state.time[RUNSTATE_blocked] - snap->time[RUNSTATE_blocked];
        runnable = state.time[RUNSTATE_runnable] - snap->time[RUNSTATE_runnable];
        offline = state.time[RUNSTATE_offline] - snap->time[RUNSTATE_offline];
 
@@ -142,17 +141,6 @@ static void do_stolen_accounting(void)
        ticks = iter_div_u64_rem(stolen, NS_PER_TICK, &stolen);
        __this_cpu_write(xen_residual_stolen, stolen);
        account_steal_ticks(ticks);
-
-       /* Add the appropriate number of ticks of blocked time,
-          including any left-overs from last time. */
-       blocked += __this_cpu_read(xen_residual_blocked);
-
-       if (blocked < 0)
-               blocked = 0;
-
-       ticks = iter_div_u64_rem(blocked, NS_PER_TICK, &blocked);
-       __this_cpu_write(xen_residual_blocked, blocked);
-       account_idle_ticks(ticks);
 }
 
 /* Get the TSC speed from Xen */
@@ -400,11 +388,16 @@ static const struct clock_event_device xen_vcpuop_clockevent = {
 
 static const struct clock_event_device *xen_clockevent =
        &xen_timerop_clockevent;
-static DEFINE_PER_CPU(struct clock_event_device, xen_clock_events) = { .irq = -1 };
+
+struct xen_clock_event_device {
+       struct clock_event_device evt;
+       char *name;
+};
+static DEFINE_PER_CPU(struct xen_clock_event_device, xen_clock_events) = { .evt.irq = -1 };
 
 static irqreturn_t xen_timer_interrupt(int irq, void *dev_id)
 {
-       struct clock_event_device *evt = &__get_cpu_var(xen_clock_events);
+       struct clock_event_device *evt = &__get_cpu_var(xen_clock_events).evt;
        irqreturn_t ret;
 
        ret = IRQ_NONE;
@@ -418,14 +411,30 @@ static irqreturn_t xen_timer_interrupt(int irq, void *dev_id)
        return ret;
 }
 
+void xen_teardown_timer(int cpu)
+{
+       struct clock_event_device *evt;
+       BUG_ON(cpu == 0);
+       evt = &per_cpu(xen_clock_events, cpu).evt;
+
+       if (evt->irq >= 0) {
+               unbind_from_irqhandler(evt->irq, NULL);
+               evt->irq = -1;
+               kfree(per_cpu(xen_clock_events, cpu).name);
+               per_cpu(xen_clock_events, cpu).name = NULL;
+       }
+}
+
 void xen_setup_timer(int cpu)
 {
-       const char *name;
+       char *name;
        struct clock_event_device *evt;
        int irq;
 
-       evt = &per_cpu(xen_clock_events, cpu);
+       evt = &per_cpu(xen_clock_events, cpu).evt;
        WARN(evt->irq >= 0, "IRQ%d for CPU%d is already allocated\n", evt->irq, cpu);
+       if (evt->irq >= 0)
+               xen_teardown_timer(cpu);
 
        printk(KERN_INFO "installing Xen timer for CPU %d\n", cpu);
 
@@ -443,22 +452,15 @@ void xen_setup_timer(int cpu)
 
        evt->cpumask = cpumask_of(cpu);
        evt->irq = irq;
+       per_cpu(xen_clock_events, cpu).name = name;
 }
 
-void xen_teardown_timer(int cpu)
-{
-       struct clock_event_device *evt;
-       BUG_ON(cpu == 0);
-       evt = &per_cpu(xen_clock_events, cpu);
-       unbind_from_irqhandler(evt->irq, NULL);
-       evt->irq = -1;
-}
 
 void xen_setup_cpu_clockevents(void)
 {
        BUG_ON(preemptible());
 
-       clockevents_register_device(&__get_cpu_var(xen_clock_events));
+       clockevents_register_device(&__get_cpu_var(xen_clock_events).evt);
 }
 
 void xen_timer_resume(void)