From: Andrii Anisov <andrii.anisov@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Andrii Anisov <andrii_anisov@epam.com>, 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>, Tim Deegan <tim@xen.org>,
Julien Grall <julien.grall@arm.com>,
Jan Beulich <jbeulich@suse.com>,
Dario Faggioli <dfaggioli@suse.com>
Subject: [Xen-devel] [RFC 9/9] sched:credit2: get guest time from time accounting code
Date: Wed, 11 Sep 2019 13:32:22 +0300 [thread overview]
Message-ID: <1568197942-15374-10-git-send-email-andrii.anisov@gmail.com> (raw)
In-Reply-To: <1568197942-15374-1-git-send-email-andrii.anisov@gmail.com>
From: Andrii Anisov <andrii_anisov@epam.com>
While the Credit2 scheduler code uses guest time from the
other pcpu, we have to use locked time accounting.
Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
---
xen/common/Kconfig | 1 +
xen/common/sched_credit2.c | 17 +++++++++--------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index d17a8b4..6408c18 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -234,6 +234,7 @@ config SCHED_CREDIT
config SCHED_CREDIT2
bool "Credit2 scheduler support"
default y
+ select TACC_NEEDS_LOCK
---help---
The credit2 scheduler is a general purpose scheduler that is
optimized for lower latency and higher VM density.
diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
index 6b77da7..3b3888b 100644
--- a/xen/common/sched_credit2.c
+++ b/xen/common/sched_credit2.c
@@ -1342,7 +1342,7 @@ static inline bool is_preemptable(const struct csched2_vcpu *svc,
return true;
ASSERT(svc->vcpu->is_running);
- return now - svc->vcpu->runstate.state_entry_time >
+ return tacc_get_guest_time_delta_vcpu(svc->vcpu)>
ratelimit - CSCHED2_RATELIMIT_TICKLE_TOLERANCE;
}
@@ -1722,7 +1722,7 @@ void burn_credits(struct csched2_runqueue_data *rqd,
return;
}
- delta = now - svc->start_time;
+ delta = tacc_get_guest_time_delta_vcpu(svc->vcpu);
if ( unlikely(delta <= 0) )
{
@@ -1739,7 +1739,7 @@ void burn_credits(struct csched2_runqueue_data *rqd,
if ( has_cap(svc) )
svc->budget -= delta;
- svc->start_time = now;
+ svc->vcpu->pcpu_guest_time += delta;
out:
if ( unlikely(tb_init_done) )
@@ -3189,8 +3189,8 @@ csched2_runtime(const struct scheduler *ops, int cpu,
{
s_time_t ratelimit_min = MICROSECS(prv->ratelimit_us);
if ( snext->vcpu->is_running )
- ratelimit_min = snext->vcpu->runstate.state_entry_time +
- MICROSECS(prv->ratelimit_us) - now;
+ ratelimit_min = tacc_get_guest_time_delta_vcpu(snext->vcpu) +
+ MICROSECS(prv->ratelimit_us);
if ( ratelimit_min > min_time )
min_time = ratelimit_min;
}
@@ -3265,6 +3265,7 @@ runq_candidate(struct csched2_runqueue_data *rqd,
struct csched2_vcpu *snext = NULL;
struct csched2_private *prv = csched2_priv(per_cpu(scheduler, cpu));
bool yield = false, soft_aff_preempt = false;
+ s_time_t guest_time;
*skipped = 0;
@@ -3286,8 +3287,8 @@ 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) <
- MICROSECS(prv->ratelimit_us) )
+ ((guest_time = tacc_get_guest_time_delta_vcpu(scurr->vcpu)) <
+ MICROSECS(prv->ratelimit_us)))
{
if ( unlikely(tb_init_done) )
{
@@ -3297,7 +3298,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 = guest_time;
__trace_var(TRC_CSCHED2_RATELIMIT, 1,
sizeof(d),
(unsigned char *)&d);
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
prev parent reply other threads:[~2019-09-11 10:33 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-11 10:32 [Xen-devel] [RFC 0/9] Changes to time accounting Andrii Anisov
2019-09-11 10:32 ` [Xen-devel] [RFC 1/9] schedule: Introduce per-pcpu " Andrii Anisov
2019-09-11 18:01 ` Volodymyr Babchuk
2019-09-12 10:26 ` Andrii Anisov
2019-10-28 14:28 ` Julien Grall
2019-11-06 11:24 ` Andrii Anisov
2020-05-26 2:27 ` Volodymyr Babchuk
2020-05-29 8:48 ` Dario Faggioli
2020-06-02 1:12 ` Volodymyr Babchuk
2020-06-03 15:22 ` Dario Faggioli
2019-09-11 10:32 ` [Xen-devel] [RFC 2/9] sysctl: extend XEN_SYSCTL_getcpuinfo interface Andrii Anisov
2019-10-28 14:52 ` Julien Grall
2019-11-06 11:25 ` Andrii Anisov
2019-09-11 10:32 ` [Xen-devel] [RFC 3/9] xentop: show CPU load information Andrii Anisov
2019-09-11 10:32 ` [Xen-devel] [RFC 4/9] arm64: utilize time accounting Andrii Anisov
2019-09-11 17:48 ` Volodymyr Babchuk
2019-09-12 12:09 ` Andrii Anisov
2019-09-12 12:17 ` Julien Grall
2019-09-12 12:29 ` Andrii Anisov
2019-10-28 14:47 ` Julien Grall
2019-11-06 11:31 ` Andrii Anisov
2019-09-11 10:32 ` [Xen-devel] [RFC 5/9] tacc: Introduce a lockless interface for guest time Andrii Anisov
2019-09-11 10:32 ` [Xen-devel] [RFC 6/9] sched:rtds: get guest time from time accounting code Andrii Anisov
2019-09-11 10:32 ` [Xen-devel] [RFC 7/9] tacc: Introduce a locked interface for guest time Andrii Anisov
2019-09-11 10:32 ` [Xen-devel] [RFC 8/9] sched:credit: get guest time from time accounting code Andrii Anisov
2019-09-11 10:32 ` Andrii Anisov [this message]
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=1568197942-15374-10-git-send-email-andrii.anisov@gmail.com \
--to=andrii.anisov@gmail.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=andrii_anisov@epam.com \
--cc=dfaggioli@suse.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@arm.com \
--cc=konrad.wilk@oracle.com \
--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).