sched/debug: schedstats bug fix and improvement
v2 cover sched/debug: schedstats bug fix and improvement
v2:
- fixed !SCHEDSTATS build for patch 1 using new schedstat_val() macro
- dropped patch 3
A schedstats-related bug fix and improvement.
Josh Poimboeuf (2):
sched/debug: fix /proc/sched_debug regression
sched/debug: always show nr_migrations
kernel/sched/debug.c | 17 +++++------------ kernel/sched/stats.h | 3 +++ 2 files changed, 8 insertions(+), 12 deletions(-)
Signature · 1 line
2.4.11
PATCH v2 1/2 sched/debug: fix /proc/sched_debug regression
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 with a new schedstat_val() macro which returns the field value when schedstats is enabled and zero otherwise. The macro works with both SCHEDSTATS and !SCHEDSTATS. I put the macro in stats.h since it might end up being useful in other places.
--- kernel/sched/debug.c | 15 ++++----------- kernel/sched/stats.h | 3 +++ 2 files changed, 7 insertions(+), 11 deletions(-)
kernel/sched/debug.c +4 -11
@@ -427,19 +427,12 @@ 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 ()) { -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 (schedstat_val (p, se.statistics.wait_sum)),SPLIT_NS (p->se.sum_exec_runtime), -0LL ,0L ); -#endif +SPLIT_NS (schedstat_val (p, se.statistics.sum_sleep_runtime))); +#ifdef CONFIG_NUMA_BALANCING SEQ_printf (m," %d %d" ,task_node (p),task_numa_group_id (p));#endif
kernel/sched/stats.h +3 -0
@@ -33,6 +33,8 @@ rq_sched_info_dequeued(struct rq *rq, unsigned long long delta)# define schedstat_inc (rq, field) do { if (schedstat_enabled()) { (rq)->field++; } } while (0)# define schedstat_add (rq, field, amt) do { if (schedstat_enabled()) { (rq)->field += (amt); } } while (0)# define schedstat_set (var, val) do { if (schedstat_enabled()) { var = (val); } } while (0) +# define schedstat_val (rq, field) ((schedstat_enabled()) ? (rq)->field : 0) +#else /* !CONFIG_SCHEDSTATS */ static inline void rq_sched_info_arrive (struct rq *rq,unsigned long long delta)
@@ -47,6 +49,7 @@ rq_sched_info_depart(struct rq *rq, unsigned long long delta)# define schedstat_inc (rq, field) do { } while (0)# define schedstat_add (rq, field, amt) do { } while (0)# define schedstat_set (var, val) do { } while (0) +# define schedstat_val (rq, field) 0#endif #ifdef CONFIG_SCHED_INFO
Signature · 1 line
2.4.11
Re: [PATCH v2 1/2] sched/debug: fix /proc/sched_debug regression
Quoted 6 lines · Josh Poimboeuf
Commit
cb2517653fcc("sched/debug: Make schedstats a runtime tunable that is disabled by default") introduced a bug whenCONFIG_SCHEDSTATSis 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_debugfile in therunnable_taskssection.
I take it that this breaks userspace parsing?
Quoted 8 lines
Fix it with a new
schedstat_val()macro which returns the field value when schedstats is enabled and zero otherwise. The macro works with both SCHEDSTATS and !SCHEDSTATS. I put the macro instats.hsince it might end up being useful in other places.Fixes cb2517653fcc ("sched/debug: Make schedstats a runtime tunable that is disabled by default")Signed-off-by Josh Poimboeuf <[email protected]>
Signature · 2 lines
Mel Gorman SUSE Labs
Re: [PATCH v2 1/2] sched/debug: fix /proc/sched_debug regression
Quoted 9 lines · Mel Gorman
Quoted 6 lines · Josh Poimboeuf
Commit
cb2517653fcc("sched/debug: Make schedstats a runtime tunable that is disabled by default") introduced a bug whenCONFIG_SCHEDSTATSis 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_debugfile in therunnable_taskssection.I take it that this breaks userspace parsing?
In theory, yes, though I don't know if there are any tools out there which parse it.
Quoted 10 lines
Quoted 8 lines
Fix it with a new
schedstat_val()macro which returns the field value when schedstats is enabled and zero otherwise. The macro works with both SCHEDSTATS and !SCHEDSTATS. I put the macro instats.hsince it might end up being useful in other places.Fixes cb2517653fcc ("sched/debug: Make schedstats a runtime tunable that is disabled by default")Signed-off-by Josh Poimboeuf <[email protected]>Acked-by Mel Gorman <[email protected]>
Thanks!
Signature · 1 line
Josh
tip-bot for Josh Poimboeuf
merge bot[tip:sched/core] sched/debug: Fix /proc/sched_debug regression
In reply to Josh Poimboeufsched/debug: Fix /proc/sched_debug regression
Commit-ID: 9c57259117b9c25472a3fa6d5a14d6bb3b647e87 Gitweb: http://git.kernel.org/tip/9c57259117b9c25472a3fa6d5a14d6bb3b647e87 Author: Josh Poimboeuf <[email protected]> AuthorDate: Fri, 3 Jun 2016 17:58:40 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 8 Jun 2016 14:31:58 +0200
sched/debug: Fix /proc/sched_debug regression
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 with a new schedstat_val() macro which returns the field value when schedstats is enabled and zero otherwise. The macro works with both SCHEDSTATS and !SCHEDSTATS. I put the macro in stats.h since it might end up being useful in other places.
--- kernel/sched/debug.c | 15 ++++----------- kernel/sched/stats.h | 3 +++ 2 files changed, 7 insertions(+), 11 deletions(-)
kernel/sched/debug.c +4 -11
@@ -427,19 +427,12 @@ 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 ()) { -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 (schedstat_val (p, se.statistics.wait_sum)),SPLIT_NS (p->se.sum_exec_runtime), -0LL ,0L ); -#endif +SPLIT_NS (schedstat_val (p, se.statistics.sum_sleep_runtime))); +#ifdef CONFIG_NUMA_BALANCING SEQ_printf (m," %d %d" ,task_node (p),task_numa_group_id (p));#endif
kernel/sched/stats.h +3 -0
@@ -33,6 +33,8 @@ rq_sched_info_dequeued(struct rq *rq, unsigned long long delta)# define schedstat_inc (rq, field) do { if (schedstat_enabled()) { (rq)->field++; } } while (0)# define schedstat_add (rq, field, amt) do { if (schedstat_enabled()) { (rq)->field += (amt); } } while (0)# define schedstat_set (var, val) do { if (schedstat_enabled()) { var = (val); } } while (0) +# define schedstat_val (rq, field) ((schedstat_enabled()) ? (rq)->field : 0) +#else /* !CONFIG_SCHEDSTATS */ static inline void rq_sched_info_arrive (struct rq *rq,unsigned long long delta)
@@ -47,6 +49,7 @@ rq_sched_info_depart(struct rq *rq, unsigned long long delta)# define schedstat_inc (rq, field) do { } while (0)# define schedstat_add (rq, field, amt) do { } while (0)# define schedstat_set (var, val) do { } while (0) +# define schedstat_val (rq, field) 0#endif #ifdef CONFIG_SCHED_INFO
PATCH v2 2/2 sched/debug: always show nr_migrations
In reply to Josh PoimboeufThe nr_migrations field is updated independently of CONFIG_SCHEDSTATS, so it can be displayed regardless.
--- kernel/sched/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/debug.c +1 -1
@@ -879,9 +879,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;
Signature · 1 line
2.4.11
Re: [PATCH v2 2/2] sched/debug: always show nr_migrations
Quoted 4 lines · Josh Poimboeuf
The
nr_migrationsfield is updated independently ofCONFIG_SCHEDSTATS, so it can be displayed regardless.Signed-off-by Josh Poimboeuf <[email protected]>
Signature · 2 lines
Mel Gorman SUSE Labs
tip-bot for Josh Poimboeuf
merge bot[tip:sched/core] sched/debug: Always show 'nr_migrations'
In reply to Josh Poimboeufsched/debug: Always show 'nr_migrations'
Commit-ID: 03c041c5bf6ed584dff36b7cd509e0146a124277 Gitweb: http://git.kernel.org/tip/03c041c5bf6ed584dff36b7cd509e0146a124277 Author: Josh Poimboeuf <[email protected]> AuthorDate: Fri, 3 Jun 2016 17:58:41 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 8 Jun 2016 14:34:49 +0200
sched/debug: Always show 'nr_migrations'
The nr_migrations field is updated independently of CONFIG_SCHEDSTATS, so it can be displayed regardless.
--- kernel/sched/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/debug.c +1 -1
@@ -879,9 +879,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;