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=-20.9 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 10FEEC388F9 for ; Thu, 19 Nov 2020 09:39:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F94A2469D for ; Thu, 19 Nov 2020 09:39:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FcP//IHN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726776AbgKSJi4 (ORCPT ); Thu, 19 Nov 2020 04:38:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726385AbgKSJi4 (ORCPT ); Thu, 19 Nov 2020 04:38:56 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E826DC0613CF for ; Thu, 19 Nov 2020 01:38:55 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id h21so6103864wmb.2 for ; Thu, 19 Nov 2020 01:38:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Zh6jK0nTwF8Mjff9qMjpCT6FseWaEgBbFKmM+bidrxk=; b=FcP//IHNuyf1Vp9U2tB/k1bP76J7+crZ59cPVvIDOTpY9p2EwDRC4nte+8bqd0O1FQ 4VG0bPOk3gL+NkMBDkNqMtn0nQgRTtk6lGintUAsDa4frSh8rGMfKYDDQqMp62l5fd+C 6PoaYyp5J3nNUftwG1E0PhGb9lAuOdEENl/SNqCogDRRQqIfJJRrDgyOWcab7glWNI+g krBKu+G0QHF9y4/qh+nGfMR0TkuihBile34SqvVd34uRfEpRPFGL45F4io09zYR6lMXI 5/rdbtWMJRclOKf+/lSiZDOMEL4fQImvtN6GdUtJH1wNRMTyte51BrcApCnXFw4zAy7Y XdlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Zh6jK0nTwF8Mjff9qMjpCT6FseWaEgBbFKmM+bidrxk=; b=qkfQOiy1FdCRg5XktsUcJedNEoW/uEWvsDENLeeA52ekpZ5vJUkIe/CnNRQpdmxTMz 7R5Eo54lmtq7NcitgCa1O7TOgNl/DMdOz27TWxvFm3KplnOG0NoWm0YK1r9XFkgOZgBY uyhjSKaCrx8RyfDUXUAILOx8GGrZkj8vAf5nZJ7hJvLqppkC197vDq6XSuGWSGO8lBQG r1jZ2xsqmSYPWK/GFqlARJvRQjU5GfsxlUyKqVK6nk33wbL4nyyDAtd3Kf1UWeKxiV7r JumG1ZXbRu994VnMcYoEol0Mk41HlAVvZr5p6a6dprNlnkYJGQPGPlPXLMuk8SmrkOv8 G9/A== X-Gm-Message-State: AOAM533zHHVFoIpIbYStsnuqFt9d3mXoE4tC4nKIaJlCQ0sVBASe6m6I eTtqUGhkz8b76oNG3R9kcwM6+A== X-Google-Smtp-Source: ABdhPJxxLp0CX7ilKK6FIe9rSVDycd8yjVil3Bjlh72aOQ9txwqOsOBf4t7SQ75Zl4Oh80pXRlmBLg== X-Received: by 2002:a7b:c05a:: with SMTP id u26mr3710902wmc.159.1605778734546; Thu, 19 Nov 2020 01:38:54 -0800 (PST) Received: from google.com ([2a00:79e0:d:210:f693:9fff:fef4:a7ef]) by smtp.gmail.com with ESMTPSA id 31sm16398540wre.43.2020.11.19.01.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2020 01:38:54 -0800 (PST) Date: Thu, 19 Nov 2020 09:38:50 +0000 From: Quentin Perret To: Will Deacon 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: <20201119093850.GD2416649@google.com> References: <20201113093720.21106-1-will@kernel.org> <20201113093720.21106-11-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201113093720.21106-11-will@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? In any case: Reviewed-by: Quentin Perret