From patchwork Wed Sep 11 10:32:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Anisov X-Patchwork-Id: 11140883 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 CA25217E6 for ; Wed, 11 Sep 2019 10:34:42 +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 A5D9A2087E for ; Wed, 11 Sep 2019 10:34:42 +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="mkSkUftQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5D9A2087E 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 1i7zvx-0000Q7-Ta; Wed, 11 Sep 2019 10:33:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7zvw-0000P1-AV for xen-devel@lists.xenproject.org; Wed, 11 Sep 2019 10:33:08 +0000 X-Inumbo-ID: 7a46ec36-d47f-11e9-b299-bc764e2007e4 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7a46ec36-d47f-11e9-b299-bc764e2007e4; Wed, 11 Sep 2019 10:32:39 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id u14so19450744ljj.11 for ; Wed, 11 Sep 2019 03:32:39 -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=D1tmQx4QQQTXiGm/taYp9ljWrLsYP/6Sdp2V1mTvY5Q=; b=mkSkUftQESBwTE4pIFjxK9nOfDpujozkVjuwu1pLch7xAXRF/bECdIU1TZyHk5wChg UOWQlOXQPb+UjPLj1fcfEKamv9s8PynMB/StH3U1vRP3AVaxbIt6pFCra/d5IR0oaQ7N y1dARxwpsAU8HA4wOmcyUrXnodrkPo2Z2BlzebyvDBGOSb5pOKWcckzW0t2j7WZ1hVT7 R0m8q0eaAzywezFAe9j1YCCFj/MzugvLzL2bEl1hD7r+TQXlb1Z6aydmgpSAnAFAVSFH 4ybJJfc3bCZccsg+w7QQKvZRgQdFcaChtvEEeXHp1GLQq+AB+t2h01uvp+cZrj+uefcl dLTQ== 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=D1tmQx4QQQTXiGm/taYp9ljWrLsYP/6Sdp2V1mTvY5Q=; b=Gi0uxWIXJRxiLsFeowNR8QaCk/ZcT1BtiEG0h9rrZLOUU8AtRKatA5tq85Y/B457TX GSAEGcWY6QaHXIn52YV45MESDIi6t9t589qYFQunRgHe/5lMYFuqrPiw6TGQCQUURhN4 dk84kLfOtbKFMUU6oF+JqELdjN/UP8cYBrvJT99dmF2eI47erFfP2buIWNwjR+jDV+iI 9H9yU+V2/D8ZSDA4NEDvsjbdUSKCSVbqMWNMBnBBaFW5DShDKhh8gcHiwiJClCpdnXvC vmX8mXh2R3rjThzcxUC9eYjF14RBiZfqk6dSW8YvVi+ZXCyAsWO2wX+Ut2YdNuKOSJpG Ur3w== X-Gm-Message-State: APjAAAUNA9baGP0Pw155WKcVU6WkOAm9+rc2Lp4h3KsxRqPw4WdNmUXY R1d+k5tH2c9GYhBGHP8r6zkenr/m40U= X-Google-Smtp-Source: APXvYqzHZOS70e5XAk+zkJW0cCEdc6izNMK3UieVBImeIDCwGtsLRl0Oq/AKUp5DG3TGajQ0KAUjAw== X-Received: by 2002:a2e:504f:: with SMTP id v15mr23161379ljd.67.1568197957942; Wed, 11 Sep 2019 03:32:37 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Sep 2019 03:32:37 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Wed, 11 Sep 2019 13:32:21 +0300 Message-Id: <1568197942-15374-9-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 8/9] sched:credit: 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 Credit 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_credit.c | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/xen/common/Kconfig b/xen/common/Kconfig index c1748dd..d17a8b4 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -227,6 +227,7 @@ config TACC_NEEDS_LOCK config SCHED_CREDIT bool "Credit scheduler support" default y + select TACC_NEEDS_LOCK ---help--- The traditional credit scheduler is a general purpose scheduler. diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 81dee5e..ac6b9e6 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -324,16 +324,15 @@ runq_remove(struct csched_vcpu *svc) __runq_remove(svc); } -static void burn_credits(struct csched_vcpu *svc, s_time_t now) +static void burn_credits(struct csched_vcpu *svc, s_time_t delta) { - s_time_t delta; uint64_t val; unsigned int credits; /* Assert svc is current */ ASSERT( svc == CSCHED_VCPU(curr_on_cpu(svc->vcpu->processor)) ); - if ( (delta = now - svc->start_time) <= 0 ) + if ( delta <= 0 ) return; val = delta * CSCHED_CREDITS_PER_MSEC + svc->residual; @@ -341,7 +340,6 @@ static void burn_credits(struct csched_vcpu *svc, s_time_t now) credits = val; ASSERT(credits == val); /* make sure we haven't truncated val */ atomic_sub(credits, &svc->credit); - svc->start_time += (credits * MILLISECS(1)) / CSCHED_CREDITS_PER_MSEC; } static bool_t __read_mostly opt_tickle_one_idle = 1; @@ -956,7 +954,7 @@ csched_vcpu_acct(struct csched_private *prv, unsigned int cpu) /* * Update credits */ - burn_credits(svc, NOW()); + burn_credits(svc, tacc_get_guest_time_delta_vcpu(svc->vcpu)); /* * Put this VCPU and domain back on the active list if it was @@ -1856,14 +1854,14 @@ csched_schedule( (unsigned char *)&d); } - runtime = now - current->runstate.state_entry_time; + runtime = tacc_get_guest_time_delta(); if ( runtime < 0 ) /* Does this ever happen? */ runtime = 0; if ( !is_idle_vcpu(scurr->vcpu) ) { /* Update credits of a non-idle VCPU. */ - burn_credits(scurr, now); + burn_credits(scurr, runtime); scurr->start_time -= now; scurr->last_sched_time = now; }