Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2108582pxa; Mon, 24 Aug 2020 05:32:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7CncZNGS53AfbQ4kQW7BxgnCAtwNot8qoRs8olBWhbZLRAMluxD3lnQinHT+bumsj8ZeW X-Received: by 2002:a17:907:9ed:: with SMTP id ce13mr5198349ejc.180.1598272342556; Mon, 24 Aug 2020 05:32:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598272342; cv=none; d=google.com; s=arc-20160816; b=qoG+nAO2qSJPla47w5urm4iecDDsepT9F+SBvOs0VtRbs+804TPeggEaWyI5sPHrkg Xz61QxUW9mnICSMKtKAGUUkolSRVL02meDDh0jAOktHBA389Ynv2urtm6akQndOEhYXF Q6gWeLC8/OK8O2JW3nBKsNwdVoBeZHIwARpVbeTUG7IGTjXN/WsnbaNaxqXPYLPGreFi AzKDr/VQnxeOQ7Jdm5ssKDuqq6n9LisVaC07695gs2G5sgbuDZrxC3uanuv/T/e2k0bo B3/u7MlKgxU9ztLc3SCgXuhQAQ9/7bNzcPWrUtVK70cS5FKGv/fqm2lq1uTZ1x4mpuYJ Woqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=RbpFRjfIyzI8wjQnOL22slhtww0BJXVPwQD5ZdGAhqc=; b=v0Xrf+9XmouKvZsVoipFa0x1rs+MJQ9NZJBgwqop8D0DtYWr7ryMS3EbUlXmZHe0in eyxS88xXob0wfXJcrWabp8CWIHzyiSf2f9+DoyPtDnkIwSqUBq9dxK5eGcZKS4gneq1c 0QSbU2tMc2HaHK7Xa1Fxx0FZ7Am4LnMdT2mcDSK8LGcoPH+fw4ptps36T6ghogzhWHZB F4ZTTKbUkRbOM0gdJsgX+4ud5dkWF5/kp1KqfJW10HPlRDV4ryxCdwFC1ncfjpsBp6RY 8dobZCkW+8ouOy6vzAbi0RIka7elRS2Uq92uclo9aiQrG9H/diBFjuHxkcvLUMnDhKOY Ynmg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si6638069edv.224.2020.08.24.05.31.58; Mon, 24 Aug 2020 05:32:22 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727042AbgHXMbM (ORCPT + 99 others); Mon, 24 Aug 2020 08:31:12 -0400 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:53200 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727000AbgHXMbB (ORCPT ); Mon, 24 Aug 2020 08:31:01 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04397;MF=xlpang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0U6k8x2u_1598272219; Received: from localhost(mailfrom:xlpang@linux.alibaba.com fp:SMTPD_---0U6k8x2u_1598272219) by smtp.aliyun-inc.com(127.0.0.1); Mon, 24 Aug 2020 20:30:51 +0800 From: Xunlei Pang To: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Juri Lelli , Wetp Zhang Cc: linux-kernel@vger.kernel.org Subject: [PATCH] sched/fair: Fix wrong cpu selecting from isolated domain Date: Mon, 24 Aug 2020 20:30:19 +0800 Message-Id: <1598272219-43040-1-git-send-email-xlpang@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We've met problems that occasionally tasks with full cpumask (e.g. by putting it into a cpuset or setting to full affinity) were migrated to our isolated cpus in production environment. After some analysis, we found that it is due to the current select_idle_smt() not considering the sched_domain mask. Fix it by checking the valid domain mask in select_idle_smt(). Fixes: 10e2f1acd010 ("sched/core: Rewrite and improve select_idle_siblings()) Reported-by: Wetp Zhang Signed-off-by: Xunlei Pang --- kernel/sched/fair.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 1a68a05..fa942c4 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6075,7 +6075,7 @@ static int select_idle_core(struct task_struct *p, struct sched_domain *sd, int /* * Scan the local SMT mask for idle CPUs. */ -static int select_idle_smt(struct task_struct *p, int target) +static int select_idle_smt(struct task_struct *p, struct sched_domain *sd, int target) { int cpu; @@ -6083,7 +6083,8 @@ static int select_idle_smt(struct task_struct *p, int target) return -1; for_each_cpu(cpu, cpu_smt_mask(target)) { - if (!cpumask_test_cpu(cpu, p->cpus_ptr)) + if (!cpumask_test_cpu(cpu, p->cpus_ptr) || + !cpumask_test_cpu(cpu, sched_domain_span(sd))) continue; if (available_idle_cpu(cpu) || sched_idle_cpu(cpu)) return cpu; @@ -6099,7 +6100,7 @@ static inline int select_idle_core(struct task_struct *p, struct sched_domain *s return -1; } -static inline int select_idle_smt(struct task_struct *p, int target) +static inline int select_idle_smt(struct task_struct *p, struct sched_domain *sd, int target) { return -1; } @@ -6274,7 +6275,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target) if ((unsigned)i < nr_cpumask_bits) return i; - i = select_idle_smt(p, target); + i = select_idle_smt(p, sd, target); if ((unsigned)i < nr_cpumask_bits) return i; -- 1.8.3.1