From nobody Thu Apr 18 15:38:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1560332240; cv=none; d=zoho.com; s=zohoarc; b=arrMBllGyADfmu5rLOmfoTiev1hEPHvM/KmJXKPfeW3N3kTNDw3iEenklvmBWGagAqDywrKyUCH0Ca58pXOc3v7g9D7miUePACi/c/wmTNRTqiE+C2xKIebnRAIHwlqz5dnPaRp4yTPNtPLWkU1TdZ0Z7XRl+3+Zgnsp6BNLYoE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560332240; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=d2E6IDxI6FUw3XS/vtJcGjoeaPe4Hh6Xz7VoYOqYC9I=; b=D7FdMEXS5LV9/0Y/62BDNMaPJDrkLl+UaPft/sJwNjBfy3agHQmUlK4q7yNX5mmjCZEbupYnCC83nWuCYpaL1ExZ7tq/uHlCa1X/1FXMssXKNXET7AqdhFrUqfvLTZB0dADhHO5xZP4yCI96f6RTjx5rs+175dWQUo0mSviA+QU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560332240101501.5959203232211; Wed, 12 Jun 2019 02:37:20 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hazfh-0004cH-U5; Wed, 12 Jun 2019 09:35:57 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hazfg-0004cC-1M for xen-devel@lists.xenproject.org; Wed, 12 Jun 2019 09:35:56 +0000 Received: from mail-lj1-x242.google.com (unknown [2a00:1450:4864:20::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 79205eae-8cf5-11e9-8980-bc764e045a96; Wed, 12 Jun 2019 09:35:54 +0000 (UTC) Received: by mail-lj1-x242.google.com with SMTP id s21so14508558lji.8 for ; Wed, 12 Jun 2019 02:35:54 -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 w28sm3070622ljd.12.2019.06.12.02.35.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Jun 2019 02:35:51 -0700 (PDT) X-Inumbo-ID: 79205eae-8cf5-11e9-8980-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=6uzYWLUYr4dLjg8OhfbAm/fa97iQEiGeyio575p2A/A=; b=Hglxbrt6z40TlyfwQ+oBcVNhpnZp++5OpehFr2RuSbbZ+OLetz+aM0dklNapIVWYOH D6+YJnvQWk9SNbas253Mct/woZU/K9xqyXaEWfzp9z50I/yHJW16d7fQYUwwTnkC7yNF +4SW4foD9+v/8VzdCqfQfF3VvdIyvH9pN7TS0OEZwU1bBLjRw3pvmRtNunXYa5bUvoIO x2UmABUQZFgxz31x+OA+fBmuduTwm/tXNXgLktXi9WdmczV1JmKgsFF0zi7xR3UzVE0w csPV9Vvo+/NQ24IN7WcYBrrC1D6mRZmCr/6bJ19H7i/uBlsaXcTTP7cwKxQ8E/8j1ama iWvQ== 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; bh=6uzYWLUYr4dLjg8OhfbAm/fa97iQEiGeyio575p2A/A=; b=BG0ISt6+8MQrW4sNFlx5AU9PqzgSKoPY397W4S68wK8+7EwxeM6lZaWbDl1Ah99GDh BrmVeYgsYtyDDYUzM/SeCyFskb+98bAZIhE0vc//Ht3t82+yp1SjXAhs531JnsgtdRd5 OWa7qQhMQxxkPlz0wQAnEueYtg0120Dis57HtBGZJAAB2Pvgm51o1u2zNgxOoMoyyeAn dg5uhiSh1uOOrhGhY5Qt7EXKbmAeeQ4GR3OjQc43BgH5rc6SOBCrORfPeMyjm/yOnH27 lS9ijCFerPa/bWk4u4zvtA1dGmXsHM3uJwYYojfwliVYftr7rNNoWK7DId4RF1duqAUk f1lQ== X-Gm-Message-State: APjAAAVKDaNi0IsxZaTHXf0/64ep5edRy+3MZ0QYOIOB+AO3Hw31616Z HxmyyILJFuib+k7ynmextio4nq7L31hx0w== X-Google-Smtp-Source: APXvYqyddLcdOhLJhdIUyxcjL6YGkGjxMCjeHTBREHJKDrbRoS+lpcx2SRSnMQXkGCYbCmvFgnCAZA== X-Received: by 2002:a2e:301a:: with SMTP id w26mr33292745ljw.76.1560332152824; Wed, 12 Jun 2019 02:35:52 -0700 (PDT) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Wed, 12 Jun 2019 12:35:50 +0300 Message-Id: <1560332150-27712-1-git-send-email-andrii.anisov@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [Xen-devel] [PATCH v4] schedule: move credit scheduler specific member to its privates 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: Tim Deegan , Stefano Stabellini , Andrii Anisov , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Andrii Anisov The vcpu structure member last_run_time is used by credit scheduler only. In order to get better encapsulation, it is moved from a generic structure to the credit scheduler private vcpu definition. Also, rename the member to last_sched_time in order to reflect that it is the time when the vcpu went through the scheduling path. With this move we have slight changes in functionality: - last_sched_time is not updated for an idle vcpu. But the idle vcpu is, in fact, a per-pcpu stub and never migrates so last_sched_time is meaningless for it. - The value of last_sched_time is updated on every schedule, even if the vcpu is not being changed. It is still ok, because last_sched_time is only used for runnable vcpu migration decision, and we have it correct at that moment. Scheduling parameters and statistics are tracked by other entities. Reducing code and data usage when not running credit scheduler is another nice side effect. While here, also: - turn last_sched_time into s_time_t, which is more appropriate. - properly const-ify related argument of __csched_vcpu_is_cache_hot(). Signed-off-by: Andrii Anisov Reviewed-by: Dario Faggioli --- Changes in v4: - The member renamed to last_sched_time - removed a misleading comment - commit title and message updated describing member rename,=20 change motivation and a side effect v3: - commit message updated accordingly to [1] v2: - last_run_time type changed to s_time_t - scurr changed to svc - dropped stray blanks - pointers to const are used appropriately [1] https://lists.xenproject.org/archives/html/xen-devel/2018-09/msg01201.h= tml --- xen/common/sched_credit.c | 11 ++++++++--- xen/common/schedule.c | 1 - xen/include/xen/sched.h | 3 --- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 7b7facb..07e442c 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -175,6 +175,8 @@ struct csched_vcpu { atomic_t credit; unsigned int residual; =20 + s_time_t last_sched_time; + #ifdef CSCHED_STATS struct { int credit_last; @@ -701,10 +703,11 @@ static unsigned int vcpu_migration_delay_us; integer_param("vcpu_migration_delay", vcpu_migration_delay_us); =20 static inline bool -__csched_vcpu_is_cache_hot(const struct csched_private *prv, struct vcpu *= v) +__csched_vcpu_is_cache_hot(const struct csched_private *prv, + const struct csched_vcpu *svc) { bool hot =3D prv->vcpu_migr_delay && - (NOW() - v->last_run_time) < prv->vcpu_migr_delay; + (NOW() - svc->last_sched_time) < prv->vcpu_migr_delay; =20 if ( hot ) SCHED_STAT_CRANK(vcpu_hot); @@ -716,6 +719,7 @@ static inline int __csched_vcpu_is_migrateable(const struct csched_private *prv, struct vcpu= *vc, int dest_cpu, cpumask_t *mask) { + const struct csched_vcpu *svc =3D CSCHED_VCPU(vc); /* * Don't pick up work that's hot on peer PCPU, or that can't (or * would prefer not to) run on cpu. @@ -725,7 +729,7 @@ __csched_vcpu_is_migrateable(const struct csched_privat= e *prv, struct vcpu *vc, */ ASSERT(!vc->is_running); =20 - return !__csched_vcpu_is_cache_hot(prv, vc) && + return !__csched_vcpu_is_cache_hot(prv, svc) && cpumask_test_cpu(dest_cpu, mask); } =20 @@ -1870,6 +1874,7 @@ csched_schedule( /* Update credits of a non-idle VCPU. */ burn_credits(scurr, now); scurr->start_time -=3D now; + scurr->last_sched_time =3D now; } else { diff --git a/xen/common/schedule.c b/xen/common/schedule.c index ba942a7..047f767 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1486,7 +1486,6 @@ static void schedule(void) ((prev->pause_flags & VPF_blocked) ? RUNSTATE_blocked : (vcpu_runnable(prev) ? RUNSTATE_runnable : RUNSTATE_offline)), now); - prev->last_run_time =3D now; =20 ASSERT(next->runstate.state !=3D RUNSTATE_running); vcpu_runstate_change(next, RUNSTATE_running, now); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index ccd5347..97a3ab5 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -174,9 +174,6 @@ struct vcpu } runstate_guest; /* guest address */ #endif =20 - /* last time when vCPU is scheduled out */ - uint64_t last_run_time; - /* Has the FPU been initialised? */ bool fpu_initialised; /* Has the FPU been used since it was last saved? */ --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel