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.0 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 2C44FC64E7B for ; Tue, 1 Dec 2020 16:57:34 +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 AC46420758 for ; Tue, 1 Dec 2020 16:57:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BG5i48LU"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="I1wIYNg/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC46420758 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=+K2FpUJKjxfhIsTEvk0V7ewnCnThFa1zZggsPxW3wqY=; b=BG5i48LUR8duP5uXdtXHuTcHa tKz47WSEva79pcsPHgIsN/jd9F9itC0gEw7IUHukWaqrvDtuTPZCr0zscEIRKjA+puEP5g2+UdMI+ u2ekLdjuApJE8MuAWIdw0VRQV4Sb44s+stEXjGtHzheH4B+9m95oBj2FWh9EaO5krWqDiwchfb/Z8 ljDxQJac7Kztovoafl7NyK2F1sTXNky66Rb7o/j7aENPC6sT8m+jZfArjd2biKhGjxJ1u2N2/SixO 1SbqJu+fm83irBMdLoKo0L999PORcqSTmI80Ka2S3J58aoP4bRjZykeper1PS6dLyRCmvzfXli8IP F2GIB2/fw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kk8wh-0003iv-U4; Tue, 01 Dec 2020 16:56:07 +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 1kk8we-0003ht-KB for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2020 16:56:05 +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 4AC5D20758; Tue, 1 Dec 2020 16:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606841763; bh=vUuXTXCHpWTLplaXDa7P3d5b/wIiiAS0ETXN4wuN2fk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=I1wIYNg/HvF50Fj/9wfP8UwgScivH9fyVobDbKu3FMRDi9Y45PIaNfIyFFMbk1TAI giZ1+3jsBg0JgigKTmUCm4FDNjikJjPRLTTnafkXTAtK3VboulGEVLUSDrLaTt/6cU jDqN7gTIGMZwUJM6GvOUp0J3Rh5bjTiZco63HcXs= Date: Tue, 1 Dec 2020 16:55:56 +0000 From: Will Deacon To: Qais Yousef Subject: Re: [PATCH v4 08/14] arm64: exec: Adjust affinity for compat tasks with mismatched 32-bit EL0 Message-ID: <20201201165556.GA27783@willie-the-truck> References: <20201124155039.13804-1-will@kernel.org> <20201124155039.13804-9-will@kernel.org> <20201127132306.ee4frq6ujz3fqxic@e107158-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201127132306.ee4frq6ujz3fqxic@e107158-lin.cambridge.arm.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-20201201_115604_874973_9240D596 X-CRM114-Status: GOOD ( 32.98 ) 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 , Quentin Perret , Peter Zijlstra , Catalin Marinas , Johannes Weiner , linux-kernel@vger.kernel.org, Ingo Molnar , 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 Fri, Nov 27, 2020 at 01:23:06PM +0000, Qais Yousef wrote: > On 11/24/20 15:50, Will Deacon wrote: > > When exec'ing a 32-bit task on a system with mismatched support for > > 32-bit EL0, try to ensure that it starts life on a CPU that can actually > > run it. > > > > Signed-off-by: Will Deacon > > --- > > arch/arm64/kernel/process.c | 42 ++++++++++++++++++++++++++++++++++++- > > 1 file changed, 41 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c > > index 1540ab0fbf23..72116b0c7c73 100644 > > --- a/arch/arm64/kernel/process.c > > +++ b/arch/arm64/kernel/process.c > > @@ -31,6 +31,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -625,6 +626,45 @@ unsigned long arch_align_stack(unsigned long sp) > > return sp & ~0xf; > > } > > > > +static void adjust_compat_task_affinity(struct task_struct *p) > > +{ > > + cpumask_var_t cpuset_mask; > > + const struct cpumask *possible_mask = system_32bit_el0_cpumask(); > > + const struct cpumask *newmask = possible_mask; > > + > > + /* > > + * Restrict the CPU affinity mask for a 32-bit task so that it contains > > + * only the 32-bit-capable subset of its original CPU mask. If this is > > + * empty, then try again with the cpuset allowed mask. If that fails, > > + * forcefully override it with the set of all 32-bit-capable CPUs that > > + * we know about. > > + * > > + * From the perspective of the task, this looks similar to what would > > + * happen if the 64-bit-only CPUs were hot-unplugged at the point of > > + * execve(). > > + */ > > + if (!restrict_cpus_allowed_ptr(p, possible_mask)) > > + goto out; > > + > > + if (alloc_cpumask_var(&cpuset_mask, GFP_KERNEL)) { > > + cpuset_cpus_allowed(p, cpuset_mask); > > + if (cpumask_and(cpuset_mask, cpuset_mask, possible_mask)) { > > + newmask = cpuset_mask; > > + goto out_set_mask; > > + } > > + } > > Wouldn't it be better to move this logic to restrict_cpus_allowed_ptr()? > I think it should always take cpusets into account and it's not special to > this particular handling here, no? I did actually try this but didn't pursue it further because I was worried that I was putting too much of the "can't run a 32-bit task on a 64-bit-only CPU" logic into what would otherwise be a potentially useful library function if/when other architectures want something similar. But I'll have another look because there were a couple of ideas I didn't try out. > > + if (printk_ratelimit()) { > > + printk_deferred("Overriding affinity for 32-bit process %d (%s) to CPUs %*pbl\n", > > + task_pid_nr(p), p->comm, cpumask_pr_args(newmask)); > > + } > > We have 2 cases where the affinity could have been overridden but we won't > print anything: > > 1. restrict_cpus_allowed_ptr() > 2. intersection of cpuset_mask and possible mask drops some cpus. > > Shouldn't we print something in these cases too? I don't think so: in these cases we've found a subset of CPUs that we can run on, and so there's no need to warn. Nothing says we _have_ to use all the CPUs available to us. The case where we override the affinity mask altogether, however, does warrant a warning. This is very similar to the hotplug behaviour in select_fallback_rq(). Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel