On Wed, 7 Apr 2021, Huacai Chen wrote:
This code is rather broken in an obvious way, starting from:
unsigned long long __n; \ \ __high = *__n >> 32; \ __low = __n; \
where `__n' is used uninitialised. Since this is my code originally I'll look into it; we may want to reinstate `do_div' too, which didn't have to be removed in the first place.
I think we can reuse the generic do_div().
We can, but it's not clear to me if this is optimal. We have a DIVMOD instruction which original code took advantage of (although I can see potential in reusing bits from include/asm-generic/div64.h). The two implementations would have to be benchmarked against each other across a couple of different CPUs.
Huacai, thanks for your investigation! Please be more careful in verifying your future submissions however.
Sorry, I thought there is only one bug in div64.h, but in fact there are three...
This just shows the verification you made was not good enough, hence my observation.
Maciej