linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Tejun Heo <tj@kernel.org>, Li Zefan <lizefan@huawei.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@fb.com, pjt@google.com, luto@amacapital.net,
	efault@gmx.de, torvalds@linux-foundation.org,
	Waiman Long <longman@redhat.com>
Subject: [RFC PATCH-cgroup 6/6] cgroup: Make debug controller display bypass and subtree root modes info
Date: Wed, 14 Jun 2017 11:05:37 -0400	[thread overview]
Message-ID: <1497452737-11125-7-git-send-email-longman@redhat.com> (raw)
In-Reply-To: <1497452737-11125-1-git-send-email-longman@redhat.com>

This patch enables the debug controller to display the new bypass
mode and subtree root mode information.

Signed-off-by: Waiman Long <longman@redhat.com>
---
 kernel/cgroup/cgroup-internal.h | 12 ++++++++++++
 kernel/cgroup/cgroup.c          |  9 ---------
 kernel/cgroup/debug.c           | 27 ++++++++++++++++++++-------
 3 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h
index 0e81c61..6bb0a6a 100644
--- a/kernel/cgroup/cgroup-internal.h
+++ b/kernel/cgroup/cgroup-internal.h
@@ -151,6 +151,18 @@ static inline void get_css_set(struct css_set *cset)
 	refcount_inc(&cset->refcount);
 }
 
+/*
+ * Return the cgroup parent.
+ */
+static inline struct cgroup *cgroup_parent(struct cgroup *cgrp)
+{
+	struct cgroup_subsys_state *parent_css = cgrp->self.parent;
+
+	if (parent_css)
+		return container_of(parent_css, struct cgroup, self);
+	return NULL;
+}
+
 bool cgroup_ssid_enabled(int ssid);
 bool cgroup_on_dfl(const struct cgroup *cgrp);
 
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 2a5bd49..6ffe900 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -322,15 +322,6 @@ static void cgroup_idr_remove(struct idr *idr, int id)
 	spin_unlock_bh(&cgroup_idr_lock);
 }
 
-static struct cgroup *cgroup_parent(struct cgroup *cgrp)
-{
-	struct cgroup_subsys_state *parent_css = cgrp->self.parent;
-
-	if (parent_css)
-		return container_of(parent_css, struct cgroup, self);
-	return NULL;
-}
-
 /* is @cgrp threaded? regardless of mixed / root / member? */
 static bool cgroup_is_threaded(struct cgroup *cgrp)
 {
diff --git a/kernel/cgroup/debug.c b/kernel/cgroup/debug.c
index be901c0..561539d 100644
--- a/kernel/cgroup/debug.c
+++ b/kernel/cgroup/debug.c
@@ -198,6 +198,7 @@ static int cgroup_css_links_read(struct seq_file *seq, void *v)
 static int cgroup_subsys_states_read(struct seq_file *seq, void *v)
 {
 	struct cgroup *cgrp = seq_css(seq)->cgroup;
+	struct cgroup *parent = cgroup_parent(cgrp);
 	struct cgroup_subsys *ss;
 	struct cgroup_subsys_state *css;
 	char pbuf[16];
@@ -206,9 +207,16 @@ static int cgroup_subsys_states_read(struct seq_file *seq, void *v)
 	mutex_lock(&cgroup_mutex);
 	for_each_subsys(ss, i) {
 		css = rcu_dereference_check(cgrp->subsys[ss->id], true);
-		if (!css)
+		if (!css) {
+			u16 bypass = cgrp->bypass_ss_mask;
+
+			if (parent)
+				bypass |= parent->subtree_bypass;
+			if (bypass & (1 << ss->id))
+				seq_printf(seq, "%2d: %-4s\t- [Bypass]\n",
+					   ss->id, ss->name);
 			continue;
-
+		}
 		pbuf[0] = '\0';
 
 		/* Show the parent CSS if applicable*/
@@ -234,6 +242,8 @@ static int cgroup_masks_read(struct seq_file *seq, void *v)
 	} mask_list[] = {
 		{ &cgrp->subtree_control,  "subtree_control"  },
 		{ &cgrp->subtree_ss_mask,  "subtree_ss_mask"  },
+		{ &cgrp->subtree_bypass,   "subtree_bypass"   },
+		{ &cgrp->bypass_ss_mask,   "bypass_ss_mask"   },
 	};
 
 	mutex_lock(&cgroup_mutex);
@@ -255,6 +265,8 @@ static int cgroup_masks_read(struct seq_file *seq, void *v)
 	if (cgrp->proc_cgrp)
 		seq_printf(seq, "thread mode      : %s\n",
 			  (cgrp->proc_cgrp == cgrp) ? "root" : "threaded");
+	if (test_bit(CGRP_SUBTREE_ROOT_MODE, &cgrp->flags))
+		seq_puts(seq,   "subtree root mode: on\n");
 
 	mutex_unlock(&cgroup_mutex);
 	return 0;
@@ -314,11 +326,12 @@ static u64 releasable_read(struct cgroup_subsys_state *css, struct cftype *cft)
 };
 
 struct cgroup_subsys debug_cgrp_subsys = {
-	.css_alloc	= debug_css_alloc,
-	.css_free	= debug_css_free,
-	.legacy_cftypes	= debug_files,
-	.dfl_cftypes	= debug_files,
-	.threaded	= true,
+	.css_alloc	 = debug_css_alloc,
+	.css_free	 = debug_css_free,
+	.legacy_cftypes	 = debug_files,
+	.dfl_cftypes	 = debug_files,
+	.threaded	 = true,
+	.enabled_on_root = true,
 };
 
 /*
-- 
1.8.3.1

      parent reply	other threads:[~2017-06-14 15:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-14 15:05 [RFC PATCH-cgroup 0/6] cgroup: bypass and subtree root modes Waiman Long
2017-06-14 15:05 ` [RFC PATCH-cgroup 1/6] cgroup: Relax the no internal process constraint Waiman Long
2017-06-21 20:40   ` Tejun Heo
2017-06-21 21:37     ` Waiman Long
2017-06-21 21:39       ` Tejun Heo
2017-06-21 21:50         ` Waiman Long
2017-06-21 22:02           ` Tejun Heo
2017-06-14 15:05 ` [RFC PATCH-cgroup 2/6] cgroup: Enable bypass mode in cgroup v2 Waiman Long
2017-06-21 21:17   ` Tejun Heo
2017-06-22 20:07     ` Waiman Long
2017-06-14 15:05 ` [RFC PATCH-cgroup 3/6] cgroup: Allow bypss mode in subtree_control Waiman Long
2017-06-14 15:05 ` [RFC PATCH-cgroup 4/6] cgroup: Introduce subtree root mode Waiman Long
2017-06-21 21:38   ` Tejun Heo
2017-06-22 20:27     ` Waiman Long
2017-06-14 15:05 ` [RFC PATCH-cgroup 5/6] cgroup: Skip dying css in cgroup_apply_control_{enable,disable} Waiman Long
2017-06-21 21:42   ` Tejun Heo
2017-06-21 22:01     ` Waiman Long
2017-06-21 22:04       ` Tejun Heo
2017-06-21 22:19         ` Waiman Long
2017-06-14 15:05 ` Waiman Long [this message]

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=1497452737-11125-7-git-send-email-longman@redhat.com \
    --to=longman@redhat.com \
    --cc=cgroups@vger.kernel.org \
    --cc=efault@gmx.de \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.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 NNTP newsgroup(s).