cgroup: minor cleanup for cgroup_local_stat_show()
PATCH 1/1 cgroup: minor cleanup for cgroup_local_stat_show()
Make it under CONFIG_CGROUP_SCHED to rid of __maybe_unused annotation. Also put cgroup_tryget_css() inside CONFIG_CGROUP_SCHED as it's only called when CONFIG_CGROUP_SCHED. No functional change intended.
--- kernel/cgroup/cgroup.c | 63 ++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 30 deletions(-)
kernel/cgroup/cgroup.c +33 -30
@@ -492,28 +492,6 @@ static struct cgroup_subsys_state *cgroup_css(struct cgroup *cgrp,return &cgrp->self; } -/** -* cgroup_tryget_css - try to get a cgroup's css for the specified subsystem -* @cgrp: the cgroup of interest -* @ss: the subsystem of interest -* -* Find and get @cgrp's css associated with @ss. If the css doesn't exist -* or is offline, %NULL is returned. -*/ -static struct cgroup_subsys_state *cgroup_tryget_css (struct cgroup *cgrp, -struct cgroup_subsys *ss) -{ -struct cgroup_subsys_state *css; - -rcu_read_lock (); - css =cgroup_css (cgrp, ss); -if (css && !css_tryget_online (css)) - css =NULL ; -rcu_read_unlock (); - -return css; -} -/** * cgroup_e_css_by_mask - obtain a cgroup's effective css for the specified ss * @cgrp: the cgroup of interest
@@ -3655,6 +3633,28 @@ static int cgroup_stat_show(struct seq_file *seq, void *v) }#ifdef CONFIG_CGROUP_SCHED +/** +* cgroup_tryget_css - try to get a cgroup's css for the specified subsystem +* @cgrp: the cgroup of interest +* @ss: the subsystem of interest +* +* Find and get @cgrp's css associated with @ss. If the css doesn't exist +* or is offline, %NULL is returned. +*/ +static struct cgroup_subsys_state *cgroup_tryget_css (struct cgroup *cgrp, +struct cgroup_subsys *ss) +{ +struct cgroup_subsys_state *css; + +rcu_read_lock (); + css =cgroup_css (cgrp, ss); +if (css && !css_tryget_online (css)) + css =NULL ; +rcu_read_unlock (); + +return css; +} +static int cgroup_extra_stat_show (struct seq_file *seq,int ssid) {struct cgroup *cgrp =seq_css (seq)->cgroup;
@@ -3686,8 +3686,9 @@ static int cpu_stat_show(struct seq_file *seq, void *v)return ret; } -static int __maybe_unused cgroup_local_stat_show (struct seq_file *seq, -struct cgroup *cgrp,int ssid) +#ifdef CONFIG_CGROUP_SCHED +static int cgroup_local_stat_show (struct seq_file *seq, +struct cgroup *cgrp,int ssid) {struct cgroup_subsys *ss = cgroup_subsys[ssid];struct cgroup_subsys_state *css;
@@ -3707,14 +3708,16 @@ static int __maybe_unused cgroup_local_stat_show(struct seq_file *seq,static int cpu_local_stat_show (struct seq_file *seq,void *v) { -struct cgroup __maybe_unused *cgrp =seq_css (seq)->cgroup; -int ret =0 ; +struct cgroup *cgrp =seq_css (seq)->cgroup; -#ifdef CONFIG_CGROUP_SCHED - ret =cgroup_local_stat_show (seq, cgrp, cpu_cgrp_id); -#endif -return ret; +return cgroup_local_stat_show (seq, cgrp, cpu_cgrp_id); +} +#else +static int cpu_local_stat_show (struct seq_file *seq,void *v) +{ +return 0 ; } +#endif #ifdef CONFIG_PSI static int cgroup_io_pressure_show (struct seq_file *seq,void *v)
Signature · 1 line
2.33.0
Quoted 5 lines · Miaohe Lin
Make it under
CONFIG_CGROUP_SCHEDto rid of__maybe_unusedannotation. Also putcgroup_tryget_css()insideCONFIG_CGROUP_SCHEDas it's only called whenCONFIG_CGROUP_SCHED. No functional change intended.Signed-off-by Miaohe Lin <[email protected]>
kernel/cgroup/cgroup.c static int cpu_stat_show(struct seq_file *seq, void *v) · line 3691
Quoted 9 lines
kernel/cgroup/cgroup.c +3
-2@@ -3686,8 +3686,9 @@ static int cpu_stat_show(struct seq_file *seq, void *v)return ret; } -static int __maybe_unused cgroup_local_stat_show (struct seq_file *seq, -struct cgroup *cgrp,int ssid) +#ifdef CONFIG_CGROUP_SCHED +static int cgroup_local_stat_show (struct seq_file *seq, +struct cgroup *cgrp,int ssid)
Andrew, this is based on "sched: add throttled time stat for throttled children" in -next (coming in from -tip). Hence the routing through you rather than the cgroup tree.
Quoted 4 lines · On Thu, 3 Aug 2023 10:27:58 -0400 Johannes Weiner…
Quoted 4 lines
kernel/cgroup/cgroup.c +0
-0@@ -3686,8 +3686,9 @@ static int cpu_stat_show(struct seq_file *seq, void *v)return ret; }
Quoted 9 lines
kernel/cgroup/cgroup.c static int cpu_stat_show(struct seq_file *seq, void *v) · line 3691
Quoted 5 lines
kernel/cgroup/cgroup.c +3
-2-static int __maybe_unused cgroup_local_stat_show (struct seq_file *seq, -struct cgroup *cgrp,int ssid) +#ifdef CONFIG_CGROUP_SCHED +static int cgroup_local_stat_show (struct seq_file *seq, +struct cgroup *cgrp,int ssid)Andrew, this is based on "sched: add throttled time stat for throttled children" in -next (coming in from -tip). Hence the routing through you rather than the cgroup tree.
Since switching to the more gitty workflow I have lost the power to carry patches against -next. I could regain that power I guess, but this is the first time the requirement has come up.
So for now I'll save this patch away for the next -rc cycle.