linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -tip 0/2] sched: Get group names back in /proc/sched_debug
@ 2011-01-10  5:14 Bharata B Rao
  2011-01-10  5:15 ` [PATCH -tip 1/2] sched: Reinstate group names " Bharata B Rao
  2011-01-10  5:16 ` [PATCH -tip 2/2] sched: Display autogroup " Bharata B Rao
  0 siblings, 2 replies; 7+ messages in thread
From: Bharata B Rao @ 2011-01-10  5:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mike Galbraith, Peter Zijlstra, Ingo Molnar

Hi,

With autogroup patches, the group names got dropped off from
/proc/sched_debug. Without group name info, it is difficult to figure out
which cfs_rq or task belongs to which group in /proc/sched_debug output.

This patchset brings back the group name and also adds autogroup names
to /proc/sched_debug output.

Before this patchset
====================
# grep cfs_rq /proc/sched_debug 
cfs_rq[0]:
cfs_rq[0]:
cfs_rq[1]:
cfs_rq[1]:
cfs_rq[2]:
cfs_rq[2]:
cfs_rq[3]:
cfs_rq[3]:
cfs_rq[4]:
cfs_rq[5]:
cfs_rq[6]:
cfs_rq[7]:
cfs_rq[8]:
cfs_rq[9]:
cfs_rq[10]:
cfs_rq[11]:
cfs_rq[12]:
cfs_rq[13]:
cfs_rq[13]:
cfs_rq[14]:
cfs_rq[14]:
cfs_rq[15]:
cfs_rq[15]:

# grep while1 /proc/sched_debug 
R         while1  2203     48420.920338      5007   120     48420.920338     48951.419166         7.485277
R         while1  2226     23823.872648      2865   120     23823.872648     28347.561387         3.988024
R         while1  2204     43006.490234      4851   120     43006.490234     48459.814725         0.000000

With this patchset
==================
# grep cfs_rq /proc/sched_debug 
cfs_rq[0]:/autogroup-52
cfs_rq[0]:/autogroup-0
cfs_rq[1]:/autogroup-54
cfs_rq[1]:/autogroup-0
cfs_rq[2]:/autogroup-51
cfs_rq[2]:/autogroup-0
cfs_rq[3]:/autogroup-0
cfs_rq[4]:/autogroup-50
cfs_rq[4]:/autogroup-0
cfs_rq[5]:/autogroup-11
cfs_rq[5]:/autogroup-0
cfs_rq[6]:/autogroup-0
cfs_rq[7]:/autogroup-0
cfs_rq[8]:/autogroup-13
cfs_rq[8]:/autogroup-0
cfs_rq[9]:/autogroup-0
cfs_rq[10]:/autogroup-52
cfs_rq[10]:/autogroup-0
cfs_rq[11]:/autogroup-52
cfs_rq[11]:/autogroup-0
cfs_rq[12]:/autogroup-0
cfs_rq[13]:/autogroup-0
cfs_rq[14]:/1
cfs_rq[14]:/autogroup-0
cfs_rq[15]:/autogroup-0

# grep while1 /proc/sched_debug 
R         while1  2208     38199.296761      3826   120     38199.296761     38200.395907         4.341835 /autogroup-54
R         while1  2205     31251.518310      5629   120     31251.518310     54431.493631         6.882145 /autogroup-50
R         while1  2206     43920.889967      5402   120     43920.889967     53954.315334         0.000000 /1

Regards,
Bharata.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH -tip 1/2] sched: Reinstate group names in /proc/sched_debug.
  2011-01-10  5:14 [PATCH -tip 0/2] sched: Get group names back in /proc/sched_debug Bharata B Rao
