LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* clockevent questions
@ 2007-05-12 14:54 Francis Moreau
  2007-05-12 15:14 ` Thomas Gleixner
  0 siblings, 1 reply; 9+ messages in thread
From: Francis Moreau @ 2007-05-12 14:54 UTC (permalink / raw)
  To: linux-kernel; +Cc: tglx

Hi,

I'm trying to use clocksource and clockevent new subsystem. My
platform has a timer that I'd like to use both as a clocksource and a
clockevent devices. This timer is continueous in sense that it can run
without any interruption so I assume I can flag the clocksource device
with "CLOCK_SOURCE_IS_CONTINUOUS". However I noticed that clockevent
device can be stopped by using "set_mode()" method. Are these two
behaviours compatible ?

Another question is that I have another embedded 16 bits timer that I
would like to use. Since the timer is only 16 bits, the maximum
interval is tiny, My question if a user ask for a clockevent device
using an interval is bigger that 2^16, the clockevent system doesn't
return an error. Instead it silently reduce the interval to 2^16. Is
this correct ? if so why ?

Thanks for your answers
-- 
Francis

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

* Re: clockevent questions
  2007-05-12 14:54 clockevent questions Francis Moreau
@ 2007-05-12 15:14 ` Thomas Gleixner
  2007-05-12 20:13   ` Francis Moreau
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas Gleixner @ 2007-05-12 15:14 UTC (permalink / raw)
  To: Francis Moreau; +Cc: linux-kernel

Francis,

On Sat, 2007-05-12 at 16:54 +0200, Francis Moreau wrote:
> I'm trying to use clocksource and clockevent new subsystem. My
> platform has a timer that I'd like to use both as a clocksource and a
> clockevent devices.

See arch/i386/kernel/hpet.c

> This timer is continueous in sense that it can run
> without any interruption

-ENOPARSE

Has your timer a free running counter and a match register based event
mechanism ?

> so I assume I can flag the clocksource device
> with "CLOCK_SOURCE_IS_CONTINUOUS". However I noticed that clockevent
> device can be stopped by using "set_mode()" method. Are these two
> behaviours compatible ?

the clock event stop only stops the event mechanism, it does not stop
the counter.

See arch/i386/kernel/hpet.c

> Another question is that I have another embedded 16 bits timer that I
> would like to use. Since the timer is only 16 bits, the maximum
> interval is tiny, My question if a user ask for a clockevent device
> using an interval is bigger that 2^16, the clockevent system doesn't
> return an error. Instead it silently reduce the interval to 2^16. Is
> this correct ? if so why ?

Yes, it is correct. The generic timer code requests an event in the
future. It does not care, whether the hardware device can handle that or
not. So the clock event code limits the delta to the maximum delta the
device can handle. The interrupt fires and the generic timer code
reschedules the event with the remaining delta time.

	tglx



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

* Re: clockevent questions
  2007-05-12 15:14 ` Thomas Gleixner
@ 2007-05-12 20:13   ` Francis Moreau
  2007-05-12 20:23     ` Thomas Gleixner
  0 siblings, 1 reply; 9+ messages in thread
From: Francis Moreau @ 2007-05-12 20:13 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel

Hi Thomas,

Thanks for answering so quickly !

On 5/12/07, Thomas Gleixner <tglx@linutronix.de> wrote:
> Francis,
>
> On Sat, 2007-05-12 at 16:54 +0200, Francis Moreau wrote:
> > I'm trying to use clocksource and clockevent new subsystem. My
> > platform has a timer that I'd like to use both as a clocksource and a
> > clockevent devices.
>
> See arch/i386/kernel/hpet.c
>

thanks for the pointer

> > This timer is continueous in sense that it can run
> > without any interruption
>
> -ENOPARSE
>
> Has your timer a free running counter and a match register based event
> mechanism ?
>

yes

> > so I assume I can flag the clocksource device
> > with "CLOCK_SOURCE_IS_CONTINUOUS". However I noticed that clockevent
> > device can be stopped by using "set_mode()" method. Are these two
> > behaviours compatible ?
>
> the clock event stop only stops the event mechanism, it does not stop
> the counter.
>
> See arch/i386/kernel/hpet.c
>

OK. I got it now, In my initial plan, I was thinking to stop the
counter to stop the event. But that's not the right thing to do. It
seems that I should disable event interrupt instead.

> > Another question is that I have another embedded 16 bits timer that I
> > would like to use. Since the timer is only 16 bits, the maximum
> > interval is tiny, My question if a user ask for a clockevent device
> > using an interval is bigger that 2^16, the clockevent system doesn't
> > return an error. Instead it silently reduce the interval to 2^16. Is
> > this correct ? if so why ?
>
> Yes, it is correct. The generic timer code requests an event in the
> future. It does not care, whether the hardware device can handle that or
> not. So the clock event code limits the delta to the maximum delta the
> device can handle. The interrupt fires and the generic timer code
> reschedules the event with the remaining delta time.
>

