Skip to contentSkip to conversation

hrtimers updates

PATCH In review Thomas Gleixner 5 participants 15 messages Jan 20, 2006 – Jan 25, 2006

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover hrtimers updates

Linus,

please pull from

master.kernel.org:/pub/scm/linux/kernel/git/tglx/hrtimer-2.6.git

This is an update on following issues:

- itimer locking
- NULL pointer usage
- oldvalue return in setitimer bug#5617
- posix-timer requeue race
- hrtimer cleanups and simplifications
- correct initial value for relative SIGEV_NONE timers

tglx

diff-tree a1f15939b7af18c5abcd4810ccd512467c77a6b1 (from 4b2719dcb1143a18de16162f2562045e40487e49)

Author: Thomas Gleixner <[email protected]>
Date:   Fri Jan 20 02:19:44 2006 +0100

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

:100644 100644 28e72fd0029fa466e1768d40bcb10b28a2505450 e2fa4c03c2589784a031036916a603e7fe0ac18d M kernel/posix-timers.c

diff-tree 4b2719dcb1143a18de16162f2562045e40487e49 (from 0ea0b28ad86d611745b0a55b472f46d27c38e7a2)

Author: Thomas Gleixner <[email protected]>
Date:   Fri Jan 20 01:29:11 2006 +0100

[hrtimers] Add back lost credit lines

At some point we added credits to people who actively helped to bring k/hr-timers along. This was lost in the big code revamp. Add it back.

:100644 100644 1bd6552cc34134c4e19d5565e992fc91b9785910 6aca67a569a2ff907830ef64e6b69dafc154996c M include/linux/ktime.h
:100644 100644 efff9496b2fae67de84bf2d044a901f8a546ad2d 2b6e1757aeddf118f43c31111f46224b00f5d25e M kernel/hrtimer.c

diff-tree 0ea0b28ad86d611745b0a55b472f46d27c38e7a2 (from 7a42511f275d3c895be54f4e578921fc35e25dd2)

Author: George Anzinger <[email protected]>
Date:   Thu Jan 19 23:55:54 2006 +0100

[hrtimers] Cleanups and simplifications

This patch cleans up the interface to hrtimers by changing the init code to pass the mode as well as the clock. This allow the init code to select the correct base and eliminates extra timer re-init code in posix-timers. We also simplify the restart interface nanosleep use.

:100644 100644 c657f3d4924a14e5714b818a1788c28859872a12 6361544bb6ae5fef3ee1dcd84dc8788262bd7917 M include/linux/hrtimer.h
:100644 100644 4ae8cfc1c89cffdee486c2a3b28316e583a40747 7f0ab5ee948c633a8065e685a5147e0df3d439ad M kernel/fork.c
:100644 100644 f580dd9db2863bee71e16129fce63956b7344b72 efff9496b2fae67de84bf2d044a901f8a546ad2d M kernel/hrtimer.c
:100644 100644 3b606d361b529dfda6097ba08e60bbdfd3be62aa 28e72fd0029fa466e1768d40bcb10b28a2505450 M kernel/posix-timers.c

diff-tree 7a42511f275d3c895be54f4e578921fc35e25dd2 (from 3f59dd20898d805781b3eac7ed0807e7a0b30f2f)

Author: Steven [email protected] <[email protected]>
Date:   Thu Jan 19 23:52:29 2006 +0100

[hrtimers] Fix posix-timer requeue race

CPU0 expires a posix-timer and runs the callback function.
The signal is queued.
After releasing the posix-timer lock and before returning to hrtimer_run_queue CPU0 gets interrupted.
CPU1 delivers the queued signal and rearms the timer.
CPU0 comes back to hrtimer_run_queue and sets the timer state to expired. The next modification of the timer can result in an oops, because the state information is wrong.

Keep track of state = RUNNING and check if the state has been in the return path of hrtimer_run_queue. In case the state has been changed, ignore a restart request and do not touch the state variable.

