summaryrefslogtreecommitdiff
path: root/drivers/xen/time.c
diff options
context:
space:
mode:
authorJuergen Gross <jgross@suse.com>2016-05-20 10:26:48 +0300
committerDavid Vrabel <david.vrabel@citrix.com>2016-07-06 12:34:48 +0300
commitecb23dc6f2eff0ce64dd60351a81f376f13b12cc (patch)
tree09536e5db2dc00af9dd5209fef72a1e1222f6cf2 /drivers/xen/time.c
parentc7ebf9d9c6b4e9402b978da0b0785db4129c1f79 (diff)
downloadlinux-ecb23dc6f2eff0ce64dd60351a81f376f13b12cc.tar.xz
xen: add steal_clock support on x86
The pv_time_ops structure contains a function pointer for the "steal_clock" functionality used only by KVM and Xen on ARM. Xen on x86 uses its own mechanism to account for the "stolen" time a thread wasn't able to run due to hypervisor scheduling. Add support in Xen arch independent time handling for this feature by moving it out of the arm arch into drivers/xen and remove the x86 Xen hack. Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Diffstat (limited to 'drivers/xen/time.c')
-rw-r--r--drivers/xen/time.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/xen/time.c b/drivers/xen/time.c
index 71078425c9ea..2257b6663766 100644
--- a/drivers/xen/time.c
+++ b/drivers/xen/time.c
@@ -6,6 +6,7 @@
#include <linux/math64.h>
#include <linux/gfp.h>
+#include <asm/paravirt.h>
#include <asm/xen/hypervisor.h>
#include <asm/xen/hypercall.h>
@@ -75,6 +76,15 @@ bool xen_vcpu_stolen(int vcpu)
return per_cpu(xen_runstate, vcpu).state == RUNSTATE_runnable;
}
+static u64 xen_steal_clock(int cpu)
+{
+ struct vcpu_runstate_info state;
+
+ BUG_ON(cpu != smp_processor_id());
+ xen_get_runstate_snapshot(&state);
+ return state.time[RUNSTATE_runnable] + state.time[RUNSTATE_offline];
+}
+
void xen_setup_runstate_info(int cpu)
{
struct vcpu_register_runstate_memory_area area;
@@ -86,3 +96,13 @@ void xen_setup_runstate_info(int cpu)
BUG();
}
+void __init xen_time_setup_guest(void)
+{
+ pv_time_ops.steal_clock = xen_steal_clock;
+
+ static_key_slow_inc(&paravirt_steal_enabled);
+ /*
+ * We can't set paravirt_steal_rq_enabled as this would require the
+ * capability to read another cpu's runstate info.
+ */
+}