Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3469486pxb; Sat, 9 Oct 2021 11:12:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh8FCqx6ilPI3tD9eDaLzn71VmNUnkjLTv3gGlzS2cie/8H/vOqJd8OZ1GzP/fTe0vJm+M X-Received: by 2002:a17:906:c0d4:: with SMTP id bn20mr13393796ejb.360.1633803126222; Sat, 09 Oct 2021 11:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633803126; cv=none; d=google.com; s=arc-20160816; b=qj0hUlQcH4ehqCpZgnhVrM/GihxfC4PWB6CJUeiOudoioECfPOprQwIZUqiaxq+gZ1 3ozmBXIpG9F/X5R1o5XZQ7utHKmKtXcRmTC/ap0moXQfzfwOnYifefDd06pgcDxCibJ2 6BEXJtsT2EfVol6ZBHQsoeJkB3UF4Eh2/4xhtktlvM9llsrXLPWiUpOfoCYrkXvrqXlj EMzxJeZqDC0zIbg1OwVxRwHWtJIsAXYnsWFzmuT19Hq4y+MOrf+ym3ZxgdJ9mRePV5j2 pDVQozF67RdOMJ870BvnMkrJqOw48+i3Jr40EllVlwgT+5PuRPHWP8iRN02g7UT9GUai oxIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=rGXt4f7CdKbPRXq7mN3AyHsL8/pu8WFZGYmQ2fHzFGc=; b=x1OZSOsoEU8DKykOAb0X74ymUv/g3cPiGi0rQkGp158SXFvmqCO1lrCSmn28luQKKg KRWQYDbCmTsYzTlloE0tslL9eGbORk7GYuC7c9D275JeK451dvLf1otSPMFz9uJAG808 /+6hc/jgHYq09yZs/1WPBFEO+05P2181wviZtUQh3zU/ksIFtorVC/wgPjUmSSu7IE5G a55b5abvZV0ztzR5adsuVjTYWfcjNKDEa6y0X8+dUSEEqwm0WgSIaXBtkuppif9vLul1 2WJ549T83X7rXKdbrgtFQJfagKFI5Qj8ZbhW9tsfU5ejIdtT3M+KYSqY0j6fQ5mAJRCx HPvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vqxQWXHW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v23si4134863ejh.759.2021.10.09.11.11.42; Sat, 09 Oct 2021 11:12:06 -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=@linux.dev header.s=key1 header.b=vqxQWXHW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230074AbhJISLo (ORCPT + 99 others); Sat, 9 Oct 2021 14:11:44 -0400 Received: from out0.migadu.com ([94.23.1.103]:45365 "EHLO out0.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230070AbhJISLn (ORCPT ); Sat, 9 Oct 2021 14:11:43 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1633802984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=rGXt4f7CdKbPRXq7mN3AyHsL8/pu8WFZGYmQ2fHzFGc=; b=vqxQWXHWxgtW4qmbOKuceom2R1J87crdKP0gtnOPbJ8yxbyWQvcS4FCQuK8t9pEL6u6vB1 KXAw2N/9GDxSm2VSFwbz4vc0p1RbOUey5nA7kyrDfVyf/gjxUdC0TKBI0r4e+5ULXRXBrl YUcKJ902kvt53XPDX1gqXqA+331lfEw= From: Tao Zhou To: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira Cc: Tao Zhou Subject: [PATCH] sched/fair: Check idle_cpu in select_idle_core/cpu() Date: Sun, 10 Oct 2021 02:09:41 +0800 Message-Id: <20211009180941.20458-1-tao.zhou@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: tao.zhou@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; 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); if (sched_feat(SIS_PROP) && !has_idle_core) { -- 2.32.0