Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp971147ybl; Thu, 12 Dec 2019 07:45:22 -0800 (PST) X-Google-Smtp-Source: APXvYqyhxMjiSIZQrC3z3FAZBP/2sflrgnasbYjQCQbpTrqWCxPXtGEPiTu+2909dZHB3oLP3ByU X-Received: by 2002:aca:4d4f:: with SMTP id a76mr5595039oib.26.1576165522188; Thu, 12 Dec 2019 07:45:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576165522; cv=none; d=google.com; s=arc-20160816; b=0ZX7NdRJRPeGS9goBVx5vJM0Dbbd+Wq8qt5MN9i0qRIPLT3MzI1RQgaNu0YOjVkeUp igvQZG3gkV6qM0c7Z2y9FWyVHDUL+iz7PhEf2JNjpjYwbQ/EQDjABBIYWszei2O2MFKr R/vdBEQZLmJitw5P5qk616vJjIhqDRMCQxxnSA3TvyYdcbBKzxtwoD6pPbz6oC5Vi1kd 7LChWtp5iYVjG/i0TXQto5Td86gJFway8+6X+j7ZDRKJdM+D679Tb78RV647iOxD6TMn YujrNyBuVcv2Qge3V+hGMdbCh78kj8lwhbdPygbVWlbAz1fQQMDDLHn+HdldZpUbbNVH Tzug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=dZonKolqSXBRSfZVH50TL8fVYb6UNvvjTNFtWRd/JSU=; b=LZN/9qxEkw6/SmS5DMTQ5b//yhLVNwN5RG2VoHrfbwgsJMDNsriZ0U+Oj95zUZj9D1 C/s2f2MCqTSyGX3eYjlFUkvZ/WTEpcZ7igDWps5EP0upeMMMXFtaOH1vzHg1Fhj2tNO1 qSPcQEttFilnjaO7+XECPdFyy+xD/pxnEuv+29B56+rJLSVlbp5jA6GBvaTpGSbuCys2 jpNinYeuGsQer2dCFGZ11c479bH4bQFzHHEEBM9SJNrEbDJcwi3VVpiepVfdgrMwzEym kxuYoGZfdnbLyhrw+OKXp73+LeY+H5jX5ud8iG0btbSIXwEb9dH351qCT4dpYa2rQSJK /8lA== ARC-Authentication-Results: i=1; mx.google.com; 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 z3si3047541oib.164.2019.12.12.07.45.09; Thu, 12 Dec 2019 07:45:22 -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; 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 S1729424AbfLLPo3 (ORCPT + 99 others); Thu, 12 Dec 2019 10:44:29 -0500 Received: from foss.arm.com ([217.140.110.172]:51206 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729152AbfLLPo3 (ORCPT ); Thu, 12 Dec 2019 10:44:29 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E55B530E; Thu, 12 Dec 2019 07:44:28 -0800 (PST) Received: from [10.1.194.37] (e113632-lin.cambridge.arm.com [10.1.194.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 93E793F6CF; Thu, 12 Dec 2019 07:44:27 -0800 (PST) Subject: Re: [PATCH] sched/fair: Optimize select_idle_cpu To: Peter Zijlstra , 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 References: <20191212144102.181510-1-cj.chengjian@huawei.com> <20191212152406.GB2827@hirez.programming.kicks-ass.net> From: Valentin Schneider Message-ID: <2498b792-8549-5ffd-0d85-179740e356a0@arm.com> Date: Thu, 12 Dec 2019 15:44:26 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191212152406.GB2827@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/12/2019 15:24, Peter Zijlstra wrote: > 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)) > That looks sane enough. I'd only argue the changelog should directly point out that the issue is we consume some CPUs out of 'nr' that are not allowed for the task and thus waste our attempts.