From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>, Tim Deegan <tim@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
George Dunlap <george.dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Dario Faggioli <dfaggioli@suse.com>,
Julien Grall <julien.grall@arm.com>,
Meng Xu <mengxu@cis.upenn.edu>, Jan Beulich <jbeulich@suse.com>
Subject: [Xen-devel] [PATCH v2 13/48] xen/sched: add is_running indicator to struct sched_unit
Date: Fri, 9 Aug 2019 16:57:58 +0200 [thread overview]
Message-ID: <20190809145833.1020-14-jgross@suse.com> (raw)
In-Reply-To: <20190809145833.1020-1-jgross@suse.com>
Add an is_running indicator to struct sched_unit which will be set
whenever the unit is being scheduled. Switch scheduler code to use
unit->is_running instead of vcpu->is_running for scheduling decisions.
At the same time introduce a state_entry_time field in struct
sched_unit being updated whenever the is_running indicator is changed.
Use that new field in the schedulers instead of the similar vcpu field.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
RFC V2: fix arm build, don't drop v->is_running
---
xen/common/sched_credit.c | 12 +++++++-----
xen/common/sched_credit2.c | 18 +++++++++---------
xen/common/sched_rt.c | 2 +-
xen/common/schedule.c | 15 +++++++++++----
xen/include/xen/sched.h | 5 +++++
5 files changed, 33 insertions(+), 19 deletions(-)
diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c
index 339702f3ec..143c7543e8 100644
--- a/xen/common/sched_credit.c
+++ b/xen/common/sched_credit.c
@@ -709,7 +709,7 @@ __csched_vcpu_is_migrateable(const struct csched_private *prv, struct vcpu *vc,
* The caller is supposed to have already checked that vc is also
* not running.
*/
- ASSERT(!vc->is_running);
+ ASSERT(!vc->sched_unit->is_running);
return !__csched_vcpu_is_cache_hot(prv, svc) &&
cpumask_test_cpu(dest_cpu, mask);
@@ -1033,7 +1033,8 @@ csched_unit_insert(const struct scheduler *ops, struct sched_unit *unit)
lock = unit_schedule_lock_irq(unit);
- if ( !__vcpu_on_runq(svc) && vcpu_runnable(vc) && !vc->is_running )
+ if ( !__vcpu_on_runq(svc) && vcpu_runnable(vc) &&
+ !vc->sched_unit->is_running )
runq_insert(svc);
unit_schedule_unlock_irq(lock, unit);
@@ -1646,8 +1647,9 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, int balance_step)
* vCPUs with useful soft affinities in some sort of bitmap
* or counter.
*/
- if ( vc->is_running || (balance_step == BALANCE_SOFT_AFFINITY &&
- !has_soft_affinity(vc->sched_unit)) )
+ if ( vc->sched_unit->is_running ||
+ (balance_step == BALANCE_SOFT_AFFINITY &&
+ !has_soft_affinity(vc->sched_unit)) )
continue;
affinity_balance_cpumask(vc->sched_unit, balance_step, cpumask_scratch);
@@ -1855,7 +1857,7 @@ csched_schedule(
(unsigned char *)&d);
}
- runtime = now - current->runstate.state_entry_time;
+ runtime = now - current->sched_unit->state_entry_time;
if ( runtime < 0 ) /* Does this ever happen? */
runtime = 0;
diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
index ed83381ddb..5487d087e1 100644
--- a/xen/common/sched_credit2.c
+++ b/xen/common/sched_credit2.c
@@ -1284,7 +1284,7 @@ runq_insert(const struct scheduler *ops, struct csched2_unit *svc)
ASSERT(&svc->rqd->runq == runq);
ASSERT(!is_idle_vcpu(svc->vcpu));
- ASSERT(!svc->vcpu->is_running);
+ ASSERT(!svc->vcpu->sched_unit->is_running);
ASSERT(!(svc->flags & CSFLAG_scheduled));
list_for_each( iter, runq )
@@ -1341,8 +1341,8 @@ static inline bool is_preemptable(const struct csched2_unit *svc,
if ( ratelimit <= CSCHED2_RATELIMIT_TICKLE_TOLERANCE )
return true;
- ASSERT(svc->vcpu->is_running);
- return now - svc->vcpu->runstate.state_entry_time >
+ ASSERT(svc->vcpu->sched_unit->is_running);
+ return now - svc->vcpu->sched_unit->state_entry_time >
ratelimit - CSCHED2_RATELIMIT_TICKLE_TOLERANCE;
}
@@ -2932,7 +2932,7 @@ csched2_dom_cntl(
{
svc = csched2_unit(v->sched_unit);
lock = unit_schedule_lock(svc->vcpu->sched_unit);
- if ( v->is_running )
+ if ( v->sched_unit->is_running )
{
unsigned int cpu = v->processor;
struct csched2_runqueue_data *rqd = c2rqd(ops, cpu);
@@ -3205,8 +3205,8 @@ csched2_runtime(const struct scheduler *ops, int cpu,
if ( prv->ratelimit_us )
{
s_time_t ratelimit_min = MICROSECS(prv->ratelimit_us);
- if ( snext->vcpu->is_running )
- ratelimit_min = snext->vcpu->runstate.state_entry_time +
+ if ( snext->vcpu->sched_unit->is_running )
+ ratelimit_min = snext->vcpu->sched_unit->state_entry_time +
MICROSECS(prv->ratelimit_us) - now;
if ( ratelimit_min > min_time )
min_time = ratelimit_min;
@@ -3303,7 +3303,7 @@ runq_candidate(struct csched2_runqueue_data *rqd,
* no point forcing it to do so until rate limiting expires.
*/
if ( !yield && prv->ratelimit_us && vcpu_runnable(scurr->vcpu) &&
- (now - scurr->vcpu->runstate.state_entry_time) <
+ (now - scurr->vcpu->sched_unit->state_entry_time) <
MICROSECS(prv->ratelimit_us) )
{
if ( unlikely(tb_init_done) )
@@ -3314,7 +3314,7 @@ runq_candidate(struct csched2_runqueue_data *rqd,
} d;
d.dom = scurr->vcpu->domain->domain_id;
d.vcpu = scurr->vcpu->vcpu_id;
- d.runtime = now - scurr->vcpu->runstate.state_entry_time;
+ d.runtime = now - scurr->vcpu->sched_unit->state_entry_time;
__trace_var(TRC_CSCHED2_RATELIMIT, 1,
sizeof(d),
(unsigned char *)&d);
@@ -3562,7 +3562,7 @@ csched2_schedule(
if ( snext != scurr )
{
ASSERT(snext->rqd == rqd);
- ASSERT(!snext->vcpu->is_running);
+ ASSERT(!snext->vcpu->sched_unit->is_running);
runq_remove(snext);
__set_bit(__CSFLAG_scheduled, &snext->flags);
diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c
index b662924483..df1a874c97 100644
--- a/xen/common/sched_rt.c
+++ b/xen/common/sched_rt.c
@@ -906,7 +906,7 @@ rt_unit_insert(const struct scheduler *ops, struct sched_unit *unit)
{
replq_insert(ops, svc);
- if ( !vc->is_running )
+ if ( !unit->is_running )
runq_insert(ops, svc);
}
unit_schedule_unlock_irq(lock, unit);
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 8cbb6320c6..03119af25c 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -407,6 +407,8 @@ int sched_init_vcpu(struct vcpu *v, unsigned int processor)
{
get_sched_res(v->processor)->curr = unit;
v->is_running = 1;
+ unit->is_running = 1;
+ unit->state_entry_time = NOW();
}
else
{
@@ -727,7 +729,8 @@ static void vcpu_migrate_finish(struct vcpu *v)
* context_saved(); and in any case, if the bit is cleared, then
* someone else has already done the work so we don't need to.
*/
- if ( v->is_running || !test_bit(_VPF_migrating, &v->pause_flags) )
+ if ( v->sched_unit->is_running ||
+ !test_bit(_VPF_migrating, &v->pause_flags) )
return;
old_cpu = new_cpu = v->processor;
@@ -781,7 +784,7 @@ static void vcpu_migrate_finish(struct vcpu *v)
* because they both happen in (different) spinlock regions, and those
* regions are strictly serialised.
*/
- if ( v->is_running ||
+ if ( v->sched_unit->is_running ||
!test_and_clear_bit(_VPF_migrating, &v->pause_flags) )
{
sched_spin_unlock_double(old_lock, new_lock, flags);
@@ -809,7 +812,7 @@ void vcpu_force_reschedule(struct vcpu *v)
{
spinlock_t *lock = unit_schedule_lock_irq(v->sched_unit);
- if ( v->is_running )
+ if ( v->sched_unit->is_running )
vcpu_migrate_start(v);
unit_schedule_unlock_irq(lock, v->sched_unit);
@@ -1663,8 +1666,10 @@ static void schedule(void)
* switch, else lost_records resume will not work properly.
*/
- ASSERT(!next->is_running);
+ ASSERT(!next->sched_unit->is_running);
next->is_running = 1;
+ next->sched_unit->is_running = 1;
+ next->sched_unit->state_entry_time = now;
pcpu_schedule_unlock_irq(lock, cpu);
@@ -1686,6 +1691,8 @@ void context_saved(struct vcpu *prev)
smp_wmb();
prev->is_running = 0;
+ prev->sched_unit->is_running = 0;
+ prev->sched_unit->state_entry_time = NOW();
/* Check for migration request /after/ clearing running flag. */
smp_mb();
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index fa2dbf47ee..f506c0cbd4 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -272,6 +272,11 @@ struct sched_unit {
struct sched_resource *res;
int unit_id;
+ /* Last time unit got (de-)scheduled. */
+ uint64_t state_entry_time;
+
+ /* Currently running on a CPU? */
+ bool is_running;
/* Does soft affinity actually play a role (given hard affinity)? */
bool soft_aff_effective;
/* Bitmask of CPUs on which this VCPU may run. */
--
2.16.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-08-09 14:59 UTC|newest]
Thread overview: 126+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-09 14:57 [Xen-devel] [PATCH v2 00/48] xen: add core scheduling support Juergen Gross
2019-08-09 14:57 ` [Xen-devel] [PATCH v2 01/48] xen/sched: use new sched_unit instead of vcpu in scheduler interfaces Juergen Gross
2019-09-02 9:07 ` Jan Beulich
2019-09-09 5:26 ` Juergen Gross
2019-08-09 14:57 ` [Xen-devel] [PATCH v2 02/48] xen/sched: move per-vcpu scheduler private data pointer to sched_unit Juergen Gross
2019-08-23 10:47 ` Dario Faggioli
2019-08-09 14:57 ` [Xen-devel] [PATCH v2 03/48] xen/sched: build a linked list of struct sched_unit Juergen Gross
2019-08-23 10:52 ` Dario Faggioli
2019-08-09 14:57 ` [Xen-devel] [PATCH v2 04/48] xen/sched: introduce struct sched_resource Juergen Gross
2019-08-23 10:54 ` Dario Faggioli
2019-09-04 13:10 ` Jan Beulich
2019-09-09 5:31 ` Juergen Gross
2019-08-09 14:57 ` [Xen-devel] [PATCH v2 05/48] xen/sched: let pick_cpu return a scheduler resource Juergen Gross
2019-09-04 13:34 ` Jan Beulich
2019-09-09 5:43 ` Juergen Gross
2019-08-09 14:57 ` [Xen-devel] [PATCH v2 06/48] xen/sched: switch schedule_data.curr to point at sched_unit Juergen Gross
2019-09-04 13:36 ` Jan Beulich
2019-09-09 5:46 ` Juergen Gross
2019-08-09 14:57 ` [Xen-devel] [PATCH v2 07/48] xen/sched: move per cpu scheduler private data into struct sched_resource Juergen Gross
2019-09-04 13:48 ` Jan Beulich
2019-09-05 7:13 ` Juergen Gross
2019-09-05 7:38 ` Jan Beulich
2019-09-09 13:03 ` Dario Faggioli
2019-08-09 14:57 ` [Xen-devel] [PATCH v2 08/48] xen/sched: switch vcpu_schedule_lock to unit_schedule_lock Juergen Gross
2019-09-04 14:02 ` Jan Beulich
2019-09-04 14:41 ` Juergen Gross
2019-09-04 14:54 ` Jan Beulich
2019-09-04 15:02 ` Juergen Gross
2019-09-11 16:02 ` Dario Faggioli
2019-08-09 14:57 ` [Xen-devel] [PATCH v2 09/48] xen/sched: move some per-vcpu items to struct sched_unit Juergen Gross
2019-09-04 14:16 ` Jan Beulich
2019-09-09 6:39 ` Juergen Gross
2019-09-09 6:55 ` Jan Beulich
2019-09-09 7:05 ` Juergen Gross
2019-08-09 14:57 ` [Xen-devel] [PATCH v2 10/48] xen/sched: add scheduler helpers hiding vcpu Juergen Gross
2019-09-04 14:49 ` Jan Beulich
2019-09-11 13:22 ` Juergen Gross
2019-08-09 14:57 ` [Xen-devel] [PATCH v2 11/48] xen/sched: rename scheduler related perf counters Juergen Gross
2019-08-09 14:57 ` [Xen-devel] [PATCH v2 12/48] xen/sched: switch struct task_slice from vcpu to sched_unit Juergen Gross
2019-08-09 14:57 ` Juergen Gross [this message]
2019-09-04 15:06 ` [Xen-devel] [PATCH v2 13/48] xen/sched: add is_running indicator to struct sched_unit Jan Beulich
2019-09-11 13:44 ` Juergen Gross
2019-09-11 15:06 ` Jan Beulich
2019-09-11 15:32 ` Juergen Gross
2019-08-09 14:57 ` [Xen-devel] [PATCH v2 14/48] xen/sched: make null scheduler vcpu agnostic Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 15/48] xen/sched: make rt " Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 16/48] xen/sched: make credit " Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 17/48] xen/sched: make credit2 " Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 18/48] xen/sched: make arinc653 " Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 19/48] xen: add sched_unit_pause_nosync() and sched_unit_unpause() Juergen Gross
2019-09-09 13:34 ` Jan Beulich
2019-09-11 14:15 ` Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 20/48] xen: let vcpu_create() select processor Juergen Gross
2019-08-23 16:42 ` Julien Grall
2019-09-09 13:38 ` Jan Beulich
2019-09-11 14:22 ` Juergen Gross
2019-09-11 17:20 ` Dario Faggioli
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 21/48] xen/sched: use sched_resource cpu instead smp_processor_id in schedulers Juergen Gross
2019-09-09 14:17 ` Jan Beulich
2019-09-12 9:34 ` Juergen Gross
2019-09-12 10:04 ` Jan Beulich
2019-09-12 11:03 ` Juergen Gross
2019-09-12 11:17 ` Juergen Gross
2019-09-12 11:46 ` Jan Beulich
2019-09-12 11:53 ` Juergen Gross
2019-09-12 12:08 ` Jan Beulich
2019-09-12 12:13 ` Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 22/48] xen/sched: switch schedule() from vcpus to sched_units Juergen Gross
2019-09-09 14:35 ` Jan Beulich
2019-09-12 13:44 ` Juergen Gross
2019-09-12 14:34 ` Jan Beulich
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 23/48] xen/sched: switch sched_move_irqs() to take sched_unit as parameter Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 24/48] xen: switch from for_each_vcpu() to for_each_sched_unit() Juergen Gross
2019-09-09 15:14 ` Jan Beulich
2019-09-12 14:02 ` Juergen Gross
2019-09-12 14:40 ` Jan Beulich
2019-09-12 14:47 ` Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 25/48] xen/sched: add runstate counters to struct sched_unit Juergen Gross
2019-09-09 14:30 ` Jan Beulich
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 26/48] xen/sched: rework and rename vcpu_force_reschedule() Juergen Gross
2019-09-10 14:06 ` Jan Beulich
2019-09-13 9:33 ` Juergen Gross
2019-09-13 9:40 ` Jan Beulich
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 27/48] xen/sched: Change vcpu_migrate_*() to operate on schedule unit Juergen Gross
2019-09-10 15:11 ` Jan Beulich
2019-09-13 12:33 ` Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 28/48] xen/sched: move struct task_slice into struct sched_unit Juergen Gross
2019-09-10 15:18 ` Jan Beulich
2019-09-13 12:56 ` Juergen Gross
2019-09-12 8:13 ` Dario Faggioli
2019-09-12 8:21 ` Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 29/48] xen/sched: add code to sync scheduling of all vcpus of a sched unit Juergen Gross
2019-09-10 15:36 ` Jan Beulich
2019-09-13 13:12 ` Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 30/48] xen/sched: introduce unit_runnable_state() Juergen Gross
2019-09-11 10:30 ` Jan Beulich
2019-09-12 10:22 ` Dario Faggioli
2019-09-13 14:07 ` Juergen Gross
2019-09-13 14:44 ` Jan Beulich
2019-09-13 15:23 ` Juergen Gross
2019-09-12 10:24 ` Dario Faggioli
2019-09-13 14:14 ` Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 31/48] xen/sched: add support for multiple vcpus per sched unit where missing Juergen Gross
2019-09-11 10:43 ` Jan Beulich
2019-09-13 15:01 ` Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 32/48] xen/sched: modify cpupool_domain_cpumask() to be an unit mask Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 33/48] xen/sched: support allocating multiple vcpus into one sched unit Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 34/48] xen/sched: add a percpu resource index Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 35/48] xen/sched: add fall back to idle vcpu when scheduling unit Juergen Gross
2019-09-11 11:33 ` Julien Grall
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 36/48] xen/sched: make vcpu_wake() and vcpu_sleep() core scheduling aware Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 37/48] xen/sched: carve out freeing sched_unit memory into dedicated function Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 38/48] xen/sched: move per-cpu variable scheduler to struct sched_resource Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 39/48] xen/sched: move per-cpu variable cpupool " Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 40/48] xen/sched: reject switching smt on/off with core scheduling active Juergen Gross
2019-09-10 15:47 ` Jan Beulich
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 41/48] xen/sched: prepare per-cpupool scheduling granularity Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 42/48] xen/sched: split schedule_cpu_switch() Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 43/48] xen/sched: protect scheduling resource via rcu Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 44/48] xen/sched: support multiple cpus per scheduling resource Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 45/48] xen/sched: support differing granularity in schedule_cpu_[add/rm]() Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 46/48] xen/sched: support core scheduling for moving cpus to/from cpupools Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 47/48] xen/sched: disable scheduling when entering ACPI deep sleep states Juergen Gross
2019-08-09 14:58 ` [Xen-devel] [PATCH v2 48/48] xen/sched: add scheduling granularity enum Juergen Gross
2019-08-15 10:17 ` [Xen-devel] [PATCH v2 00/48] xen: add core scheduling support Sergey Dyasli
2019-09-05 6:22 ` Juergen Gross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190809145833.1020-14-jgross@suse.com \
--to=jgross@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=dfaggioli@suse.com \
--cc=george.dunlap@eu.citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@arm.com \
--cc=konrad.wilk@oracle.com \
--cc=mengxu@cis.upenn.edu \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).