cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: void@manifault.com, peterz@infradead.org, mingo@redhat.com
Cc: cgroups@vger.kernel.org, lizefan.x@bytedance.com,
	hannes@cmpxchg.org, mkoutny@suse.com, kernel-team@meta.com,
	linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>
Subject: [PATCH 4/7] sched: Make cpu_shares_read_u64() use tg_weight()
Date: Wed,  7 Aug 2024 14:25:26 -1000	[thread overview]
Message-ID: <20240808002550.731248-5-tj@kernel.org> (raw)
In-Reply-To: <20240808002550.731248-1-tj@kernel.org>

Move tg_weight() upward and make cpu_shares_read_u64() use it too. This
makes the weight retrieval shared between cgroup v1 and v2 paths and will be
used to implement cgroup support for sched_ext.

No functional changes.

Signed-off-by: Tejun Heo <tj@kernel.org>
---
 kernel/sched/core.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 49ddc7bc63f5..43a62e9ada84 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -9170,6 +9170,11 @@ static int cpu_uclamp_max_show(struct seq_file *sf, void *v)
 #endif /* CONFIG_UCLAMP_TASK_GROUP */
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
+static unsigned long tg_weight(struct task_group *tg)
+{
+	return scale_load_down(tg->shares);
+}
+
 static int cpu_shares_write_u64(struct cgroup_subsys_state *css,
 				struct cftype *cftype, u64 shareval)
 {
@@ -9181,9 +9186,7 @@ static int cpu_shares_write_u64(struct cgroup_subsys_state *css,
 static u64 cpu_shares_read_u64(struct cgroup_subsys_state *css,
 			       struct cftype *cft)
 {
-	struct task_group *tg = css_tg(css);
-
-	return (u64) scale_load_down(tg->shares);
+	return tg_weight(css_tg(css));
 }
 
 #ifdef CONFIG_CFS_BANDWIDTH
@@ -9685,11 +9688,6 @@ static int cpu_local_stat_show(struct seq_file *sf,
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
 
-static unsigned long tg_weight(struct task_group *tg)
-{
-	return scale_load_down(tg->shares);
-}
-
 static u64 cpu_weight_read_u64(struct cgroup_subsys_state *css,
 			       struct cftype *cft)
 {
-- 
2.46.0


  parent reply	other threads:[~2024-08-08  0:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-08  0:25 [PATCHSET sched_ext/for-6.12] sched_ext: Add cgroup support Tejun Heo
2024-08-08  0:25 ` [PATCH 1/7] cgroup: Implement cgroup_show_cftypes() Tejun Heo
2024-08-20 14:38   ` Michal Koutný
2024-08-26 18:35     ` Tejun Heo
2024-08-08  0:25 ` [PATCH 2/7] sched: Expose css_tg() Tejun Heo
2024-08-08  0:25 ` [PATCH 3/7] sched: Enumerate CPU cgroup file types Tejun Heo
2024-08-08  0:25 ` Tejun Heo [this message]
2024-08-08 17:38   ` [PATCH 4/7] sched: Make cpu_shares_read_u64() use tg_weight() David Vernet
2024-08-08  0:25 ` [PATCH 5/7] sched: Introduce CONFIG_GROUP_SCHED_WEIGHT Tejun Heo
2024-08-08  0:25 ` [PATCH 6/7] sched_ext: Add cgroup support Tejun Heo
2024-08-08  0:25 ` [PATCH 7/7] sched_ext: Add a cgroup scheduler which uses flattened hierarchy Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240808002550.731248-5-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=mingo@redhat.com \
    --cc=mkoutny@suse.com \
    --cc=peterz@infradead.org \
    --cc=void@manifault.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).