From patchwork Fri May 3 15:38:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eslam Elnikety X-Patchwork-Id: 10928937 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A3B51390 for ; Fri, 3 May 2019 15:42:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39AE428592 for ; Fri, 3 May 2019 15:42:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DCD128657; Fri, 3 May 2019 15:42:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C5E2328592 for ; Fri, 3 May 2019 15:42:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hMaIj-0005LF-1C; Fri, 03 May 2019 15:40:41 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hMaIi-0005LA-Aw for xen-devel@lists.xenproject.org; Fri, 03 May 2019 15:40:40 +0000 X-Inumbo-ID: ccf6bb0c-6db9-11e9-843c-bc764e045a96 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id ccf6bb0c-6db9-11e9-843c-bc764e045a96; Fri, 03 May 2019 15:40:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1556898039; x=1588434039; h=from:to:cc:subject:date:message-id:mime-version; bh=dTXzQslvZSOpAROci88yBv58wiAvUvujcvpE207EQDk=; b=JmvfcsK6Iw+oTZgp17b9aNdUnNjAQ5RVtyiUCcb0jEOzIGTRoJBV4MMa E2dAHaV+kJuFf1STiWIfqXLUp2KK4Rcb34qBKf6+L4AeTvVghVlvkAfMr HcqBte17e0C+B+vwFkj3VS8yWsJJvhFDYWaR2/kLptGYtHWYlc8/rPyJu 4=; X-IronPort-AV: E=Sophos;i="5.60,426,1549929600"; d="scan'208";a="797707739" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 03 May 2019 15:40:36 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id x43FeWCk085337 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Fri, 3 May 2019 15:40:35 GMT Received: from EX13D03EUA001.ant.amazon.com (10.43.165.33) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 3 May 2019 15:40:34 +0000 Received: from EX13MTAUEB001.ant.amazon.com (10.43.60.96) by EX13D03EUA001.ant.amazon.com (10.43.165.33) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 3 May 2019 15:40:21 +0000 Received: from dev-dsk-elnikety-1c-28a13cba.eu-west-1.amazon.com (10.15.5.186) by mail-relay.amazon.com (10.43.60.129) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 3 May 2019 15:40:14 +0000 Received: by dev-dsk-elnikety-1c-28a13cba.eu-west-1.amazon.com (Postfix, from userid 6438462) id 998F3464AF; Fri, 3 May 2019 15:40:14 +0000 (UTC) From: Eslam Elnikety To: Date: Fri, 3 May 2019 15:38:39 +0000 Message-ID: <20190503153839.19932-1-elnikety@amazon.com> X-Mailer: git-send-email 2.15.3.AMZN MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH] sched/credit: avoid priority boost for capped domains when unpark X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: George Dunlap , Eslam Elnikety , Dario Faggioli Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP When unpausing a capped domain, the scheduler currently clears the CSCHED_FLAG_VCPU_PARKED flag before vcpu_wake(). This, in turn, causes the vcpu_wake to set CSCHED_PRI_TS_BOOST, resulting in an unfair credit boost. The comment around the changed lines already states that clearing the flag should happen AFTER the unpause. This bug was introduced in commit be650750945 "credit1: Use atomic bit operations for the flags structure". Original patch author credit: Xi Xiong. Signed-off-by: Eslam Elnikety Reviewed-by: Leonard Foerster Reviewed-by: Petre Eftime Acked-by: Dario Faggioli --- xen/common/sched_credit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 3abe20def8..8eb1aba12a 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1538,7 +1538,7 @@ csched_acct(void* dummy) svc->pri = CSCHED_PRI_TS_UNDER; /* Unpark any capped domains whose credits go positive */ - if ( test_and_clear_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags) ) + if ( test_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags) ) { /* * It's important to unset the flag AFTER the unpause() @@ -1547,6 +1547,8 @@ csched_acct(void* dummy) */ SCHED_STAT_CRANK(vcpu_unpark); vcpu_unpause(svc->vcpu); + /* Now clear the PARKED flag */ + clear_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags); } /* Upper bound on credits means VCPU stops earning */