Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2038207pxu; Tue, 24 Nov 2020 15:29:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJ08zDZ6UKhlVEDRaN3wNqfsqezBunPSR63pLVMdivNiPyP+qhvah+FWfUGs2BykzsnMuN X-Received: by 2002:aa7:c2d6:: with SMTP id m22mr936171edp.368.1606260589265; Tue, 24 Nov 2020 15:29:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606260589; cv=none; d=google.com; s=arc-20160816; b=bUJKsimV9bDYPdiB3vKh+gEfIzuBZ9KArBXmb9D/Hmmua5L8v0kcH34wRNyVm3RJV5 Cl/f1mW+Lc214IzYxws6R8oEYcAPLP9xdTLxMPX27CMgAOd8XnKiC7ygf3uMUeKZvk4w U0IaiIUX3T7yEJxfhOWSQ0Ni7PYwd6Az4BBS4M6Y4RjPQf0BJTUTQ1xBSJNa//EouuVI y0MKk8T693MTyj+dzGntwhTznak3q6qGoMahcmpZBUmNz+RmoHVDlQwRD2mZjRw6sZ43 6qnLf7uHjZuM1dkeBlVZnteMhUq0v9Nihnl97ddk/oaNOO6LXUgkOoG31JuTytOahX7b 7xIQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=T53L/IcecfSHpWWcTQZH/LjMxkgsiL2gEMmrDhdR4u0=; b=fOV7mL8k3+o/OiahN9fOjz94VcKcT4go+18Jh9PzGXVM9h/sG5FPBTDhIHkF0DB5zd OsuMdXkSGPsJuQ/7sufEn1VnuCb7AQWzi2XOhyX5aQ91g+tWIXk9vaFyXa0Y4S5u6uXq YEBnlV5s/4hyBv8xIfueHPJPhaWxt1r7ZL2lDIFSUP3fJvF/uDXhRJC+mYHKzD/pKHpE XuOdQuxs3CYhyRM34jfwFLqeUN5FMYA4aOytZ+292nQI7AggXnYPFnl4FuOUMTrBCtSJ J6vu5C0SYtzc/FMzBgcQwbSWpYD3UOt+kBNLWIaMg/sUDYSDIvDBrxh1fWiFz7GMt2CE /PPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uALVM0o5; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s8si127118edh.227.2020.11.24.15.29.25; Tue, 24 Nov 2020 15:29:49 -0800 (PST) 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=@kernel.org header.s=default header.b=uALVM0o5; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390032AbgKXPve (ORCPT + 99 others); Tue, 24 Nov 2020 10:51:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:50982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390021AbgKXPvb (ORCPT ); Tue, 24 Nov 2020 10:51:31 -0500 Received: from localhost.localdomain (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 719FB20715; Tue, 24 Nov 2020 15:51:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606233090; bh=hvH0BE8HcbG7lVb8mNQA+knlFSJMTK3LFJTOseuTpTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uALVM0o5VTC1bEZE7HljUehIrSGkGIlXnv3WnV39BUUO6g21zUzScbYwWj8iSjxBz vXR7+cB4N/3LL/zD3pg6DPnFILnNi4+Tz+THSfFk/P6ZbFRCR0u2O349UG5N2ky7YC dFb0aZIz9ETLvNWw1xWlUgkrEzcSoKCFavG+23Ns= From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Will Deacon , Catalin Marinas , Marc Zyngier , Greg Kroah-Hartman , Peter Zijlstra , Morten Rasmussen , Qais Yousef , Suren Baghdasaryan , Quentin Perret , Tejun Heo , Li Zefan , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , kernel-team@android.com Subject: [PATCH v4 10/14] sched: Introduce arch_task_cpu_possible_mask() to limit fallback rq selection Date: Tue, 24 Nov 2020 15:50:35 +0000 Message-Id: <20201124155039.13804-11-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201124155039.13804-1-will@kernel.org> References: <20201124155039.13804-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Asymmetric systems may not offer the same level of userspace ISA support across all CPUs, meaning that some applications cannot be executed by some CPUs. As a concrete example, upcoming arm64 big.LITTLE designs do not feature support for 32-bit applications on both clusters. On such a system, we must take care not to migrate a task to an unsupported CPU when forcefully moving tasks in select_fallback_rq() in response to a CPU hot-unplug operation. Introduce an arch_task_cpu_possible_mask() hook which, given a task argument, allows an architecture to return a cpumask of CPUs that are capable of executing that task. The default implementation returns the cpu_possible_mask, since sane machines do not suffer from per-cpu ISA limitations that affect scheduling. The new mask is used when selecting the fallback runqueue as a last resort before forcing a migration to the first active CPU. Reviewed-by: Quentin Perret Signed-off-by: Will Deacon --- kernel/sched/core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 818c8f7bdf2a..99992d0beb65 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1696,6 +1696,11 @@ void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags) #ifdef CONFIG_SMP +/* Must contain at least one active CPU */ +#ifndef arch_task_cpu_possible_mask +#define arch_task_cpu_possible_mask(p) cpu_possible_mask +#endif + /* * Per-CPU kthreads are allowed to run on !active && online CPUs, see * __set_cpus_allowed_ptr() and select_fallback_rq(). @@ -1708,7 +1713,10 @@ static inline bool is_cpu_allowed(struct task_struct *p, int cpu) if (is_per_cpu_kthread(p)) return cpu_online(cpu); - return cpu_active(cpu); + if (!cpu_active(cpu)) + return false; + + return cpumask_test_cpu(cpu, arch_task_cpu_possible_mask(p)); } /* @@ -2361,10 +2369,9 @@ static int select_fallback_rq(int cpu, struct task_struct *p) } fallthrough; case possible: - do_set_cpus_allowed(p, cpu_possible_mask); + do_set_cpus_allowed(p, arch_task_cpu_possible_mask(p)); state = fail; break; - case fail: BUG(); break; -- 2.29.2.454.gaff20da3a2-goog