From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=158.69.130.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795096187; b=nlibmOg7PJ8nysV6o8T25/FKfClP79qgwtQhZkflH9g/pSraE88lTxsdGL1cuoyPf70M icrlaBeJEKkcqL5o0wnKGmgW8YGTdCJoqjRusLHChk+e0pozsw8JP4iQBYq6QiPunnBT7 j90bp/XG7eGeksW9MGNbwWC5MybnmDqGHZxLAdKVz2O1oMbvfaI6BUXC83pPLh/jcHkYu rkDthe2p4xXdxYZq9rZY1hvRRLsG9fOd4KTMU2v7J3E4hLrW9SF8ts8wWtIcraOHM7p78 KB3f30VoDFpgr6kUw9vf6CB51tqR1fufEFGkZfNumdcpxT+MCLyZnoupe1GHmnxDMWA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795096187; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=hjTYAqi/gpMkX55Y0igyLpnABuy/mfhM7aTE6x5O19I=; b=0qnFldkHsR+INMg5aUhIcmaFyYwwGAdi0ZMdZKeocQ11TLvo4qn2yVUA3qxp1bAUoL9g dzUpAYfEFbV9HCBG/0ICtFQGPGjRgEDbPiEQpacR7NTIA/7+hvNTtX/CRgDRabsI5zeAZ CPj5ipEzc7wOd7FC9/Da0PfYysK64LM9AolGCek7fbNqc1RbuTpOtf3PKofBcg9E4cPUC ZGdVVNHdZ7/K2PFq0/bNBFyZiRuOs4Cqg+cxbV3+HQ96qbPe4fEGrq+TKZihmVM1kllbD VmVYh1JVCXjdSQTOZdgmf7t4l5UJZDzB0TAThmwq16oHMui42MUUeIdOP5jvGJFku+w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=RMgpBpDg; arc=none smtp.remote-ip=158.69.130.18 Received: from smtpout.efficios.com (smtpout.efficios.com [158.69.130.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E24F60A383F; Thu, 19 Nov 2026 13:49:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4E24F60A383F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=RMgpBpDg DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=smtpout1; t=1795096185; bh=hjTYAqi/gpMkX55Y0igyLpnABuy/mfhM7aTE6x5O19I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RMgpBpDgSbgm+vSNTJWS1wLUhTiGkd34XbwJ+4Gk9pY4MTiJD0ROKHTGzlV25zdVb jSbWotMgeBrCWAuEe3gpKcJS5dTZgemIpPM2PSCY9RD/Qf0BYfOsZNhShCIaq1Y4uk yPPrYOcwgzwWxGSjDThuSoy/vlWCZZwntaEy7S3Go1H27GrcRExNA8XAeGLq09rXz/ yxtn18De1J8RPtJbymvf3UTh3XFUNyoKEcioPMf1ZxPc7ec3UicLMv3IDAmedqLbwd JylQ0RQt/kEmpI06Y0LUZnwiRQlM1AkWLSPy+chKqtuR4oBSpbqQme3YZoVDQ4Sfxo ndrAC8nl0uLvQ== Received: from thinkos.internal.efficios.com (mtl.efficios.com [216.120.195.104]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4jVfwT5WLGzSfW; Thu, 19 Nov 2026 08:49:45 -0500 (EST) From: Mathieu Desnoyers To: juri.lelli@redhat.com, peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , tglx@kernel.org, will@kernel.org, boqun@kernel.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, kprateek.nayak@amd.com, luca.abeni@santannapisa.it, mathieu.poirier@linaro.org, longman@redhat.com, ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, bigeasy@linutronix.de, clrkwllms@kernel.org, parri.andrea@gmail.com, m.szyprowski@samsung.com, kayracizmeci@gmail.com, weihengqiuu@gmail.com, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-rt-devel@lists.linux.dev, stable@vger.kernel.org Subject: [PATCH v3 12/17] sched/deadline: Reject SCHED_DEADLINE on exited tasks Date: Thu, 19 Nov 2026 08:49:35 -0500 Message-Id: X-Mailer: git-send-email 2.39.5 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Juri Lelli sched_setattr(SCHED_DEADLINE) on a zombie task succeeds and charges total_bw via sched_dl_overflow(), but the task has already done its final schedule() and will never run again. Nothing releases the reserved bandwidth. Repeating this fills total_bw to the admission cap, after which sched_setattr(SCHED_DEADLINE) and CPU offline fail with -EBUSY. Reject sched_setattr(SCHED_DEADLINE) on exited tasks with -ESRCH. A task of the class that exited, switched to another policy, runs switched_from_dl(), which decrements the count of deadline tasks of its cpuset that cgroup_task_dead() decremented already: at 0 with a deadline task left in it, the cpuset is skipped by the next rebuild of the root domains' accounting, and that task's bandwidth with it. Reject that as well. The deadline_bw_test selftest added later in this series has the case, death_zombie_switched: on v7.4-rc1 the switch is accepted, and the one-CPU partition root the zombie ran in admits 9 tasks of 10% after a rebuild, with a task of 30% still in it, where 6 are due. Fixes: 332ac17ef5bf ("sched/deadline: Add bandwidth management for SCHED_DEADLINE tasks") Reported-by: Weiheng Qiu Closes: https://lore.kernel.org/all/3f6e6c87-645b-45fd-8fc6-8da5bc5b82d8@gmail.com/ Link: https://lore.kernel.org/all/20261103-b4-sched-dl-bw-fixes-v1-4-dd761fe005b4@redhat.com/ Cc: stable@vger.kernel.org Signed-off-by: Juri Lelli [mathieu: reject a task of the class leaving it too, found by the Sashiko AI review of the patch] Signed-off-by: Mathieu Desnoyers --- kernel/sched/syscalls.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c index 9b04e77297ae..b87b878be63f 100644 --- a/kernel/sched/syscalls.c +++ b/kernel/sched/syscalls.c @@ -592,6 +592,19 @@ int __sched_setscheduler(struct task_struct *p, if (retval) goto unlock; + /* + * Reject SCHED_DEADLINE on exited tasks. A zombie will never be + * scheduled again, so sched_dl_overflow() would charge total_bw + * that nothing will ever release. And reject a change of policy of + * one in the class: cgroup_task_dead() took it off the count of + * deadline tasks of its cpuset, which switched_from_dl() would + * decrement a second time. + */ + if ((dl_policy(policy) || dl_task(p)) && p->exit_state) { + retval = -ESRCH; + goto unlock; + } + /* * If not changing anything there's no need to proceed further, * but store a possible modification of reset_on_fork. -- 2.47.3