linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix overflow when HZ is smaller than 60
@ 2014-01-24 17:21 Mikulas Patocka
  2014-01-24 21:41 ` [PATCH v2] " Mikulas Patocka
  0 siblings, 1 reply; 3+ messages in thread
From: Mikulas Patocka @ 2014-01-24 17:21 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner; +Cc: linux-kernel

When compiling for the IA-64 ski emulator, HZ is set to 32 because the
emulation is slow and we don't want to waste too many cycles processing
timers. Alpha also has an option to set HZ to 32.

This causes integer underflow in
kernel/time/jiffies.c:
kernel/time/jiffies.c:66:2: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  .mult  = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */
  ^

This patch reduces the JIFFIES_SHIFT value to avoid the overflow.

Signed-off-by: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Cc: stable@vger.kernel.org

---
 kernel/time/jiffies.c |    6 ++++++
 1 file changed, 6 insertions(+)

Index: linux-2.6-ia64/kernel/time/jiffies.c
===================================================================
--- linux-2.6-ia64.orig/kernel/time/jiffies.c	2014-01-24 17:48:48.000000000 +0100
+++ linux-2.6-ia64/kernel/time/jiffies.c	2014-01-24 18:14:51.000000000 +0100
@@ -51,7 +51,13 @@
  * HZ shrinks, so values greater than 8 overflow 32bits when
  * HZ=100.
  */
+#if HZ < 30
+#define JIFFIES_SHIFT	6
+#elif HZ < 60
+#define JIFFIES_SHIFT	7
+#else
 #define JIFFIES_SHIFT	8
+#endif
 
 static cycle_t jiffies_read(struct clocksource *cs)
 {

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

* [PATCH v2] Fix overflow when HZ is smaller than 60
  2014-01-24 17:21 [PATCH] Fix overflow when HZ is smaller than 60 Mikulas Patocka
@ 2014-01-24 21:41 ` Mikulas Patocka
  2014-02-06 15:04   ` [tip:timers/urgent] time: " tip-bot for Mikulas Patocka
  0 siblings, 1 reply; 3+ messages in thread
From: Mikulas Patocka @ 2014-01-24 21:41 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel

The patch that I sent before had wrong numbers in it, it could result in 
"Clocksource jiffies might overflow on 11% adjustment" message. This is 
the patch with correct numbers.

> +#if HZ < 30
> +#define JIFFIES_SHIFT	6
> +#elif HZ < 60
> +#define JIFFIES_SHIFT	7
> +#else
>  #define JIFFIES_SHIFT	8
> +#endif

From: Mikulas Patocka <mpatocka@redhat.com>

Fix overflow when HZ is 32

When compiling for the IA-64 ski emulator, HZ is set to 32 because the
emulation is slow and we don't want to waste too many cycles processing
timers. Alpha also has an option to set HZ to 32.

This causes integer underflow in
kernel/time/jiffies.c:
kernel/time/jiffies.c:66:2: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  .mult  = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */
  ^

This patch reduces the JIFFIES_SHIFT value to avoid the overflow.

Signed-off-by: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Cc: stable@vger.kernel.org

---
 kernel/time/jiffies.c |    6 ++++++
 1 file changed, 6 insertions(+)

Index: linux-2.6-ia64/kernel/time/jiffies.c
===================================================================
--- linux-2.6-ia64.orig/kernel/time/jiffies.c	2014-01-24 22:34:17.000000000 +0100
+++ linux-2.6-ia64/kernel/time/jiffies.c	2014-01-24 22:36:56.000000000 +0100
@@ -51,7 +51,13 @@
  * HZ shrinks, so values greater than 8 overflow 32bits when
  * HZ=100.
  */
+#if HZ < 34
+#define JIFFIES_SHIFT	6
+#elif HZ < 67
+#define JIFFIES_SHIFT	7
+#else
 #define JIFFIES_SHIFT	8
+#endif
 
 static cycle_t jiffies_read(struct clocksource *cs)
 {

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

* [tip:timers/urgent] time: Fix overflow when HZ is smaller than 60
  2014-01-24 21:41 ` [PATCH v2] " Mikulas Patocka
@ 2014-02-06 15:04   ` tip-bot for Mikulas Patocka
  0 siblings, 0 replies; 3+ messages in thread
From: tip-bot for Mikulas Patocka @ 2014-02-06 15:04 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, mikulas, tglx, mpatocka

Commit-ID:  80d767d770fd9c697e434fd080c2db7b5c60c6dd
Gitweb:     http://git.kernel.org/tip/80d767d770fd9c697e434fd080c2db7b5c60c6dd
Author:     Mikulas Patocka <mpatocka@redhat.com>
AuthorDate: Fri, 24 Jan 2014 16:41:36 -0500
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 6 Feb 2014 16:01:40 +0100

time: Fix overflow when HZ is smaller than 60

When compiling for the IA-64 ski emulator, HZ is set to 32 because the
emulation is slow and we don't want to waste too many cycles processing
timers. Alpha also has an option to set HZ to 32.

This causes integer underflow in
kernel/time/jiffies.c:
kernel/time/jiffies.c:66:2: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  .mult  = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */
  ^

This patch reduces the JIFFIES_SHIFT value to avoid the overflow.

Signed-off-by: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Link: http://lkml.kernel.org/r/alpine.LRH.2.02.1401241639100.23871@file01.intranet.prod.int.rdu2.redhat.com
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 kernel/time/jiffies.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/time/jiffies.c b/kernel/time/jiffies.c
index 7a925ba..a6a5bf5 100644
--- a/kernel/time/jiffies.c
+++ b/kernel/time/jiffies.c
@@ -51,7 +51,13 @@
  * HZ shrinks, so values greater than 8 overflow 32bits when
  * HZ=100.
  */
+#if HZ < 34
+#define JIFFIES_SHIFT	6
+#elif HZ < 67
+#define JIFFIES_SHIFT	7
+#else
 #define JIFFIES_SHIFT	8
+#endif
 
 static cycle_t jiffies_read(struct clocksource *cs)
 {

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

end of thread, other threads:[~2014-02-06 15:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-24 17:21 [PATCH] Fix overflow when HZ is smaller than 60 Mikulas Patocka
2014-01-24 21:41 ` [PATCH v2] " Mikulas Patocka
2014-02-06 15:04   ` [tip:timers/urgent] time: " tip-bot for Mikulas Patocka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).