linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: openvswitch: use do_div() for 64-by-32 divisions:
@ 2020-04-24 12:10 Geert Uytterhoeven
  2020-04-24 15:05 ` Eric Dumazet
  0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2020-04-24 12:10 UTC (permalink / raw)
  To: Pravin B Shelar, David S . Miller, Jakub Kicinski, Tonghao Zhang
  Cc: netdev, dev, linux-kernel, Geert Uytterhoeven

On 32-bit architectures (e.g. m68k):

    ERROR: modpost: "__udivdi3" [net/openvswitch/openvswitch.ko] undefined!
    ERROR: modpost: "__divdi3" [net/openvswitch/openvswitch.ko] undefined!

Fixes: e57358873bb5d6ca ("net: openvswitch: use u64 for meter bucket")
Reported-by: noreply@ellerman.id.au
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 net/openvswitch/meter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
index 915f31123f235c03..3498a5ab092ab2b8 100644
--- a/net/openvswitch/meter.c
+++ b/net/openvswitch/meter.c
@@ -393,7 +393,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
 		 * Start with a full bucket.
 		 */
 		band->bucket = (band->burst_size + band->rate) * 1000ULL;
-		band_max_delta_t = band->bucket / band->rate;
+		band_max_delta_t = do_div(band->bucket, band->rate);
 		if (band_max_delta_t > meter->max_delta_t)
 			meter->max_delta_t = band_max_delta_t;
 		band++;
-- 
2.17.1


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

* Re: [PATCH] net: openvswitch: use do_div() for 64-by-32 divisions:
  2020-04-24 12:10 [PATCH] net: openvswitch: use do_div() for 64-by-32 divisions: Geert Uytterhoeven
@ 2020-04-24 15:05 ` Eric Dumazet
  2020-04-24 15:12   ` Geert Uytterhoeven
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2020-04-24 15:05 UTC (permalink / raw)
  To: Geert Uytterhoeven, Pravin B Shelar, David S . Miller,
	Jakub Kicinski, Tonghao Zhang
  Cc: netdev, dev, linux-kernel



On 4/24/20 5:10 AM, Geert Uytterhoeven wrote:
> On 32-bit architectures (e.g. m68k):
> 
>     ERROR: modpost: "__udivdi3" [net/openvswitch/openvswitch.ko] undefined!
>     ERROR: modpost: "__divdi3" [net/openvswitch/openvswitch.ko] undefined!
> 
> Fixes: e57358873bb5d6ca ("net: openvswitch: use u64 for meter bucket")
> Reported-by: noreply@ellerman.id.au
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
>  net/openvswitch/meter.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
> index 915f31123f235c03..3498a5ab092ab2b8 100644
> --- a/net/openvswitch/meter.c
> +++ b/net/openvswitch/meter.c
> @@ -393,7 +393,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
>  		 * Start with a full bucket.
>  		 */
>  		band->bucket = (band->burst_size + band->rate) * 1000ULL;
> -		band_max_delta_t = band->bucket / band->rate;
> +		band_max_delta_t = do_div(band->bucket, band->rate);
>  		if (band_max_delta_t > meter->max_delta_t)
>  			meter->max_delta_t = band_max_delta_t;
>  		band++;
> 

This is fascinating... Have you tested this patch ?

Please double check what do_div() return value is supposed to be !

Thanks.

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

* Re: [PATCH] net: openvswitch: use do_div() for 64-by-32 divisions:
  2020-04-24 15:05 ` Eric Dumazet
@ 2020-04-24 15:12   ` Geert Uytterhoeven
  2020-04-24 16:45     ` Toke Høiland-Jørgensen
  0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2020-04-24 15:12 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Pravin B Shelar, David S . Miller, Jakub Kicinski, Tonghao Zhang,
	netdev, dev, Linux Kernel Mailing List

Hi Eric,

On Fri, Apr 24, 2020 at 5:05 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On 4/24/20 5:10 AM, Geert Uytterhoeven wrote:
> > On 32-bit architectures (e.g. m68k):
> >
> >     ERROR: modpost: "__udivdi3" [net/openvswitch/openvswitch.ko] undefined!
> >     ERROR: modpost: "__divdi3" [net/openvswitch/openvswitch.ko] undefined!
> >
> > Fixes: e57358873bb5d6ca ("net: openvswitch: use u64 for meter bucket")
> > Reported-by: noreply@ellerman.id.au
> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > ---
> >  net/openvswitch/meter.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
> > index 915f31123f235c03..3498a5ab092ab2b8 100644
> > --- a/net/openvswitch/meter.c
> > +++ b/net/openvswitch/meter.c
> > @@ -393,7 +393,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
> >                * Start with a full bucket.
> >                */
> >               band->bucket = (band->burst_size + band->rate) * 1000ULL;
> > -             band_max_delta_t = band->bucket / band->rate;
> > +             band_max_delta_t = do_div(band->bucket, band->rate);
> >               if (band_max_delta_t > meter->max_delta_t)
> >                       meter->max_delta_t = band_max_delta_t;
> >               band++;
> >
>
> This is fascinating... Have you tested this patch ?