Thanks again for explanations. Could you give me a pointer of this reschedules ?

-- 
Francis

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

* Re: clockevent questions
  2007-05-12 20:13   ` Francis Moreau
@ 2007-05-12 20:23     ` Thomas Gleixner
  2007-05-13  5:52       ` Francis Moreau
  2007-05-15  8:47       ` Francis Moreau
  0 siblings, 2 replies; 9+ messages in thread
From: Thomas Gleixner @ 2007-05-12 20:23 UTC (permalink / raw)
  To: Francis Moreau; +Cc: linux-kernel

On Sat, 2007-05-12 at 22:13 +0200, Francis Moreau wrote:
> > Yes, it is correct. The generic timer code requests an event in the
> > future. It does not care, whether the hardware device can handle that or
> > not. So the clock event code limits the delta to the maximum delta the
> > device can handle. The interrupt fires and the generic timer code
> > reschedules the event with the remaining delta time.
> >
> 
> Thanks again for explanations. Could you give me a pointer of this reschedules ?

Well, it ends up in hrtimer_interrupt() and the code there finds out,
that the next timer is not due right now, so it simply requests the same
(absolute) time event again, which is processed by the clock events code
and eventually limited to the max delta of the device again.

	tglx



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

* Re: clockevent questions
  2007-05-12 20:23     ` Thomas Gleixner
@ 2007-05-13  5:52       ` Francis Moreau
  2007-05-15  8:47       ` Francis Moreau
  1 sibling, 0 replies; 9+ messages in thread
From: Francis Moreau @ 2007-05-13  5:52 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel

On 5/12/07, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Sat, 2007-05-12 at 22:13 +0200, Francis Moreau wrote:
> > > Yes, it is correct. The generic timer code requests an event in the
> > > future. It does not care, whether the hardware device can handle that or
> > > not. So the clock event code limits the delta to the maximum delta the
> > > device can handle. The interrupt fires and the generic timer code
> > > reschedules the event with the remaining delta time.
> > >
> >
> > Thanks again for explanations. Could you give me a pointer of this reschedules ?
>
> Well, it ends up in hrtimer_interrupt() and the code there finds out,
> that the next timer is not due right now, so it simply requests the same
> (absolute) time event again, which is processed by the clock events code
> and eventually limited to the max delta of the device again.
>

OK, I'll give it a deeper look soon.

Thanks for your great work !
-- 
Francis

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

* Re: clockevent questions
  2007-05-12 20:23     ` Thomas Gleixner
  2007-05-13  5:52       ` Francis Moreau
@ 2007-05-15  8:47       ` Francis Moreau
  2007-05-15 22:10         ` Thomas Gleixner
  1 sibling, 1 reply; 9+ messages in thread
From: Francis Moreau @ 2007-05-15  8:47 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel

Thomas,

On 5/12/07, Thomas Gleixner <tglx@linutronix.de> wrote:
> Well, it ends up in hrtimer_interrupt() and the code there finds out,
> that the next timer is not due right now, so it simply requests the same
> (absolute) time event again, which is processed by the clock events code
> and eventually limited to the max delta of the device again.
>

My timer is finally using the clockevent subsystem. Below is the
output of '/proc/timer_list':

cat /proc/timer_list
Timer List Version: v0.3
HRTIMER_MAX_CLOCK_BASES: 2
now at 64696544360531 nsecs

cpu: 0
 clock 0:
  .index:      0
  .resolution: 1 nsecs
  .get_time:   ktime_get_real
  .offset:     1179151153000000000 nsecs
active timers:
 clock 1:
  .index:      1
  .resolution: 1 nsecs
  .get_time:   ktime_get
  .offset:     0 nsecs
active timers:
 #0: <c03fde10>, tick_sched_timer, S:01
 # expires at 64696546875000 nsecs [in 2514469 nsecs]
  .expires_next   : 64696546875000 nsecs
  .hres_active    : 1
  .nr_events      : 16562163
  .nohz_mode      : 0
  .idle_tick      : 0 nsecs
  .tick_stopped   : 0
  .idle_jiffies   : 0
  .idle_calls     : 0
  .idle_sleeps    : 0
  .idle_entrytime : 0 nsecs
  .idle_sleeptime : 0 nsecs
  .last_jiffies   : 0
  .next_jiffies   : 0
  .idle_expires   : 0 nsecs
jiffies: 16485515


Tick Device: mode:     1
Clock Event Device: hrt
 max_delta_ns:   2147483647
 min_delta_ns:   1000
 mult:           206158430
 shift:          32
 mode:           3
 next_event:     64696546875000 nsecs
 set_next_event: hrt_next_event
 set_mode:       hrt_timer_setup
 event_handler:  hrtimer_interrupt

My question is about the clock resolution field which is equal to 1ns.
How is this possible since my timer's frequency is only 100Mhz ?

My 2 cents, it looks like some tabs are missing when printing the list
of hrtimers of each clock...

Thanks
-- 
Francis

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

* Re: clockevent questions
  2007-05-15  8:47       ` Francis Moreau
