From patchwork Thu Apr 6 08:16:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9666333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5D50260364 for ; Thu, 6 Apr 2017 08:18:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BA292830A for ; Thu, 6 Apr 2017 08:18:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 409762848E; Thu, 6 Apr 2017 08:18:42 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 08C9C2830A for ; Thu, 6 Apr 2017 08:18:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cw2ad-0000Xa-H0; Thu, 06 Apr 2017 08:16:23 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cw2ac-0000XJ-Kb for xen-devel@lists.xenproject.org; Thu, 06 Apr 2017 08:16:22 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 14/74-27545-559F5E85; Thu, 06 Apr 2017 08:16:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgleJIrShJLcpLzFFi42K5GNpwRDf059M Ig6kbxCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ox12xqYCk4KVdxruMHawDiZr4uRi0NIYAaj xMQFu9hBHBaBNawSh3buYuli5OSQELjEKnGnzxbCjpM4//USI4RdJfGyp50ZxBYSUJG4uX0VE 8SkX4wSHdOegSWEBfQkjhz9wQ5he0lcX3MPrJlNwEDizY69rCC2iICSxL1Vk5lAbGaBKIkzy5 uBejmArlCV2NOiARLmFfCWmNn0kAUkzCngI7GiWRzEFAIKz31dAFIhKiAnsfJyCytEtaDEyZl PwKqZBTQl1u/Sh5gtL7H97RzmCYwis5BUzUKomoWkagEj8ypG9eLUorLUIl1LvaSizPSMktzE zBxdQwMzvdzU4uLE9NScxKRiveT83E2MwLBnAIIdjHc3BRxilORgUhLlVfB5EiHEl5SfUpmRW JwRX1Sak1p8iFGDg0Ngwtm505mkWPLy81KVJHiDfjyNEBIsSk1PrUjLzAFGJkypBAePkgivL0 iat7ggMbc4Mx0idYrRmOPF5ffvmTierPzxnkkIbJKUOO+X70ClAiClGaV5cINgCeMSo6yUMC8 j0JlCPAWpRbmZJajyrxjFORiVhHkjQRbyZOaVwO17BXQKE9ApPrfATilJREhJNTCq/Szcufqk maDlHpFpNbu+7Tv3Jtld65O6ZEPk3UkPDrd0e3uUeTHciNy3aoPeeYbjxpdNDWL/N/D73SuX5 qgXeVy9pOj9HbOljv5XG1eG3eM2af+ru4VZlpWJ6+nVO5JTXC+sOugZfsLxHN/PNbJG10XKbj BmvN/kf0xn3uFLEvFWjcrJXIuVWIozEg21mIuKEwH2EjNFEwMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1491466581!43504472!1 X-Originating-IP: [209.85.128.196] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 65199 invoked from network); 6 Apr 2017 08:16:21 -0000 Received: from mail-wr0-f196.google.com (HELO mail-wr0-f196.google.com) (209.85.128.196) by server-2.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Apr 2017 08:16:21 -0000 Received: by mail-wr0-f196.google.com with SMTP id t20so9012168wra.2 for ; Thu, 06 Apr 2017 01:16:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=sh3QlJNTILGiQAYEk2zgHAmDia4J7hsNAWx3qG7Gguo=; b=ffeeZZq9dR9urBXWca+1/C1ItIq1e9RKS+XWmWoH8vCGuzmdfCHQTY3tRZbKhOC0JT Ze0wLZw+Z4GgNBv56tTQ8pItHOyrD/7+HsX6SKo3vqsL+jJkwWz3SVnWNrBAgq60HvA1 2FBjPts+yz315s6mnPFAC9ftyydMdIqk/BkvWKkJ2N6JYQvWwwBoNqA3fy8DZVuR0mOW dxDHEfpbMF9ADfg/3slVpKskMZiV5afiRXJxSnZh0dWt4vccigMyxG3NP/CIWMF5ruAs HwiAoLzYVTYelraxP03IGR0inClBzD+WHngHpaWde3wT0a6U1N8FmPL5i/FEmUfEHjyW 13vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=sh3QlJNTILGiQAYEk2zgHAmDia4J7hsNAWx3qG7Gguo=; b=UzxjXjJT7y/7x9APmV8AEgB1KD+OQdYVmsM1P0C7v7UOlGlbV0HgGmgyLVC//pnl4V QP+ZQI3hAxiaXHqV+GPmNw80BdVk/ZHvXDNCfNOQ26UKl+CCi78axsRioJghvsBRJzJO htOErMeK5y81lkQ9Je1NjGnmZTzJ7931RfElQOnMF1lc+apOzh1RfqbUKlaW1y8JEdSn eztz8Tg3rRNOVSERW2kab2QwjaTHy9HD2DO8dTr0qiSFMfBSeWXew7YLPEXRkpUswDit SHb3ZOu5eEuyH2M9Kk4rZrDv0Zwo5/11trGaQpR3VzExWBZOW/pePDFCScuwdfFyOpip gfmA== X-Gm-Message-State: AFeK/H0Arql4VbsT5HyDPuFAL3mGHwmyBjBMHewR8098w5QlGAxdsJOj dkWv6RD515DICQ== X-Received: by 10.28.66.207 with SMTP id k76mr23249482wmi.121.1491466580954; Thu, 06 Apr 2017 01:16:20 -0700 (PDT) Received: from Solace.fritz.box ([80.66.223.217]) by smtp.gmail.com with ESMTPSA id a66sm1139280wrc.58.2017.04.06.01.16.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Apr 2017 01:16:20 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Thu, 06 Apr 2017 10:16:19 +0200 Message-ID: <149146657883.21348.4003508836159742945.stgit@Solace.fritz.box> In-Reply-To: <149146456487.21348.8554211499146017782.stgit@Solace.fritz.box> References: <149146456487.21348.8554211499146017782.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Anshul Makkar Subject: [Xen-devel] [PATCH v2 2/7] xen: credit: (micro) optimize csched_runq_steal(). X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Chacking whether or not a vCPU can be 'stolen' from a peer pCPU's runqueue is relatively cheap. Therefore, let's do that as early as possible, avoiding potentially useless complex checks, and cpumask manipulations. Signed-off-by: Dario Faggioli --- Cc: George Dunlap Cc: Anshul Makkar --- Changes from v1: * fixed a typo in a comment. --- xen/common/sched_credit.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 63a8675..5a3f13f 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -708,12 +708,10 @@ static inline int __csched_vcpu_is_migrateable(struct vcpu *vc, int dest_cpu, cpumask_t *mask) { /* - * Don't pick up work that's in the peer's scheduling tail or hot on - * peer PCPU. Only pick up work that prefers and/or is allowed to run - * on our CPU. + * Don't pick up work that's hot on peer PCPU, or that can't (or + * would prefer not to) run on cpu. */ - return !vc->is_running && - !__csched_vcpu_is_cache_hot(vc) && + return !__csched_vcpu_is_cache_hot(vc) && cpumask_test_cpu(dest_cpu, mask); } @@ -1622,7 +1620,9 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, int balance_step) BUG_ON( is_idle_vcpu(vc) ); /* - * If the vcpu has no useful soft affinity, skip this vcpu. + * If the vcpu is still in peer_cpu's scheduling tail, or if it + * has no useful soft affinity, skip it. + * * In fact, what we want is to check if we have any "soft-affine * work" to steal, before starting to look at "hard-affine work". * @@ -1633,8 +1633,9 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, int balance_step) * vCPUs with useful soft affinities in some sort of bitmap * or counter. */ - if ( balance_step == CSCHED_BALANCE_SOFT_AFFINITY - && !__vcpu_has_soft_affinity(vc, vc->cpu_hard_affinity) ) + if ( vc->is_running || + (balance_step == CSCHED_BALANCE_SOFT_AFFINITY + && !__vcpu_has_soft_affinity(vc, vc->cpu_hard_affinity)) ) continue; csched_balance_cpumask(vc, balance_step, cpumask_scratch);