[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC 5/9] tacc: Introduce a lockless interface for guest time



From: Andrii Anisov <andrii_anisov@xxxxxxxx>

The lockless interface to acquire guest time by scheduling code
is introduced. It can be used by schedulers what do not require
guest time from a different pcpu to take scheduling decission.

Signed-off-by: Andrii Anisov <andrii_anisov@xxxxxxxx>
---
 xen/common/schedule.c   | 10 ++++++++++
 xen/include/xen/sched.h |  8 ++++++++
 2 files changed, 18 insertions(+)

diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 2007034..62df77e 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -1643,6 +1643,16 @@ void tacc_irq_exit(int place)
     tacc->irq_cnt--;
 }
 
+s_time_t tacc_get_guest_time(struct tacc *tacc)
+{
+    s_time_t guest_time;
+
+    guest_time = tacc->state_time[TACC_GUEST];
+    guest_time += tacc->state_time[TACC_GSYNC];
+
+    return guest_time;
+}
+
 void context_saved(struct vcpu *prev)
 {
     /* Clear running flag /after/ writing context to memory. */
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 8167608..5b41805 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -266,6 +266,8 @@ struct vcpu
 
     struct evtchn_fifo_vcpu *evtchn_fifo;
 
+    s_time_t    pcpu_guest_time;
+
     /* vPCI per-vCPU area, used to store data for long running operations. */
     struct vpci_vcpu vpci;
 
@@ -1033,6 +1035,12 @@ DECLARE_PER_CPU(struct tacc, tacc);
 void tacc_hyp(int place);
 void tacc_idle(int place);
 
+s_time_t tacc_get_guest_time(struct tacc *tacc);
+inline s_time_t tacc_get_guest_time_delta(void)
+{
+    return tacc_get_guest_time(&this_cpu(tacc)) - current->pcpu_guest_time;
+}
+
 #endif /* __SCHED_H__ */
 
 /*
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.