[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <sga4nmj2jsvglpazvzbwtuvarvciu7phumgye3m2tocfdyjjoj@o4fygeq3jbg3>
Date: Thu, 20 Mar 2025 08:36:13 +0100
From: Uwe Kleine-König <u.kleine-koenig@...libre.com>
To: Nicolas Pitre <npitre@...libre.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] math64: Provide an uprounding variant of
mul_u64_u64_div_u64()
Hello Nico,
On Wed, Mar 19, 2025 at 03:38:03PM -0400, Nicolas Pitre wrote:
> On Wed, 19 Mar 2025, Uwe Kleine-König wrote:
> [...]
> > +#ifndef mul_u64_u64_div_u64_roundup
> > +u64 mul_u64_u64_div_u64_roundup(u64 a, u64 b, u64 c)
> > +{
> > + u64 res = mul_u64_u64_div_u64(a, b, c);
> > + /* Those multiplications might overflow but it doesn't matter */
> > + u64 rem = a * b - c * res;
> > +
> > + if (rem)
> > + res += 1;
> > +
> > + return res;
> > +}
> > +EXPORT_SYMBOL(mul_u64_u64_div_u64_roundup);
> > +#endif
>
> Might there ever be a need for a _rem variant similar to
> div64_u64_rem()? If so the _roundup could then be a simple wrapper.
If such a need pops up I hope this synergy is taken care of. I wouldn't
proactively create a _rem variant now though.
> Reviewed-by: Nicolas Pitre <npitre@...libre.com>
Thanks!
Best regards
Uwe
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists