From nobody Mon Dec 1 22:05:42 2025 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCFA228F5 for ; Thu, 27 Nov 2025 02:02:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764208970; cv=none; b=qA5dqgjX/fxiKXBNh14bgwOWg3P8EY7kMLVoBfawmz4VET5BUrtN+ZyVQ2koflWZTC85QntM5nXU88Y5QjG8Wh3my3HW2nNZGzlmvH4xQzz3v2tLqId91h7ijCE2DPsMpYiyWRX8GuXwH0X7yrkwcJRatzvS3UeINz8YElouank= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764208970; c=relaxed/simple; bh=4rQL75s1CdSUH1sMvjFbkn2jR0UfCkJMUFw+TXoszQE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=H5bsO8DS3Lvp85HzvFQYIGTAuNJP2RwvHm8RsRJvhoWW3kKulpY7oZQuWbywVRMmF4k42vakX6m1tgrbXeO3JWGQuNtTee5OSUZ4BGpEyLFeArhQVsDzOvvR5D9a4PJTwpbSStcd4mwbFi5bdakidEWUtlBUtYQn6alO6zAtz3Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 0df558b6cb3511f0a38c85956e01ac42-20251127 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.6,REQID:a832cba9-e173-4f6f-a45c-9f7b1518ed31,IP:0,UR L:0,TC:0,Content:0,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:25 X-CID-META: VersionHash:a9d874c,CLOUDID:0f27813f3df6038f5845c1b77e52aa36,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|850|898,TC:nil,Content:0|15|50,EDM:5 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 0df558b6cb3511f0a38c85956e01ac42-20251127 X-User: fangqiurong@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 197482323; Thu, 27 Nov 2025 10:01:57 +0800 From: fangqiurong To: mingo@redhat.com Cc: peterz@infradead.org, linux-kernel@vger.kernel.org, fangqiurong Subject: [PATCH] sched: Fix RT task setup failures by disabling rt_bandwidth for cgroup v2 Date: Thu, 27 Nov 2025 10:01:25 +0800 Message-Id: <20251127020125.657611-1-fangqiurong@kylinos.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When CONFIG_RT_GROUP_SCHED is enabled, RT tasks cannot be created in non-ro= ot cgroups under cgroup v2 because rt_runtime defaults to 0, causing sched_setscheduler() to fail with -EPERM. The cgroup v2 design makes per-cgroup RT bandwidth control impractical, as non-root groups have no meaningful RT runtime allocation. In this configuration, rt_bandwidth only serves as a starvation prevention mechanism for CFS tasks, which is no longer necessary in modern schedulers. This fix disables rt_bandwidth checks when using cgroup v2 with CONFIG_RT_GROUP_SCHED, allowing RT tasks to be created normally while relyi= ng on the scheduler's inherent fairness mechanisms instead of artificial bandw= idth limitations. Signed-off-by: fangqiurong --- kernel/sched/sched.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index adfb6e340..f7290b80d 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -814,6 +814,12 @@ struct scx_rq { =20 static inline int rt_bandwidth_enabled(void) { +#ifdef CONFIG_RT_GROUP_SCHED + /* Disable rt_bandwidth for cgroup v2 */ + if (root_task_group.css.cgroup && + root_task_group.css.cgroup->root =3D=3D &cgrp_dfl_root) + return 0; +#endif return sysctl_sched_rt_runtime >=3D 0; } =20 --=20 2.25.1