:100644 100644 089bfb1fa01a771d7c11ee7de4227deb88d29b00 c657f3d4924a14e5714b818a1788c28859872a12 M include/linux/hrtimer.h
:100644 100644 f1c4155b49ac140051538f12046cb553674657f9 f580dd9db2863bee71e16129fce63956b7344b72 M kernel/hrtimer.c

diff-tree 3f59dd20898d805781b3eac7ed0807e7a0b30f2f (from a42e5a139db5c1759bc98729152618ed5b80410e)

Author: Thomas Gleixner <[email protected]>
Date:   Thu Jan 19 15:36:22 2006 +0100

[hrtimers] Fix oldvalue return in setitimer

This resolves bugzilla bug#5617. The oldvalue of the timer was read after the timer was cancelled, so the remaining time was always zero.

:100644 100644 6433d06855063d477c4c037e00ad660aea4319fd 379be2f8c84c33445b9cea549fe2c7215d3d6cc4 M kernel/itimer.c

diff-tree a42e5a139db5c1759bc98729152618ed5b80410e (from 52ae41e3d11d6f1828c5827861b7b83b7e854222)

Author: Thomas Gleixner <[email protected]>
Date:   Tue Jan 17 22:50:51 2006 +0100

[hrtimers] Fix possible use of NULL pointer in posix-timers

Fixup the conversion of posix-timers to hrtimers.

:100644 100644 197208b3aa2ad837517d27662e5bacaafd75258b 3b606d361b529dfda6097ba08e60bbdfd3be62aa M kernel/posix-timers.c

diff-tree 52ae41e3d11d6f1828c5827861b7b83b7e854222 (from 2664b25051f7ab96b22b199aa2f5ef6a949a4296)

Author: Thomas Gleixner <[email protected]>
Date:   Tue Jan 17 20:03:14 2006 +0100

[hrtimers] Fixup itimer conversion

The itimer conversion removed the locking which protects the timer and variables in the shared signal structure. Steven Rostedt found the problem in the latest -rt patches.

:100644 100644 c2c05c4ff28d5bd7bd32cf8ca1eea1dc768b71c2 6433d06855063d477c4c037e00ad660aea4319fd M kernel/itimer.c

--

#1 lore raw

PATCH 1/7 Fixup itimer conversion

The itimer conversion removed the locking which protects the timer and variables in the shared signal structure. Steven Rostedt found the problem in the latest -rt patches.

---

 kernel/itimer.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

52ae41e3d11d6f1828c5827861b7b83b7e854222

