From nobody Mon Dec 1 22:05:39 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 A6042242D88 for ; Thu, 27 Nov 2025 02:08:01 +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=1764209285; cv=none; b=UPTZIjpfyRpGS0qjsjlvFbDg7k3jwUCI8YyyuaIooN/8AFXVYFlQoDTS1I1eB1IxS/qmuoh8Jr58cF0yWUAzBrdGDvStqZB+EwrpWVz/xk/Kbr4tqbBnF5fIwmyB/+WEloxju28yGITVKlkUy72UQqIHd/da9XY4R982u1lS3YA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764209285; c=relaxed/simple; bh=ADi2inW7/tafI3ektYpVw/IcRNO+pnYf/vvsb0gg3sM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=gRP2vXA434xwIWHKDqDtrle+GLIN62vPsvH8RkCRlU6Ryuyz4stOXUaVjTrn/BMIQ6lamH/oOchBFCjxkSVziSLMaHYyPZKGZRCxP62V2eICS8SwWOKVpEyJUGCUe7iAa2BA74D3XX9RvzuB5aWkw2yOH3WEvx1aWBtkrcBwG1Y= 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: e2aed384cb3511f0a38c85956e01ac42-20251127 X-CID-CACHE: Type:Local,Time:202511271001+08,HitQuantity:1 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.6,REQID:83b0855b-181e-4932-bf44-77bd1104350a,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: e2aed384cb3511f0a38c85956e01ac42-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 1400325480; Thu, 27 Nov 2025 10:07:54 +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:07:32 +0800 Message-Id: <20251127020732.660528-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 since fair_server was introduced. 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