From nobody Mon Feb 9 21:03:03 2026 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEF73236447 for ; Mon, 10 Feb 2025 15:13:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739200383; cv=none; b=WBlkbPF4mJDJasXrj1AYJ0/rQFptO+zAQwDf0IfYv7bVpJ3/OTAzsANL5xiXlnxE7IvcVmZoeVIWDB4uR+5UliNbrtTXWPetMRnP4LOKi1UvSak3GI31/co5aeFw3OZPTJHWSFsWEpSCfBgqxX6RGE8Dhbh841JJUcq0DtQWHJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739200383; c=relaxed/simple; bh=e1GtMQHyXqLttzeCe+LsTrtmYMYgOJr+zxNK5BFPZ+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aZdcmZas/fJdBluj7PhY61FEQUzO14PLfj+V87d6yCfKmMV4G/RTuGKcbt91mEW+ek71TaYNpoH+bCwIOf0viA0oxmsa6IzUBEjPwPrIYuyfe0eajhZ1vSsB1a2/WtCES/mlBTZEaFjGZx+NebyX6TZMqPJdP4jlC+3etd3gfW4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=JhQanq6C; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="JhQanq6C" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-ab7d601bda0so39502366b.2 for ; Mon, 10 Feb 2025 07:13:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1739200379; x=1739805179; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/CdFzOQJ6hH6QUOgKxio0cWYoQzFtWX3s2A4l5iJzf4=; b=JhQanq6CRa2EtQcyBxaCpgZ2DLlBaqsGzPhZe5P53it/db8YkCM0GHQAoPAjD8ckTu ChBQ/1L47cUHRWvkaIYMzRfNDgtAwY/GDD7b7ZAmbiCaclMK6yeiEVq5lQ3ec8SQpPCQ yEQPXq740/3U0wPx6O2+0xx5SDsGZhDfWkHOyH02vRe5lDygKj0uk6n2fSs29JSjYCmz IV2rTj3O/rL9y3tIu+tdz1S3h56tQ2FPuYu4kFn2bDx2CdqNPgfJVNlowE0KmY+cTFr+ v5kNXFLbBgCNZJs0TLBbRYfkKhIrWZ/jC04LLXQGTlYGm0B0/KYKahOG+4FP/40t9bqm F/jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739200379; x=1739805179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/CdFzOQJ6hH6QUOgKxio0cWYoQzFtWX3s2A4l5iJzf4=; b=cdUxjkjZLxZA92sLBC7i58EF7arSOYAvHnh8h11euvg5k9kO4mJHdgmHY+yDhEe3vp DpPSQj51u4GzjQwynV/F99rgxaj6aK3X+LolE4Nnp5yUlqH9aK2L+ztesMe57DwhKChE Ymb1fF0WvKueWsDfJKyoCe55Sqab00eeBI8AX8WhUKK5pShVKhmxHjdAaxbV3qajjUKf bNsWtEPFTO3uiw7rYaW9oGKGQq5ze5QaTGcvLg21RG5VD6SSADZcQ1CHa4xjeAFe7bCw DfDbNPZ2v1+weRaqzy8g1RHBybzhKCghH7q8Uqpbbk/dC4P+VGa/8jDfJECVaVl/ohLk PPag== X-Forwarded-Encrypted: i=1; AJvYcCWFjRrstc7FEm8lbQBH165quGdcx+u3fV0HR1UceEpVrjhBjZabJPZLI4TDrKEHrvbDN2evjvAO9OOB6Xw=@vger.kernel.org X-Gm-Message-State: AOJu0Yxvqp1CkFweDvwyCaSCf/a2A1oEAGjJkKKBOOOCOSmpi1dgPAVz AbuRXO71/HVp5jkbRJcZNLTFjE+/OE5KVifPMWZ/W3qOS1amVa1PhixKanZXS04= X-Gm-Gg: ASbGncstXozysUNcGcEkyfbieqD3DTgAH+5HuQ75BYUj3EDcjZ5OJqDkLi0enB8Sz4D MXTd08zt1Cf7UYTvBjwSDq/+W8Vo9na2ULSSk28zxCRF5/lIQucEb2+G44RAbhUymT6Ym8c6sol FQpzaJLP8wZbz+vaKbEefqKmkq8Q6CLcIbtLvc632qhcEvTCEVPdvL0AVatK6KEu0o8WBJr3Tiq hQJnmOCm+VvoCpYyQKx+oOoj+xbvEYIwOIBmB9Kr7mp08G1DtTSt4QwrkxpcoTEWKXjCAwK7wJK Yl+9lIfy0Ru7XwiKTA== X-Google-Smtp-Source: AGHT+IH/BV7V8vs1uXFvIC4uN9ZnTMvJSeRLysfZRy4ypVIbXT1Ov45yrEhapv3A6zivAa4othcS2Q== X-Received: by 2002:a17:907:6d12:b0:ab7:cd83:98c4 with SMTP id a640c23a62f3a-ab7cd839b76mr268690466b.50.1739200379226; Mon, 10 Feb 2025 07:12:59 -0800 (PST) Received: from blackdock.suse.cz ([193.86.92.181]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab773339e82sm895192866b.143.2025.02.10.07.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 07:12:59 -0800 (PST) From: =?UTF-8?q?Michal=20Koutn=C3=BD?= To: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Frederic Weisbecker Subject: [PATCH 7/9] sched: Do not construct nor expose RT_GROUP_SCHED structures if disabled Date: Mon, 10 Feb 2025 16:12:37 +0100 Message-ID: <20250210151239.50055-8-mkoutny@suse.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250210151239.50055-1-mkoutny@suse.com> References: <20250210151239.50055-1-mkoutny@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Thanks to kernel cmdline being available early, before any cgroup hierarchy exists, we can achieve the RT_GROUP_SCHED boottime disabling goal by simply skipping any creation (and destruction) of RT_GROUP data and its exposure via RT attributes. We can do this thanks to previously placed runtime guards that would redirect all operations to root_task_group's data when RT_GROUP_SCHED disabled. Signed-off-by: Michal Koutn=C3=BD --- kernel/sched/core.c | 36 ++++++++++++++++++++++++------------ kernel/sched/rt.c | 9 +++++++++ 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a418e7bc6a123..4b2d9ec0c1f23 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -9827,18 +9827,6 @@ static struct cftype cpu_legacy_files[] =3D { .seq_show =3D cpu_cfs_local_stat_show, }, #endif -#ifdef CONFIG_RT_GROUP_SCHED - { - .name =3D "rt_runtime_us", - .read_s64 =3D cpu_rt_runtime_read, - .write_s64 =3D cpu_rt_runtime_write, - }, - { - .name =3D "rt_period_us", - .read_u64 =3D cpu_rt_period_read_uint, - .write_u64 =3D cpu_rt_period_write_uint, - }, -#endif #ifdef CONFIG_UCLAMP_TASK_GROUP { .name =3D "uclamp.min", @@ -9857,6 +9845,20 @@ static struct cftype cpu_legacy_files[] =3D { }; =20 #ifdef CONFIG_RT_GROUP_SCHED +static struct cftype rt_group_files[] =3D { + { + .name =3D "rt_runtime_us", + .read_s64 =3D cpu_rt_runtime_read, + .write_s64 =3D cpu_rt_runtime_write, + }, + { + .name =3D "rt_period_us", + .read_u64 =3D cpu_rt_period_read_uint, + .write_u64 =3D cpu_rt_period_write_uint, + }, + { } /* Terminate */ +}; + # ifdef CONFIG_RT_GROUP_SCHED_DEFAULT_DISABLED DEFINE_STATIC_KEY_FALSE(rt_group_sched); # else @@ -9879,6 +9881,16 @@ static int __init setup_rt_group_sched(char *str) return 1; } __setup("rt_group_sched=3D", setup_rt_group_sched); + +static int __init cpu_rt_group_init(void) +{ + if (!rt_group_sched_enabled()) + return 0; + + WARN_ON(cgroup_add_legacy_cftypes(&cpu_cgrp_subsys, rt_group_files)); + return 0; +} +subsys_initcall(cpu_rt_group_init); #endif /* CONFIG_RT_GROUP_SCHED */ =20 static int cpu_extra_stat_show(struct seq_file *sf, diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index f25fe2862a7df..1633b49b2ce26 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -195,6 +195,9 @@ static inline struct rq *rq_of_rt_se(struct sched_rt_en= tity *rt_se) =20 void unregister_rt_sched_group(struct task_group *tg) { + if (!rt_group_sched_enabled()) + return; + if (tg->rt_se) destroy_rt_bandwidth(&tg->rt_bandwidth); } @@ -203,6 +206,9 @@ void free_rt_sched_group(struct task_group *tg) { int i; =20 + if (!rt_group_sched_enabled()) + return; + for_each_possible_cpu(i) { if (tg->rt_rq) kfree(tg->rt_rq[i]); @@ -247,6 +253,9 @@ int alloc_rt_sched_group(struct task_group *tg, struct = task_group *parent) struct sched_rt_entity *rt_se; int i; =20 + if (!rt_group_sched_enabled()) + return 1; + tg->rt_rq =3D kcalloc(nr_cpu_ids, sizeof(rt_rq), GFP_KERNEL); if (!tg->rt_rq) goto err; --=20 2.48.1