Sorry, I should have said this is compile-tested only.

> Please double check what do_div() return value is supposed to be !

I do not have any openvswitch setups, let alone on the poor m68k box.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] net: openvswitch: use do_div() for 64-by-32 divisions:
  2020-04-24 15:12   ` Geert Uytterhoeven
@ 2020-04-24 16:45     ` Toke Høiland-Jørgensen
  2020-04-24 17:54       ` Geert Uytterhoeven
  0 siblings, 1 reply; 6+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-04-24 16:45 UTC (permalink / raw)
  To: Geert Uytterhoeven, Eric Dumazet
  Cc: Pravin B Shelar, David S . Miller, Jakub Kicinski, Tonghao Zhang,
	netdev, dev, Linux Kernel Mailing List

Geert Uytterhoeven <geert@linux-m68k.org> writes:

> Hi Eric,
>
> On Fri, Apr 24, 2020 at 5:05 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
>> On 4/24/20 5:10 AM, Geert Uytterhoeven wrote:
>> > On 32-bit architectures (e.g. m68k):
>> >
>> >     ERROR: modpost: "__udivdi3" [net/openvswitch/openvswitch.ko] undefined!
>> >     ERROR: modpost: "__divdi3" [net/openvswitch/openvswitch.ko] undefined!
>> >
>> > Fixes: e57358873bb5d6ca ("net: openvswitch: use u64 for meter bucket")
>> > Reported-by: noreply@ellerman.id.au
>> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
>> > ---
>> >  net/openvswitch/meter.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
>> > index 915f31123f235c03..3498a5ab092ab2b8 100644
>> > --- a/net/openvswitch/meter.c
>> > +++ b/net/openvswitch/meter.c
>> > @@ -393,7 +393,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
>> >                * Start with a full bucket.
>> >                */
>> >               band->bucket = (band->burst_size + band->rate) * 1000ULL;
>> > -             band_max_delta_t = band->bucket / band->rate;
>> > +             band_max_delta_t = do_div(band->bucket, band->rate);
>> >               if (band_max_delta_t > meter->max_delta_t)
>> >                       meter->max_delta_t = band_max_delta_t;
>> >               band++;
>> >
>>
>> This is fascinating... Have you tested this patch ?
>
> Sorry, I should have said this is compile-tested only.
>
>> Please double check what do_div() return value is supposed to be !
>
> I do not have any openvswitch setups, let alone on the poor m68k box.

I think what Eric is referring to is this, from the documentation of
do_div:

 * do_div - returns 2 values: calculate remainder and update new dividend
 * @n: uint64_t dividend (will be updated)
 * @base: uint32_t divisor
 *
 * Summary:
 * ``uint32_t remainder = n % base;``
 * ``n = n / base;``
 *
 * Return: (uint32_t)remainder


Specifically that last part :)

-Toke


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

* Re: [PATCH] net: openvswitch: use do_div() for 64-by-32 divisions:
  2020-04-24 16:45     ` Toke Høiland-Jørgensen
@ 2020-04-24 17:54       ` Geert Uytterhoeven
  2020-04-25  3:40         ` Tonghao Zhang
  0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2020-04-24 17:54 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: Eric Dumazet, Pravin B Shelar, David S . Miller, Jakub Kicinski,
	Tonghao Zhang, netdev, dev, Linux Kernel Mailing List

Hi Toke,

On Fri, Apr 24, 2020 at 6:45 PM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
> Geert Uytterhoeven <geert@linux-m68k.org> writes:
> > On Fri, Apr 24, 2020 at 5:05 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
> >> On 4/24/20 5:10 AM, Geert Uytterhoeven wrote:
> >> > On 32-bit architectures (e.g. m68k):
> >> >
> >> >     ERROR: modpost: "__udivdi3" [net/openvswitch/openvswitch.ko] undefined!
> >> >     ERROR: modpost: "__divdi3" [net/openvswitch/openvswitch.ko] undefined!
> >> >
> >> > Fixes: e57358873bb5d6ca ("net: openvswitch: use u64 for meter bucket")
> >> > Reported-by: noreply@ellerman.id.au
> >> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> >> > ---
> >> >  net/openvswitch/meter.c | 2 +-
> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
> >> > index 915f31123f235c03..3498a5ab092ab2b8 100644
> >> > --- a/net/openvswitch/meter.c
> >> > +++ b/net/openvswitch/meter.c
> >> > @@ -393,7 +393,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
> >> >                * Start with a full bucket.
> >> >                */
> >> >               band->bucket = (band->burst_size + band->rate) * 1000ULL;
> >> > -             band_max_delta_t = band->bucket / band->rate;
> >> > +             band_max_delta_t = do_div(band->bucket, band->rate);
> >> >               if (band_max_delta_t > meter->max_delta_t)
> >> >                       meter->max_delta_t = band_max_delta_t;
> >> >               band++;
> >> >
> >>
> >> This is fascinating... Have you tested this patch ?
> >
> > Sorry, I should have said this is compile-tested only.
> >
> >> Please double check what do_div() return value is supposed to be !
> >
> > I do not have any openvswitch setups, let alone on the poor m68k box.
>
> I think what Eric is referring to is this, from the documentation of
> do_div:
>
>  * do_div - returns 2 values: calculate remainder and update new dividend
>  * @n: uint64_t dividend (will be updated)
>  * @base: uint32_t divisor
>  *
>  * Summary:
>  * ``uint32_t remainder = n % base;``
>  * ``n = n / base;``
>  *
>  * Return: (uint32_t)remainder

