forked from Minki/linux
cgroup: update debug controller to print out thread mode information
Update debug controller so that it prints out debug info about thread mode. 1) The relationship between proc_cset and threaded_csets are displayed. 2) The status of being a thread root or threaded cgroup is displayed. This patch is extracted from Waiman's larger patch. v2: - Removed [thread root] / [threaded] from debug.cgroup_css_links file as the same information is available from cgroup.type. Suggested by Waiman. - Threaded marking is moved to the previous patch. Patch-originally-by: Waiman Long <longman@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
8cfd8147df
commit
7a0cf0e74a
|
@ -153,6 +153,8 @@ static inline void get_css_set(struct css_set *cset)
|
||||||
|
|
||||||
bool cgroup_ssid_enabled(int ssid);
|
bool cgroup_ssid_enabled(int ssid);
|
||||||
bool cgroup_on_dfl(const struct cgroup *cgrp);
|
bool cgroup_on_dfl(const struct cgroup *cgrp);
|
||||||
|
bool cgroup_is_thread_root(struct cgroup *cgrp);
|
||||||
|
bool cgroup_is_threaded(struct cgroup *cgrp);
|
||||||
|
|
||||||
struct cgroup_root *cgroup_root_from_kf(struct kernfs_root *kf_root);
|
struct cgroup_root *cgroup_root_from_kf(struct kernfs_root *kf_root);
|
||||||
struct cgroup *task_cgroup_from_root(struct task_struct *task,
|
struct cgroup *task_cgroup_from_root(struct task_struct *task,
|
||||||
|
|
|
@ -333,7 +333,7 @@ static bool cgroup_has_tasks(struct cgroup *cgrp)
|
||||||
return cgrp->nr_populated_csets;
|
return cgrp->nr_populated_csets;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool cgroup_is_threaded(struct cgroup *cgrp)
|
bool cgroup_is_threaded(struct cgroup *cgrp)
|
||||||
{
|
{
|
||||||
return cgrp->dom_cgrp != cgrp;
|
return cgrp->dom_cgrp != cgrp;
|
||||||
}
|
}
|
||||||
|
@ -372,7 +372,7 @@ static bool cgroup_can_be_thread_root(struct cgroup *cgrp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* is @cgrp root of a threaded subtree? */
|
/* is @cgrp root of a threaded subtree? */
|
||||||
static bool cgroup_is_thread_root(struct cgroup *cgrp)
|
bool cgroup_is_thread_root(struct cgroup *cgrp)
|
||||||
{
|
{
|
||||||
/* thread root should be a domain */
|
/* thread root should be a domain */
|
||||||
if (cgroup_is_threaded(cgrp))
|
if (cgroup_is_threaded(cgrp))
|
||||||
|
|
|
@ -114,27 +114,49 @@ static int cgroup_css_links_read(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
struct cgroup_subsys_state *css = seq_css(seq);
|
struct cgroup_subsys_state *css = seq_css(seq);
|
||||||
struct cgrp_cset_link *link;
|
struct cgrp_cset_link *link;
|
||||||
int dead_cnt = 0, extra_refs = 0;
|
int dead_cnt = 0, extra_refs = 0, threaded_csets = 0;
|
||||||
|
|
||||||
spin_lock_irq(&css_set_lock);
|
spin_lock_irq(&css_set_lock);
|
||||||
|
|
||||||
list_for_each_entry(link, &css->cgroup->cset_links, cset_link) {
|
list_for_each_entry(link, &css->cgroup->cset_links, cset_link) {
|
||||||
struct css_set *cset = link->cset;
|
struct css_set *cset = link->cset;
|
||||||
struct task_struct *task;
|
struct task_struct *task;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int refcnt = refcount_read(&cset->refcount);
|
int refcnt = refcount_read(&cset->refcount);
|
||||||
|
|
||||||
seq_printf(seq, " %d", refcnt);
|
/*
|
||||||
if (refcnt - cset->nr_tasks > 0) {
|
* Print out the proc_cset and threaded_cset relationship
|
||||||
int extra = refcnt - cset->nr_tasks;
|
* and highlight difference between refcount and task_count.
|
||||||
|
*/
|
||||||
|
seq_printf(seq, "css_set %pK", cset);
|
||||||
|
if (rcu_dereference_protected(cset->dom_cset, 1) != cset) {
|
||||||
|
threaded_csets++;
|
||||||
|
seq_printf(seq, "=>%pK", cset->dom_cset);
|
||||||
|
}
|
||||||
|
if (!list_empty(&cset->threaded_csets)) {
|
||||||
|
struct css_set *tcset;
|
||||||
|
int idx = 0;
|
||||||
|
|
||||||
seq_printf(seq, " +%d", extra);
|
list_for_each_entry(tcset, &cset->threaded_csets,
|
||||||
/*
|
threaded_csets_node) {
|
||||||
* Take out the one additional reference in
|
seq_puts(seq, idx ? "," : "<=");
|
||||||
* init_css_set.
|
seq_printf(seq, "%pK", tcset);
|
||||||
*/
|
idx++;
|
||||||
if (cset == &init_css_set)
|
}
|
||||||
extra--;
|
} else {
|
||||||
extra_refs += extra;
|
seq_printf(seq, " %d", refcnt);
|
||||||
|
if (refcnt - cset->nr_tasks > 0) {
|
||||||
|
int extra = refcnt - cset->nr_tasks;
|
||||||
|
|
||||||
|
seq_printf(seq, " +%d", extra);
|
||||||
|
/*
|
||||||
|
* Take out the one additional reference in
|
||||||
|
* init_css_set.
|
||||||
|
*/
|
||||||
|
if (cset == &init_css_set)
|
||||||
|
extra--;
|
||||||
|
extra_refs += extra;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
seq_puts(seq, "\n");
|
seq_puts(seq, "\n");
|
||||||
|
|
||||||
|
@ -163,10 +185,12 @@ static int cgroup_css_links_read(struct seq_file *seq, void *v)
|
||||||
}
|
}
|
||||||
spin_unlock_irq(&css_set_lock);
|
spin_unlock_irq(&css_set_lock);
|
||||||
|
|
||||||
if (!dead_cnt && !extra_refs)
|
if (!dead_cnt && !extra_refs && !threaded_csets)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
seq_puts(seq, "\n");
|
seq_puts(seq, "\n");
|
||||||
|
if (threaded_csets)
|
||||||
|
seq_printf(seq, "threaded css_sets = %d\n", threaded_csets);
|
||||||
if (extra_refs)
|
if (extra_refs)
|
||||||
seq_printf(seq, "extra references = %d\n", extra_refs);
|
seq_printf(seq, "extra references = %d\n", extra_refs);
|
||||||
if (dead_cnt)
|
if (dead_cnt)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user