From patchwork Thu Mar 2 10:38:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9599905 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 0410F60522 for ; Thu, 2 Mar 2017 10:40:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D723227F7F for ; Thu, 2 Mar 2017 10:40:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBE5A28562; Thu, 2 Mar 2017 10:40:36 +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 62095284F4 for ; Thu, 2 Mar 2017 10:40: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 1cjO7l-00049C-5p; Thu, 02 Mar 2017 10:38:17 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjO7k-000491-9H for xen-devel@lists.xenproject.org; Thu, 02 Mar 2017 10:38:16 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id F0/5E-19731-716F7B85; Thu, 02 Mar 2017 10:38:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleJIrShJLcpLzFFi42K5GNpwWFfs2/Y IgweL9S2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owzfy6yFrwVrPi0y7SB8ShvFyMXh5DADEaJ fxfesoE4LAJrWCW+t19lBnEkBC6xSlzu/8PSxcgJ5MRIvDn+kxnCrpbYufsNE4gtJKAicXP7K iaIUb8YJdq/LWYHSQgL6EkcOfoDynaXeL5rC1gDm4CBxJsde1lBbBEBJYl7qyYDxTk4mAX0JV Z/5QEJswioStzZ+wtsF6+At8Saqw/BbE4BX4nOvxdYIfb6SPyY2Q9miwrISay83MIKUS8ocXL mExaIkZoS63fpg4SZBeQltr+dwzyBUWQWkqpZCFWzkFQtYGRexahRnFpUllqka2iul1SUmZ5R kpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kRGPwMQLCD8fbGgEOMkhxMSqK8vM+2RwjxJeWnV GYkFmfEF5XmpBYfYtTg4BCYcHbudCYplrz8vFQlCV7Hr0B1gkWp6akVaZk5wPiEKZXg4FES4S 0HSfMWFyTmFmemQ6ROMRpzPDi16w0Tx6f+w2+YhMAmSYnzsoGUCoCUZpTmwQ2CpY1LjLJSwry MQGcK8RSkFuVmlqDKv2IU52BUEub9+wVoCk9mXgncvldApzABnfJCZSvIKSWJCCmpBsYpHmJ7 uj7L5Rrfvfq2RM/58FzbFKvtLuEHLRk74i+4fBJmlWN3XM/c+uG2dmHK+/qKBZ3Vjsu5X65bZ PpRUKWa3eTyGi+NX40f4yefYkkqXZVrUnnLXbVo7sd/h9/UsK/gPTXbbb+V2dudAZ1BCeK+K2 dtr5R6bWIvFbHmyYRDs2zv7nn9S1aJpTgj0VCLuag4EQDN7o9FFgMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-16.tower-21.messagelabs.com!1488451094!55771557!1 X-Originating-IP: [209.85.128.195] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4468 invoked from network); 2 Mar 2017 10:38:14 -0000 Received: from mail-wr0-f195.google.com (HELO mail-wr0-f195.google.com) (209.85.128.195) by server-16.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 2 Mar 2017 10:38:14 -0000 Received: by mail-wr0-f195.google.com with SMTP id l37so8892268wrc.3 for ; Thu, 02 Mar 2017 02:38:14 -0800 (PST) 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=GR33jeJ1jGFsEuCDtz+HUewpG3g6Xib7pgLzao8NKUY=; b=qPFBu5GvnrzG/Nyq/obzsTC5FevsizyR+f5o4LhZj2iIWVn3baYgoYoPRdiajEPvju 1CdmDtPG9Kk63HxBHralh1w2jg/9OPBms66lZ1GSkcuIUWzBp3WHPyrh+A9j0Eq8+Oyy dJkQFRAPk3jjDA/bpPe4cNIrg1ULsfUch7ju05NyoulI91c9OGJnk1yzHCPNR0onSPQw UEaA16aOkLx67y2dBDnOJ0MLPe4+Dbz62CDF+c5HfgvCwvlLYa3SKwCxJPGBd39nC2sc ZVmzJhd111Vpk4wfXGY3H3gCVSVulcQxykiuc9KnWHWcYQaijZZBHQX9ktUjtByco6jH iH5Q== 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=GR33jeJ1jGFsEuCDtz+HUewpG3g6Xib7pgLzao8NKUY=; b=hSmfRhzKBMVS+Mz318wwTE9uRaGp745G20rPTr7v1HPRi6dQRYJBh5zbmRNpXWhPZw I7mqTjprQBwX7Fki3oCcO59farHbQ1D/tkmUaLKa6K+H6oR7ZbufMpjP+y2aPFQx6uS8 rIQKFjldjSn/vADUM8OPWmAMsLgNz1vDfDR5wBldZV/1UbMLCvlrzQkFz6H2XS4kf1RW xYkRWivFsPW7XMUO0/lofjpbBGSbNC7z9qR1yL6671nF1HPaC9DDEnwaklkHgy1ScG7A puY3QHLo0LIv2CLVHXrZujg7q+gda7l0zwbVbHJr0NCkyKo9Gkb1TLZTwWdYqmi8WCRI t0Hg== X-Gm-Message-State: AMke39mkiXPVODdeV2kM4AjO4qqcvRDxcH+JjuSRRYadOxVk7X1ELm13O9lwZigZme9CJg== X-Received: by 10.223.145.227 with SMTP id 90mr12181373wri.156.1488451094445; Thu, 02 Mar 2017 02:38:14 -0800 (PST) Received: from Solace.fritz.box ([80.66.223.93]) by smtp.gmail.com with ESMTPSA id o143sm10669937wmd.3.2017.03.02.02.38.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 02:38:13 -0800 (PST) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Thu, 02 Mar 2017 11:38:12 +0100 Message-ID: <148845109247.23452.8451353979591593272.stgit@Solace.fritz.box> In-Reply-To: <148844531279.23452.17528540110704914171.stgit@Solace.fritz.box> References: <148844531279.23452.17528540110704914171.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap Subject: [Xen-devel] [PATCH 2/6] 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 --- 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..2b13e99 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 or 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);