From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Waiman Long <longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org,
peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-team-b10kYP2dOMg@public.gmane.org,
Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: [PATCH 6/7] cgroup: refactor cgroup_masks_read() in the debug controller
Date: Wed, 14 Jun 2017 16:08:41 -0400 [thread overview]
Message-ID: <20170614200842.15174-7-tj@kernel.org> (raw)
In-Reply-To: <20170614200842.15174-1-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Factor out cgroup_masks_read_one() out of cgroup_masks_read() for
simplicity.
Signed-off-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Waiman Long <longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
kernel/cgroup/debug.c | 46 +++++++++++++++++++++-------------------------
1 file changed, 21 insertions(+), 25 deletions(-)
diff --git a/kernel/cgroup/debug.c b/kernel/cgroup/debug.c
index d61e692a5338..163fdbd7adf6 100644
--- a/kernel/cgroup/debug.c
+++ b/kernel/cgroup/debug.c
@@ -200,36 +200,32 @@ static int cgroup_subsys_states_read(struct seq_file *seq, void *v)
return 0;
}
-static int cgroup_masks_read(struct seq_file *seq, void *v)
+static void cgroup_masks_read_one(struct seq_file *seq, const char *name,
+ u16 mask)
{
- struct cgroup *cgrp = seq_css(seq)->cgroup;
struct cgroup_subsys *ss;
- int i, j;
- struct {
- u16 *mask;
- char *name;
- } mask_list[] = {
- { &cgrp->subtree_control, "subtree_control" },
- { &cgrp->subtree_ss_mask, "subtree_ss_mask" },
- };
+ int ssid;
+ bool first = true;
- mutex_lock(&cgroup_mutex);
- for (i = 0; i < ARRAY_SIZE(mask_list); i++) {
- u16 mask = *mask_list[i].mask;
- bool first = true;
-
- seq_printf(seq, "%-17s: ", mask_list[i].name);
- for_each_subsys(ss, j) {
- if (!(mask & (1 << ss->id)))
- continue;
- if (!first)
- seq_puts(seq, ", ");
- seq_puts(seq, ss->name);
- first = false;
- }
- seq_putc(seq, '\n');
+ seq_printf(seq, "%-17s: ", name);
+ for_each_subsys(ss, ssid) {
+ if (!(mask & (1 << ssid)))
+ continue;
+ if (!first)
+ seq_puts(seq, ", ");
+ seq_puts(seq, ss->name);
+ first = false;
}
+ seq_putc(seq, '\n');
+}
+static int cgroup_masks_read(struct seq_file *seq, void *v)
+{
+ struct cgroup *cgrp = seq_css(seq)->cgroup;
+
+ mutex_lock(&cgroup_mutex);
+ cgroup_masks_read_one(seq, "subtree_control", cgrp->subtree_control);
+ cgroup_masks_read_one(seq, "subtree_ss_mask", cgrp->subtree_ss_mask);
mutex_unlock(&cgroup_mutex);
return 0;
}
--
2.13.0
WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: Waiman Long <longman@redhat.com>
Cc: lizefan@huawei.com, hannes@cmpxchg.org, peterz@infradead.org,
mingo@redhat.com, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-team@fb.com,
Tejun Heo <tj@kernel.org>
Subject: [PATCH 6/7] cgroup: refactor cgroup_masks_read() in the debug controller
Date: Wed, 14 Jun 2017 16:08:41 -0400 [thread overview]
Message-ID: <20170614200842.15174-7-tj@kernel.org> (raw)
In-Reply-To: <20170614200842.15174-1-tj@kernel.org>
Factor out cgroup_masks_read_one() out of cgroup_masks_read() for
simplicity.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Waiman Long <longman@redhat.com>
---
kernel/cgroup/debug.c | 46 +++++++++++++++++++++-------------------------
1 file changed, 21 insertions(+), 25 deletions(-)
diff --git a/kernel/cgroup/debug.c b/kernel/cgroup/debug.c
index d61e692a5338..163fdbd7adf6 100644
--- a/kernel/cgroup/debug.c
+++ b/kernel/cgroup/debug.c
@@ -200,36 +200,32 @@ static int cgroup_subsys_states_read(struct seq_file *seq, void *v)
return 0;
}
-static int cgroup_masks_read(struct seq_file *seq, void *v)
+static void cgroup_masks_read_one(struct seq_file *seq, const char *name,
+ u16 mask)
{
- struct cgroup *cgrp = seq_css(seq)->cgroup;
struct cgroup_subsys *ss;
- int i, j;
- struct {
- u16 *mask;
- char *name;
- } mask_list[] = {
- { &cgrp->subtree_control, "subtree_control" },
- { &cgrp->subtree_ss_mask, "subtree_ss_mask" },
- };
+ int ssid;
+ bool first = true;
- mutex_lock(&cgroup_mutex);
- for (i = 0; i < ARRAY_SIZE(mask_list); i++) {
- u16 mask = *mask_list[i].mask;
- bool first = true;
-
- seq_printf(seq, "%-17s: ", mask_list[i].name);
- for_each_subsys(ss, j) {
- if (!(mask & (1 << ss->id)))
- continue;
- if (!first)
- seq_puts(seq, ", ");
- seq_puts(seq, ss->name);
- first = false;
- }
- seq_putc(seq, '\n');
+ seq_printf(seq, "%-17s: ", name);
+ for_each_subsys(ss, ssid) {
+ if (!(mask & (1 << ssid)))
+ continue;
+ if (!first)
+ seq_puts(seq, ", ");
+ seq_puts(seq, ss->name);
+ first = false;
}
+ seq_putc(seq, '\n');
+}
+static int cgroup_masks_read(struct seq_file *seq, void *v)
+{
+ struct cgroup *cgrp = seq_css(seq)->cgroup;
+
+ mutex_lock(&cgroup_mutex);
+ cgroup_masks_read_one(seq, "subtree_control", cgrp->subtree_control);
+ cgroup_masks_read_one(seq, "subtree_ss_mask", cgrp->subtree_ss_mask);
mutex_unlock(&cgroup_mutex);
return 0;
}
--
2.13.0
next prev parent reply other threads:[~2017-06-14 20:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-14 20:08 [PATCHSET] cgroup: Make debug controller useful for debugging Tejun Heo
2017-06-14 20:08 ` Tejun Heo
2017-06-14 20:08 ` [PATCH 1/7] cgroup: Keep accurate count of tasks in each css_set Tejun Heo
2017-06-14 20:08 ` [PATCH 2/7] cgroup: Move debug cgroup to its own file Tejun Heo
2017-06-14 20:08 ` [PATCH 3/7] cgroup: Make Kconfig prompt of debug cgroup more accurate Tejun Heo
2017-06-14 20:08 ` [PATCH 4/7] cgroup: Make debug cgroup support v2 and thread mode Tejun Heo
2017-06-14 20:08 ` [PATCH 5/7] cgroup: make debug an implicit controller on cgroup2 Tejun Heo
[not found] ` <20170614200842.15174-1-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-06-14 20:08 ` Tejun Heo [this message]
2017-06-14 20:08 ` [PATCH 6/7] cgroup: refactor cgroup_masks_read() in the debug controller Tejun Heo
2017-06-14 20:53 ` [PATCHSET] cgroup: Make debug controller useful for debugging Waiman Long
2017-06-14 20:53 ` Waiman Long
2017-06-14 20:08 ` [PATCH 7/7] cgroup: fix lockdep warning in debug controller 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=20170614200842.15174-7-tj@kernel.org \
--to=tj-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=kernel-team-b10kYP2dOMg@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.