Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1655187pxj; Wed, 19 May 2021 10:44:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTdymvPPDQ+pfp9QQV4Dxv/i1miskoOIajv1d54tKsv9j+XdMownSU4azgNKFhEDfdYz5H X-Received: by 2002:a05:6402:13c3:: with SMTP id a3mr262942edx.18.1621446270538; Wed, 19 May 2021 10:44:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621446270; cv=none; d=google.com; s=arc-20160816; b=IntXrq0vs9VoCCRugeSaO72LCR5VSBdTdaF3SsJ3hSFEVUAnxYpcp3mj5SsvqUi3P1 5aAePP4lStV9PZFX94RdBEvqQYcmJ/rBbm5nG1ZUpfc6iCQ108ZteCiFQ1YIBcFt2XeH VZnRAcwDxEWkcZ3iCA29l28P/mWTPUdQzY1xgzR59EdzwPAKWgUe8SZPmBcNO+HuC5l7 mhFOpPWGmhxIr0P6BLZuTfoINGpNnk1Xl0nwNI8BocsvyOHZgLcBjASY1UzNQO6a0aXd B4mPcxGHdlQmRXSk4aERS885AsRyrEiPfo71BN//gZBtrf/W3kn6uzeL5u6gTGv+JuN2 ZKDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ykl5GInEicBrXAQCD7ZOD64wvKf+8lVn/3ZZzg6geLs=; b=CPVhID9ZUIZ2yPuuSl0ovn6VTsIdzs0fqRsEVDbM6/Nmu9gsV3PtLaIpleysLTqx0K 5TTCyPPKEyAxbUimGImar0NmojTa/CE+xCY3S5UA4N6Csqq5jbIiM89tM85oltxykATO A6kRlqF+GfmmlA/BoVTCgZv+zu+mpzfrqMOgIxuPr7ic21tTk97jrn6GsqljdK4WOVpM PkU5o3zc3/JH6a1o0O6BFrgV7wvfE1nM20ngbMprlqCDudCeWsAya0yzel7CZ58XL+K8 twGmEYKaUJz5Un1mNfFU513Q52huES7l+EZHHn4d3BYI8Oe3gySYe6bGjMt3JD4m2S4U 43GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nVxji+yS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dh5si1647832edb.241.2021.05.19.10.44.06; Wed, 19 May 2021 10:44:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nVxji+yS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243202AbhERJui (ORCPT + 99 others); Tue, 18 May 2021 05:50:38 -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