public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix endless looping between cascade() and internal_add_timer()
@ 2012-10-08 13:49 Hildner, Christian
  2012-10-09 19:49 ` [tip:timers/core] timers: " tip-bot for Hildner, Christian
  0 siblings, 1 reply; 2+ messages in thread
From: Hildner, Christian @ 2012-10-08 13:49 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org; +Cc: Kiszka, Jan, tglx@linutronix.de

From: Christian Hildner <christian.hildner@siemens.com>

This patch ensures that when cascade() is called timers within tv5 are not added endlessly to their own list again, instead they are added to the next lower tv level tv4 (as expected).

Signed-off-by: Christian Hildner <christian.hildner@siemens.com>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
---
Adding two (or more) timers with large values for "expires" (they have to reside within tv5 in the same list) leads to endless looping between cascade() and internal_add_timer() in case CONFIG_BASE_SMALL is one and jiffies are crossing the value 1 << 18. The bug was introduced between 2.6.11 and 2.6.12 (and survived for quite some time).

Tested with 2.6.14, patch is for 3.6.1 - see below.


diff -urN linux-3.6.1_orig/kernel/timer.c linux-3.6.1/kernel/timer.c
--- linux-3.6.1_orig/kernel/timer.c	2012-10-07 17:41:28.000000000 +0200
+++ linux-3.6.1/kernel/timer.c	2012-10-08 09:34:40.000000000 +0200
@@ -63,6 +63,7 @@
 #define TVR_SIZE (1 << TVR_BITS)
 #define TVN_MASK (TVN_SIZE - 1)
 #define TVR_MASK (TVR_SIZE - 1)
+#define MAX_TVAL ((unsigned long)((1ULL << (TVR_BITS + 4*TVN_BITS)) - 1))
 
 struct tvec {
 	struct list_head vec[TVN_SIZE];
@@ -358,11 +359,12 @@
 		vec = base->tv1.vec + (base->timer_jiffies & TVR_MASK);
 	} else {
 		int i;
-		/* If the timeout is larger than 0xffffffff on 64-bit
-		 * architectures then we use the maximum timeout:
+		/* If the timeout is larger than MAX_TVAL (on 64-bit
+		 * architectures or with CONFIG_BASE_SMALL=1) then we
+		 * use the maximum timeout.
 		 */
-		if (idx > 0xffffffffUL) {
-			idx = 0xffffffffUL;
+		if (idx > MAX_TVAL) {
+			idx = MAX_TVAL;
 			expires = idx + base->timer_jiffies;
 		}
 		i = (expires >> (TVR_BITS + 3 * TVN_BITS)) & TVN_MASK;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-09 19:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-08 13:49 [PATCH] Fix endless looping between cascade() and internal_add_timer() Hildner, Christian
2012-10-09 19:49 ` [tip:timers/core] timers: " tip-bot for Hildner, Christian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox