diff mbox series

[RFC,5/9] tacc: Introduce a lockless interface for guest time

Message ID 1568197942-15374-6-git-send-email-andrii.anisov@gmail.com (mailing list archive)
State New, archived
Headers show
Series Changes to time accounting | expand

Commit Message

Andrii Anisov Sept. 11, 2019, 10:32 a.m. UTC
From: Andrii Anisov <andrii_anisov@epam.com>

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@epam.com>
---
 xen/common/schedule.c   | 10 ++++++++++
 xen/include/xen/sched.h |  8 ++++++++
 2 files changed, 18 insertions(+)
diff mbox series

Patch

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__ */
 
 /*