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

Configure Feed

Select the types of activity you want to include in your feed.

[PATCH] Fix cpu timers expiration time

There's a silly off-by-one error in the code that updates the expiration
of posix CPU timers, causing them to not be properly updated when they
hit exactly on their expiration time (which should be the normal case).

This causes them to then fire immediately again, and only _then_ get
properly updated.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Oleg Nesterov and committed by
Linus Torvalds
7a4ed937 e02fd440

+3 -3
+3 -3
kernel/posix-cpu-timers.c
··· 91 91 * Update expiry time from increment, and increase overrun count, 92 92 * given the current clock sample. 93 93 */ 94 - static inline void bump_cpu_timer(struct k_itimer *timer, 94 + static void bump_cpu_timer(struct k_itimer *timer, 95 95 union cpu_time_count now) 96 96 { 97 97 int i; ··· 110 110 for (i = 0; incr < delta - incr; i++) 111 111 incr = incr << 1; 112 112 for (; i >= 0; incr >>= 1, i--) { 113 - if (delta <= incr) 113 + if (delta < incr) 114 114 continue; 115 115 timer->it.cpu.expires.sched += incr; 116 116 timer->it_overrun += 1 << i; ··· 128 128 for (i = 0; cputime_lt(incr, cputime_sub(delta, incr)); i++) 129 129 incr = cputime_add(incr, incr); 130 130 for (; i >= 0; incr = cputime_halve(incr), i--) { 131 - if (cputime_le(delta, incr)) 131 + if (cputime_lt(delta, incr)) 132 132 continue; 133 133 timer->it.cpu.expires.cpu = 134 134 cputime_add(timer->it.cpu.expires.cpu, incr);