mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH]  psi-pressure-stall-information-for-cpu-memory-and-io-fix-fix-fix
@ 2018-07-17 13:51 Arnd Bergmann
  2018-07-17 15:17 ` Peter Zijlstra
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2018-07-17 13:51 UTC (permalink / raw)
  To: akpm, Ingo Molnar, Peter Zijlstra
  Cc: Arnd Bergmann, Stephen Rothwell, Johannes Weiner, linux-kernel

The addition of do_div() did not do the right thing, as it assigned the
result of the multiplication to an 'unsigned long', which truncates
it before the division. GCC warns in various ways about this depending
on the architecuture, e.g.

arch/arm/include/asm/div64.h:33:45: note: expected 'uint64_t *' {aka 'long long unsigned int *'} but argument is of type 'long unsigned int *'

This uses div_u64() instead. This is probably still a bad idea since
we should avoid 64-bit division altogether in the scheduler, but at
least it does the correct calculation.

Fixes: 13a67bcb35f5 ("psi-pressure-stall-information-for-cpu-memory-and-io-fix-fix")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Please fold into the fix
---
 kernel/sched/psi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index eefe988ea7ce..9c3255ff50df 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -173,11 +173,10 @@ void __init psi_init(void)
 
 static void calc_avgs(unsigned long avg[3], u64 time, int missed_periods)
 {
-	unsigned long pct;
+	u64 pct;
 
 	/* Sample the most recent active period */
-	pct = time * 100;
-	do_div(pct, psi_period);
+	pct = div_u64(time * 100, psi_period);
 	pct *= FIXED_1;
 	avg[0] = calc_load(avg[0], EXP_10s, pct);
 	avg[1] = calc_load(avg[1], EXP_60s, pct);
-- 
2.9.0


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

* Re: [PATCH] psi-pressure-stall-information-for-cpu-memory-and-io-fix-fix-fix
  2018-07-17 13:51 [PATCH] psi-pressure-stall-information-for-cpu-memory-and-io-fix-fix-fix Arnd Bergmann
@ 2018-07-17 15:17 ` Peter Zijlstra
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2018-07-17 15:17 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: akpm, Ingo Molnar, Stephen Rothwell, Johannes Weiner, linux-kernel

On Tue, Jul 17, 2018 at 03:51:24PM +0200, Arnd Bergmann wrote:
> The addition of do_div() did not do the right thing, as it assigned the
> result of the multiplication to an 'unsigned long', which truncates
> it before the division. GCC warns in various ways about this depending
> on the architecuture, e.g.
> 
> arch/arm/include/asm/div64.h:33:45: note: expected 'uint64_t *' {aka 'long long unsigned int *'} but argument is of type 'long unsigned int *'
> 
> This uses div_u64() instead. This is probably still a bad idea since
> we should avoid 64-bit division altogether in the scheduler, but at
> least it does the correct calculation.
> 
> Fixes: 13a67bcb35f5 ("psi-pressure-stall-information-for-cpu-memory-and-io-fix-fix")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> Please fold into the fix

Please drop the entire PSI series instead.

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

end of thread, other threads:[~2018-07-17 15:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17 13:51 [PATCH] psi-pressure-stall-information-for-cpu-memory-and-io-fix-fix-fix Arnd Bergmann
2018-07-17 15:17 ` Peter Zijlstra

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

Powered by JetHome