Display -rt related stats in /proc/schedstat
PATCH 1/1 Display -rt related stats in /proc/schedstat
Hi,
This patch adds support to display captured -rt stats under /proc/schedstat.
--
sched_stats.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/sched_stats.h +4 -1
@@ -21,12 +21,15 @@/* runqueue-specific stats */ seq_printf (seq, -"cpu%d %lu %lu %lu %lu %lu %lu %lu %lu %lu %llu %llu %lu" , +"cpu%d %lu %lu %lu %lu %lu %lu %lu %lu %lu %llu %lu %lu %lu %llu %lu" , cpu, rq->yld_both_empty, rq->yld_act_empty, rq->yld_exp_empty, rq->yld_cnt, rq->sched_switch, rq->sched_cnt, rq->sched_goidle, rq->ttwu_cnt, rq->ttwu_local, rq->rq_sched_info.cpu_time, +#ifdef CONFIG_PREEMPT_RT + rq->rto_schedule, rq->rto_wakeup, rq->rto_pulled, +#endif rq->rq_sched_info.run_delay, rq->rq_sched_info.pcnt);seq_printf (seq,"\n" );
Signature · 5 lines
Regards, Ankita Garg ([email protected]) Linux Technology Center IBM India Systems & Technology Labs, Bangalore, India
Quoted 4 lines · On Monday 23 July 2007 14:59:25 Ankita Garg wrote:
Hi,
This patch adds support to display captured -rt stats under
/proc/schedstat.
You need to +1 SCHEDSTAT_VERSION if you are going to do this. I would also suggest the number of fields printed out it in schedstats is invariable of CONFIG_PREEMPT_RT rather whether the fields have meaning data or zeros depends on the define. Finally an addition to Documentation/sched-stats.txt is always desirable with such a change.
-Joachim
Quoted 11 lines · Joachim Deguara
Quoted 4 lines · On Monday 23 July 2007 14:59:25 Ankita Garg wrote:
Hi,
This patch adds support to display captured -rt stats under
/proc/schedstat.You need to +1
SCHEDSTAT_VERSIONif you are going to do this. I would also suggest the number of fields printed out it in schedstats is invariable ofCONFIG_PREEMPT_RTrather whether the fields have meaning data or zeros depends on the define. Finally an addition toDocumentation/sched-stats.txtis always desirable with such a change.
Yep, that sounds fine to me, because the fields are being defined irrespective of CONFIG_PREEMPT_RT. Besides, it looks much cleaner! Have updated the SCHEDSTAT_VERSION to 15.
As for documentation update, Documentation/sched-stats.txt seems to be a little old. Under CPU statistics, it indicates 28 fields being printed, but version 14 seems to be printing only 12 (iiuc). So, requires some update. Will send it along in the next patch.
--
sched_stats.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/sched_stats.h +3 -2
@@ -4,7 +4,7 @@* bump this up when changing the output format or the meaning of an existing * format, so that tools can adapt (or abort) */ -#define SCHEDSTAT_VERSION 14 +#define SCHEDSTAT_VERSION 15static int show_schedstat (struct seq_file *seq,void *v) {
@@ -21,12 +21,13 @@/* runqueue-specific stats */ seq_printf (seq, -"cpu%d %lu %lu %lu %lu %lu %lu %lu %lu %lu %llu %llu %lu" , +"cpu%d %lu %lu %lu %lu %lu %lu %lu %lu %lu %llu %lu %lu %lu %llu %lu" , cpu, rq->yld_both_empty, rq->yld_act_empty, rq->yld_exp_empty, rq->yld_cnt, rq->sched_switch, rq->sched_cnt, rq->sched_goidle, rq->ttwu_cnt, rq->ttwu_local, rq->rq_sched_info.cpu_time, + rq->rto_schedule, rq->rto_wakeup, rq->rto_pulled, rq->rq_sched_info.run_delay, rq->rq_sched_info.pcnt);seq_printf (seq,"\n" );
Signature · 5 lines
Regards, Ankita Garg ([email protected]) Linux Technology Center IBM India Systems & Technology Labs, Bangalore, India
Quoted 2 lines · On Monday 23 July 2007 16:58:43 [email protected] wrote:
As for documentation update,
Documentation/sched-stats.txtseems to be a little old.
Look in the -mm tree, my patch to bring it up to date got in there last week ;)
-Joachim
Quoted 18 lines · Ankita Garg
This patch adds support to display captured -rt stats under
/proc/schedstat.Signed-off-by Ankita Garg <[email protected]>--
sched_stats.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)Index:
linux-2.6.22.1/kernel/sched_stats.h
===================================================================kernel/sched_stats.h +1
-1@@ -21,12 +21,15 @@/* runqueue-specific stats */ seq_printf(seq, - "cpu%d %lu %lu %lu %lu %lu %lu %lu %lu %lu %llu %llu %lu", + "cpu%d %lu %lu %lu %lu %lu %lu %lu %lu %lu %llu %lu %lu %lu %llu %lu", cpu, rq->yld_both_empty,
kernel/sched_stats.h line 35
Quoted 10 lines
kernel/sched_stats.h +3
-0rq->yld_act_empty, rq->yld_exp_empty, rq->yld_cnt, rq->sched_switch, rq->sched_cnt, rq->sched_goidle, rq->ttwu_cnt, rq->ttwu_local, rq->rq_sched_info.cpu_time, +#ifdef CONFIG_PREEMPT_RT + rq->rto_schedule, rq->rto_wakeup, rq->rto_pulled, +#endif rq->rq_sched_info.run_delay, rq->rq_sched_info.pcnt);seq_printf (seq,"\n" );
I know you've written a new patch that makes this one obsolete, but I wanted to discuss this specific patch.
Originally, there were 13 conversion specifications, and your patch adds 3, for a total of 16 conversion specifications.
However, if CONFIG_PREEMPT_RT is not defined, then seq_printf is called with only 13 arguments.
Is it safe to call seq_printf with too few arguments?
Calling printf(3) with too few arguments leads to undefined behavior.
seq_printf is a wrapper around vsnprintf() so there might be no issue?
Regards.
Quoted 39 lines · John Sigler
Quoted 32 lines · Ankita Garg
This patch adds support to display captured -rt stats under
/proc/schedstat.Signed-off-by Ankita Garg <[email protected]>--
sched_stats.h| 5 ++++-1 file changed, 4 insertions(+), 1 deletion(-)Index:
linux-2.6.22.1/kernel/sched_stats.h
===================================================================
---linux-2.6.22.1.orig/kernel/sched_stats.h2007-07-23
18:15:57.000000000 +0530
+++linux-2.6.22.1/kernel/sched_stats.h2007-07-23
18:24:03.000000000 +0530kernel/sched_stats.h +4
-1@@ -21,12 +21,15 @@/* runqueue-specific stats */ seq_printf (seq, - "cpu%d %lu %lu %lu %lu %lu %lu %lu %lu %lu %llu %llu %lu", +" cpu%d %lu %lu %lu %lu %lu %lu %lu %lu %lu %llu %lu %lu %lu %llu %lu", cpu, rq->yld_both_empty, rq->yld_act_empty, rq->yld_exp_empty, rq->yld_cnt, rq->sched_switch, rq->sched_cnt, rq->sched_goidle, rq->ttwu_cnt, rq->ttwu_local, rq->rq_sched_info.cpu_time, +#ifdef CONFIG_PREEMPT_RT + rq->rto_schedule, rq->rto_wakeup, rq->rto_pulled, +#endif rq->rq_sched_info.run_delay, rq->rq_sched_info.pcnt);Quoted 1 line
seq_printf(seq, "\n");I know you've written a new patch that makes this one obsolete, but I wanted to discuss this specific patch.
Quoted 7 lines
Originally, there were 13 conversion specifications, and your patch adds 3, for a total of 16 conversion specifications.
However, if
CONFIG_PREEMPT_RTis not defined, thenseq_printfis called with only 13 arguments.Is it safe to call
seq_printfwith too few arguments?
So I tried to run the code disabling CONFIG_PREEMPT_RT, to see the behavior vsnprintf() on supplying fewer arguments. Arbit/garbage value is printed for conversion specifications that do not have a matching argument. It did not cause any issue at all beyond that point. But considering the correctness and quality of code, was going to post the updated patch (if the re-work had not happened)!
Quoted 6 lines
Calling printf(3) with too few arguments leads to undefined behavior.
seq_printfis a wrapper aroundvsnprintf()so there might be no issue?Regards.
Signature · 5 lines
Regards, Ankita Garg ([email protected]) Linux Technology Center IBM India Systems & Technology Labs, Bangalore, India
Quoted 4 lines · Ankita Garg
Hi,
This patch adds support to display captured -rt stats under
/proc/schedstat.
hm, could you add it to /proc/sched_debug instead? That's where all the runqueue values are showing up normally. I'm also a bit wary about introducing a new schedstats version for -rt.
Ingo
Quoted 11 lines · Ingo Molnar
Quoted 4 lines · Ankita Garg
Hi,
This patch adds support to display captured -rt stats under
/proc/schedstat.hm, could you add it to
/proc/sched_debuginstead? That's where all the runqueue values are showing up normally. I'm also a bit wary about introducing a new schedstats version for -rt.
So, I have merged my previous patch (to display rt_nr_running info in sched_debug.c) with this one.
--
sched_debug.c | 9 +++++++++ 1 file changed, 9 insertions(+)
kernel/sched_debug.c +9 -0
@@ -161,6 +161,15 @@P (cpu_load[2 ]);P (cpu_load[3 ]);P (cpu_load[4 ]); +#ifdef CONFIG_PREEMPT_RT +/* Print rt related rq stats */ +P (rt_nr_running); +P (rt_nr_uninterruptible); +P (rto_schedule); +P (rto_wakeup); +P (rto_pulled); +#endif +#undef Pprint_cfs_stats (m, cpu, now);
Signature · 5 lines
Regards, Ankita Garg ([email protected]) Linux Technology Center IBM India Systems & Technology Labs, Bangalore, India
Ingo Molnar
AppliedQuoted 9 lines · Ankita Garg
Quoted 6 lines
Quoted 2 lines
This patch adds support to display captured -rt stats under
/proc/schedstat.hm, could you add it to
/proc/sched_debuginstead? That's where all the runqueue values are showing up normally. I'm also a bit wary about introducing a new schedstats version for -rt.So, I have merged my previous patch (to display
rt_nr_runninginfo insched_debug.c) with this one.
thanks, applied.
Ingo
Quoted 44 lines · Ankita Garg
Quoted 43 lines · John Sigler
Quoted 31 lines · Ankita Garg
This patch adds support to display captured -rt stats under
/proc/schedstat.Signed-off-by Ankita Garg <[email protected]>--
sched_stats.h| 5 ++++-1 file changed, 4 insertions(+), 1 deletion(-)Index:
linux-2.6.22.1/kernel/sched_stats.h
===================================================================
---linux-2.6.22.1.orig/kernel/sched_stats.h2007-07-23
18:15:57.000000000 +0530
+++linux-2.6.22.1/kernel/sched_stats.h2007-07-23
18:24:03.000000000 +0530kernel/sched_stats.h +4
-1@@ -21,12 +21,15 @@/* runqueue-specific stats */ seq_printf (seq, - "cpu%d %lu %lu %lu %lu %lu %lu %lu %lu %lu %llu %llu %lu", +" cpu%d %lu %lu %lu %lu %lu %lu %lu %lu %lu %llu %lu %lu %lu %llu %lu", cpu, rq->yld_both_empty, rq->yld_act_empty, rq->yld_exp_empty, rq->yld_cnt, rq->sched_switch, rq->sched_cnt, rq->sched_goidle, rq->ttwu_cnt, rq->ttwu_local, rq->rq_sched_info.cpu_time, +#ifdef CONFIG_PREEMPT_RT + rq->rto_schedule, rq->rto_wakeup, rq->rto_pulled, +#endif rq->rq_sched_info.run_delay, rq->rq_sched_info.pcnt);Quoted 1 line
seq_printf(seq, "\n");I know you've written a new patch that makes this one obsolete, but I wanted to discuss this specific patch.
Originally, there were 13 conversion specifications, and your patch adds 3, for a total of 16 conversion specifications.
However, if
CONFIG_PREEMPT_RTis not defined, thenseq_printfis called with only 13 arguments.
Quoted 8 lines
Quoted 1 line
Is it safe to call
seq_printfwith too few arguments?So I tried to run the code disabling
CONFIG_PREEMPT_RT, to see the behaviorvsnprintf()on supplying fewer arguments. Arbit/garbage value is printed for conversion specifications that do not have a matching argument. It did not cause any issue at all beyond that point. But considering the correctness and quality of code, was going to post the updated patch (if the re-work had not happened)!
I double-checked. Calling v*printf with too few parameters also leads to undefined behavior.
You didn't notice any ill effects on your particular compiler / platform combination, but the code above remains a time bomb :-)
Once in UB land, all bets are off.
Regards.