From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40EB3C388F9 for ; Thu, 19 Nov 2020 11:07:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA3E4246EE for ; Thu, 19 Nov 2020 11:07:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="pLRb0ge/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726866AbgKSLHT (ORCPT ); Thu, 19 Nov 2020 06:07:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:33350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726580AbgKSLHS (ORCPT ); Thu, 19 Nov 2020 06:07:18 -0500 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1C08C22248; Thu, 19 Nov 2020 11:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605784037; bh=+WwDHFmhE9MS11P7KUuWkxiPo6fvIEVugJhgXLZJcR0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pLRb0ge/P3ZJCh1BzFlpiY5cYssXpnuUKk5rQraPQgkYekjSdJIH+GG7/ythHuLFu /wK8Q88KDTgfi36pa6wtpoFZec5+heJzw2pFzr6rQqgUzYw+1IWA/ZmWrkT9GXWXtF Lr3+RfK/JFkN8imWgqExNyP4UOh6LX4kKZHKiEjI= Date: Thu, 19 Nov 2020 11:07:09 +0000 From: Will Deacon To: Quentin Perret Cc: linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , Marc Zyngier , Greg Kroah-Hartman , Peter Zijlstra , Morten Rasmussen , Qais Yousef , Suren Baghdasaryan , Tejun Heo , Li Zefan , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , kernel-team@android.com Subject: Re: [PATCH v3 10/14] sched: Introduce arch_cpu_allowed_mask() to limit fallback rq selection Message-ID: <20201119110709.GD3946@willie-the-truck> References: <20201113093720.21106-1-will@kernel.org> <20201113093720.21106-11-will@kernel.org> <20201119093850.GD2416649@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201119093850.GD2416649@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 19, 2020 at 09:38:50AM +0000, Quentin Perret wrote: > On Friday 13 Nov 2020 at 09:37:15 (+0000), Will Deacon wrote: > > 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_cpu_allowed_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. > > > > 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..8df38ebfe769 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_cpu_allowed_mask > > +#define arch_cpu_allowed_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_cpu_allowed_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_cpu_allowed_mask(p)); > > Nit: I'm wondering if this should be called arch_cpu_possible_mask() > instead? I'm open to renaming it, so if nobody else has any better ideas then I'll go with this. > In any case: > > Reviewed-by: Quentin Perret X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B590C2D0E4 for ; Thu, 19 Nov 2020 11:07:52 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 79F05246EE for ; Thu, 19 Nov 2020 11:07:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dVcnVvbb"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="pLRb0ge/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79F05246EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uSloCD/LwwvXr8qZQCrbdzXZYJjIcvZhyY2/NV3ctjU=; b=dVcnVvbbao345yvYPgEgJFjw7 ywMCHOAYWfQbIHXgjU60aA04EJ1hXBuq/wTEUOmDXNuH9FX7oDIRkXvQQ5UBvgkMtHg3MucSVxk7p 7uz572ofKqgHpvikikEHHBW3o5z4sJU9UfCEc8ED8cZGtI4jkESZz95Y68/TVASiWlEvX6KgENlDc HheNBaFH2A6TmJrR87dQ31se5yqlyhNnPgUJ8Fjx1ao8YiIfqX2TrMbSN8sUUZSyTHVPLMmqHIgZ3 VjId/R7M99kSDde/in6t4csgAa+u3EEMoDKdclzDAqLxVucn2PuvJUM/QLTHfe7Z7oeHLP8kVDiRF Nm9DV346A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfhmc-0003EU-Qu; Thu, 19 Nov 2020 11:07:22 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfhmY-0003Cu-HU for linux-arm-kernel@lists.infradead.org; Thu, 19 Nov 2020 11:07:19 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1C08C22248; Thu, 19 Nov 2020 11:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605784037; bh=+WwDHFmhE9MS11P7KUuWkxiPo6fvIEVugJhgXLZJcR0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pLRb0ge/P3ZJCh1BzFlpiY5cYssXpnuUKk5rQraPQgkYekjSdJIH+GG7/ythHuLFu /wK8Q88KDTgfi36pa6wtpoFZec5+heJzw2pFzr6rQqgUzYw+1IWA/ZmWrkT9GXWXtF Lr3+RfK/JFkN8imWgqExNyP4UOh6LX4kKZHKiEjI= Date: Thu, 19 Nov 2020 11:07:09 +0000 From: Will Deacon To: Quentin Perret Subject: Re: [PATCH v3 10/14] sched: Introduce arch_cpu_allowed_mask() to limit fallback rq selection Message-ID: <20201119110709.GD3946@willie-the-truck> References: <20201113093720.21106-1-will@kernel.org> <20201113093720.21106-11-will@kernel.org> <20201119093850.GD2416649@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201119093850.GD2416649@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201119_060718_794409_0BFB7E54 X-CRM114-Status: GOOD ( 27.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Marc Zyngier , kernel-team@android.com, Vincent Guittot , Juri Lelli , Ingo Molnar , Peter Zijlstra , Catalin Marinas , Johannes Weiner , linux-kernel@vger.kernel.org, Qais Yousef , Li Zefan , Greg Kroah-Hartman , Tejun Heo , Suren Baghdasaryan , Morten Rasmussen , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Nov 19, 2020 at 09:38:50AM +0000, Quentin Perret wrote: > On Friday 13 Nov 2020 at 09:37:15 (+0000), Will Deacon wrote: > > 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_cpu_allowed_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. > > > > 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..8df38ebfe769 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_cpu_allowed_mask > > +#define arch_cpu_allowed_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_cpu_allowed_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_cpu_allowed_mask(p)); > > Nit: I'm wondering if this should be called arch_cpu_possible_mask() > instead? I'm open to renaming it, so if nobody else has any better ideas then I'll go with this. > In any case: > > Reviewed-by: Quentin Perret