linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] sched/debug: schedstats bug fix and cleanups
@ 2016-06-03 20:44 Josh Poimboeuf
  2016-06-03 20:44 ` [PATCH 1/3] sched/debug: fix /proc/sched_debug regression Josh Poimboeuf
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Josh Poimboeuf @ 2016-06-03 20:44 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: linux-kernel, Mel Gorman, Matt Fleming, Srikar Dronamraju

A /proc/sched_debug bug fix and a couple of other schedstats-related
cleanups.

Josh Poimboeuf (3):
  sched/debug: fix /proc/sched_debug regression
  sched/debug: always show nr_migrations
  sched/debug: remove unnecessary CONFIG_SCHEDSTATS checks

 kernel/sched/debug.c | 24 +++++++++---------------
 kernel/sched/fair.c  |  4 ++--
 2 files changed, 11 insertions(+), 17 deletions(-)

-- 
2.4.11

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

* [PATCH 1/3] sched/debug: fix /proc/sched_debug regression
  2016-06-03 20:44 [PATCH 0/3] sched/debug: schedstats bug fix and cleanups Josh Poimboeuf
@ 2016-06-03 20:44 ` Josh Poimboeuf
  2016-06-03 20:44 ` [PATCH 2/3] sched/debug: always show nr_migrations Josh Poimboeuf
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Josh Poimboeuf @ 2016-06-03 20:44 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: linux-kernel, Mel Gorman, Matt Fleming, Srikar Dronamraju

Commit cb2517653fcc ("sched/debug: Make schedstats a runtime tunable
that is disabled by default") introduced a bug when CONFIG_SCHEDSTATS is
enabled and the runtime tunable is disabled (which is the default).  The
wait-time, sum-exec, and sum-sleep fields are missing from the
/proc/sched_debug file in the runnable_tasks section.

Fix it by getting rid of the explicit check for CONFIG_SCHEDSTATS.  It's
already implicitly checked by schedstat_enabled() anyway.

Fixes: cb2517653fcc ("sched/debug: Make schedstats a runtime tunable that is disabled by default")
Cc: stable@vger.kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 kernel/sched/debug.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index cf905f6..500ea7e 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -427,19 +427,18 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
 		SPLIT_NS(p->se.vruntime),
 		(long long)(p->nvcsw + p->nivcsw),
 		p->prio);
-#ifdef CONFIG_SCHEDSTATS
-	if (schedstat_enabled()) {
+
+	if (schedstat_enabled())
 		SEQ_printf(m, "%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld",
 			SPLIT_NS(p->se.statistics.wait_sum),
 			SPLIT_NS(p->se.sum_exec_runtime),
 			SPLIT_NS(p->se.statistics.sum_sleep_runtime));
-	}
-#else
-	SEQ_printf(m, "%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld",
-		0LL, 0L,
-		SPLIT_NS(p->se.sum_exec_runtime),
-		0LL, 0L);
-#endif
+	else
+		SEQ_printf(m, "%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld",
+			0LL, 0L,
+			SPLIT_NS(p->se.sum_exec_runtime),
+			0LL, 0L);
+
 #ifdef CONFIG_NUMA_BALANCING
 	SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p));
 #endif
-- 
2.4.11

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

* [PATCH 2/3] sched/debug: always show nr_migrations
  2016-06-03 20:44 [PATCH 0/3] sched/debug: schedstats bug fix and cleanups Josh Poimboeuf
  2016-06-03 20:44 ` [PATCH 1/3] sched/debug: fix /proc/sched_debug regression Josh Poimboeuf
