Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

posix-timers: Retrieve interval in common timer_settime() code

No point in doing this all over the place.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Reviewed-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>

authored by

Thomas Gleixner and committed by
Frederic Weisbecker
bfa408f0 c20b99e3

+6 -9
+2 -8
kernel/time/posix-cpu-timers.c
··· 622 622 { 623 623 bool sigev_none = timer->it_sigev_notify == SIGEV_NONE; 624 624 clockid_t clkid = CPUCLOCK_WHICH(timer->it_clock); 625 - u64 old_expires, new_expires, old_incr, now; 626 625 struct cpu_timer *ctmr = &timer->it.cpu; 626 + u64 old_expires, new_expires, now; 627 627 struct sighand_struct *sighand; 628 628 struct task_struct *p; 629 629 unsigned long flags; ··· 660 660 return -ESRCH; 661 661 } 662 662 663 - /* 664 - * Disarm any old timer after extracting its expiry time. 665 - */ 666 - old_incr = timer->it_interval; 663 + /* Retrieve the current expiry time before disarming the timer */ 667 664 old_expires = cpu_timer_getexpires(ctmr); 668 665 669 666 if (unlikely(timer->it.cpu.firing)) { ··· 739 742 cpu_timer_fire(timer); 740 743 out: 741 744 rcu_read_unlock(); 742 - if (old) 743 - old->it_interval = ns_to_timespec64(old_incr); 744 - 745 745 return ret; 746 746 } 747 747
+4 -1
kernel/time/posix-timers.c
··· 904 904 const struct k_clock *kc; 905 905 struct k_itimer *timr; 906 906 unsigned long flags; 907 - int error = 0; 907 + int error; 908 908 909 909 if (!timespec64_valid(&new_spec64->it_interval) || 910 910 !timespec64_valid(&new_spec64->it_value)) ··· 917 917 retry: 918 918 if (!timr) 919 919 return -EINVAL; 920 + 921 + if (old_spec64) 922 + old_spec64->it_interval = ktime_to_timespec64(timr->it_interval); 920 923 921 924 kc = timr->kclock; 922 925 if (WARN_ON_ONCE(!kc || !kc->timer_set))