@ 2011-01-10  5:15 ` Bharata B Rao
  2011-01-11  1:53   ` Yong Zhang
  2011-01-10  5:16 ` [PATCH -tip 2/2] sched: Display autogroup " Bharata B Rao
  1 sibling, 1 reply; 7+ messages in thread
From: Bharata B Rao @ 2011-01-10  5:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mike Galbraith, Peter Zijlstra, Ingo Molnar

sched: Reinstate group names in /proc/sched_debug.

Displaying of group names in /proc/sched_debug was dropped in autogroup
patches. Add group names while displaying cfs_rq and tasks information.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
 kernel/sched_debug.c |   34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -16,6 +16,9 @@
 #include <linux/kallsyms.h>
 #include <linux/utsname.h>
 
+static char group_path[PATH_MAX];
+static DEFINE_SPINLOCK(sched_debug_lock);
+
 /*
  * This allows printing both to /proc/sched_debug and
  * to the console
@@ -86,6 +89,23 @@ static void print_cfs_group_stats(struct
 }
 #endif
 
+#ifdef CONFIG_CGROUP_SCHED
+static char * task_group_path(struct task_group *tg)
+{
+	/*
+	 * May be NULL if the underlying cgroup isn't fully-created yet
+	 */
+	if (!tg->css.cgroup) {
+		group_path[0] = '\0';
+		return group_path;
+	}
+	rcu_read_lock();
+	cgroup_path(tg->css.cgroup, group_path, PATH_MAX);
+	rcu_read_unlock();
+	return group_path;
+}
+#endif
+
 static void
 print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
 {
@@ -108,6 +128,9 @@ print_task(struct seq_file *m, struct rq
 	SEQ_printf(m, "%15Ld %15Ld %15Ld.%06ld %15Ld.%06ld %15Ld.%06ld",
 		0LL, 0LL, 0LL, 0L, 0LL, 0L, 0LL, 0L);
 #endif
+#ifdef CONFIG_CGROUP_SCHED
+	SEQ_printf(m, " %s", task_group_path(task_group(p)));
+#endif
 
 	SEQ_printf(m, "\n");
 }
@@ -144,7 +167,11 @@ void print_cfs_rq(struct seq_file *m, in
 	struct sched_entity *last;
 	unsigned long flags;
 
+#if defined(CONFIG_CGROUP_SCHED) && defined(CONFIG_FAIR_GROUP_SCHED)
+	SEQ_printf(m, "\ncfs_rq[%d]:%s\n", cpu, task_group_path(cfs_rq->tg));
+#else
 	SEQ_printf(m, "\ncfs_rq[%d]:\n", cpu);
+#endif
 	SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "exec_clock",
 			SPLIT_NS(cfs_rq->exec_clock));
 
@@ -191,7 +218,11 @@ void print_cfs_rq(struct seq_file *m, in
 
 void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq)
 {
+#if defined(CONFIG_CGROUP_SCHED) && defined(CONFIG_RT_GROUP_SCHED)
+	SEQ_printf(m, "\nrt_rq[%d]:%s\n", cpu, task_group_path(rt_rq->tg));
+#else
 	SEQ_printf(m, "\nrt_rq[%d]:\n", cpu);
+#endif
 
 #define P(x) \
 	SEQ_printf(m, "  .%-30s: %Ld\n", #x, (long long)(rt_rq->x))
@@ -212,6 +243,7 @@ extern __read_mostly int sched_clock_run
 static void print_cpu(struct seq_file *m, int cpu)
 {
 	struct rq *rq = cpu_rq(cpu);
+	unsigned long flags;
 
 #ifdef CONFIG_X86
 	{
@@ -266,10 +298,12 @@ static void print_cpu(struct seq_file *m
 
 #undef P
 #endif
+	spin_lock_irqsave(&sched_debug_lock, flags);
 	print_cfs_stats(m, cpu);
 	print_rt_stats(m, cpu);
 
 	print_rq(m, rq, cpu);
+	spin_unlock_irqrestore(&sched_debug_lock, flags);
 }
 
 static const char *sched_tunable_scaling_names[] = {

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH -tip 2/2] sched: Display autogroup names in /proc/sched_debug.
  2011-01-10  5:14 [PATCH -tip 0/2] sched: Get group names back in /proc/sched_debug Bharata B Rao
  2011-01-10  5:15 ` [PATCH -tip 1/2] sched: Reinstate group names " Bharata B Rao
