[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <41180245c6e94a06b789cd44b8aebd62@AcuMS.aculab.com>
Date: Thu, 2 May 2024 16:25:58 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Jules Irenge' <jbi.octave@...il.com>, "mark.rutland@....com"
<mark.rutland@....com>
CC: "alexander.shishkin@...ux.intel.com" <alexander.shishkin@...ux.intel.com>,
"jolsa@...nel.org" <jolsa@...nel.org>, "irogers@...gle.com"
<irogers@...gle.com>, "adrian.hunter@...el.com" <adrian.hunter@...el.com>,
"bp@...en8.de" <bp@...en8.de>, "dave.hansen@...ux.intel.com"
<dave.hansen@...ux.intel.com>, "x86@...nel.org" <x86@...nel.org>,
"hpa@...or.com" <hpa@...or.com>, "linux-perf-users@...r.kernel.org"
<linux-perf-users@...r.kernel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] perf/x86/amd/power: Use div64_u64 onstead of do_div()
From: Jules Irenge <jbi.octave@...il.com>
> Sent: 28 April 2024 17:40
>
> 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_u64 instead
>
> Signed-off-by: Jules Irenge <jbi.octave@...il.com>
> ---
> arch/x86/events/amd/power.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/events/amd/power.c b/arch/x86/events/amd/power.c
> index 37d5b380516e..ff003c1a645b 100644
> --- a/arch/x86/events/amd/power.c
> +++ b/arch/x86/events/amd/power.c
> @@ -64,7 +64,7 @@ static void event_update(struct perf_event *event)
> delta *= cpu_pwr_sample_ratio * 1000;
> tdelta = new_ptsc - prev_ptsc;
>
> - do_div(delta, tdelta);
> + div64_u64(delta, tdelta);
Nak - you've not tested it.
David
> local64_add(delta, &event->count);
> }
>
> --
> 2.43.2
>
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists