From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Juergen Gross <jgross@suse.com>
Subject: [PATCH v3 4/6] xen: sched: better handle (not) inserting idle vCPUs in runqueues
Date: Fri, 30 Oct 2015 00:04:35 +0100 [thread overview]
Message-ID: <20151029230435.25219.56819.stgit@Solace.station> (raw)
In-Reply-To: <20151029225158.25219.4625.stgit@Solace.station>
Idle vCPUs are set to run immediately, as a part of their
own initialization, so we shouldn't even try to put them
in a runqueue. In fact, actual schedulers don't do that,
even when asked to (that is rather explicit in Credit2
and RTDS, a bit less evident in Credit1).
Let's make things look as follows:
- in generic code, explicitly avoid even trying to
insert idle vcpus in runqueues;
- in specific schedulers' code, enforce that.
Note that, as csched_vcpu_insert() is no longer being
called, during boot, from sched_init_vcpu(), we can
safely avoid saving the flags when taking the runqueue
lock.
Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
---
Changes from v1:
* changelog: updated and made a little bit less verbose.
---
xen/common/sched_credit.c | 7 ++++---
xen/common/sched_credit2.c | 25 ++++++++++---------------
xen/common/sched_rt.c | 4 +---
xen/common/schedule.c | 20 +++++++++++---------
4 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c
index e16bd3a..fc447a7 100644
--- a/xen/common/sched_credit.c
+++ b/xen/common/sched_credit.c
@@ -904,14 +904,15 @@ csched_vcpu_insert(const struct scheduler *ops, struct vcpu *vc)
{
struct csched_vcpu *svc = vc->sched_priv;
spinlock_t *lock;
- unsigned long flags;
- lock = vcpu_schedule_lock_irqsave(vc, &flags);
+ BUG_ON( is_idle_vcpu(vc) );
+
+ lock = vcpu_schedule_lock_irq(vc);
if ( !__vcpu_on_runq(svc) && vcpu_runnable(vc) && !vc->is_running )
__runq_insert(vc->processor, svc);
- vcpu_schedule_unlock_irqrestore(lock, flags, vc);
+ vcpu_schedule_unlock_irq(lock, vc);
SCHED_STAT_CRANK(vcpu_insert);
}
diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
index fc51a75..556ca0f 100644
--- a/xen/common/sched_credit2.c
+++ b/xen/common/sched_credit2.c
@@ -868,30 +868,25 @@ csched2_vcpu_insert(const struct scheduler *ops, struct vcpu *vc)
{
struct csched2_vcpu *svc = vc->sched_priv;
struct csched2_dom * const sdom = svc->sdom;
+ spinlock_t *lock;
printk("%s: Inserting %pv\n", __func__, vc);
- /* NB: On boot, idle vcpus are inserted before alloc_pdata() has
- * been called for that cpu.
- */
- if ( ! is_idle_vcpu(vc) )
- {
- spinlock_t *lock;
+ BUG_ON(is_idle_vcpu(vc));
- /* FIXME: Do we need the private lock here? */
- list_add_tail(&svc->sdom_elem, &svc->sdom->vcpu);
+ /* FIXME: Do we need the private lock here? */
+ list_add_tail(&svc->sdom_elem, &svc->sdom->vcpu);
- /* Add vcpu to runqueue of initial processor */
- lock = vcpu_schedule_lock_irq(vc);
+ /* Add vcpu to runqueue of initial processor */
+ lock = vcpu_schedule_lock_irq(vc);
- runq_assign(ops, vc);
+ runq_assign(ops, vc);
- vcpu_schedule_unlock_irq(lock, vc);
+ vcpu_schedule_unlock_irq(lock, vc);
- sdom->nr_vcpus++;
+ sdom->nr_vcpus++;
- SCHED_STAT_CRANK(vcpu_insert);
- }
+ SCHED_STAT_CRANK(vcpu_insert);
CSCHED2_VCPU_CHECK(vc);
}
diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c
index 3a66c9a..cbe7b17 100644
--- a/xen/common/sched_rt.c
+++ b/xen/common/sched_rt.c
@@ -624,9 +624,7 @@ rt_vcpu_insert(const struct scheduler *ops, struct vcpu *vc)
s_time_t now = NOW();
spinlock_t *lock;
- /* not addlocate idle vcpu to dom vcpu list */
- if ( is_idle_vcpu(vc) )
- return;
+ BUG_ON( is_idle_vcpu(vc) );
lock = vcpu_schedule_lock_irq(vc);
if ( now >= svc->cur_deadline )
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 9f5e12b..6ad516f 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -240,20 +240,22 @@ int sched_init_vcpu(struct vcpu *v, unsigned int processor)
init_timer(&v->poll_timer, poll_timer_fn,
v, v->processor);
- /* Idle VCPUs are scheduled immediately. */
+ v->sched_priv = SCHED_OP(DOM2OP(d), alloc_vdata, v, d->sched_priv);
+ if ( v->sched_priv == NULL )
+ return 1;
+
+ TRACE_2D(TRC_SCHED_DOM_ADD, v->domain->domain_id, v->vcpu_id);
+
+ /* Idle VCPUs are scheduled immediately, so don't put them in runqueue. */
if ( is_idle_domain(d) )
{
per_cpu(schedule_data, v->processor).curr = v;
v->is_running = 1;
}
-
- TRACE_2D(TRC_SCHED_DOM_ADD, v->domain->domain_id, v->vcpu_id);
-
- v->sched_priv = SCHED_OP(DOM2OP(d), alloc_vdata, v, d->sched_priv);
- if ( v->sched_priv == NULL )
- return 1;
-
- SCHED_OP(DOM2OP(d), insert_vcpu, v);
+ else
+ {
+ SCHED_OP(DOM2OP(d), insert_vcpu, v);
+ }
return 0;
}
next prev parent reply other threads:[~2015-10-29 23:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-29 23:04 [PATCH v3 0/6] xen: sched: fix locking of {insert, remove}_vcpu() Dario Faggioli
2015-10-29 23:04 ` [PATCH v3 1/6] xen: sched: fix locking of remove_vcpu() in credit1 Dario Faggioli
2015-11-02 18:04 ` George Dunlap
2015-11-03 17:15 ` Dario Faggioli
2015-10-29 23:04 ` [PATCH v3 2/6] xen: sched: fix locking for insert_vcpu() in credit1 and RTDS Dario Faggioli
2015-10-30 23:00 ` Meng Xu
2015-11-02 8:03 ` Dario Faggioli
2015-11-02 14:45 ` Meng Xu
2015-11-04 14:12 ` Dario Faggioli
2015-11-04 15:01 ` Meng Xu
2015-11-04 15:52 ` Dario Faggioli
2015-11-05 3:55 ` Meng Xu
2015-10-29 23:04 ` [PATCH v3 3/6] xen: sched: clarify use cases of schedule_cpu_switch() Dario Faggioli
2015-10-29 23:59 ` Dario Faggioli
2015-10-30 4:33 ` Juergen Gross
2015-11-02 18:23 ` George Dunlap
2015-10-29 23:04 ` Dario Faggioli [this message]
2015-10-29 23:04 ` [PATCH v3 5/6] xen: sched: get rid of the per domain vCPU list in RTDS Dario Faggioli
2015-11-02 18:57 ` George Dunlap
2015-10-29 23:04 ` [PATCH v3 6/6] xen: sched: get rid of the per domain vCPU list in Credit2 Dario Faggioli
2015-11-02 18:56 ` George Dunlap
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=20151029230435.25219.56819.stgit@Solace.station \
--to=dario.faggioli@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=jgross@suse.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.