From patchwork Fri May 3 19:43:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eslam Elnikety X-Patchwork-Id: 10929165 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 83A7014B6 for ; Fri, 3 May 2019 19:46:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70D1E28783 for ; Fri, 3 May 2019 19:46:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 648972878F; Fri, 3 May 2019 19:46:07 +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 1260328783 for ; Fri, 3 May 2019 19:46:06 +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 1hMe6o-0007yM-Im; Fri, 03 May 2019 19:44:38 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hMe6n-0007yB-6M for xen-devel@lists.xenproject.org; Fri, 03 May 2019 19:44:37 +0000 X-Inumbo-ID: dac026d2-6ddb-11e9-8178-7f0b5cf1e509 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id dac026d2-6ddb-11e9-8178-7f0b5cf1e509; Fri, 03 May 2019 19:44:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1556912665; x=1588448665; h=from:to:cc:subject:date:message-id:mime-version; bh=JMgTeVh3LJ7XutkW2AJXxZ0fct7USoQjhlwd4pQOBrs=; b=YIIWkvs/rI8PU05uleGftP6QeUZPO5pX+RJ8yn/MBK4Y+6j9Aho5g9nC qPGD+qTF54JC9r8nCCgQqEnCZN7oRyuXb9o9vjCYXA/LeZfaBU84iKBRu iVB11UE2FFjEfVNbDHqt1OrDE8LAF/VTlhqF9HpeCdFuJrnYDPAjUN/xK w=; X-IronPort-AV: E=Sophos;i="5.60,426,1549929600"; d="scan'208";a="797762025" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1d-5dd976cd.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 19:44:22 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-5dd976cd.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id x43JiJYu013399 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Fri, 3 May 2019 19:44:20 GMT Received: from EX13D03EUA002.ant.amazon.com (10.43.165.166) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 3 May 2019 19:44:20 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D03EUA002.ant.amazon.com (10.43.165.166) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 3 May 2019 19:44:19 +0000 Received: from dev-dsk-elnikety-1c-28a13cba.eu-west-1.amazon.com (10.15.5.186) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 3 May 2019 19:44:17 +0000 Received: by dev-dsk-elnikety-1c-28a13cba.eu-west-1.amazon.com (Postfix, from userid 6438462) id 6DC5A462B6; Fri, 3 May 2019 19:44:17 +0000 (UTC) From: Eslam Elnikety To: Date: Fri, 3 May 2019 19:43:49 +0000 Message-ID: <20190503194349.42831-1-elnikety@amazon.com> X-Mailer: git-send-email 2.15.3.AMZN MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v2] 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 , Lars Kurth , 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 while at Amazon. Signed-off-by: Eslam Elnikety Reviewed-by: Leonard Foerster Reviewed-by: Petre Eftime Acked-by: Dario Faggioli --- Changes in v2: - Adjusted commit message, adding Xi's previous affiliation - Dropped comment: /* Now clear the PARKED flag */ - Added Dario's A-b --- xen/common/sched_credit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 3abe20def8..7b7facbace 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,7 @@ csched_acct(void* dummy) */ SCHED_STAT_CRANK(vcpu_unpark); vcpu_unpause(svc->vcpu); + clear_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags); } /* Upper bound on credits means VCPU stops earning */