cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xiu Jianfeng <xiujianfeng@huaweicloud.com>
To: tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH -next] cgroup: move proc_cgroupstats_show() to cgroup.c
Date: Fri, 12 Apr 2024 02:54:02 +0000	[thread overview]
Message-ID: <20240412025402.780603-1-xiujianfeng@huaweicloud.com> (raw)

From: Xiu Jianfeng <xiujianfeng@huawei.com>

Currently proc_cgroupstats_show() is in cgroup-v1.c, however it can be
used for v2 too, so it's better to move it cgroup.c.

Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
 kernel/cgroup/cgroup-internal.h |  1 -
 kernel/cgroup/cgroup-v1.c       | 21 ---------------------
 kernel/cgroup/cgroup.c          | 21 +++++++++++++++++++++
 3 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h
index 520b90dd97ec..9afb39da0d8d 100644
--- a/kernel/cgroup/cgroup-internal.h
+++ b/kernel/cgroup/cgroup-internal.h
@@ -284,7 +284,6 @@ extern struct cftype cgroup1_base_files[];
 extern struct kernfs_syscall_ops cgroup1_kf_syscall_ops;
 extern const struct fs_parameter_spec cgroup1_fs_parameters[];
 
-int proc_cgroupstats_show(struct seq_file *m, void *v);
 bool cgroup1_ssid_disabled(int ssid);
 void cgroup1_pidlist_destroy_all(struct cgroup *cgrp);
 void cgroup1_release_agent(struct work_struct *work);
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
index 520a11cb12f4..ca22f66b5c64 100644
--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -663,27 +663,6 @@ struct cftype cgroup1_base_files[] = {
 	{ }	/* terminate */
 };
 
-/* Display information about each subsystem and each hierarchy */
-int proc_cgroupstats_show(struct seq_file *m, void *v)
-{
-	struct cgroup_subsys *ss;
-	int i;
-
-	seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n");
-	/*
-	 * Grab the subsystems state racily. No need to add avenue to
-	 * cgroup_mutex contention.
-	 */
-
-	for_each_subsys(ss, i)
-		seq_printf(m, "%s\t%d\t%d\t%d\n",
-			   ss->legacy_name, ss->root->hierarchy_id,
-			   atomic_read(&ss->root->nr_cgrps),
-			   cgroup_ssid_enabled(i));
-
-	return 0;
-}
-
 /**
  * cgroupstats_build - build and fill cgroupstats
  * @stats: cgroupstats to fill information into
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index a66c088c851c..dcdc23d66aa0 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -6028,6 +6028,27 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early)
 	cgroup_unlock();
 }
 
+/* Display information about each subsystem and each hierarchy */
+static int proc_cgroupstats_show(struct seq_file *m, void *v)
+{
+	struct cgroup_subsys *ss;
+	int i;
+
+	seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n");
+	/*
+	 * Grab the subsystems state racily. No need to add avenue to
+	 * cgroup_mutex contention.
+	 */
+
+	for_each_subsys(ss, i)
+		seq_printf(m, "%s\t%d\t%d\t%d\n",
+			   ss->legacy_name, ss->root->hierarchy_id,
+			   atomic_read(&ss->root->nr_cgrps),
+			   cgroup_ssid_enabled(i));
+
+	return 0;
+}
+
 /**
  * cgroup_init_early - cgroup initialization at system boot
  *
-- 
2.34.1


             reply	other threads:[~2024-04-12  3:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-12  2:54 Xiu Jianfeng [this message]
2024-04-12 17:20 ` [PATCH -next] cgroup: move proc_cgroupstats_show() to cgroup.c 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=20240412025402.780603-1-xiujianfeng@huaweicloud.com \
    --to=xiujianfeng@huaweicloud.com \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).