From: David Laight <David.Laight@ACULAB.COM>
To: 'Jules Irenge' <jbi.octave@gmail.com>,
"mark.rutland@arm.com" <mark.rutland@arm.com>
Cc: "alexander.shishkin@linux.intel.com"
<alexander.shishkin@linux.intel.com>,
"jolsa@kernel.org" <jolsa@kernel.org>,
"irogers@google.com" <irogers@google.com>,
"adrian.hunter@intel.com" <adrian.hunter@intel.com>,
"bp@alien8.de" <bp@alien8.de>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"x86@kernel.org" <x86@kernel.org>,
"hpa@zytor.com" <hpa@zytor.com>,
"linux-perf-users@vger.kernel.org"
<linux-perf-users@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] perf/x86/amd/power: Use div64_u64 onstead of do_div()
Date: Thu, 2 May 2024 16:25:58 +0000 [thread overview]
Message-ID: <41180245c6e94a06b789cd44b8aebd62@AcuMS.aculab.com> (raw)
In-Reply-To: <Zi57-TMgU19puaQM@octinomon.home>
From: Jules Irenge <jbi.octave@gmail.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@gmail.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)
next prev parent reply other threads:[~2024-05-02 16:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-28 16:40 [PATCH] perf/x86/amd/power: Use div64_u64 onstead of do_div() Jules Irenge
2024-05-02 16:25 ` David Laight [this message]
2024-05-02 16:34 ` Jules Bashizi Irenge
2024-05-02 22:18 ` David Laight
2024-05-02 22:59 ` Linus Torvalds
2024-05-04 22:53 ` David Laight
2024-05-05 19:38 ` Linus Torvalds
2024-05-06 16:39 ` David Laight
2024-05-06 16:45 ` Linus Torvalds
2024-05-06 17:26 ` Linus Torvalds
2024-05-06 20:25 ` David Laight
2024-05-06 17:43 ` David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41180245c6e94a06b789cd44b8aebd62@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=irogers@google.com \
--cc=jbi.octave@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.