[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7EE9AB38-3103-4091-A558-BF0DEAF61E1D@zytor.com>
Date: Sun, 28 Apr 2024 12:13:11 -0700
From: "H. Peter Anvin" <hpa@...or.com>
To: Jules Irenge <jbi.octave@...il.com>, mingo@...hat.com
CC: tglx@...utronix.de, bp@...en8.de, x86@...nel.org, peterz@...radead.org,
rdunlap@...radead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] x86/tsc: Use div64_ul instead of do_div()
On April 28, 2024 10:31:16 AM PDT, Jules Irenge <jbi.octave@...il.com> wrote:
>do_div() truncates a u64 divisor to 32 bit.
>This can lead to non-zero being truncated to zero for division.
>
>Fix coccinelle warning
>WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead
>
>Signed-off-by: Jules Irenge <jbi.octave@...il.com>
>---
> arch/x86/kernel/tsc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
>index 5a69a49acc96..2da37f33dd17 100644
>--- a/arch/x86/kernel/tsc.c
>+++ b/arch/x86/kernel/tsc.c
>@@ -484,7 +484,7 @@ static unsigned long pit_calibrate_tsc(u32 latch, unsigned long ms, int loopmin)
>
> /* Calculate the PIT value */
> delta = t2 - t1;
>- do_div(delta, ms);
>+ div64_ul(delta, ms);
> return delta;
> }
>
Are you sure this is not a false positive? This is a *much* more expensive operation on 32 bits.
Powered by blists - more mailing lists