@ 2016-06-03 20:44 ` Josh Poimboeuf
  2016-06-03 20:44 ` [PATCH 3/3] sched/debug: remove unnecessary CONFIG_SCHEDSTATS checks Josh Poimboeuf
  2016-06-03 21:40 ` [PATCH 0/3] sched/debug: schedstats bug fix and cleanups Josh Poimboeuf
  3 siblings, 0 replies; 6+ messages in thread
From: Josh Poimboeuf @ 2016-06-03 20:44 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: linux-kernel, Mel Gorman, Matt Fleming, Srikar Dronamraju

The nr_migrations field is updated independently of CONFIG_SCHEDSTATS,
so it can be displayed regardless.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 kernel/sched/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 500ea7e..cbdf208 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -885,9 +885,9 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
 
 	nr_switches = p->nvcsw + p->nivcsw;
 
-#ifdef CONFIG_SCHEDSTATS
 	P(se.nr_migrations);
 
+#ifdef CONFIG_SCHEDSTATS
 	if (schedstat_enabled()) {
 		u64 avg_atom, avg_per_cpu;
 
-- 
2.4.11

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

* [PATCH 3/3] sched/debug: remove unnecessary CONFIG_SCHEDSTATS checks
  2016-06-03 20:44 [PATCH 0/3] sched/debug: schedstats bug fix and cleanups Josh Poimboeuf
  2016-06-03 20:44 ` [PATCH 1/3] sched/debug: fix /proc/sched_debug regression Josh Poimboeuf
  2016-06-03 20:44 ` [PATCH 2/3] sched/debug: always show nr_migrations Josh Poimboeuf
@ 2016-06-03 20:44 ` Josh Poimboeuf
  2016-06-03 21:13   ` Josh Poimboeuf
  2016-06-03 21:40 ` [PATCH 0/3] sched/debug: schedstats bug fix and cleanups Josh Poimboeuf
  3 siblings, 1 reply; 6+ messages in thread
From: Josh Poimboeuf @ 2016-06-03 20:44 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: linux-kernel, Mel Gorman, Matt Fleming, Srikar Dronamraju

The schedstat_enabled() macro already has an implicit check for
CONFIG_SCHEDSTATS, so these explicit checks can be removed.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 kernel/sched/debug.c | 7 +------
 kernel/sched/fair.c  | 4 ++--
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index cbdf208..8f595f0 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -378,7 +378,6 @@ static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group
 	PN(se->exec_start);
 	PN(se->vruntime);
 	PN(se->sum_exec_runtime);
-#ifdef CONFIG_SCHEDSTATS
 	if (schedstat_enabled()) {
 		PN(se->statistics.wait_start);
 		PN(se->statistics.sleep_start);
@@ -391,7 +390,6 @@ static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group
 		PN(se->statistics.wait_sum);
 		P(se->statistics.wait_count);
 	}
-#endif
 	P(se->load.weight);
 #ifdef CONFIG_SMP
 	P(se->avg.load_avg);