Oops, that was a serious brain fart. Sorry for that!

That should have been div_u64() instead of do_div().
Feel free to update my patch while applying, else I'll send a v2 later.

/me hides in a brown paper bag for the whole weekend...

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] net: openvswitch: use do_div() for 64-by-32 divisions:
  2020-04-24 17:54       ` Geert Uytterhoeven
@ 2020-04-25  3:40         ` Tonghao Zhang
  0 siblings, 0 replies; 6+ messages in thread
From: Tonghao Zhang @ 2020-04-25  3:40 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Toke Høiland-Jørgensen, Eric Dumazet, Pravin B Shelar,
	David S . Miller, Jakub Kicinski, netdev, ovs dev,
	Linux Kernel Mailing List

On Sat, Apr 25, 2020 at 1:54 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Toke,
>
> On Fri, Apr 24, 2020 at 6:45 PM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
> > Geert Uytterhoeven <geert@linux-m68k.org> writes:
> > > On Fri, Apr 24, 2020 at 5:05 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > >> On 4/24/20 5:10 AM, Geert Uytterhoeven wrote:
> > >> > On 32-bit architectures (e.g. m68k):
> > >> >
> > >> >     ERROR: modpost: "__udivdi3" [net/openvswitch/openvswitch.ko] undefined!
> > >> >     ERROR: modpost: "__divdi3" [net/openvswitch/openvswitch.ko] undefined!
> > >> >
> > >> > Fixes: e57358873bb5d6ca ("net: openvswitch: use u64 for meter bucket")
> > >> > Reported-by: noreply@ellerman.id.au
> > >> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > >> > ---
> > >> >  net/openvswitch/meter.c | 2 +-
> > >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >> >
> > >> > diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
> > >> > index 915f31123f235c03..3498a5ab092ab2b8 100644
> > >> > --- a/net/openvswitch/meter.c
> > >> > +++ b/net/openvswitch/meter.c
> > >> > @@ -393,7 +393,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
> > >> >                * Start with a full bucket.
> > >> >                */
> > >> >               band->bucket = (band->burst_size + band->rate) * 1000ULL;
> > >> > -             band_max_delta_t = band->bucket / band->rate;
> > >> > +             band_max_delta_t = do_div(band->bucket, band->rate);
> > >> >               if (band_max_delta_t > meter->max_delta_t)
> > >> >                       meter->max_delta_t = band_max_delta_t;
> > >> >               band++;
> > >> >
> > >>
> > >> This is fascinating... Have you tested this patch ?
> > >
> > > Sorry, I should have said this is compile-tested only.
> > >
> > >> Please double check what do_div() return value is supposed to be !
> > >
> > > I do not have any openvswitch setups, let alone on the poor m68k box.
> >
> > I think what Eric is referring to is this, from the documentation of
> > do_div:
> >
> >  * do_div - returns 2 values: calculate remainder and update new dividend
> >  * @n: uint64_t dividend (will be updated)
> >  * @base: uint32_t divisor
> >  *
> >  * Summary:
> >  * ``uint32_t remainder = n % base;``
> >  * ``n = n / base;``
> >  *
> >  * Return: (uint32_t)remainder
>
> Oops, that was a serious brain fart. Sorry for that!
>
> That should have been div_u64() instead of do_div().
> Feel free to update my patch while applying, else I'll send a v2 later.
>
> /me hides in a brown paper bag for the whole weekend...
I sent the patch with updated, change the reported tag, test it, and
add more commit msg,
and author should be you. Thanks.
> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds



-- 
Best regards, Tonghao

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

end of thread, other threads:[~2020-04-25  3:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24 12:10 [PATCH] net: openvswitch: use do_div() for 64-by-32 divisions: Geert Uytterhoeven
2020-04-24 15:05 ` Eric Dumazet
2020-04-24 15:12   ` Geert Uytterhoeven
2020-04-24 16:45     ` Toke Høiland-Jørgensen
2020-04-24 17:54       ` Geert Uytterhoeven
2020-04-25  3:40         ` Tonghao Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).