Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1431078ybx; Thu, 31 Oct 2019 10:28:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5NIrtkM0TuGfLZEfYWQmP7UgZIC4JlAsHr+GpoOXuEkGqrzBHP0e1yEbCu48+nUJzaRAo X-Received: by 2002:aa7:c44e:: with SMTP id n14mr7484216edr.162.1572542913852; Thu, 31 Oct 2019 10:28:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572542913; cv=none; d=google.com; s=arc-20160816; b=AxLQd0tk4qFrbkbFUZ3JKJm9rssPDvhtlS2LW1ptmlvfSm97e8sNX0z1YyRpmrHqdM aC90adqpJstUZkjwX7pWszVJEiTQIdtnA7Lc7SNIT8uxwMfFGGSyp9iLn5gYFR2jVer8 r6iEdi4WkrJcj6BFQy7eBD7EX2QB1De3J2QVE7vQWqyYYH3iw42BSY45bKz/g97fZ5tC X74+s+bsZtl/px5+K8XcTi3QbMa0i+x5hDETx3XCdCWGCSyNdhhohcWL4jnVzmnFruyz Yz01rl0Scy7iza9XQIeOz7trnDk8U7oTOM0rYJQHb70CaLGIZcah5VB5nEAotD4JBgPz P3+A== 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=bzKNVgqZiPlPUKIV7/1D7QQOPnaMKf0KzIMZ5hG/W34=; b=SFQt0ijtD6B+F3rk/3S+OYvEldH465O9cpdw9ybP4j+UXJYi3PZHK4jquyE3Gwrpiw gtRU08q0kNZs1SsdXJJ6rOXhoNKH9WWqRJXaDg8EMpJRYD5VPFKkQsC2zdSkv4sKbhv1 thFgMmUwDd0DgZy4n0TuCKDkGoq3/alHGCzz+9AV5sJWF8jhMSg/haSDJ+4W2HoY9uS5 mqaYBi5inKycIiIA3f29bP+eZSCclCK86LqHdlpmU3ruXhJuif0EtZmlWDpRjK0zXy4O yBYWI6MmgsXLUKZ9zKUiBKYPirR+VqPiPZx3lbCKMaJlE/8ZkhAHHyZhmv+EMtVlYDqZ aYXA== 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 g4si5161828edj.263.2019.10.31.10.28.10; Thu, 31 Oct 2019 10:28:33 -0700 (PDT) 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 S1728952AbfJaRXY (ORCPT + 99 others); Thu, 31 Oct 2019 13:23:24 -0400 Received: from foss.arm.com ([217.140.110.172]:52846 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728655AbfJaRXY (ORCPT ); Thu, 31 Oct 2019 13:23:24 -0400 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 3DEEB1FB; Thu, 31 Oct 2019 10:23:23 -0700 (PDT) Received: from [10.188.222.161] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8C35D3F6C4; Thu, 31 Oct 2019 10:23:21 -0700 (PDT) Subject: Re: [PATCH v4 1/2] sched/topology: Don't try to build empty sched domains To: =?UTF-8?Q?Michal_Koutn=c3=bd?= Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, lizefan@huawei.com, tj@kernel.org, hannes@cmpxchg.org, mingo@kernel.org, peterz@infradead.org, vincent.guittot@linaro.org, Dietmar.Eggemann@arm.com, morten.rasmussen@arm.com, qperret@google.com, stable@vger.kernel.org References: <20191023153745.19515-1-valentin.schneider@arm.com> <20191023153745.19515-2-valentin.schneider@arm.com> <20191031162334.GA18570@blackbody.suse.cz> From: Valentin Schneider Message-ID: <3752bca9-a670-f415-4aaa-e8ff75ea6fcc@arm.com> Date: Thu, 31 Oct 2019 18:23:12 +0100 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: <20191031162334.GA18570@blackbody.suse.cz> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michal, On 31/10/2019 17:23, Michal Koutn? wrote: > On Wed, Oct 23, 2019 at 04:37:44PM +0100, Valentin Schneider wrote: >> Prevent generate_sched_domains() from returning empty cpumasks, and add >> some assertion in build_sched_domains() to scream bloody murder if it >> happens again. > Good catch. It makes sense to prune the empty domains in > generate_sched_domains already. > >> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c >> index c52bc91f882b..c87ee6412b36 100644 >> --- a/kernel/cgroup/cpuset.c >> +++ b/kernel/cgroup/cpuset.c >> @@ -798,7 +798,8 @@ static int generate_sched_domains(cpumask_var_t **domains, >> cpumask_subset(cp->cpus_allowed, top_cpuset.effective_cpus)) >> continue; >> >> - if (is_sched_load_balance(cp)) >> + if (is_sched_load_balance(cp) && >> + !cpumask_empty(cp->effective_cpus)) >> csa[csn++] = cp; > If I didn't overlook anything, cp->effective_cpus can contain CPUs > exluded by housekeeping_cpumask(HK_FLAG_DOMAIN) later, i.e. possibly > still returning domains with empty cpusets. > > I'd suggest moving the emptiness check down into the loop where domain > cpumasks are ultimately constructed. > Ah, wasn't aware of this - thanks for having a look! I think I need to have the check before the final cpumask gets built, because at this point the cpumask array is already built and it's handed off directly to the sched domain rebuild. Do you reckon the following would work? ----8<---- diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index c87ee6412b36..e4c10785dc7c 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -798,8 +798,14 @@ static int generate_sched_domains(cpumask_var_t **domains, cpumask_subset(cp->cpus_allowed, top_cpuset.effective_cpus)) continue; + /* + * Skip cpusets that would lead to an empty sched domain. + * That could be because effective_cpus is empty, or because + * it's only spanning CPUs outside the housekeeping mask. + */ if (is_sched_load_balance(cp) && - !cpumask_empty(cp->effective_cpus)) + cpumask_intersects(cp->effective_cpus, + housekeeping_cpumask(HK_FLAG_DOMAIN))) csa[csn++] = cp; /* skip @cp's subtree if not a partition root */