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=-19.4 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_GIT 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 9663FC43460 for ; Tue, 18 May 2021 09:49:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 695C0613F2 for ; Tue, 18 May 2021 09:49:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348204AbhERJuk (ORCPT ); Tue, 18 May 2021 05:50:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:50332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348069AbhERJts (ORCPT ); Tue, 18 May 2021 05:49:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A95B613F4; Tue, 18 May 2021 09:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621331304; bh=CXXSJFTLguIC0wnRzVNZjaiEiV5Q9Ps2gUQifPQxHXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nVxji+ySFLgIHKy055Xm1GNP1NonfdXGEDwTzeg4wNyAOJ5ruRznguUI8CcX2GpKY FMM0QlUPUDq6Ugowra6N7/hicfp/zkzLQKQxQSkeMGXd0jP5LJRlVIZ5HMJ5zrIRMz 4yBQB33CX/K6WLegiITaoiNArqpRa9ybEKWitb0A210zhqZNxJz+FOsPehG2vVwcv+ bQgyVRTAB7FERd6FEDduJGLLQPXUhGZry4E8mlU3AKIdFoB0GCFrz+TT40UVn89+fK 39vHAVB+VZYbgai9BGmpnAjaoagZ47Fd3lLdqxHqCU4Q9wc4eA3lN+O0FeC5K44w0M M7OVoBumfEQTQ== 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 , "Rafael J. Wysocki" , kernel-team@android.com Subject: [PATCH v6 13/21] sched: Admit forcefully-affined tasks into SCHED_DEADLINE Date: Tue, 18 May 2021 10:47:17 +0100 Message-Id: <20210518094725.7701-14-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210518094725.7701-1-will@kernel.org> References: <20210518094725.7701-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On asymmetric systems where the affinity of a task is restricted to contain only the CPUs capable of running it, admission to the deadline scheduler is likely to fail because the span of the sched domain contains incompatible CPUs. Although this is arguably the right thing to do, it is inconsistent with the case where the affinity of a task is restricted after already having been admitted to the deadline scheduler. For example, on an arm64 system where not all CPUs support 32-bit applications, a 64-bit deadline task can exec() a 32-bit image and have its affinity forcefully restricted. Rather than reject these tasks altogether, favour the requested user affinity saved in 'task_struct::user_cpus_ptr' over the actual affinity of the task which has been restricted by the kernel. Signed-off-by: Will Deacon --- kernel/sched/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ba66bcf8e812..d7d058fc012e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6403,13 +6403,14 @@ static int __sched_setscheduler(struct task_struct *p, if (dl_bandwidth_enabled() && dl_policy(policy) && !(attr->sched_flags & SCHED_FLAG_SUGOV)) { cpumask_t *span = rq->rd->span; + const cpumask_t *aff = p->user_cpus_ptr ?: p->cpus_ptr; /* * Don't allow tasks with an affinity mask smaller than * the entire root_domain to become SCHED_DEADLINE. We * will also fail if there's no bandwidth available. */ - if (!cpumask_subset(span, p->cpus_ptr) || + if (!cpumask_subset(span, aff) || rq->rd->dl_bw.bw == 0) { retval = -EPERM; goto unlock; -- 2.31.1.751.gd2f1c929bd-goog 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.4 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,USER_AGENT_GIT autolearn=ham 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 82567C43461 for ; Tue, 18 May 2021 10:04:41 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 141A2610CB for ; Tue, 18 May 2021 10:04:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 141A2610CB 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dh153rgEbdL34wZklmCH0TmlwQFYbS/rpl/ZSgqBD08=; b=ePj8PevuhIVhN/Wjaqkf3vNga uXH+KyYnPRQr1sNG5/DEOF7jiDDIZi6la14JR+34oSFP25p3T0V7uKCTDbS4Efvl4x0zVLtnAA1ML RQ4ECvxHehEb9GQMvNlLf4T/ioNGXLSU7YRTVz3YnD5IPOSB1XNOdsJB6WiopBqwz250EAfvoK1m8 cTCnzGQoUAJlw+sZYDl8QWL8PwioUxvn+mWJc8+zwNlmMrcmUSw29XmVhLtDFTkoYR8f9jiRn5Cy3 Q+waBwjEtHOlvy5sLaEbqDNteu22+e4AiiJ+fUdJIxtNv6K4lia4JCCje62o1dDxIjdneuvRymDPX +B49Cc+Qg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1liwYp-000Ggj-Ke; Tue, 18 May 2021 10:02:48 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liwKx-000DyJ-1Z for linux-arm-kernel@desiato.infradead.org; Tue, 18 May 2021 09:48:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=ykl5GInEicBrXAQCD7ZOD64wvKf+8lVn/3ZZzg6geLs=; b=Cx1PMkdcq6Y4xrLqTZoQJMY5Cg j0nSqiqdMBSXp2OxOs4F0d3jdTujvJNBCMiW2pOuqjsvjjBi8MEy2DcFjRoLCwE4FCfHE/OEy6bHc iNoqpLQY7jwukGz0IZk5MRA9Vcqkr9095BSgBmZm9wxPt8/wbjbcprahUucGou2/LSjzF9C85cfU2 sXt0AHgWZQSNqWDripRqSiDL9qsS+xmQrRp6wAhJKqKLGhHBWsF6JAtpPkpgVFJqbbbrCHtojBKoN pKLvN00GYNA5XB24P/sUWbO3A2BqI1Ryq08jo2yQagiWzeLV09iBJD8IJ/untOMHcvIuB4aIt0eCW EZ2RVFxA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liwKu-00EWk5-E9 for linux-arm-kernel@lists.infradead.org; Tue, 18 May 2021 09:48:25 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A95B613F4; Tue, 18 May 2021 09:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621331304; bh=CXXSJFTLguIC0wnRzVNZjaiEiV5Q9Ps2gUQifPQxHXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nVxji+ySFLgIHKy055Xm1GNP1NonfdXGEDwTzeg4wNyAOJ5ruRznguUI8CcX2GpKY FMM0QlUPUDq6Ugowra6N7/hicfp/zkzLQKQxQSkeMGXd0jP5LJRlVIZ5HMJ5zrIRMz 4yBQB33CX/K6WLegiITaoiNArqpRa9ybEKWitb0A210zhqZNxJz+FOsPehG2vVwcv+ bQgyVRTAB7FERd6FEDduJGLLQPXUhGZry4E8mlU3AKIdFoB0GCFrz+TT40UVn89+fK 39vHAVB+VZYbgai9BGmpnAjaoagZ47Fd3lLdqxHqCU4Q9wc4eA3lN+O0FeC5K44w0M M7OVoBumfEQTQ== 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 , "Rafael J. Wysocki" , kernel-team@android.com Subject: [PATCH v6 13/21] sched: Admit forcefully-affined tasks into SCHED_DEADLINE Date: Tue, 18 May 2021 10:47:17 +0100 Message-Id: <20210518094725.7701-14-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210518094725.7701-1-will@kernel.org> References: <20210518094725.7701-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_024824_516159_61EEFFBC X-CRM114-Status: GOOD ( 14.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 asymmetric systems where the affinity of a task is restricted to contain only the CPUs capable of running it, admission to the deadline scheduler is likely to fail because the span of the sched domain contains incompatible CPUs. Although this is arguably the right thing to do, it is inconsistent with the case where the affinity of a task is restricted after already having been admitted to the deadline scheduler. For example, on an arm64 system where not all CPUs support 32-bit applications, a 64-bit deadline task can exec() a 32-bit image and have its affinity forcefully restricted. Rather than reject these tasks altogether, favour the requested user affinity saved in 'task_struct::user_cpus_ptr' over the actual affinity of the task which has been restricted by the kernel. Signed-off-by: Will Deacon --- kernel/sched/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ba66bcf8e812..d7d058fc012e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6403,13 +6403,14 @@ static int __sched_setscheduler(struct task_struct *p, if (dl_bandwidth_enabled() && dl_policy(policy) && !(attr->sched_flags & SCHED_FLAG_SUGOV)) { cpumask_t *span = rq->rd->span; + const cpumask_t *aff = p->user_cpus_ptr ?: p->cpus_ptr; /* * Don't allow tasks with an affinity mask smaller than * the entire root_domain to become SCHED_DEADLINE. We * will also fail if there's no bandwidth available. */ - if (!cpumask_subset(span, p->cpus_ptr) || + if (!cpumask_subset(span, aff) || rq->rd->dl_bw.bw == 0) { retval = -EPERM; goto unlock; -- 2.31.1.751.gd2f1c929bd-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel