public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: akpm@linux-foundation.org
Cc: tj@kernel.org, hannes@cmpxchg.org, lizefan.x@bytedance.com,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	linmiaohe@huawei.com
Subject: [PATCH] cgroup: minor cleanup for cgroup_local_stat_show()
Date: Thu, 3 Aug 2023 19:31:23 +0800	[thread overview]
Message-ID: <20230803113123.577023-1-linmiaohe@huawei.com> (raw)

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.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 kernel/cgroup/cgroup.c | 63 ++++++++++++++++++++++--------------------
 1 file changed, 33 insertions(+), 30 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index c2c97529235a..e9239651cf4a 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -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)
-- 
2.33.0


             reply	other threads:[~2023-08-03 11:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03 11:31 Miaohe Lin [this message]
     [not found] ` <20230803113123.577023-1-linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2023-08-03 14:27   ` [PATCH] cgroup: minor cleanup for cgroup_local_stat_show() Johannes Weiner
     [not found]     ` <20230803142758.GC219857-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
2023-08-03 17:05       ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2023-07-23  3:19 Miaohe Lin
     [not found] ` <20230723031932.3152951-1-linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2023-07-25 21:53   ` Tejun Heo
     [not found]     ` <ZMBERCXR27X_gRAt-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-07-26  1:06       ` Miaohe Lin
     [not found]         ` <ec3df402-7681-3d0c-b9ce-d50eb7383b1e-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2023-07-27 11:50           ` Miaohe Lin
     [not found]             ` <719a19c4-3be5-2260-7349-b3f1bb774f4f-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2023-07-31 23:47               ` Tejun Heo
     [not found]                 ` <ZMhIFUsxEtA_B781-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-08-01  7:48                   ` Miaohe Lin
     [not found]                     ` <3ec1f5d9-4887-4583-a973-92298a9bc924-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2023-08-02 19:39                       ` Tejun Heo
     [not found]                         ` <ZMqxCVOkU7pKK9OO-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-08-03  1:38                           ` Miaohe Lin

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=20230803113123.577023-1-linmiaohe@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=tj@kernel.org \
    /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