public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] block: more scalable inflight tracking
@ 2017-08-03 20:01 Jens Axboe
  2017-08-03 20:01 ` [PATCH 1/4] blk-mq-tag: check for NULL rq when iterating tags Jens Axboe
                   ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: Jens Axboe @ 2017-08-03 20:01 UTC (permalink / raw)
  To: linux-block; +Cc: brking

One scaling issue we currently have in the block code is the
inflight accounting. It's based on a per-device atomic count
for reads and writes, which means that even for an mq device
with lots of hardware queues, we end up dirtying a per-device
cacheline for each IO. The issue can easily be observed by
using null_blk:

modprobe null_blk submit_queues=48 queue_mode=2

and running a fio job that has 32 jobs doing sync reads on
the device (average of 3 runs, though deviation is low):

stats		IOPS		usr		sys
------------------------------------------------------
on		 2.6M		 5.4%		94.6%
off		21.0M		33.7%		67.3%

which shows a 10x slowdown with stats enabled. If we look at
the profile for stats on, the top entries are:

37.38%  fio      [kernel.vmlinux]    [k] blk_account_io_done
14.65%  fio      [kernel.vmlinux]    [k] blk_account_io_start
14.29%  fio      [kernel.vmlinux]    [k] part_round_stats_single
11.81%  fio      [kernel.vmlinux]    [k] blk_account_io_completion
 3.62%  fio      [kernel.vmlinux]    [k] part_round_stats
 0.81%  fio      [kernel.vmlinux]    [k] __blkdev_direct_IO_simple

which shows the system time being dominated by the stats accounting.

This patch series replaces the atomic counter with using the tags
hamming weight for tracking infligh counts. This means we don't have
to do anything when IO starts or completes, and for reading the value
we just have to check how many bits we have set in the tag maps on
the queues. This part is limited to 1000 per second (for HZ=1000).
Using this approach, running the same test again results in:

stats		IOPS		usr		sys
------------------------------------------------------
on		20.4M		30.9%		69.0%
off		21.4M		32.4%		67.4%

and doing a profiled run with stats on, the top of stats reporting is
now:

1.23%  fio  [kernel.vmlinux]  [k] blk_account_io_done
0.83%  fio  [kernel.vmlinux]  [k] blk_account_io_start
0.55%  fio  [kernel.vmlinux]  [k] blk_account_io_completion

which is a lot more reasonable. The difference between stats on and
off is now also neglible.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2017-08-07 19:54 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-03 20:01 [PATCH 0/4] block: more scalable inflight tracking Jens Axboe
2017-08-03 20:01 ` [PATCH 1/4] blk-mq-tag: check for NULL rq when iterating tags Jens Axboe
2017-08-03 20:29   ` Bart Van Assche
2017-08-03 20:35     ` Jens Axboe
2017-08-03 20:40       ` Jens Axboe
2017-08-03 20:50         ` Bart Van Assche
2017-08-03 20:56           ` Jens Axboe
2017-08-03 20:01 ` [PATCH 2/4] block: pass in queue to inflight accounting Jens Axboe
2017-08-03 20:35   ` Bart Van Assche
2017-08-03 20:37     ` Jens Axboe
2017-08-03 20:01 ` [PATCH 3/4] blk-mq: provide internal in-flight variant Jens Axboe
2017-08-03 20:41   ` Bart Van Assche
2017-08-03 20:45     ` Jens Axboe
2017-08-03 20:54       ` Bart Van Assche
2017-08-03 21:25   ` Bart Van Assche
2017-08-03 22:36     ` Jens Axboe
2017-08-04 11:17   ` Ming Lei
2017-08-04 13:55     ` Jens Axboe
2017-08-04 22:19       ` Ming Lei
2017-08-07 19:54         ` Brian King
2017-08-03 20:01 ` [PATCH 4/4] blk-mq: enable checking two part inflight counts at the same time Jens Axboe
2017-08-03 21:29   ` Bart Van Assche
2017-08-03 22:38     ` Jens Axboe
2017-08-03 22:30   ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox