Re: [PATCH] iio: gts-helper: Fix division loop

From: Matti Vaittinen
Date: Mon Jan 08 2024 - 01:35:40 EST


On 1/7/24 18:22, Jonathan Cameron wrote:
On Thu, 4 Jan 2024 11:34:28 +0200
Matti Vaittinen <mazziesaccount@xxxxxxxxx> wrote:

The loop based 64bit division may run for a long time when dividend is a
lot bigger than the divider. Replace the division loop by the
div64_u64() which implementation may be significantly faster.

Signed-off-by: Matti Vaittinen <mazziesaccount@xxxxxxxxx>
Fixes: 38416c28e168 ("iio: light: Add gain-time-scale helpers")

Hmm. Fix or not perf improvement?

Ha. I don't fancy calling my own doings as bugs - but when a code can keep kernel busy looping for several seconds... :|

I'm going to take the middle ground
and leave the fixes tag, but not rush this in.

I think this is fine. It is nice to get this fix in stable if we have longer living stables with GTS helpers, because that's where many people do "real work" - and because it is likely some devices with new sensors are being built on products using these stable releases.

Still, the current users (ROHM light sensors) don't use that big dividends. Hence I don't think this needs any high speed fixup process :)

Thanks!


--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~