* Drift when measuring time using add_timer
@ 2010-12-28 12:05 Mohan V
2010-12-28 12:14 ` Nikita V. Youshchenko
2010-12-29 8:45 ` Yong Zhang
0 siblings, 2 replies; 5+ messages in thread
From: Mohan V @ 2010-12-28 12:05 UTC (permalink / raw)
To: linux-kernel
Hello All,
I am testing the timers on a OMAP4 based board. I am seeing a drift or
the time difference between the timer value and when the function callback
happens. This drift is around 1000ms or 1s for a expiry value of >=5mins.
Is the time drift expected? Is this way of measuring right or is there
any other way?
OMAP4 as you may know is a multi-core processor and CONFIG_SMP is enabled
along with the following:
CONFIG_NO_HZ, CONFIG_HIGH_RES_TIMERS
My kernel configurations:
kernel: 2.6.37-rc7 (commit id: ffc96d)
config: omap2plus_defconfig
My driver does the following:
struct timeval tv;
test_timer_proc_write()
{
del_timer_sync(&my_timer);
period = 300000; /* 5min */
my_timer.expires = jiffies + msecs_to_jiffies(period);
my_timer.function = func_timeout; /* Call back function*/
/* Save the current time in global variable */
do_gettimeofday(&timeval);
/* add timer with an expiry value of 5mins*/
add_timer(&my_timer);
}
/* Get the current time and print the difference between the two values */
func_timeout()
{
struct timeval tv1;
do_gettimeofday(&tv);
/* take the difference between current time and saved time */
ms = (tv.tv_sec - tv1.tv_sec) * 1000 + \
(tv.tv_usec - tv1.tv_usec) / 1000;
printk("Interval = %d\n", ms);
}
Thanks for your time.
Regards,
Mohan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Drift when measuring time using add_timer
2010-12-28 12:05 Drift when measuring time using add_timer Mohan V
@ 2010-12-28 12:14 ` Nikita V. Youshchenko
2010-12-29 5:18 ` Mohan V
2010-12-29 8:45 ` Yong Zhang
1 sibling, 1 reply; 5+ messages in thread
From: Nikita V. Youshchenko @ 2010-12-28 12:14 UTC (permalink / raw)
To: Mohan V; +Cc: linux-kernel
> do_gettimeofday(&timeval);
Try getnstimeofday() instead
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Drift when measuring time using add_timer
2010-12-28 12:14 ` Nikita V. Youshchenko
@ 2010-12-29 5:18 ` Mohan V
0 siblings, 0 replies; 5+ messages in thread
From: Mohan V @ 2010-12-29 5:18 UTC (permalink / raw)
To: Nikita V. Youshchenko; +Cc: linux-kernel
On Tue, Dec 28, 2010 at 5:44 PM, Nikita V. Youshchenko <yoush@cs.msu.su> wrote:
>> do_gettimeofday(&timeval);
>
> Try getnstimeofday() instead
>
I tried with getnstimeofday(), I am getting the same result. Anyway
getnstimeofday()
gets called from do_gettimeofday().
Thanks,
Mohan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Drift when measuring time using add_timer
2010-12-28 12:05 Drift when measuring time using add_timer Mohan V
2010-12-28 12:14 ` Nikita V. Youshchenko
@ 2010-12-29 8:45 ` Yong Zhang
2010-12-29 10:20 ` Mohan V
1 sibling, 1 reply; 5+ messages in thread
From: Yong Zhang @ 2010-12-29 8:45 UTC (permalink / raw)
To: Mohan V; +Cc: linux-kernel
On Tue, Dec 28, 2010 at 8:05 PM, Mohan V <mohanvforum@gmail.com> wrote:
> Hello All,
>
> I am testing the timers on a OMAP4 based board. I am seeing a drift or
> the time difference between the timer value and when the function callback
> happens. This drift is around 1000ms or 1s for a expiry value of >=5mins.
> Is the time drift expected? Is this way of measuring right or is there
> any other way?
>
> OMAP4 as you may know is a multi-core processor and CONFIG_SMP is enabled
> along with the following:
> CONFIG_NO_HZ, CONFIG_HIGH_RES_TIMERS
>
> My kernel configurations:
> kernel: 2.6.37-rc7 (commit id: ffc96d)
> config: omap2plus_defconfig
>
> My driver does the following:
>
> struct timeval tv;
> test_timer_proc_write()
> {
> del_timer_sync(&my_timer);
> period = 300000; /* 5min */
> my_timer.expires = jiffies + msecs_to_jiffies(period);
> my_timer.function = func_timeout; /* Call back function*/
what's the slack of your timer?
And what about setting my_timer.slack = 0; ?
Thanks,
Yong
> /* Save the current time in global variable */
> do_gettimeofday(&timeval);
> /* add timer with an expiry value of 5mins*/
> add_timer(&my_timer);
> }
>
> /* Get the current time and print the difference between the two values */
> func_timeout()
> {
> struct timeval tv1;
> do_gettimeofday(&tv);
> /* take the difference between current time and saved time */
> ms = (tv.tv_sec - tv1.tv_sec) * 1000 + \
> (tv.tv_usec - tv1.tv_usec) / 1000;
> printk("Interval = %d\n", ms);
> }
>
> Thanks for your time.
>
> Regards,
> Mohan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
Only stand for myself.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Drift when measuring time using add_timer
2010-12-29 8:45 ` Yong Zhang
@ 2010-12-29 10:20 ` Mohan V
0 siblings, 0 replies; 5+ messages in thread
From: Mohan V @ 2010-12-29 10:20 UTC (permalink / raw)
To: Yong Zhang; +Cc: linux-kernel
On Wed, Dec 29, 2010 at 2:15 PM, Yong Zhang <yong.zhang0@gmail.com> wrote:
> On Tue, Dec 28, 2010 at 8:05 PM, Mohan V <mohanvforum@gmail.com> wrote:
>> Hello All,
>>
>> I am testing the timers on a OMAP4 based board. I am seeing a drift or
>> the time difference between the timer value and when the function callback
>> happens. This drift is around 1000ms or 1s for a expiry value of >=5mins.
>> Is the time drift expected? Is this way of measuring right or is there
>> any other way?
>>
>> OMAP4 as you may know is a multi-core processor and CONFIG_SMP is enabled
>> along with the following:
>> CONFIG_NO_HZ, CONFIG_HIGH_RES_TIMERS
>>
>> My kernel configurations:
>> kernel: 2.6.37-rc7 (commit id: ffc96d)
>> config: omap2plus_defconfig
>>
>> My driver does the following:
>>
>> struct timeval tv;
>> test_timer_proc_write()
>> {
>> del_timer_sync(&my_timer);
>> period = 300000; /* 5min */
>> my_timer.expires = jiffies + msecs_to_jiffies(period);
>> my_timer.function = func_timeout; /* Call back function*/
>
> what's the slack of your timer?
> And what about setting my_timer.slack = 0; ?
>
I hadn't set the slack value for the timer. Setting it to "0", gives me
much better results. Thanks a lot Yong.
Regards,
Mohan
> Thanks,
> Yong
>
>> /* Save the current time in global variable */
>> do_gettimeofday(&timeval);
>> /* add timer with an expiry value of 5mins*/
>> add_timer(&my_timer);
>> }
>>
>> /* Get the current time and print the difference between the two values */
>> func_timeout()
>> {
>> struct timeval tv1;
>> do_gettimeofday(&tv);
>> /* take the difference between current time and saved time */
>> ms = (tv.tv_sec - tv1.tv_sec) * 1000 + \
>> (tv.tv_usec - tv1.tv_usec) / 1000;
>> printk("Interval = %d\n", ms);
>> }
>>
>> Thanks for your time.
>>
>> Regards,
>> Mohan
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://www.tux.org/lkml/
>>
>
>
>
> --
> Only stand for myself.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-12-29 10:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-28 12:05 Drift when measuring time using add_timer Mohan V
2010-12-28 12:14 ` Nikita V. Youshchenko
2010-12-29 5:18 ` Mohan V
2010-12-29 8:45 ` Yong Zhang
2010-12-29 10:20 ` Mohan V
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®