]> www.infradead.org Git - users/dwmw2/linux.git/commit
block/genhd: use seq_put_decimal_ull for diskstats decimal values
authorDavid Wang <00107082@163.com>
Fri, 8 Nov 2024 05:45:00 +0000 (13:45 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 13 Nov 2024 21:02:19 +0000 (14:02 -0700)
commitbda9c7d92f24b693eaf0262c090de4c8c108a28e
treeddb54108a2b8fa8a1c84d75f50109beede0a4514
parent00e8d290b55f2fa5c5a0500b4dccf9e090650447
block/genhd: use seq_put_decimal_ull for diskstats decimal values

seq_printf is costly. For each block device, 19 decimal values are
yielded in /proc/diskstats via seq_printf. On a system with 16 logical
block devices, profiling for open/read/close sequences shows seq_printf
took ~75% samples of diskstats_show:

diskstats_show(92.626% 2269372/2450040)
    seq_printf(76.026% 1725313/2269372)
vsnprintf(99.163% 1710866/1725313)
    format_decode(26.597% 455040/1710866)
    number(19.554% 334542/1710866)
    memcpy_orig(4.183% 71570/1710866)
...
srso_return_thunk(0.009% 148/1725313)
    part_stat_read_all(8.030% 182236/2269372)

One million rounds of open/read/close /proc/diskstats takes:

real 0m37.687s
user 0m0.264s
sys 0m32.911s
On average, each sequence tooks ~0.032ms

With this patch, most decimal values are yield via seq_put_decimal_ull,
performance is significantly improved:

real 0m20.792s
user 0m0.316s
sys 0m20.463s
On average, each sequence tooks ~0.020ms, a ~37.5% improvement.

Signed-off-by: David Wang <00107082@163.com>
Link: https://lore.kernel.org/r/20241108054500.4251-1-00107082@163.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/genhd.c