public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/fair: avoid integer overflow warning for fair_server_period_max;
@ 2024-08-07  8:00 Arnd Bergmann
  2024-08-07 10:00 ` Vincent Guittot
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2024-08-07  8:00 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
  Cc: Arnd Bergmann, Dietmar Eggemann, Steven Rostedt, Ben Segall,
	Mel Gorman, Valentin Schneider, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

The clalculation of fair_server_period_max includes an integer overflow:

In file included from kernel/sched/build_utility.c:72:
kernel/sched/debug.c:341:57: error: integer overflow in expression of type 'long int' results in '-100663296' [-Werror=overflow]
  341 | static unsigned long fair_server_period_max = (1 << 22) * NSEC_PER_USEC; /* ~4 seconds */

Avoids this by using an unsigned constant to start with.

Fixes: d741f297bcea ("sched/fair: Fair server interface")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/sched/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 0148bc65d39c..242e7f264a0b 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -338,7 +338,7 @@ enum dl_param {
 	DL_PERIOD,
 };
 
-static unsigned long fair_server_period_max = (1 << 22) * NSEC_PER_USEC; /* ~4 seconds */
+static unsigned long fair_server_period_max = (1u << 22) * NSEC_PER_USEC; /* ~4 seconds */
 static unsigned long fair_server_period_min = (100) * NSEC_PER_USEC;     /* 100 us */
 
 static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubuf,
-- 
2.39.2


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

end of thread, other threads:[~2024-08-07 10:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-07  8:00 [PATCH] sched/fair: avoid integer overflow warning for fair_server_period_max; Arnd Bergmann
2024-08-07 10:00 ` Vincent Guittot
2024-08-07 10:39   ` Peter Zijlstra

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