kernel/itimer.c +10 -1
index c2c05c4..6433d06 100644
@@ -49,9 +49,11 @@ int do_getitimer(int which, struct itime
 
 	switch (which) {
 	case ITIMER_REAL:
+		spin_lock_irq(&tsk->sighand->siglock);
 		value->it_value = itimer_get_remtime(&tsk->signal->real_timer);
 		value->it_interval =
 			ktime_to_timeval(tsk->signal->it_real_incr);
+		spin_unlock_irq(&tsk->sighand->siglock);
 		break;
 	case ITIMER_VIRTUAL:
 		read_lock(&tasklist_lock);
@@ -150,8 +152,14 @@ int do_setitimer(int which, struct itime
 
 	switch (which) {
 	case ITIMER_REAL:
+again:
+		spin_lock_irq(&tsk->sighand->siglock);
 		timer = &tsk->signal->real_timer;
-		hrtimer_cancel(timer);
+		/* We are sharing ->siglock with it_real_fn() */
+		if (hrtimer_try_to_cancel(timer) < 0) {
+			spin_unlock_irq(&tsk->sighand->siglock);
+			goto again;
+		}
 		if (ovalue) {
 			ovalue->it_value = itimer_get_remtime(timer);
 			ovalue->it_interval
@@ -162,6 +170,7 @@ int do_setitimer(int which, struct itime
 		expires = timeval_to_ktime(value->it_value);
 		if (expires.tv64 != 0)
 			hrtimer_start(timer, expires, HRTIMER_REL);
+		spin_unlock_irq(&tsk->sighand->siglock);
 		break;
 	case ITIMER_VIRTUAL:
 		nval = timeval_to_cputime(&value->it_value);
Signature · 3 lines
1.0.8

--
#2 lore raw

PATCH 2/7 Fix possible use of NULL pointer in posix-timers

In reply to Thomas Gleixner

Fixup the conversion of posix-timers to hrtimers.

---

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

a42e5a139db5c1759bc98729152618ed5b80410e

kernel/posix-timers.c +2 -1
index 197208b..3b606d3 100644
@@ -290,7 +290,8 @@ void do_schedule_next_timer(struct sigin
 		info->si_overrun = timr->it_overrun_last;
 	}
 
-	unlock_timer(timr, flags);
+	if (timr)
+		unlock_timer(timr, flags);
 }
 
 int posix_timer_event(struct k_itimer *timr,int si_private)
Signature · 3 lines
1.0.8

--
#3 lore raw

PATCH 3/7 Fix oldvalue return in setitimer

In reply to Thomas Gleixner

This resolves bugzilla bug#5617. The oldvalue of the timer was read after the timer was cancelled, so the remaining time was always zero.

---

 kernel/itimer.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

3f59dd20898d805781b3eac7ed0807e7a0b30f2f

kernel/itimer.c +5 -5
index 6433d06..379be2f 100644
@@ -155,16 +155,16 @@ int do_setitimer(int which, struct itime
 again:
 		spin_lock_irq(&tsk->sighand->siglock);
 		timer = &tsk->signal->real_timer;
-		/* We are sharing ->siglock with it_real_fn() */
-		if (hrtimer_try_to_cancel(timer) < 0) {
-			spin_unlock_irq(&tsk->sighand->siglock);
-			goto again;
-		}
 		if (ovalue) {
 			ovalue->it_value = itimer_get_remtime(timer);
 			ovalue->it_interval
 				= ktime_to_timeval(tsk->signal->it_real_incr);
 		}
+		/* We are sharing ->siglock with it_real_fn() */
+		if (hrtimer_try_to_cancel(timer) < 0) {
+			spin_unlock_irq(&tsk->sighand->siglock);
+			goto again;
+		}
 		tsk->signal->it_real_incr =
 			timeval_to_ktime(value->it_interval);
 		expires = timeval_to_ktime(value->it_value);
Signature · 3 lines
1.0.8

--
#4 lore raw

Re: [PATCH 3/7] [hrtimers] Fix oldvalue return in setitimer

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 4 lines · Thomas Gleixner

This resolves bugzilla bug#5617. The oldvalue of the timer was read after the timer was cancelled, so the remaining time was always zero.

I'm seeing this problem on recent Fedore development kernels. Interestingly, it causes the IDL 7 minute timed demo to exit immediately upon trying to plot since it resets the timer and expects the old value to be returned.

- - Orion
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFD1qJyORnzrtFC2/sRAnp4AJ9ZQ/E0huj2sk8TOxF/1QF7OnrtQQCdHwsT g0YGeKL3Co9isimpQJ8f3mU=
=R+Z4
-----END PGP SIGNATURE-----

#5 lore raw

Re: [PATCH 3/7] [hrtimers] Fix oldvalue return in setitimer

Quoted 9 lines · Orion Poplawski

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 4 lines · Thomas Gleixner

This resolves bugzilla bug#5617. The oldvalue of the timer was read after the timer was cancelled, so the remaining time was always zero.

Quoted 4 lines

I'm seeing this problem on recent Fedore development kernels. Interestingly, it causes the IDL 7 minute timed demo to exit immediately upon trying to plot since it resets the timer and expects the old value to be returned.

Thats the same problem.

tglx

#6 lore raw

PATCH 4/7 Fix posix-timer requeue race

In reply to Thomas Gleixner

From: Steven [email protected] <[email protected]>
Date: 1137711149 +0100

CPU0 expires a posix-timer and runs the callback function.
The signal is queued.
After releasing the posix-timer lock and before returning to hrtimer_run_queue CPU0 gets interrupted.
CPU1 delivers the queued signal and rearms the timer.
CPU0 comes back to hrtimer_run_queue and sets the timer state to expired. The next modification of the timer can result in an oops, because the state information is wrong.

Keep track of state = RUNNING and check if the state has been in the return path of hrtimer_run_queue. In case the state has been changed, ignore a restart request and do not touch the state variable.

---

 include/linux/hrtimer.h |    1 +
 kernel/hrtimer.c        |    5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)

7a42511f275d3c895be54f4e578921fc35e25dd2

include/linux/hrtimer.h +1 -0
index 089bfb1..c657f3d 100644
@@ -40,6 +40,7 @@ enum hrtimer_restart {
 enum hrtimer_state {
 	HRTIMER_INACTIVE,	/* Timer is inactive */
 	HRTIMER_EXPIRED,		/* Timer is expired */
+	HRTIMER_RUNNING,		/* Timer is running the callback function */
 	HRTIMER_PENDING,		/* Timer is pending */
 };
 
kernel/hrtimer.c +5 -0
index f1c4155..f580dd9 100644
@@ -550,6 +550,7 @@ static inline void run_hrtimer_queue(str
 		fn = timer->function;
 		data = timer->data;
 		set_curr_timer(base, timer);
+		timer->state = HRTIMER_RUNNING;
 		__remove_hrtimer(timer, base);
 		spin_unlock_irq(&base->lock);
 
@@ -565,6 +566,10 @@ static inline void run_hrtimer_queue(str
 
 		spin_lock_irq(&base->lock);
 
+		/* Another CPU has added back the timer */
+		if (timer->state != HRTIMER_RUNNING)
+			continue;
+
 		if (restart == HRTIMER_RESTART)
 			enqueue_hrtimer(timer, base);
 		else
Signature · 3 lines
1.0.8

--
#7 lore raw

Re: [PATCH 4/7] [hrtimers] Fix posix-timer requeue race

Hi,

Quoted 8 lines · Thomas Gleixner

CPU0 expires a posix-timer and runs the callback function.
The signal is queued.
After releasing the posix-timer lock and before returning to hrtimer_run_queue CPU0 gets interrupted.
CPU1 delivers the queued signal and rearms the timer.
CPU0 comes back to hrtimer_run_queue and sets the timer state to expired. The next modification of the timer can result in an oops, because the state information is wrong.

Thomas, this is exactly what I meant with overloaded state machines, enumerated states are very hard to get right with concurrent processes. Please get rid of the state field and at least use a flag field instead.

bye, Roman

#8 lore raw

PATCH 5/7 Cleanups and simplifications

In reply to Thomas Gleixner

From: George Anzinger <[email protected]>
Date: 1137711354 +0100

This patch cleans up the interface to hrtimers by changing the init code to pass the mode as well as the clock. This allow the init code to select the correct base and eliminates extra timer re-init code in posix-timers. We also simplify the restart interface nanosleep use.

---

 include/linux/hrtimer.h |    5 ++--
 kernel/fork.c           |    2 +-
 kernel/hrtimer.c        |   59 +++++++++++++++++++----------------------------
 kernel/posix-timers.c   |   37 +++++++----------------------
 4 files changed, 36 insertions(+), 67 deletions(-)

0ea0b28ad86d611745b0a55b472f46d27c38e7a2

include/linux/hrtimer.h +2 -3
index c657f3d..6361544 100644
@@ -101,9 +101,8 @@ struct hrtimer_base {
 /* Exported timer functions: */
 
 /* Initialize timers: */
-extern void hrtimer_init(struct hrtimer *timer, const clockid_t which_clock);
-extern void hrtimer_rebase(struct hrtimer *timer, const clockid_t which_clock);
-
+extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
+			 enum hrtimer_mode mode);
 
 /* Basic timer operations: */
 extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
kernel/fork.c +1 -1
index 4ae8cfc..7f0ab5e 100644
@@ -802,7 +802,7 @@ static inline int copy_signal(unsigned l
 	init_sigpending(&sig->shared_pending);
 	INIT_LIST_HEAD(&sig->posix_timers);
 
-	hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC);
+	hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_REL);
 	sig->it_real_incr.tv64 = 0;
 	sig->real_timer.function = it_real_fn;
 	sig->real_timer.data = tsk;
kernel/hrtimer.c +24 -35

125 lines not on this page · raw message

kernel/posix-timers.c +9 -28
index 3b606d3..28e72fd 100644
@@ -194,9 +194,7 @@ static inline int common_clock_set(const
 
 static int common_timer_create(struct k_itimer *new_timer)
 {
-	hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock);
-	new_timer->it.real.timer.data = new_timer;
-	new_timer->it.real.timer.function = posix_timer_fn;
+	hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0);
 	return 0;
 }
 
@@ -693,6 +691,7 @@ common_timer_set(struct k_itimer *timr, 
 		 struct itimerspec *new_setting, struct itimerspec *old_setting)
 {
 	struct hrtimer *timer = &timr->it.real.timer;
+	enum hrtimer_mode mode;
 
 	if (old_setting)
 		common_timer_get(timr, old_setting);
@@ -714,14 +713,10 @@ common_timer_set(struct k_itimer *timr, 
 	if (!new_setting->it_value.tv_sec && !new_setting->it_value.tv_nsec)
 		return 0;
 
-	/* Posix madness. Only absolute CLOCK_REALTIME timers
-	 * are affected by clock sets. So we must reiniatilize
-	 * the timer.
-	 */
-	if (timr->it_clock == CLOCK_REALTIME && (flags & TIMER_ABSTIME))
-		hrtimer_rebase(timer, CLOCK_REALTIME);
-	else
-		hrtimer_rebase(timer, CLOCK_MONOTONIC);
+	mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL;
+	hrtimer_init(&timr->it.real.timer, timr->it_clock, mode);
+	timr->it.real.timer.data = timr;
+	timr->it.real.timer.function = posix_timer_fn;
 
 	timer->expires = timespec_to_ktime(new_setting->it_value);
 
@@ -732,8 +727,7 @@ common_timer_set(struct k_itimer *timr, 
 	if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE))
 		return 0;
 
-	hrtimer_start(timer, timer->expires, (flags & TIMER_ABSTIME) ?
-		      HRTIMER_ABS : HRTIMER_REL);
+	hrtimer_start(timer, timer->expires, mode);
 	return 0;
 }
 
@@ -948,21 +942,8 @@ sys_clock_getres(const clockid_t which_c
 static int common_nsleep(const clockid_t which_clock, int flags,
 			 struct timespec *tsave, struct timespec __user *rmtp)
 {
-	int mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL;
-	int clockid = which_clock;
-
-	switch (which_clock) {
-	case CLOCK_REALTIME:
-		/* Posix madness. Only absolute timers on clock realtime
-		   are affected by clock set. */
-		if (mode != HRTIMER_ABS)
-			clockid = CLOCK_MONOTONIC;
-	case CLOCK_MONOTONIC:
-		break;
-	default:
-		return -EINVAL;
-	}
-	return hrtimer_nanosleep(tsave, rmtp, mode, clockid);
+	return hrtimer_nanosleep(tsave, rmtp, flags & TIMER_ABSTIME ?
+				 HRTIMER_ABS : HRTIMER_REL, which_clock);
 }
 
 asmlinkage long
Signature · 3 lines
1.0.8

--
#9 lore raw

PATCH 6/7 Add back lost credit lines

In reply to Thomas Gleixner

At some point we added credits to people who actively helped to bring k/hr-timers along. This was lost in the big code revamp. Add it back.

---

 include/linux/ktime.h |    6 ++++++
 kernel/hrtimer.c      |    6 ++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

4b2719dcb1143a18de16162f2562045e40487e49

include/linux/ktime.h +6 -0
index 1bd6552..6aca67a 100644
@@ -10,6 +10,12 @@
  *
  *  Started by: Thomas Gleixner and Ingo Molnar
  *
+ *  Credits:
+ *
+ *  	Roman Zippel provided the ideas and primary code snippets of
+ *  	the ktime_t union and further simplifications of the original
+ *  	code.
+ *
  *  For licencing details see kernel-base/COPYING
  */
 #ifndef _LINUX_KTIME_H
kernel/hrtimer.c +6 -0
index efff949..2b6e175 100644
@@ -21,6 +21,12 @@
  *  Credits:
  *	based on kernel/timer.c
  *
+ *	Help, testing, suggestions, bugfixes, improvements were
+ *	provided by:
+ *
+ *	George Anzinger, Andrew Morton, Steven Rostedt, Roman Zippel
+ *	et. al.
+ *
  *  For licencing details see kernel-base/COPYING
  */
 
Signature · 3 lines
1.0.8

--
#10 lore raw

PATCH 7/7 Set correct initial expiry time for relative SIGEV_NONE timers

In reply to Thomas Gleixner

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

Pointed out by George Anzinger.

---

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

a1f15939b7af18c5abcd4810ccd512467c77a6b1

kernel/posix-timers.c +6 -1
index 28e72fd..e2fa4c0 100644
@@ -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;
Signature · 3 lines
1.0.8

--
#11 lore raw

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

Quoted 5 lines · Thomas Gleixner

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

Ahem.

Review

Quoted 3 lines
(quoted diff) +3 -0
+		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?

kernel/posix-timers.c renamed from kernel/posix-timers.c~hrtimers-set-correct-initial-expiry-time-for-relative-fix +1 -1
@@ -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;
 	}

_

#12 lore raw

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

Quoted 7 lines · Andrew Morton
Quoted 5 lines · Thomas Gleixner

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

Quoted 7 lines

Ahem.

Review

Quoted 3 lines
(quoted diff) +3 -0
+		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

#13 lore raw

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

In reply to Thomas Gleixner
Quoted 18 lines · Thomas Gleixner

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

Pointed out by George Anzinger.

---

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

a1f15939b7af18c5abcd4810ccd512467c77a6b1

kernel/posix-timers.c +0 -0
index 28e72fd..e2fa4c0 100644

kernel/posix-timers.c common_timer_set(struct k_itimer *timr, · line 731

Quoted 9 lines
kernel/posix-timers.c +5 -1
@@ -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

Quoted 5 lines
kernel/posix-timers.c +1 -0
 		return 0;
+	}
 
 	hrtimer_start(timer, timer->expires, mode);
 	return 0;
Signature · 2 lines
George Anzinger   [email protected]
HRT (High-res-timers):  http://sourceforge.net/projects/high-res-timers/
#14 lore raw

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

Quoted 8 lines · George Anzinger
Quoted 8 lines

a1f15939b7af18c5abcd4810ccd512467c77a6b1

kernel/posix-timers.c +0 -0
index 28e72fd..e2fa4c0 100644
@@ -724,8 +724,13 @@ common_timer_set(struct k_itimer *timr, 
 	timr->it.real.interval = timespec_to_ktime(new_setting->it_interval);
 
Quoted 10 lines

kernel/posix-timers.c common_timer_set(struct k_itimer *timr, · line 731

Quoted 7 lines
kernel/posix-timers.c +5 -1
 	/* 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