diff mbox series

[v2,25/48] xen/sched: add runstate counters to struct sched_unit

Message ID 20190809145833.1020-26-jgross@suse.com (mailing list archive)
State Superseded
Headers show
Series xen: add core scheduling support | expand

Commit Message

Jürgen Groß Aug. 9, 2019, 2:58 p.m. UTC
Add counters to struct sched_unit summing up runstates of associated
vcpus.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
RFC V2: add counters for each possible runstate
---
 xen/common/schedule.c   | 5 +++++
 xen/include/xen/sched.h | 2 ++
 2 files changed, 7 insertions(+)

Comments

Jan Beulich Sept. 9, 2019, 2:30 p.m. UTC | #1
On 09.08.2019 16:58, Juergen Gross wrote:
> Add counters to struct sched_unit summing up runstates of associated
> vcpus.

What use are they (going to be)? Some justification of their
introduction and the associated (however small or large)
overhead of maintaining them would be nice here.

Jan
diff mbox series

Patch

diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 7b0ff8395e..3f8fffc329 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -236,6 +236,7 @@  static inline void vcpu_runstate_change(
     struct vcpu *v, int new_state, s_time_t new_entry_time)
 {
     s_time_t delta;
+    struct sched_unit *unit = v->sched_unit;
 
     ASSERT(v->runstate.state != new_state);
     ASSERT(spin_is_locked(get_sched_res(v->processor)->schedule_lock));
@@ -244,6 +245,9 @@  static inline void vcpu_runstate_change(
 
     trace_runstate_change(v, new_state);
 
+    unit->runstate_cnt[v->runstate.state]--;
+    unit->runstate_cnt[new_state]++;
+
     delta = new_entry_time - v->runstate.state_entry_time;
     if ( delta > 0 )
     {
@@ -366,6 +370,7 @@  static struct sched_unit *sched_alloc_unit(struct vcpu *v)
     unit->vcpu_list = v;
     unit->unit_id = v->vcpu_id;
     unit->domain = d;
+    unit->runstate_cnt[v->runstate.state]++;
 
     for ( prev_unit = &d->sched_unit_list; *prev_unit;
           prev_unit = &(*prev_unit)->next_in_list )
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index f639b164b5..0cece3b921 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -274,6 +274,8 @@  struct sched_unit {
 
     /* Last time unit got (de-)scheduled. */
     uint64_t               state_entry_time;
+    /* Vcpu state summary. */
+    unsigned int           runstate_cnt[4];
 
     /* Currently running on a CPU? */
     bool                   is_running;