From patchwork Wed Sep 11 10:32:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Anisov X-Patchwork-Id: 11140877 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA74617E6 for ; Wed, 11 Sep 2019 10:34:31 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C656E2087E for ; Wed, 11 Sep 2019 10:34:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uj8hwhqH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C656E2087E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zw3-0000UL-8N; Wed, 11 Sep 2019 10:33:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zw1-0000T0-AK for xen-devel@lists.xenproject.org; Wed, 11 Sep 2019 10:33:13 +0000 X-Inumbo-ID: 7b29eefa-d47f-11e9-b76c-bc764e2007e4 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7b29eefa-d47f-11e9-b76c-bc764e2007e4; Wed, 11 Sep 2019 10:32:41 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id y23so19132831ljn.5 for ; Wed, 11 Sep 2019 03:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nTxSIglmusaJTq+slsHa0UgJ/0RrGOlxtblHgFLIsZ4=; b=uj8hwhqHEt/YuJweovSp6KjRqgNBJw149U13EqsUdElkHyDRWKs2ERrR5JC3TyROTE pETd614g2kxfVzS2TX2Vf6MtN+l7zm0DRFgilUicOfsCz4rR5uOVstSqCdZqkcqgfIsr QoiOZHxg6Tr/hdRRqvateyzO2vF39//gz/tdd2nUu62ZQWMdgYCdE5sUjC8mT8LTCj8P aQ3KPkkHQtWLiV6FUWAQD6ChOFGbQTVQxtNfR64FPVy9vYc+HdGOo3JkWyTLh75FnQmD yWh1aIKOG97JEiYgnavoWAG9ZG6loIVH1mV2J2fN/7uBUD3GjHSy7aI5MtDMiy5DW9vC gYbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nTxSIglmusaJTq+slsHa0UgJ/0RrGOlxtblHgFLIsZ4=; b=WdheIRjDD0cjz2fiJxKthDRXZsrwfd+lH2TuLJmmejaOsAsiQdGY0iyFO7zJrn0AEK StmnRtXNqPNXrwI8xIvFbvK76R2HUpOvHOyRnH2sLX3TiK7jR/sgFuCKswb1EYCxZWGg dxeMCHmFcMVZru+mhM/1JoGY+SJZYdTK6YlXfj8IjILTy54i+azrxvSc7NOo7DedLEvI RMfpSURHo+Fq1wcwZFI+/PfqSAV1MVPe+SDdEHjwZ5e2f/04FGpA8vJYl4qbeGs5byiC mGfDcTbQyMi1LUM6CoQVRwRWsIEUx8TAoyGrzbtuyXXg+s58wRSeGekdeHh0MF2hQLLv 1Xug== X-Gm-Message-State: APjAAAUWnbSHnfvHo/izFNwB60MDU88vRGLJ/OaaZdlxxI7KxkboLKRW w4r/BiU7JvlA9OXt02sLa8gXxTYJKYQ= X-Google-Smtp-Source: APXvYqw7Zpe3MGMlHtgBgNuE9VQf7Mufhx7GHZJO8jeINlKDc+9rZNrgrh9XUoy2yHDqq24BiZzGIA== X-Received: by 2002:a2e:88c6:: with SMTP id a6mr23164351ljk.39.1568197959507; Wed, 11 Sep 2019 03:32:39 -0700 (PDT) Received: from aanisov-work.kyiv.epam.com (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id w27sm4585275ljd.55.2019.09.11.03.32.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Sep 2019 03:32:38 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Wed, 11 Sep 2019 13:32:22 +0300 Message-Id: <1568197942-15374-10-git-send-email-andrii.anisov@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1568197942-15374-1-git-send-email-andrii.anisov@gmail.com> References: <1568197942-15374-1-git-send-email-andrii.anisov@gmail.com> Subject: [Xen-devel] [RFC 9/9] sched:credit2: get guest time from time accounting code X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Andrii Anisov , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Dario Faggioli MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Andrii Anisov While the Credit2 scheduler code uses guest time from the other pcpu, we have to use locked time accounting. Signed-off-by: Andrii Anisov --- 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);