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=-23.2 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 05E37C63777 for ; Fri, 27 Nov 2020 10:02:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A107B221FD for ; Fri, 27 Nov 2020 10:02:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GwxYEgEL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728849AbgK0KBp (ORCPT ); Fri, 27 Nov 2020 05:01:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728066AbgK0KBp (ORCPT ); Fri, 27 Nov 2020 05:01:45 -0500 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43B3DC0613D4 for ; Fri, 27 Nov 2020 02:01:43 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id l1so4928764wrb.9 for ; Fri, 27 Nov 2020 02:01:43 -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=DiX1BOjtmBdaUBxd27sZjTmBGtSbOqX8zXkWXxLiRSk=; b=GwxYEgELirhM4f500MGN6ZFp3noYdf/8Ef7FA6s88Xk/mMJF0NTCWLt7bn3UMVwQ2j ivOYZrZ/U6WwhLiN7txIvY2IzgJMUvzOwnQIBq8nI0aNcWHIyJKov+bVttYznU+BOCsN a5/JOAE18R3ga1KK/KLZDXZdf8+YxYQ+mzcil/SUuWnm7J84ouIW1r28MQBtSBzpuOFo 1Lo0z0RamLAUYRay4Ddq0bEKeuTNXfUTfqnmsnXCne24qUsm3Kmi6ik7yqSiDIpLPBRU +CT828fA8QhQP3Xv1H5hmzCx+r8TpgGgLKWFbcbykSNw83H95I43TYImE2HXQ0h7vrgH RWmQ== 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=DiX1BOjtmBdaUBxd27sZjTmBGtSbOqX8zXkWXxLiRSk=; b=uQcITUhBHXY0dCnN7WqyMMrjo8xH6GZkXzLz+thLDqV1czh7hYmxbD3bBIaVAqWuto 0Q1s9lCPBBprorsRzxU4MwL9p4PkuDIwYo7Crpmv8PfaYEWDbwEEndJrkUaPv7sMMpPw fOG/+/Owf/xxFwepFNcYcm7izzrLP6tHjgvDi8W5RmYQeS1h7IUXZvPAxBLLSFqhA3Es R0NsYhNG45fKjIocBjRMCFRVx5pa0JtUWjzjS/WRPFucZ530TK8Vx9soMAw5Cct70Zdw K95heR2CCYNui6CPQT2AFk/PWs2pa87TVV1LlmlVrDMOCd+8jmn6EmhSQqcNY1AOulc3 Z+jA== X-Gm-Message-State: AOAM533lG/FpPosfJRVXxXAuBOqgFjU89SLxjFmlnEgVWEeTs0K79iRx k+eqzbpcOELjaOA1zf4XeNgvZw== X-Google-Smtp-Source: ABdhPJwC7qIr57iRwDeZya4zpiIbaD6hFj4axD8WZpWw0JGDRKDzWKHN8vWhzQjFj6ySkcVIUCt4oQ== X-Received: by 2002:a5d:56cb:: with SMTP id m11mr9781162wrw.346.1606471301740; Fri, 27 Nov 2020 02:01:41 -0800 (PST) Received: from google.com ([2a00:79e0:d:210:f693:9fff:fef4:a7ef]) by smtp.gmail.com with ESMTPSA id e27sm16006352wrc.9.2020.11.27.02.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2020 02:01:41 -0800 (PST) Date: Fri, 27 Nov 2020 10:01:38 +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 v4 08/14] arm64: exec: Adjust affinity for compat tasks with mismatched 32-bit EL0 Message-ID: <20201127100138.GC906877@google.com> References: <20201124155039.13804-1-will@kernel.org> <20201124155039.13804-9-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201124155039.13804-9-will@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday 24 Nov 2020 at 15:50:33 (+0000), 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; > + } > + } > + > + 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)); > + } > +out_set_mask: > + set_cpus_allowed_ptr(p, newmask); > + free_cpumask_var(cpuset_mask); > +out: > + set_tsk_thread_flag(current, TIF_NOTIFY_RESUME); > +} This starts to look an awful lot like select_fallback_rq(), but I suppose we shouldn't bother factoring out that code yet as we probably don't want this pattern to be re-used all over, so: Reviewed-by: Quentin Perret Thanks, Quentin 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=-13.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 BDBEBC2D0E4 for ; Fri, 27 Nov 2020 10:03:00 +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 42EB5221F7 for ; Fri, 27 Nov 2020 10:03:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0/EOnUNV"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="GwxYEgEL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42EB5221F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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=qt34oOR5BCC9H9piINh6RhwE00EBoX2roY1it6JeX8I=; b=0/EOnUNVlBcmO/B7YKjHNHxgz /smTXIaALM0/S2GANLDH1TZGg7UMlJiCF6xpGIy0qOg8mH4G3kRfTR+m5s2ZntoVT0T265XSK8p1E 0to3KK4K1KmF507UwJ1FBAf5+29NLAbRj/PEKYCZmeyrDUSJTcX3QPL6jUYuAn+wR9BYmXFJBU3z3 Pr+uL+XO8S3XXf+mYm2V3pIm0S1Ic9BH35WU/NZdNpGHw5kn3ET8CLnRGA/HRs7btuFNG1Rz1G8Tp 0qmg5pf0DHPQDB70oZHr0x6lVXTAf5FkVZwg1vpncR8GeBrT/Um5NM9n7rE124oIJAAnbiEIfNl23 SX62m3kEQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiaZV-00039F-RR; Fri, 27 Nov 2020 10:01:45 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiaZT-00038B-0B for linux-arm-kernel@lists.infradead.org; Fri, 27 Nov 2020 10:01:44 +0000 Received: by mail-wr1-x442.google.com with SMTP id p8so4935515wrx.5 for ; Fri, 27 Nov 2020 02:01:42 -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=DiX1BOjtmBdaUBxd27sZjTmBGtSbOqX8zXkWXxLiRSk=; b=GwxYEgELirhM4f500MGN6ZFp3noYdf/8Ef7FA6s88Xk/mMJF0NTCWLt7bn3UMVwQ2j ivOYZrZ/U6WwhLiN7txIvY2IzgJMUvzOwnQIBq8nI0aNcWHIyJKov+bVttYznU+BOCsN a5/JOAE18R3ga1KK/KLZDXZdf8+YxYQ+mzcil/SUuWnm7J84ouIW1r28MQBtSBzpuOFo 1Lo0z0RamLAUYRay4Ddq0bEKeuTNXfUTfqnmsnXCne24qUsm3Kmi6ik7yqSiDIpLPBRU +CT828fA8QhQP3Xv1H5hmzCx+r8TpgGgLKWFbcbykSNw83H95I43TYImE2HXQ0h7vrgH RWmQ== 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=DiX1BOjtmBdaUBxd27sZjTmBGtSbOqX8zXkWXxLiRSk=; b=OPPZhi5qWe9uOyxwJRum3/tbCEx2tzFuUKoAQaVMmrSDzgqPx407IY06MwhDgEgRWn R4waaRQyowjZdjUatE8qRB7+riD1fanwZUYb3W9EZ4MmeWg90azswhu/YfSJKHN06ywI wifaxBa1P5dH5xCSEAfnzGcjGJoMh+F37oGOtuHCvIqSRpq7dUxEWoCSK9TrzRRnhQYK uSMLeh3vBCx6n9UGzt4beUymjeLXxkLw4w0Cu3edL16rAMEXRh+0ToqJyQ59KIT33lau 2pJwclV0Wmvg8r49meLgFR3rob8gqa2X9Zl2mfweanZyIlhinPfHkSgT5P6e0O4Uw5Jd tO9Q== X-Gm-Message-State: AOAM531/jmQI++EHU5lFY0/ML9oJv/Q0Wm/iA9yM1kMdht6C+Pyjm/qj bJ+9bij/9uNLEUNWXyDB9YA69Q== X-Google-Smtp-Source: ABdhPJwC7qIr57iRwDeZya4zpiIbaD6hFj4axD8WZpWw0JGDRKDzWKHN8vWhzQjFj6ySkcVIUCt4oQ== X-Received: by 2002:a5d:56cb:: with SMTP id m11mr9781162wrw.346.1606471301740; Fri, 27 Nov 2020 02:01:41 -0800 (PST) Received: from google.com ([2a00:79e0:d:210:f693:9fff:fef4:a7ef]) by smtp.gmail.com with ESMTPSA id e27sm16006352wrc.9.2020.11.27.02.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2020 02:01:41 -0800 (PST) Date: Fri, 27 Nov 2020 10:01:38 +0000 From: Quentin Perret To: Will Deacon Subject: Re: [PATCH v4 08/14] arm64: exec: Adjust affinity for compat tasks with mismatched 32-bit EL0 Message-ID: <20201127100138.GC906877@google.com> References: <20201124155039.13804-1-will@kernel.org> <20201124155039.13804-9-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201124155039.13804-9-will@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201127_050143_117918_C7368839 X-CRM114-Status: GOOD ( 26.34 ) 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 Tuesday 24 Nov 2020 at 15:50:33 (+0000), 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; > + } > + } > + > + 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)); > + } > +out_set_mask: > + set_cpus_allowed_ptr(p, newmask); > + free_cpumask_var(cpuset_mask); > +out: > + set_tsk_thread_flag(current, TIF_NOTIFY_RESUME); > +} This starts to look an awful lot like select_fallback_rq(), but I suppose we shouldn't bother factoring out that code yet as we probably don't want this pattern to be re-used all over, so: Reviewed-by: Quentin Perret Thanks, Quentin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel