2006-01-20 02:56:10

by Thomas Gleixner

[permalink] [raw]
Subject: [PATCH 7/7] [hrtimers] Set correct initial expiry time for relative SIGEV_NONE timers


The expiry time for relative timers with SIGEV_NONE set was never
updated to the correct value.

Pointed out by George Anzinger.

Signed-off-by: Thomas Gleixner <[email protected]>

---

kernel/posix-timers.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)

a1f15939b7af18c5abcd4810ccd512467c77a6b1
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 28e72fd..e2fa4c0 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -724,8 +724,13 @@ common_timer_set(struct k_itimer *timr,
timr->it.real.interval = timespec_to_ktime(new_setting->it_interval);

/* SIGEV_NONE timers are not queued ! See common_timer_get */
- if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE))
+ if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) {
+ /* Setup correct expiry time for relative timers */
+ if (mode == HRTIMER_REL)
+ timer->expires = ktime_add(timer-expires,
+ timer->base->get_time());
return 0;
+ }

hrtimer_start(timer, timer->expires, mode);
return 0;
--
1.0.8

--


2006-01-20 05:12:10

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 7/7] [hrtimers] Set correct initial expiry time for relative SIGEV_NONE timers

Thomas Gleixner <[email protected]> wrote:
>
>
> The expiry time for relative timers with SIGEV_NONE set was never
> updated to the correct value.
>

Ahem.

> + if (mode == HRTIMER_REL)
> + timer->expires = ktime_add(timer-expires,
> + timer->base->get_time());

doesn't compile, hence isn't tested.

Please confirm that with the below fix we get something which works OK?

--- devel/kernel/posix-timers.c~hrtimers-set-correct-initial-expiry-time-for-relative-fix 2006-01-19 21:08:44.000000000 -0800
+++ devel-akpm/kernel/posix-timers.c 2006-01-19 21:08:44.000000000 -0800
@@ -727,7 +727,7 @@ common_timer_set(struct k_itimer *timr,
if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) {
/* Setup correct expiry time for relative timers */
if (mode == HRTIMER_REL)
- timer->expires = ktime_add(timer-expires,
+ timer->expires = ktime_add(timer->expires,
timer->base->get_time());
return 0;
}
_

2006-01-20 09:49:18

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH 7/7] [hrtimers] Set correct initial expiry time for relative SIGEV_NONE timers

On Thu, 2006-01-19 at 21:11 -0800, Andrew Morton wrote:
> Thomas Gleixner <[email protected]> wrote:
> >
> >
> > The expiry time for relative timers with SIGEV_NONE set was never
> > updated to the correct value.
> >
>
> Ahem.
>
> > + if (mode == HRTIMER_REL)
> > + timer->expires = ktime_add(timer-expires,
> > + timer->base->get_time());
>
> doesn't compile, hence isn't tested.

Oh well, I wanted to add quilt autorefresh mode since long :(

tglx


2006-01-20 16:39:18

by George Anzinger

[permalink] [raw]
Subject: Re: [PATCH 7/7] [hrtimers] Set correct initial expiry time for relative SIGEV_NONE timers

Thomas Gleixner wrote:
> The expiry time for relative timers with SIGEV_NONE set was never
> updated to the correct value.
>
> Pointed out by George Anzinger.
>
> Signed-off-by: Thomas Gleixner <[email protected]>
>
> ---
>
> kernel/posix-timers.c | 7 ++++++-
> 1 files changed, 6 insertions(+), 1 deletions(-)
>
> a1f15939b7af18c5abcd4810ccd512467c77a6b1
> diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
> index 28e72fd..e2fa4c0 100644
> --- a/kernel/posix-timers.c
> +++ b/kernel/posix-timers.c
> @@ -724,8 +724,13 @@ common_timer_set(struct k_itimer *timr,
> timr->it.real.interval = timespec_to_ktime(new_setting->it_interval);
>
> /* SIGEV_NONE timers are not queued ! See common_timer_get */
> - if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE))
> + if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) {
> + /* Setup correct expiry time for relative timers */
> + if (mode == HRTIMER_REL)
> + timer->expires = ktime_add(timer-expires,
> + timer->base->get_time());
This is only part of the problem. When the user does a timer_gettime() the
expiry time is taken from the hrtimer field and NOT the posix-timer part.
Somewhere this value needs to be copied to the hrtimer sub structure.

George
--

> return 0;
> + }
>
> hrtimer_start(timer, timer->expires, mode);
> return 0;

--
George Anzinger [email protected]
HRT (High-res-timers): http://sourceforge.net/projects/high-res-timers/

2006-01-20 16:57:35

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH 7/7] [hrtimers] Set correct initial expiry time for relative SIGEV_NONE timers

On Fri, 2006-01-20 at 08:33 -0800, George Anzinger wrote:
> > a1f15939b7af18c5abcd4810ccd512467c77a6b1
> > diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
> > index 28e72fd..e2fa4c0 100644
> > --- a/kernel/posix-timers.c
> > +++ b/kernel/posix-timers.c
> > @@ -724,8 +724,13 @@ common_timer_set(struct k_itimer *timr,
> > timr->it.real.interval = timespec_to_ktime(new_setting->it_interval);
> >
> > /* SIGEV_NONE timers are not queued ! See common_timer_get */
> > - if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE))
> > + if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) {
> > + /* Setup correct expiry time for relative timers */
> > + if (mode == HRTIMER_REL)
> > + timer->expires = ktime_add(timer-expires,
> > + timer->base->get_time());
> This is only part of the problem. When the user does a timer_gettime() the
> expiry time is taken from the hrtimer field and NOT the posix-timer part.
> Somewhere this value needs to be copied to the hrtimer sub structure.

Well timer->expires is the hrtimer struct itself.

tglx