timer fixes for 3.17
Linus,
please pull the latest timers-urgent-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers-urgent-for-linus
The timer department is not too proud about the following fixes:
- Deal with a long standing rounding bug in the timeval to jiffies conversion. It's a real issue and this fix fell through the cracks for quite some time.
- Another round of alarmtimer fixes. Finally this code gets used more widely and the subtle issues hidden for quite some time are noticed and fixed. Nothing really exciting, just the itty bitty details which bite the serious users here and there.
Thanks,
tglx
------------------>
Andrew Hunter (1):
jiffies: Fix timeval conversion to jiffies
Richard Larocque (3):
alarmtimer: Return relative times in timer_gettime
alarmtimer: Do not signal SIGEV_NONE timers
alarmtimer: Lock k_itimer during timer callback
include/linux/jiffies.h | 12 ----------- kernel/time/alarmtimer.c | 34 +++++++++++++++++++---------- kernel/time/time.c | 56 +++++++++++++++++++++++++++--------------------- 3 files changed, 54 insertions(+), 48 deletions(-)
include/linux/jiffies.h +0 -12
@@ -258,23 +258,11 @@ extern unsigned long preset_lpj;#define SEC_JIFFIE_SC (32 - SHIFT_HZ)#endif #define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 29) -#define USEC_JIFFIE_SC (SEC_JIFFIE_SC + 19)#define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC) +\ TICK_NSEC -1) / (u64)TICK_NSEC))#define NSEC_CONVERSION ((unsigned long)((((u64)1 << NSEC_JIFFIE_SC) +\ TICK_NSEC -1) / (u64)TICK_NSEC)) -#define USEC_CONVERSION \ - ((unsigned long)((((u64)NSEC_PER_USEC << USEC_JIFFIE_SC) +\ - TICK_NSEC -1) / (u64)TICK_NSEC)) -/* -* USEC_ROUND is used in the timeval to jiffie conversion. See there -* for more details. It is the scaled resolution rounding value. Note -* that it is a 64-bit value. Since, when it is applied, we are already -* in jiffies (albit scaled), it is nothing but the bits we will shift -* off. -*/ -#define USEC_ROUND (u64)(((u64)1 << USEC_JIFFIE_SC) - 1)/* * The maximum jiffie value is (MAX_INT >> 1). Here we translate that * into seconds. The 64-bit case will overflow if we are not careful,
kernel/time/alarmtimer.c +23 -11
@@ -464,18 +464,26 @@ static enum alarmtimer_type clock2alarm(clockid_t clockid)static enum alarmtimer_restart alarm_handle_timer (struct alarm *alarm,ktime_t now) { +unsigned long flags; struct k_itimer *ptr = container_of(alarm, struct k_itimer, it.alarm.alarmtimer); -if (posix_timer_event (ptr,0 ) !=0 ) - ptr->it_overrun++; +enum alarmtimer_restart result =ALARMTIMER_NORESTART ; + +spin_lock_irqsave (&ptr->it_lock, flags); +if ((ptr->it_sigev_notify & ~SIGEV_THREAD_ID ) !=SIGEV_NONE ) { +if (posix_timer_event (ptr,0 ) !=0 ) + ptr->it_overrun++; + }/* Re-add periodic timers */ if (ptr->it.alarm.interval.tv64) { ptr->it_overrun +=alarm_forward (alarm, now, ptr->it.alarm.interval); -return ALARMTIMER_RESTART ; + result =ALARMTIMER_RESTART ; } -return ALARMTIMER_NORESTART ; +spin_unlock_irqrestore (&ptr->it_lock, flags); + +return result; }/**
@@ -541,18 +549,22 @@ static int alarm_timer_create(struct k_itimer *new_timer)* @new_timer: k_itimer pointer * @cur_setting: itimerspec data to fill * -* Copies the itimerspec data out from the k_itimer +* Copies out the current itimerspec data */ static void alarm_timer_get (struct k_itimer *timr,struct itimerspec *cur_setting) { -memset (cur_setting,0 ,sizeof (struct itimerspec )); +ktime_t relative_expiry_time = +alarm_expires_remaining (&(timr->it.alarm.alarmtimer)); + +if (ktime_to_ns (relative_expiry_time) >0 ) { + cur_setting->it_value =ktime_to_timespec (relative_expiry_time); + }else { + cur_setting->it_value.tv_sec =0 ; + cur_setting->it_value.tv_nsec =0 ; + } - cur_setting->it_interval = -ktime_to_timespec (timr->it.alarm.interval); - cur_setting->it_value = -ktime_to_timespec (timr->it.alarm.alarmtimer.node.expires); -return ; + cur_setting->it_interval =ktime_to_timespec (timr->it.alarm.interval); }/**
kernel/time/time.c +31 -25
85 lines not on this page · raw message