[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <23f90fd3273a4d7f961b277758ac7af8@AcuMS.aculab.com>
Date: Tue, 31 Oct 2023 09:35:23 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'José Pekkarinen' <jose.pekkarinen@...hound.fi>,
"seanjc@...gle.com" <seanjc@...gle.com>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"mingo@...hat.com" <mingo@...hat.com>,
"bp@...en8.de" <bp@...en8.de>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
"skhan@...uxfoundation.org" <skhan@...uxfoundation.org>
CC: "x86@...nel.org" <x86@...nel.org>, "hpa@...or.com" <hpa@...or.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-kernel-mentees@...ts.linuxfoundation.org"
<linux-kernel-mentees@...ts.linuxfoundation.org>
Subject: RE: [PATCH] KVM: x86: replace do_div with div64_ul
From: José Pekkarinen
> Sent: 29 October 2023 09:39
>
> Reported by coccinelle, there is a do_div call that does
> 64-by-32 divisions even in 64bit platforms, this patch will
> move it to div64_ul macro that will decide the correct
> division function for the platform underneath. The output
> the warning follows:
>
> arch/x86/kvm/lapic.c:1948:1-7: WARNING: do_div() does a 64-by-32 division, please consider using
> div64_ul instead.
That is about the worst message from the coccinelle scripts.
It really ought to ask you to check the domain on the values.
>
> Signed-off-by: José Pekkarinen <jose.pekkarinen@...hound.fi>
> ---
> arch/x86/kvm/lapic.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 3e977dbbf993..0b90c6ad5091 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1945,7 +1945,7 @@ static void start_sw_tscdeadline(struct kvm_lapic *apic)
> guest_tsc = kvm_read_l1_tsc(vcpu, rdtsc());
>
> ns = (tscdeadline - guest_tsc) * 1000000ULL;
> - do_div(ns, this_tsc_khz);
> + div64_ul(ns, this_tsc_khz);
Did you test this?
Hint - you didn't.
David
>
> if (likely(tscdeadline > guest_tsc) &&
> likely(ns > apic->lapic_timer.timer_advance_ns)) {
> --
> 2.39.2
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists