Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp132755pxb; Sat, 9 Oct 2021 15:54:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypUW+Bf3Ja9sTrzh+YtAjVB7OiqUI3n3issZ/Ru3p/cWz7Q/fsMsTHnd9D3v7uFSMVFe1w X-Received: by 2002:a17:906:f184:: with SMTP id gs4mr14862063ejb.116.1633820042725; Sat, 09 Oct 2021 15:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633820042; cv=none; d=google.com; s=arc-20160816; b=wIVsaLSHaZNZDS00XLj+xEp/OUj/KpfoF5NA9yaAWLwXyxreQssjqGrHcaf5cXsUr/ HIU/dsID6mq3+r56GuWwqxJr4GMys+NeOzw1zzxZF1W5O2VdT2zg/F944mE6hIdNcviF 1Vjf541QogkU7hxT7QblA8luCWj8nQXqHs0Jz5BVlg7C1REEO0Y2BWkyX0KDVnbhdU3E BXbWU84FGDYVVas8fXHd80BSdovPw5Al4vOOd1ZtdbdWZQZ/cNVKh2jKlFJg/GQO3KA5 bvUvZknSfYS9a+peAcvIN8shI4nUmwhXgEOp2GuZ7EqfoMq7ec3cOOOpvJZlz5OPsOQm /b4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HlKWYN2dw8uuQPxr2tgsDfcykAdf/apHp3S9FQkV370=; b=wZ2PP1/vof9H4VP2GjwfH3uFtbb2WYbZ8kJvaoufj64I+AEmDCZpgwN1QXg3aSRxRu HivqR/wsI2/vDoDcUbutYKnXzTYdCa7f4fJx4ILrHqv8UyNpUkJ7m/NKElzJbal8Wg70 Zsm8ReWzPTGw/o/F29EQ0BSLI+pmD0Y2XsApkQmwfUwsw5pQLtlJHw+74cLARxxuqcBt 8e/g6BsPBngt45xR8L+Q7aZ6kc9/x2Suwry+uQKE/8WK1R/X7gbTd1pstlxsKBOp4IYH pMn9eiUKOZcvyRvmAPVs7nL1+OfHlDrBb8vc9gXHUAiart2rnpcCyex2EU0ZPf/Xzp77 q4TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qk9H63Eq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p25si6152389edu.254.2021.10.09.15.53.39; Sat, 09 Oct 2021 15:54:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qk9H63Eq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231139AbhJIWyW (ORCPT + 99 others); Sat, 9 Oct 2021 18:54:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230296AbhJIWyS (ORCPT ); Sat, 9 Oct 2021 18:54:18 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B6AFC061570 for ; Sat, 9 Oct 2021 15:52:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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; bh=HlKWYN2dw8uuQPxr2tgsDfcykAdf/apHp3S9FQkV370=; b=qk9H63EqlV+cMSj2hs8OSZ5oac RtLNYC37cNC862LycoSvAKYfUanYEXUG9Det5ZBNgpP98WCYlwhsERVwlJLbfUYItiX7wzoeLTKVv swRoqZgcvoO5HBHXijyx71h0r+Z2IctlwhtuksO/1HfO1a1Renjx5O9kNvNXseoJV1SJ39QLmDgTI FjIYaG/a1/feq0Z9kTpHvlbt2NHb66HF2Hqfwu2UFnha2CIAFP2FT/7tH5YLMriDErMpk08Yagi/n XlLDvKtXpSySU/KGObNuAejiBxzk/vVmqzao2YoLVwhVS5tPzNnInsm1NEjiz384fomLpIV/lCTwm fdE7z7FQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZLBB-004SNm-LJ; Sat, 09 Oct 2021 22:51:09 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 414639811D4; Sun, 10 Oct 2021 00:50:57 +0200 (CEST) Date: Sun, 10 Oct 2021 00:50:57 +0200 From: Peter Zijlstra To: Tao Zhou Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira Subject: Re: [PATCH] sched/fair: Check idle_cpu in select_idle_core/cpu() Message-ID: <20211009225057.GB174703@worktop.programming.kicks-ass.net> References: <20211009180941.20458-1-tao.zhou@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211009180941.20458-1-tao.zhou@linux.dev> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 10, 2021 at 02:09:41AM +0800, Tao Zhou wrote: > In select_idle_core(), the idle core returned may have no cpu > allowed. I think the idle core returned for the task is the one > that can be allowed to run. I insist on this semantics. > > In select_idle_cpu(), if select_idle_core() can not find the > idle core, one reason is that the core is not allowed for the > task, but the core itself is idle from the point of > sds->has_idle_cores. I insist on this semantics. > > No others, just two additional check. > --- > kernel/sched/fair.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index f6a05d9b5443..a44aca5095d3 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6213,7 +6213,7 @@ static int select_idle_core(struct task_struct *p, int core, struct cpumask *cpu > *idle_cpu = cpu; > } > > - if (idle) > + if (idle && *idle_cpu != -1) > return core; In that case, core would be nr_cpu_ids (==nr_cpumask_bits), and then the caller checks: (unsigned)i < nr_cpumask_bits > cpumask_andnot(cpus, cpus, cpu_smt_mask(core)); > @@ -6324,7 +6324,7 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, bool > } > } > > - if (has_idle_core) > + if (has_idle_core && *idle_cpu != -1) > set_idle_cores(target, false); And this one I'm completely failing, why shouldn't we mark the core as non-idle when there is a single idle CPU found? That's just worng.