Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4683027ybg; Tue, 29 Oct 2019 10:48:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZ0spbtu8uBTNG/Or5RfiEOd7TL1ANjMFbNzJ2r4ERY9MlaozIn/P9NOLagJvZWtbtA5K+ X-Received: by 2002:a17:906:bcfb:: with SMTP id op27mr4634558ejb.59.1572371339793; Tue, 29 Oct 2019 10:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572371339; cv=none; d=google.com; s=arc-20160816; b=WulFVIZP5iucEiYXeG5/OJ2OKvrX4qTEQjHH/yTSc1wOkBwyGMsctDj7bo20NWiV6l wCVBApxXimSA8jT6srKkYQPN+CWBe7a3+WgYHHZmdoXkrzCl0ykIOarTEvAZ7LxifxwF QAQVD1H7dhuPtfiLypaagqLK+idvnNrHq8sy+Xw5F19BXsHN+c8zT1vPGiKfRPIW/PWe 0qjoezL/XxmSsQIOjUsaqLGMnnPC8ycmAfr9dAiuGwJhB6sdVIGfq1dEdEJ2UnVYfVQX CL1hNZWtONHCzn0jqEGXR1igGNTlDp1Z+pyDeBnmbu2BOAPZ6apKbenOnbNADp0Wvwqu GOcQ== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=qL3tayF7gEy+o8PtyAKfVFXYbdIrUzNQYqI9u0vSqEQ=; b=r3WGgLhzFIxQMnTKsbhaknUzDNlzuKgIIrgc6iEpKWHTPE04QXe8roqOl+EcoS5FlS iHStfY9QwlMv3ie3uVYDG3bWsRCej8tXSbjEjU+eJBEaqELENisFMas8u88jYCDWPWN8 nC3l3mLZo34t4bbR2rLPlZF289isntWb7jnkb+8Rewm9rNL4Xu+f38TiZidQ6PrZiQ2c fyI1Ny2q0bM/43lg/KE45fLIu5PKq8FG7Htp8DryrdBO3A/gQDhyyGa3/14wcWFfgaFI 3MGsAkeT9Xm+WkbrsKszBAG6ivXRg7utlksrJywjyCODN+yUDk5fzeEVFTT4JubB4a9d m+eg== 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 i47si10942593eda.91.2019.10.29.10.48.36; Tue, 29 Oct 2019 10:48:59 -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 S1729503AbfJ2Jwa (ORCPT + 99 others); Tue, 29 Oct 2019 05:52:30 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:47697 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726912AbfJ2Jw3 (ORCPT ); Tue, 29 Oct 2019 05:52:29 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iPOAk-0004MA-Hl; Tue, 29 Oct 2019 10:52:18 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 230E71C047B; Tue, 29 Oct 2019 10:52:18 +0100 (CET) Date: Tue, 29 Oct 2019 09:52:17 -0000 From: "tip-bot2 for Valentin Schneider" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/topology: Don't try to build empty sched domains Cc: Valentin Schneider , "Peter Zijlstra (Intel)" , Dietmar.Eggemann@arm.com, Linus Torvalds , Thomas Gleixner , hannes@cmpxchg.org, lizefan@huawei.com, morten.rasmussen@arm.com, qperret@google.com, tj@kernel.org, vincent.guittot@linaro.org, Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <20191023153745.19515-2-valentin.schneider@arm.com> References: <20191023153745.19515-2-valentin.schneider@arm.com> MIME-Version: 1.0 Message-ID: <157234273774.29376.13053377889800055975.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/urgent branch of tip: Commit-ID: cd1cb3350561d2bf544ddfef76fbf0b1c9c7178f Gitweb: https://git.kernel.org/tip/cd1cb3350561d2bf544ddfef76fbf0b1c9c7178f Author: Valentin Schneider AuthorDate: Wed, 23 Oct 2019 16:37:44 +01:00 Committer: Ingo Molnar CommitterDate: Tue, 29 Oct 2019 09:58:45 +01:00 sched/topology: Don't try to build empty sched domains Turns out hotplugging CPUs that are in exclusive cpusets can lead to the cpuset code feeding empty cpumasks to the sched domain rebuild machinery. This leads to the following splat: Internal error: Oops: 96000004 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 235 Comm: kworker/5:2 Not tainted 5.4.0-rc1-00005-g8d495477d62e #23 Hardware name: ARM Juno development board (r0) (DT) Workqueue: events cpuset_hotplug_workfn pstate: 60000005 (nZCv daif -PAN -UAO) pc : build_sched_domains (./include/linux/arch_topology.h:23 kernel/sched/topology.c:1898 kernel/sched/topology.c:1969) lr : build_sched_domains (kernel/sched/topology.c:1966) Call trace: build_sched_domains (./include/linux/arch_topology.h:23 kernel/sched/topology.c:1898 kernel/sched/topology.c:1969) partition_sched_domains_locked (kernel/sched/topology.c:2250) rebuild_sched_domains_locked (./include/linux/bitmap.h:370 ./include/linux/cpumask.h:538 kernel/cgroup/cpuset.c:955 kernel/cgroup/cpuset.c:978 kernel/cgroup/cpuset.c:1019) rebuild_sched_domains (kernel/cgroup/cpuset.c:1032) cpuset_hotplug_workfn (kernel/cgroup/cpuset.c:3205 (discriminator 2)) process_one_work (./arch/arm64/include/asm/jump_label.h:21 ./include/linux/jump_label.h:200 ./include/trace/events/workqueue.h:114 kernel/workqueue.c:2274) worker_thread (./include/linux/compiler.h:199 ./include/linux/list.h:268 kernel/workqueue.c:2416) kthread (kernel/kthread.c:255) ret_from_fork (arch/arm64/kernel/entry.S:1167) Code: f860dae2 912802d6 aa1603e1 12800000 (f8616853) The faulty line in question is: cap = arch_scale_cpu_capacity(cpumask_first(cpu_map)); and we're not checking the return value against nr_cpu_ids (we shouldn't have to!), which leads to the above. Prevent generate_sched_domains() from returning empty cpumasks, and add some assertion in build_sched_domains() to scream bloody murder if it happens again. The above splat was obtained on my Juno r0 with the following reproducer: $ cgcreate -g cpuset:asym $ cgset -r cpuset.cpus=0-3 asym $ cgset -r cpuset.mems=0 asym $ cgset -r cpuset.cpu_exclusive=1 asym $ cgcreate -g cpuset:smp $ cgset -r cpuset.cpus=4-5 smp $ cgset -r cpuset.mems=0 smp $ cgset -r cpuset.cpu_exclusive=1 smp $ cgset -r cpuset.sched_load_balance=0 . $ echo 0 > /sys/devices/system/cpu/cpu4/online $ echo 0 > /sys/devices/system/cpu/cpu5/online Signed-off-by: Valentin Schneider Signed-off-by: Peter Zijlstra (Intel) Cc: Dietmar.Eggemann@arm.com Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: hannes@cmpxchg.org Cc: lizefan@huawei.com Cc: morten.rasmussen@arm.com Cc: qperret@google.com Cc: tj@kernel.org Cc: vincent.guittot@linaro.org Fixes: 05484e098448 ("sched/topology: Add SD_ASYM_CPUCAPACITY flag detection") Link: https://lkml.kernel.org/r/20191023153745.19515-2-valentin.schneider@arm.com Signed-off-by: Ingo Molnar --- kernel/cgroup/cpuset.c | 3 ++- kernel/sched/topology.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index c52bc91..c87ee64 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; /* skip @cp's subtree if not a partition root */ diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index b5667a2..9318acf 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -1948,7 +1948,7 @@ next_level: static int build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *attr) { - enum s_alloc alloc_state; + enum s_alloc alloc_state = sa_none; struct sched_domain *sd; struct s_data d; struct rq *rq = NULL; @@ -1956,6 +1956,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att struct sched_domain_topology_level *tl_asym; bool has_asym = false; + if (WARN_ON(cpumask_empty(cpu_map))) + goto error; + alloc_state = __visit_domain_allocation_hell(&d, cpu_map); if (alloc_state != sa_rootdomain) goto error;