From: John Sigler <linux.kernel@free.fr>
To: Ankita Garg <ankita@in.ibm.com>
Cc: linux-rt-users <linux-rt-users@vger.kernel.org>,
Ingo Molnar <mingo@elte.hu>,
Dinakar Guniguntala <dino@in.ibm.com>
Subject: Re: [PATCH] Display -rt related stats in /proc/schedstat
Date: Wed, 25 Jul 2007 14:53:25 +0200 [thread overview]
Message-ID: <46A747C5.8050900@free.fr> (raw)
In-Reply-To: <20070725060843.GB7745@in.ibm.com>
Ankita Garg wrote:
> On Tue, Jul 24, 2007 at 12:36:22PM +0200, John Sigler wrote:
>> Ankita Garg wrote:
>>
>>> This patch adds support to display captured -rt stats under
>>> /proc/schedstat.
>>>
>>> Signed-off-by: Ankita Garg <ankita@in.ibm.com>
>>> --
>>> 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.h 2007-07-23
>>> 18:15:57.000000000 +0530
>>> +++ linux-2.6.22.1/kernel/sched_stats.h 2007-07-23
>>> 18:24:03.000000000 +0530
>>> @@ -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");
>>
>> 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?
>
> 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)!
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.
next prev parent reply other threads:[~2007-07-25 12:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-23 12:59 [PATCH] Display -rt related stats in /proc/schedstat Ankita Garg
2007-07-23 12:24 ` Joachim Deguara
2007-07-23 14:58 ` Ankita Garg
2007-07-23 18:48 ` Joachim Deguara
2007-07-24 10:36 ` John Sigler
2007-07-25 6:08 ` Ankita Garg
2007-07-25 12:53 ` John Sigler [this message]
2007-07-25 8:05 ` Ingo Molnar
2007-07-25 11:29 ` Ankita Garg
2007-07-25 11:35 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46A747C5.8050900@free.fr \
--to=linux.kernel@free.fr \
--cc=ankita@in.ibm.com \
--cc=dino@in.ibm.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.