@ 2007-05-15 22:10         ` Thomas Gleixner
  2007-05-16  7:42           ` Francis Moreau
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas Gleixner @ 2007-05-15 22:10 UTC (permalink / raw)
  To: Francis Moreau; +Cc: linux-kernel, Ingo Molnar

Francis,

On Tue, 2007-05-15 at 10:47 +0200, Francis Moreau wrote:
> My question is about the clock resolution field which is equal to 1ns.
> How is this possible since my timer's frequency is only 100Mhz ?

you are right. It is a bit strange. The resolution info is not really
reflecting the clock event source capability. I look if there is a sane
solution for that.

	tglx



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

* Re: clockevent questions
  2007-05-15 22:10         ` Thomas Gleixner
@ 2007-05-16  7:42           ` Francis Moreau
  2007-05-16  8:00             ` Thomas Gleixner
  0 siblings, 1 reply; 9+ messages in thread
From: Francis Moreau @ 2007-05-16  7:42 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel, Ingo Molnar

Hi Thomas,

On 5/16/07, Thomas Gleixner <tglx@linutronix.de> wrote:
> Francis,
>
> On Tue, 2007-05-15 at 10:47 +0200, Francis Moreau wrote:
> > My question is about the clock resolution field which is equal to 1ns.
> > How is this possible since my timer's frequency is only 100Mhz ?
>
> you are right. It is a bit strange. The resolution info is not really
> reflecting the clock event source capability. I look if there is a sane
> solution for that.
>

Doesn't that make hrtimer_get_res() and its callers buggy since they
return this 1ns value which is not reflecting the correct clock event
capability ?

Another question about the output of '/proc/timer_list':

[...]
active timers:
 #0: <c03fde10>, tick_sched_timer, S:01
 # expires at 64696546875000 nsecs [in 2514469 nsecs]
 .expires_next   : 64696546875000 nsecs
[...]

Doesn't the 2 expire time lines give the same information ? If so,
couldn't we merge them into : ".expires_next   : 64696546875000 nsecs
[in 2514469 nsecs]" ?

Thanks
-- 
Francis

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

* Re: clockevent questions
  2007-05-16  7:42           ` Francis Moreau
@ 2007-05-16  8:00             ` Thomas Gleixner
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Gleixner @ 2007-05-16  8:00 UTC (permalink / raw)
  To: Francis Moreau; +Cc: linux-kernel, Ingo Molnar

On Wed, 2007-05-16 at 09:42 +0200, Francis Moreau wrote:
> > On Tue, 2007-05-15 at 10:47 +0200, Francis Moreau wrote:
> > > My question is about the clock resolution field which is equal to 1ns.
> > > How is this possible since my timer's frequency is only 100Mhz ?
> >
> > you are right. It is a bit strange. The resolution info is not really
> > reflecting the clock event source capability. I look if there is a sane
> > solution for that.
> >
> 
> Doesn't that make hrtimer_get_res() and its callers buggy since they
> return this 1ns value which is not reflecting the correct clock event
> capability ?

Well, it's not really buggy. It's just not telling the truth.

> Another question about the output of '/proc/timer_list':
> 
> [...]
> active timers:
>  #0: <c03fde10>, tick_sched_timer, S:01
>  # expires at 64696546875000 nsecs [in 2514469 nsecs]
>  .expires_next   : 64696546875000 nsecs
> [...]
> 
> Doesn't the 2 expire time lines give the same information ? If so,
> couldn't we merge them into : ".expires_next   : 64696546875000 nsecs
> [in 2514469 nsecs]" ?

No. The timers are taken from the hrtimer queue and the expires_next
value is the clock events code internal value of the next timer event.
The expiry time of the first timer and the clock events code should
match of course, but we definitely want to have them seperate.

	tglx



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

end of thread, other threads:[~2007-05-16  7:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-12 14:54 clockevent questions Francis Moreau
2007-05-12 15:14 ` Thomas Gleixner
2007-05-12 20:13   ` Francis Moreau
2007-05-12 20:23     ` Thomas Gleixner
2007-05-13  5:52       ` Francis Moreau
2007-05-15  8:47       ` Francis Moreau
2007-05-15 22:10         ` Thomas Gleixner
2007-05-16  7:42           ` Francis Moreau
2007-05-16  8:00             ` Thomas Gleixner

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