[PATCH] lib: hint GCC to inlilne _find_next_bit() helper

From: Clement Courbet
Date: Mon Oct 30 2017 - 04:41:47 EST


Hi Yury,

I've tried your benchmark on x86-64 (haswell). Inlining is a pretty small
increase in binary size: 48B (2%).

In terms of speed, results are not very stable from one run to another
(I've included two runs to give you an idea), but overall there seems
to be small improvement on the random-filled bitmap, and not so much on
the sparse one.

Before (2312B):
[ 312.912746] Start testing find_bit() with random-filled bitmap
[ 312.919066] find_next_bit: 170226 cycles, 16267 iterations
[ 312.924657] find_next_zero_bit: 170826 cycles, 16502 iterations
[ 312.930674] find_last_bit: 152900 cycles, 16266 iterations
[ 312.938856] find_first_bit: 5335034 cycles, 16267 iterations
[ 312.944533] Start testing find_bit() with sparse bitmap
[ 312.949780] find_next_bit: 2644 cycles, 66 iterations
[ 312.955016] find_next_zero_bit: 320294 cycles, 32703 iterations
[ 312.960957] find_last_bit: 2170 cycles, 66 iterations
[ 312.966048] find_first_bit: 21704 cycles, 66 iterations

[ 515.310376] Start testing find_bit() with random-filled bitmap
[ 515.316693] find_next_bit: 164854 cycles, 16350 iterations
[ 515.322293] find_next_zero_bit: 173710 cycles, 16419 iterations
[ 515.328312] find_last_bit: 155458 cycles, 16350 iterations
[ 515.336584] find_first_bit: 5518332 cycles, 16351 iterations
[ 515.342272] Start testing find_bit() with sparse bitmap
[ 515.347519] find_next_bit: 2538 cycles, 66 iterations
[ 515.352763] find_next_zero_bit: 334828 cycles, 32703 iterations
[ 515.358703] find_last_bit: 2250 cycles, 66 iterations
[ 515.363787] find_first_bit: 23804 cycles, 66 iterations

After (2360B):
[ 183.844318] Start testing find_bit() with random-filled bitmap
[ 183.850588] find_next_bit: 148976 cycles, 16342 iterations
[ 183.856186] find_next_zero_bit: 173298 cycles, 16427 iterations
[ 183.862202] find_last_bit: 148728 cycles, 16341 iterations
[ 183.870404] find_first_bit: 5390470 cycles, 16342 iterations
[ 183.876084] Start testing find_bit() with sparse bitmap
[ 183.881341] find_next_bit: 2144 cycles, 66 iterations
[ 183.886586] find_next_zero_bit: 335558 cycles, 32703 iterations
[ 183.892535] find_last_bit: 2376 cycles, 66 iterations
[ 183.897627] find_first_bit: 24814 cycles, 66 iterations

[ 187.842232] Start testing find_bit() with random-filled bitmap
[ 187.848505] find_next_bit: 164512 cycles, 16412 iterations
[ 187.854101] find_next_zero_bit: 172770 cycles, 16357 iterations
[ 187.860117] find_last_bit: 145050 cycles, 16412 iterations
[ 187.868312] find_first_bit: 5374792 cycles, 16413 iterations
[ 187.873996] Start testing find_bit() with sparse bitmap
[ 187.879251] find_next_bit: 2422 cycles, 66 iterations
[ 187.884500] find_next_zero_bit: 342548 cycles, 32703 iterations
[ 187.890448] find_last_bit: 2150 cycles, 66 iterations
[ 187.895539] find_first_bit: 21830 cycles, 66 iterations