Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp949682ybl; Thu, 12 Dec 2019 07:25:11 -0800 (PST) X-Google-Smtp-Source: APXvYqzM/V+W4RKk9h2q2/GdA920OCZqHZorimgtO/WQQVR3tQDNiiki+uK84SY1ozL2iNpCIf/F X-Received: by 2002:a9d:730e:: with SMTP id e14mr8305957otk.62.1576164311349; Thu, 12 Dec 2019 07:25:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576164311; cv=none; d=google.com; s=arc-20160816; b=jiVBg61wiz5GEww+SN/ee4gCpsUB11K+fGEJxlcTwD0+Ub17Q+QF3hRY6CjMWLNcyb WIIM9shdYD1uqm2u9kT50drw+BUoUN2NRUwuRdm1zNN+EzOQYpJCN/s3rW4AZzXlDpob 4rQQ2yWXHoGGqA1gIj2ULDJCi7iOA3L4gE+Tmkp9hDjXlO7V2Fq/5gAg+5c4N5QaFHIn S0MAQIoa7dIbBI+M/9+qxynPQpkG/4BMJnreWrZWlkWfg3vPaFpohljv7IFT8gZiAVTt JXltfYNoPvcMAzOzlh8By3MpfK0kfw8FhuVe0S/RtQVotDu9guA2nD/08GtowZqh4UiY LWLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/RjQApOCHLXz1ezNB0hYM9BgwHOfsdfgZjmYHBLFUwE=; b=bQyuFfFlWvOQSKUa6IyWMvyG2z8LB5AqVbJuRZXcfFayrd/OwWfmm+JdeZ56qEAMZH o8ggpXnuFXeGmurGhsoYn7Se8/OyPZV9A1GiaqIqFX6wYdT0VPsDubv+EY+/ZWVxq+rm g4w30F2ndArYPeyT1s5GqpJ6UKjx7uNzssqHQgcF4igZ2mMJE7h04IHS+WNb95sGyBgW SLAJAy/wG9seQ+Kf3HX7EsJUMCUDZxXJ5cxKCkBbI+8LNxDBkfEyvMf/gmP9HZhVVqp1 8BQfqx5N/CbL2DVXPDTrHwcO6tNH9OVTP3B0+fOv+aYAqrzdeyP+fNOAdQm3mmh/Q9Rg J1GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=MHdDBgfz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si3188017otq.95.2019.12.12.07.24.58; Thu, 12 Dec 2019 07:25:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=MHdDBgfz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729217AbfLLPYM (ORCPT + 99 others); Thu, 12 Dec 2019 10:24:12 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:43792 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728654AbfLLPYL (ORCPT ); Thu, 12 Dec 2019 10:24:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/RjQApOCHLXz1ezNB0hYM9BgwHOfsdfgZjmYHBLFUwE=; b=MHdDBgfz9CVVpwK8i4UfKFzIp ROwltcE151eEuwH18cr7vuwk+lGB98qlJCviTjjcQiGlm0TOQIlYiLF8bVW2P6t9KhJUFiN/KDLK8 +C7zbvAwwcI64XM3FlGskmC/fjod7ItxH0vyat+sOK/191DgBcs7q8VUZMlYn/+JdeZEzcJG7q5pI tBRdVYPJAatJqh4iTKYQFikoCxdnDRIyuBfjP854w9CMayXYaVG1nyXIfNKBrK+YCnWHGkD321nXF TfwwkSluIuAJ3T3kCo90TeEyUtQeS/h9iC+HdP1JDSFc3kk5YNU8PFPepGLV/6dr7ca+olVg5xprc m0v2EtMRg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifQK0-0001h0-Oa; Thu, 12 Dec 2019 15:24:08 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id A7639304D2B; Thu, 12 Dec 2019 16:22:46 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BDBCA2B195D80; Thu, 12 Dec 2019 16:24:06 +0100 (CET) Date: Thu, 12 Dec 2019 16:24:06 +0100 From: Peter Zijlstra To: Cheng Jian Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, chenwandun@huawei.com, xiexiuqi@huawei.com, liwei391@huawei.com, huawei.libin@huawei.com, bobo.shaobowang@huawei.com, juri.lelli@redhat.com, vincent.guittot@linaro.org Subject: Re: [PATCH] sched/fair: Optimize select_idle_cpu Message-ID: <20191212152406.GB2827@hirez.programming.kicks-ass.net> References: <20191212144102.181510-1-cj.chengjian@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191212144102.181510-1-cj.chengjian@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 12, 2019 at 10:41:02PM +0800, Cheng Jian wrote: > Fixes: 1ad3aaf3fcd2 ("sched/core: Implement new approach to scale select_idle_cpu()") The 'funny' thing is that select_idle_core() actually does the right thing. Copying that should work: diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 08a233e97a01..416d574dcebf 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5828,6 +5837,7 @@ static inline int select_idle_smt(struct task_struct *p, int target) */ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int target) { + struct cpumask *cpus = this_cpu_cpumask_var_ptr(select_idle_mask); struct sched_domain *this_sd; u64 avg_cost, avg_idle; u64 time, cost; @@ -5859,11 +5869,11 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t time = cpu_clock(this); - for_each_cpu_wrap(cpu, sched_domain_span(sd), target) { + cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr); + + for_each_cpu_wrap(cpu, cpus, target) { if (!--nr) return si_cpu; - if (!cpumask_test_cpu(cpu, p->cpus_ptr)) - continue; if (available_idle_cpu(cpu)) break; if (si_cpu == -1 && sched_idle_cpu(cpu))