Re: [PATCH RFC 03/17] lib/crc: crc_kunit: add benchmark for crc32c_flip_range()

Baokun Li <[email protected]> Sun, 10 May 2026 18:03:05 +0800
Newsgroups dev.linux.lists.sashiko
Message-ID <[email protected]>
在 2026/5/9 04:54, [email protected] 写道:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] Native 64-bit division (`/ 10`) and modulo (`% 10`) on `u64` values will cause build failures on 32-bit architectures.
> --
>
> commit d1411c693c30ea46d5821fc2f72f158dd0cea8d2
> Author: Baokun Li <[email protected]>
>
> lib/crc: crc_kunit: add benchmark for crc32c_flip_range()
>
> This commit adds a kunit benchmark to compare crc32c_flip_range() against
> full crc32c recomputation for various bitmap sizes.
>
>> diff --git a/lib/crc/tests/crc_kunit.c b/lib/crc/tests/crc_kunit.c
>> --- a/lib/crc/tests/crc_kunit.c
>> +++ b/lib/crc/tests/crc_kunit.c
> [ ... ]
>
>> +static void crc32c_flip_range_benchmark(struct kunit *test)
>> +{
> [ ... ]
>
>> +		kunit_info(test,
>> +			   "bitmap=%zu: flip_range=%llu ns, full_crc=%llu ns, speedup=%llu.%01llux\n",
>> +			   buflen,
>> +			   div64_u64(t_flip, num_iters),
>> +			   div64_u64(t_full, num_iters),
>> +			   div64_u64(t_full * 10, t_flip ? t_flip : 1) / 10,
>> +			   div64_u64(t_full * 10, t_flip ? t_flip : 1) % 10);
> Since div64_u64() returns a u64, will applying the native division (/ 10)
> and modulo (% 10) operators directly to this return value cause build
> failures on 32-bit architectures?
>
> The kernel typically prevents native 64-bit division to catch performance
> issues, which results in linker errors for __udivdi3 and __umoddi3 on 32-bit
> builds.
>
> Should this use a helper like div_u64_rem() instead?
>
>
Yes, it should. I’ll update it to use the div_u64_rem() helper.


Thanks,
Baokun