public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hrtimer: add hrtimer_start_now()
@ 2015-01-22  6:12 Olliver Schinagl
  2015-01-22 11:01 ` Thomas Gleixner
  0 siblings, 1 reply; 4+ messages in thread
From: Olliver Schinagl @ 2015-01-22  6:12 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel, Olliver Schinagl

From: Olliver Schinagl <oliver@schinagl.nl>

When using a hrtimer for repeating periodic ticks, hrtimer_forward_now()
is often used. Quite possibly the timer loop is thus probably fully
controlled by hrtimer_forward_now() and we don't really care when the
timer is started. With hrtimer_start() we need to define exactly when a
event has to start. By introducing hrtimer_start_now() we do the same as
what hrtimer_forward_now() does, start as soon as possible and get into
the timer loop.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
---
 include/linux/hrtimer.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index a036d05..080a5f5 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -353,6 +353,12 @@ static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
 /* Basic timer operations: */
 extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
 			 const enum hrtimer_mode mode);
+
+static inline int hrtimer_start_now(struct hrtimer *timer,
+				    const enum hrtimer_mode mode)
+{
+	return hrtimer_start(timer, timer->base->get_time(), mode);
+}
 extern int hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
 			unsigned long range_ns, const enum hrtimer_mode mode);
 extern int
-- 
2.1.4


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

* Re: [PATCH] hrtimer: add hrtimer_start_now()
  2015-01-22  6:12 [PATCH] hrtimer: add hrtimer_start_now() Olliver Schinagl
@ 2015-01-22 11:01 ` Thomas Gleixner
  2015-01-22 11:07   ` Olliver Schinagl
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2015-01-22 11:01 UTC (permalink / raw)
  To: Olliver Schinagl; +Cc: linux-kernel, Olliver Schinagl

On Thu, 22 Jan 2015, Olliver Schinagl wrote:

> From: Olliver Schinagl <oliver@schinagl.nl>
> 
> When using a hrtimer for repeating periodic ticks, hrtimer_forward_now()
> is often used. Quite possibly the timer loop is thus probably fully
> controlled by hrtimer_forward_now() and we don't really care when the
> timer is started. With hrtimer_start() we need to define exactly when a
> event has to start. By introducing hrtimer_start_now() we do the same as
> what hrtimer_forward_now() does, start as soon as possible and get into
> the timer loop.
 
> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
> ---
>  include/linux/hrtimer.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
> index a036d05..080a5f5 100644
> --- a/include/linux/hrtimer.h
> +++ b/include/linux/hrtimer.h
> @@ -353,6 +353,12 @@ static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
>  /* Basic timer operations: */
>  extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
>  			 const enum hrtimer_mode mode);
> +
> +static inline int hrtimer_start_now(struct hrtimer *timer,
> +				    const enum hrtimer_mode mode)
> +{
> +	return hrtimer_start(timer, timer->base->get_time(), mode);
> +}

What's the mode argument for? How is this supposed to do what you
want:

       hrtimer_start_now(timer, HRTIMER_MODE_REL);

Aside of that, what's wrong with doing:

      static const ktime_t ktime_zero = { .tv64 = 0 };

      hrtimer_start(timer, ktime_zero, HRTIMER_MODE_REL);

Thanks,

	tglx

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

* Re: [PATCH] hrtimer: add hrtimer_start_now()
  2015-01-22 11:01 ` Thomas Gleixner
@ 2015-01-22 11:07   ` Olliver Schinagl
  2015-01-22 19:35     ` Thomas Gleixner
  0 siblings, 1 reply; 4+ messages in thread
From: Olliver Schinagl @ 2015-01-22 11:07 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel, Olliver Schinagl

Hey Thomas,

On 22-01-15 12:01, Thomas Gleixner wrote:
> On Thu, 22 Jan 2015, Olliver Schinagl wrote:
>
>> From: Olliver Schinagl <oliver@schinagl.nl>
>>
>> When using a hrtimer for repeating periodic ticks, hrtimer_forward_now()
>> is often used. Quite possibly the timer loop is thus probably fully
>> controlled by hrtimer_forward_now() and we don't really care when the
>> timer is started. With hrtimer_start() we need to define exactly when a
>> event has to start. By introducing hrtimer_start_now() we do the same as
>> what hrtimer_forward_now() does, start as soon as possible and get into
>> the timer loop.
>   
>> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
>> ---
>>   include/linux/hrtimer.h | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
>> index a036d05..080a5f5 100644
>> --- a/include/linux/hrtimer.h
>> +++ b/include/linux/hrtimer.h
>> @@ -353,6 +353,12 @@ static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
>>   /* Basic timer operations: */
>>   extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
>>   			 const enum hrtimer_mode mode);
>> +
>> +static inline int hrtimer_start_now(struct hrtimer *timer,
>> +				    const enum hrtimer_mode mode)
>> +{
>> +	return hrtimer_start(timer, timer->base->get_time(), mode);
>> +}
> What's the mode argument for? How is this supposed to do what you
> want:
>
>         hrtimer_start_now(timer, HRTIMER_MODE_REL);
Ah, of course, I guess we'd have to use a fixed default, my bad.
>
> Aside of that, what's wrong with doing:
>
>        static const ktime_t ktime_zero = { .tv64 = 0 };
>
>        hrtimer_start(timer, ktime_zero, HRTIMER_MODE_REL);
I guess the same could be said for hrtimer_forward_now I suppose. It was 
just intended as a little helper, with emphasis on helper.
Olliver
>
> Thanks,
>
> 	tglx

-- 
Met vriendelijke groeten, Kind regards, 与亲切的问候

Olliver Schinagl
Research & Development
Ultimaker B.V.
http://www.ultimaker.com


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

* Re: [PATCH] hrtimer: add hrtimer_start_now()
  2015-01-22 11:07   ` Olliver Schinagl
@ 2015-01-22 19:35     ` Thomas Gleixner
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2015-01-22 19:35 UTC (permalink / raw)
  To: Olliver Schinagl; +Cc: linux-kernel, Olliver Schinagl

On Thu, 22 Jan 2015, Olliver Schinagl wrote:
> On 22-01-15 12:01, Thomas Gleixner wrote:
> > Aside of that, what's wrong with doing:
> > 
> >        static const ktime_t ktime_zero = { .tv64 = 0 };
> > 
> >        hrtimer_start(timer, ktime_zero, HRTIMER_MODE_REL);
> I guess the same could be said for hrtimer_forward_now I suppose. It was just
> intended as a little helper, with emphasis on helper.

Well, no. htimer_forward_now() is mainly there to maintain a periodic
schedule which takes gaps into account.

I have nothing against the start_now() helper, but it's simpler and
less code with start relative than with abs and get_time().

Thanks,

	tglx

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

end of thread, other threads:[~2015-01-22 19:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-22  6:12 [PATCH] hrtimer: add hrtimer_start_now() Olliver Schinagl
2015-01-22 11:01 ` Thomas Gleixner
2015-01-22 11:07   ` Olliver Schinagl
2015-01-22 19:35     ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox