]> xenbits.xensource.com Git - people/larsk/xen.git/commitdiff
xen/sched: add runstate counters to struct sched_unit
authorJuergen Gross <jgross@suse.com>
Fri, 27 Sep 2019 07:00:29 +0000 (09:00 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 27 Sep 2019 14:02:23 +0000 (16:02 +0200)
Add counters to struct sched_unit summing up runstates of associated
vcpus. This allows doing quick checks whether a unit has any vcpu
running or whether only a single vcpu of a unit is running.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Dario Faggioli <dfaggioli@suse.com>
xen/common/schedule.c
xen/include/xen/sched.h

index d9fdb82fe26e6564c5c9a9f978e51122ba594b10..feef90f8ebb97bc8d3937251b8f19fd61e09570a 100644 (file)
@@ -248,6 +248,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));
@@ -256,6 +257,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 )
     {
@@ -380,6 +384,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 )
index 6de9ddaaa952a2e86ec3686eba414a2f2afa62d1..92272256eadca9d5b726f9a0242e5e4aa91e0241 100644 (file)
@@ -277,6 +277,8 @@ struct sched_unit {
 
     /* Last time unit got (de-)scheduled. */
     uint64_t               state_entry_time;
+    /* Vcpu state summary. */
+    unsigned int           runstate_cnt[4];
 
     /* Bitmask of CPUs on which this VCPU may run. */
     cpumask_var_t          cpu_hard_affinity;