@ 2011-01-10  5:16 ` Bharata B Rao
  2011-01-10  9:38   ` Mike Galbraith
  1 sibling, 1 reply; 7+ messages in thread
From: Bharata B Rao @ 2011-01-10  5:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mike Galbraith, Peter Zijlstra, Ingo Molnar

sched: Display autogroup names in /proc/sched_debug.

Add autogroup name to cfs_rq and tasks information in /proc/sched_debug.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
 kernel/sched_debug.c |    8 ++++++++
 1 file changed, 8 insertions(+)

--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -92,6 +92,14 @@ static void print_cfs_group_stats(struct
 #ifdef CONFIG_CGROUP_SCHED
 static char * task_group_path(struct task_group *tg)
 {
+#ifdef CONFIG_SCHED_AUTOGROUP
+	int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
+
+	if (enabled && tg->autogroup) {
+		autogroup_path(tg, group_path, PATH_MAX);
+		return group_path;
+	}
+#endif
 	/*
 	 * May be NULL if the underlying cgroup isn't fully-created yet
 	 */

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH -tip 2/2] sched: Display autogroup names in /proc/sched_debug.
  2011-01-10  5:16 ` [PATCH -tip 2/2] sched: Display autogroup " Bharata B Rao
@ 2011-01-10  9:38   ` Mike Galbraith
  2011-01-10 10:09     ` Bharata B Rao
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Galbraith @ 2011-01-10  9:38 UTC (permalink / raw)
  To: bharata; +Cc: linux-kernel, Peter Zijlstra, Ingo Molnar

On Mon, 2011-01-10 at 10:46 +0530, Bharata B Rao wrote:
> sched: Display autogroup names in /proc/sched_debug.
> 
> Add autogroup name to cfs_rq and tasks information in /proc/sched_debug.
> 
> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> ---
>  kernel/sched_debug.c |    8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> --- a/kernel/sched_debug.c
> +++ b/kernel/sched_debug.c
> @@ -92,6 +92,14 @@ static void print_cfs_group_stats(struct
>  #ifdef CONFIG_CGROUP_SCHED
>  static char * task_group_path(struct task_group *tg)
>  {
> +#ifdef CONFIG_SCHED_AUTOGROUP
> +	int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
> +
> +	if (enabled && tg->autogroup) {
> +		autogroup_path(tg, group_path, PATH_MAX);
> +		return group_path;
> +	}
> +#endif
>  	/*
>  	 * May be NULL if the underlying cgroup isn't fully-created yet
>  	 */

What prevents the task being moved, and the task group being freed under
you?  Looks to me like task_group_path() needs rcu_read_lock().  It is
locked in the other two instances.  How about the below?

Date: Mon, 10 Jan 2011 10:46:43 +0530
From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: Mike Galbraith <efault@gmx.de>, Peter Zijlstra <a.p.zijlstra@chello.nl>, Ingo Molnar <mingo@elte.hu>
Subject: [PATCH -tip 2/2] sched: Display autogroup names in /proc/sched_debug.

sched: Display autogroup names in /proc/sched_debug.

Add autogroup name to cfs_rq and tasks information in /proc/sched_debug.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
 kernel/sched_autogroup.c |    5 +++++
 kernel/sched_debug.c     |    7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

Index: linux-2.6/kernel/sched_debug.c
===================================================================
--- linux-2.6.orig/kernel/sched_debug.c
+++ linux-2.6/kernel/sched_debug.c
@@ -92,6 +92,9 @@ static void print_cfs_group_stats(struct
 #ifdef CONFIG_CGROUP_SCHED
 static char * task_group_path(struct task_group *tg)
 {
+	if (autogroup_path(tg, group_path, PATH_MAX))
+		return group_path;
+
 	/*
 	 * May be NULL if the underlying cgroup isn't fully-created yet
 	 */
@@ -99,9 +102,7 @@ static char * task_group_path(struct tas
 		group_path[0] = '\0';
 		return group_path;
 	}
-	rcu_read_lock();
 	cgroup_path(tg->css.cgroup, group_path, PATH_MAX);
-	rcu_read_unlock();
 	return group_path;
 }
 #endif
@@ -302,7 +303,9 @@ static void print_cpu(struct seq_file *m
 	print_cfs_stats(m, cpu);
 	print_rt_stats(m, cpu);
 
+	rcu_read_lock();
 	print_rq(m, rq, cpu);
+	rcu_read_unlock();
 	spin_unlock_irqrestore(&sched_debug_lock, flags);
 }
 
Index: linux-2.6/kernel/sched_autogroup.c
===================================================================
--- linux-2.6.orig/kernel/sched_autogroup.c
+++ linux-2.6/kernel/sched_autogroup.c
@@ -231,6 +231,11 @@ void proc_sched_autogroup_show_task(stru
 #ifdef CONFIG_SCHED_DEBUG
 static inline int autogroup_path(struct task_group *tg, char *buf, int buflen)
 {
+	int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
+
+	if (!enabled || tg == &root_task_group)
+		return 0;
+
 	return snprintf(buf, buflen, "%s-%ld", "/autogroup", tg->autogroup->id);
 }
 #endif /* CONFIG_SCHED_DEBUG */



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH -tip 2/2] sched: Display autogroup names in /proc/sched_debug.
  2011-01-10  9:38   ` Mike Galbraith
@ 2011-01-10 10:09     ` Bharata B Rao
  0 siblings, 0 replies; 7+ messages in thread
From: Bharata B Rao @ 2011-01-10 10:09 UTC (permalink / raw)
  To: Mike Galbraith; +Cc: linux-kernel, Peter Zijlstra, Ingo Molnar

On Mon, Jan 10, 2011 at 10:38:07AM +0100, Mike Galbraith wrote:
> On Mon, 2011-01-10 at 10:46 +0530, Bharata B Rao wrote:
> > sched: Display autogroup names in /proc/sched_debug.
> > 
> > Add autogroup name to cfs_rq and tasks information in /proc/sched_debug.
> > 
> > Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> > ---
> >  kernel/sched_debug.c |    8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > --- a/kernel/sched_debug.c
> > +++ b/kernel/sched_debug.c
> > @@ -92,6 +92,14 @@ static void print_cfs_group_stats(struct
> >  #ifdef CONFIG_CGROUP_SCHED
> >  static char * task_group_path(struct task_group *tg)
> >  {
> > +#ifdef CONFIG_SCHED_AUTOGROUP
> > +	int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
> > +
> > +	if (enabled && tg->autogroup) {
> > +		autogroup_path(tg, group_path, PATH_MAX);
> > +		return group_path;
> > +	}
> > +#endif
> >  	/*
> >  	 * May be NULL if the underlying cgroup isn't fully-created yet
> >  	 */
> 
> What prevents the task being moved, and the task group being freed under
> you?  Looks to me like task_group_path() needs rcu_read_lock().  It is
> locked in the other two instances.  How about the below?

You are right, we need rcu_read_lock() there. Let me spin out an other
version with the changes.

Thanks,
Bharata.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH -tip 1/2] sched: Reinstate group names in /proc/sched_debug.
  2011-01-10  5:15 ` [PATCH -tip 1/2] sched: Reinstate group names " Bharata B Rao
@ 2011-01-11  1:53   ` Yong Zhang
  2011-01-11 10:13     ` Bharata B Rao
  0 siblings, 1 reply; 7+ messages in thread
From: Yong Zhang @ 2011-01-11  1:53 UTC (permalink / raw)
  To: bharata; +Cc: linux-kernel, Mike Galbraith, Peter Zijlstra, Ingo Molnar

On Mon, Jan 10, 2011 at 1:15 PM, Bharata B Rao
<bharata@linux.vnet.ibm.com> wrote:
> sched: Reinstate group names in /proc/sched_debug.
>
> Displaying of group names in /proc/sched_debug was dropped in autogroup
> patches. Add group names while displaying cfs_rq and tasks information.
>
> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> ---
> @@ -144,7 +167,11 @@ void print_cfs_rq(struct seq_file *m, in
>        struct sched_entity *last;
>        unsigned long flags;
>
> +#if defined(CONFIG_CGROUP_SCHED) && defined(CONFIG_FAIR_GROUP_SCHED)

defined(CONFIG_CGROUP_SCHED) is not necessary here,
CONFIG_[FAIR|RT]_GROUP_SCHED always imply CONFIG_CGROUP_SCHED

> +       SEQ_printf(m, "\ncfs_rq[%d]:%s\n", cpu, task_group_path(cfs_rq->tg));
> +#else
>        SEQ_printf(m, "\ncfs_rq[%d]:\n", cpu);
> +#endif
>        SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "exec_clock",
>                        SPLIT_NS(cfs_rq->exec_clock));
>
> @@ -191,7 +218,11 @@ void print_cfs_rq(struct seq_file *m, in
>
>  void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq)
>  {
> +#if defined(CONFIG_CGROUP_SCHED) && defined(CONFIG_RT_GROUP_SCHED)

Ditto.

Thanks,
Yong

-- 
Only stand for myself

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH -tip 1/2] sched: Reinstate group names in /proc/sched_debug.
  2011-01-11  1:53   ` Yong Zhang
@ 2011-01-11 10:13     ` Bharata B Rao
  0 siblings, 0 replies; 7+ messages in thread
From: Bharata B Rao @ 2011-01-11 10:13 UTC (permalink / raw)
  To: Yong Zhang; +Cc: linux-kernel, Mike Galbraith, Peter Zijlstra, Ingo Molnar

On Tue, Jan 11, 2011 at 09:53:05AM +0800, Yong Zhang wrote:
> On Mon, Jan 10, 2011 at 1:15 PM, Bharata B Rao
> <bharata@linux.vnet.ibm.com> wrote:
> > sched: Reinstate group names in /proc/sched_debug.
> >
> > Displaying of group names in /proc/sched_debug was dropped in autogroup
> > patches. Add group names while displaying cfs_rq and tasks information.
> >
> > Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> > ---
> > @@ -144,7 +167,11 @@ void print_cfs_rq(struct seq_file *m, in
> >        struct sched_entity *last;
> >        unsigned long flags;
> >
> > +#if defined(CONFIG_CGROUP_SCHED) && defined(CONFIG_FAIR_GROUP_SCHED)
> 
> defined(CONFIG_CGROUP_SCHED) is not necessary here,
> CONFIG_[FAIR|RT]_GROUP_SCHED always imply CONFIG_CGROUP_SCHED

Took care of this in my latest post.

Thanks,
Bharata.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-01-11 10:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-10  5:14 [PATCH -tip 0/2] sched: Get group names back in /proc/sched_debug Bharata B Rao
2011-01-10  5:15 ` [PATCH -tip 1/2] sched: Reinstate group names " Bharata B Rao
2011-01-11  1:53   ` Yong Zhang
2011-01-11 10:13     ` Bharata B Rao
2011-01-10  5:16 ` [PATCH -tip 2/2] sched: Display autogroup " Bharata B Rao
2011-01-10  9:38   ` Mike Galbraith
2011-01-10 10:09     ` Bharata B Rao

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).