@@ -632,7 +630,6 @@ do {									\
 #undef P64
 #endif
 
-#ifdef CONFIG_SCHEDSTATS
 #define P(n) SEQ_printf(m, "  .%-30s: %d\n", #n, rq->n);
 
 	if (schedstat_enabled()) {
@@ -644,7 +641,6 @@ do {									\
 	}
 
 #undef P
-#endif
 	spin_lock_irqsave(&sched_debug_lock, flags);
 	print_cfs_stats(m, cpu);
 	print_rt_stats(m, cpu);
@@ -887,7 +883,6 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
 
 	P(se.nr_migrations);
 
-#ifdef CONFIG_SCHEDSTATS
 	if (schedstat_enabled()) {
 		u64 avg_atom, avg_per_cpu;
 
@@ -936,7 +931,7 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
 		__PN(avg_atom);
 		__PN(avg_per_cpu);
 	}
-#endif
+
 	__P(nr_switches);
 	SEQ_printf(m, "%-45s:%21Ld\n",
 		   "nr_voluntary_switches", (long long)p->nvcsw);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c6dd8ba..dce0bf4 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3447,7 +3447,7 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
 
 	update_stats_curr_start(cfs_rq, se);
 	cfs_rq->curr = se;
-#ifdef CONFIG_SCHEDSTATS
+
 	/*
 	 * Track our maximum slice length, if the CPU's load is at
 	 * least twice that of our own weight (i.e. dont track it
@@ -3457,7 +3457,7 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
 		se->statistics.slice_max = max(se->statistics.slice_max,
 			se->sum_exec_runtime - se->prev_sum_exec_runtime);
 	}
-#endif
+
 	se->prev_sum_exec_runtime = se->sum_exec_runtime;
 }
 
-- 
2.4.11

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

* Re: [PATCH 3/3] sched/debug: remove unnecessary CONFIG_SCHEDSTATS checks
  2016-06-03 20:44 ` [PATCH 3/3] sched/debug: remove unnecessary CONFIG_SCHEDSTATS checks Josh Poimboeuf
@ 2016-06-03 21:13   ` Josh Poimboeuf
  0 siblings, 0 replies; 6+ messages in thread
From: Josh Poimboeuf @ 2016-06-03 21:13 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: linux-kernel, Mel Gorman, Matt Fleming, Srikar Dronamraju

On Fri, Jun 03, 2016 at 03:44:41PM -0500, Josh Poimboeuf wrote:
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -3447,7 +3447,7 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
>  
>  	update_stats_curr_start(cfs_rq, se);
>  	cfs_rq->curr = se;
> -#ifdef CONFIG_SCHEDSTATS
> +
>  	/*
>  	 * Track our maximum slice length, if the CPU's load is at
>  	 * least twice that of our own weight (i.e. dont track it
> @@ -3457,7 +3457,7 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
>  		se->statistics.slice_max = max(se->statistics.slice_max,
>  			se->sum_exec_runtime - se->prev_sum_exec_runtime);
>  	}
> -#endif
> +
>  	se->prev_sum_exec_runtime = se->sum_exec_runtime;

Oops.  This part fails to build without CONFIG_SCHEDSTATS.  This hunk
can just be removed from the patch.

-- 
Josh

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

* Re: [PATCH 0/3] sched/debug: schedstats bug fix and cleanups
  2016-06-03 20:44 [PATCH 0/3] sched/debug: schedstats bug fix and cleanups Josh Poimboeuf
                   ` (2 preceding siblings ...)
  2016-06-03 20:44 ` [PATCH 3/3] sched/debug: remove unnecessary CONFIG_SCHEDSTATS checks Josh Poimboeuf
@ 2016-06-03 21:40 ` Josh Poimboeuf
  3 siblings, 0 replies; 6+ messages in thread
From: Josh Poimboeuf @ 2016-06-03 21:40 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: linux-kernel, Mel Gorman, Matt Fleming, Srikar Dronamraju

On Fri, Jun 03, 2016 at 03:44:38PM -0500, Josh Poimboeuf wrote:
> A /proc/sched_debug bug fix and a couple of other schedstats-related
> cleanups.
> 
> Josh Poimboeuf (3):
>   sched/debug: fix /proc/sched_debug regression
>   sched/debug: always show nr_migrations
>   sched/debug: remove unnecessary CONFIG_SCHEDSTATS checks
> 
>  kernel/sched/debug.c | 24 +++++++++---------------
>  kernel/sched/fair.c  |  4 ++--
>  2 files changed, 11 insertions(+), 17 deletions(-)
> 
> -- 
> 2.4.11

Sorry, the whole series is bad for the !SCHEDSTATS case.  That's what I
get for posting on a Friday afternoon!

-- 
Josh

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

end of thread, other threads:[~2016-06-03 21:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-03 20:44 [PATCH 0/3] sched/debug: schedstats bug fix and cleanups Josh Poimboeuf
2016-06-03 20:44 ` [PATCH 1/3] sched/debug: fix /proc/sched_debug regression Josh Poimboeuf
2016-06-03 20:44 ` [PATCH 2/3] sched/debug: always show nr_migrations Josh Poimboeuf
2016-06-03 20:44 ` [PATCH 3/3] sched/debug: remove unnecessary CONFIG_SCHEDSTATS checks Josh Poimboeuf
2016-06-03 21:13   ` Josh Poimboeuf
2016-06-03 21:40 ` [PATCH 0/3] sched/debug: schedstats bug fix and cleanups Josh Poimboeuf

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