* [PATCH v5] xen: rtds: only tickle non-already tickled CPUs
@ 2017-08-03 2:13 Meng Xu
2017-08-29 13:43 ` George Dunlap
0 siblings, 1 reply; 2+ messages in thread
From: Meng Xu @ 2017-08-03 2:13 UTC (permalink / raw)
To: xen-devel; +Cc: george.dunlap, dario.faggioli, xumengpanda, Meng Xu, Haoran Li
When more than one idle VCPUs that have the same PCPU as their
previous running core invoke runq_tickle(), they will tickle the same
PCPU. The tickled PCPU will only pick at most one VCPU, i.e., the
highest-priority one, to execute. The other VCPUs will not be
scheduled for a period, even when there is an idle core, making these
VCPUs unnecessarily starve for one period.
Therefore, always make sure that we only tickle PCPUs that have not
been tickled already.
Signed-off-by: Haoran Li <naroahlee@gmail.com>
Signed-off-by: Meng Xu <mengxu@cis.upenn.edu>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
---
The initial discussion of this patch can be found at
https://lists.xenproject.org/archives/html/xen-devel/2017-02/msg02857.html
Changes in v5:
Revise comments as Dario suggested
Changes in v4:
1) Take Dario's suggestions:
Search the new->cpu first for the cpu to tickle.
This get rid of the if statement in previous versions.
2) Reword the comments and commit messages.
3) Rebased on staging branch.
Issues in v2 and v3:
Did not rebase on the latest staging branch.
Did not solve the comments/issues in v1.
Please ignore the v2 and v3.
---
xen/common/sched_rt.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c
index 39f6bee..0ac5816 100644
--- a/xen/common/sched_rt.c
+++ b/xen/common/sched_rt.c
@@ -1147,9 +1147,9 @@ rt_vcpu_sleep(const struct scheduler *ops, struct vcpu *vc)
* Called by wake() and context_saved()
* We have a running candidate here, the kick logic is:
* Among all the cpus that are within the cpu affinity
- * 1) if the new->cpu is idle, kick it. This could benefit cache hit
- * 2) if there are any idle vcpu, kick it.
- * 3) now all pcpus are busy;
+ * 1) if there are any idle CPUs, kick one.
+ For cache benefit, we check new->cpu as first
+ * 2) now all pcpus are busy;
* among all the running vcpus, pick lowest priority one
* if snext has higher priority, kick it.
*
@@ -1177,17 +1177,13 @@ runq_tickle(const struct scheduler *ops, struct rt_vcpu *new)
cpumask_and(¬_tickled, online, new->vcpu->cpu_hard_affinity);
cpumask_andnot(¬_tickled, ¬_tickled, &prv->tickled);
- /* 1) if new's previous cpu is idle, kick it for cache benefit */
- if ( is_idle_vcpu(curr_on_cpu(new->vcpu->processor)) )
- {
- SCHED_STAT_CRANK(tickled_idle_cpu);
- cpu_to_tickle = new->vcpu->processor;
- goto out;
- }
-
- /* 2) if there are any idle pcpu, kick it */
- /* The same loop also find the one with lowest priority */
- for_each_cpu(cpu, ¬_tickled)
+ /*
+ * 1) If there are any idle CPUs, kick one.
+ * For cache benefit,we first search new->cpu.
+ * The same loop also find the one with lowest priority.
+ */
+ cpu = cpumask_test_or_cycle(new->vcpu->processor, ¬_tickled);
+ while ( cpu!= nr_cpu_ids )
{
iter_vc = curr_on_cpu(cpu);
if ( is_idle_vcpu(iter_vc) )
@@ -1200,9 +1196,12 @@ runq_tickle(const struct scheduler *ops, struct rt_vcpu *new)
if ( latest_deadline_vcpu == NULL ||
iter_svc->cur_deadline > latest_deadline_vcpu->cur_deadline )
latest_deadline_vcpu = iter_svc;
+
+ cpumask_clear_cpu(cpu, ¬_tickled);
+ cpu = cpumask_cycle(cpu, ¬_tickled);
}
- /* 3) candicate has higher priority, kick out lowest priority vcpu */
+ /* 2) candicate has higher priority, kick out lowest priority vcpu */
if ( latest_deadline_vcpu != NULL &&
new->cur_deadline < latest_deadline_vcpu->cur_deadline )
{
--
1.9.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v5] xen: rtds: only tickle non-already tickled CPUs
2017-08-03 2:13 [PATCH v5] xen: rtds: only tickle non-already tickled CPUs Meng Xu
@ 2017-08-29 13:43 ` George Dunlap
0 siblings, 0 replies; 2+ messages in thread
From: George Dunlap @ 2017-08-29 13:43 UTC (permalink / raw)
To: Meng Xu, xen-devel; +Cc: george.dunlap, dario.faggioli, xumengpanda, Haoran Li
On 08/03/2017 03:13 AM, Meng Xu wrote:
> When more than one idle VCPUs that have the same PCPU as their
> previous running core invoke runq_tickle(), they will tickle the same
> PCPU. The tickled PCPU will only pick at most one VCPU, i.e., the
> highest-priority one, to execute. The other VCPUs will not be
> scheduled for a period, even when there is an idle core, making these
> VCPUs unnecessarily starve for one period.
>
> Therefore, always make sure that we only tickle PCPUs that have not
> been tickled already.
>
> Signed-off-by: Haoran Li <naroahlee@gmail.com>
> Signed-off-by: Meng Xu <mengxu@cis.upenn.edu>
> Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Committed.
-George
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-29 13:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-03 2:13 [PATCH v5] xen: rtds: only tickle non-already tickled CPUs Meng Xu
2017-08-29 13:43 ` George Dunlap
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).