Introduce block I/O performance histograms
Subsystems (2)
PATCH 1/1 Introduce block I/O performance histograms
This patch introduces performance histogram record keeping for block I/O, used for performance tuning. It is turned off by default.
When turned on, you simply do something like:
# cat /sys/block/sda/read_request_histo
rows = bytes columns = ms
10 20 50 100 200 500 1000 2000
2048 5 0 0 0 0 0 0 0
4096 0 0 0 0 0 0 0 0
8192 17231 135 41 10 0 0 0 0
16384 4400 24 6 2 0 0 0 0
32768 2897 34 4 4 0 0 0 0
65536 7089 87 5 1 2 0 0 0
#block/Kconfig +25 -0
@@ -24,6 +24,31 @@ config BLK_DEV_IO_TRACE git://brick.kernel.dk/data/git/blktrace.git +config BLOCK_HISTOGRAM + bool "Performance histogram data" + help + This option causes block devices to collect statistics on transfer + sizes and times. Useful for performance-tuning a system. Creates + entries in /sys/block/. Increases kernel size about 21k. + + If you are unsure, say N here. + +config HISTO_SIZE_BUCKETS + int "Number of size buckets in histogram" + depends on BLOCK_HISTOGRAM + default "6" + help + This option controls how many buckets are used to collect + transfer size statistics. + +config HISTO_TIME_BUCKETS + int "Number of time buckets in histogram" + depends on BLOCK_HISTOGRAM + default "8" + help + This option controls how many buckets are used to collect + transfer time statistics. + config LSF bool "Support for Large Single Files" depends on X86 || (MIPS && 32BIT) || PPC32 || ARCH_S390_31 || SUPERH || UML
block/genhd.c +317 -0
338 lines not on this page · raw message
block/ll_rw_blk.c +1 -0
@@ -3469,6 +3469,7 @@ void end_that_request_last(struct reques__disk_stat_add (disk, ticks[rw], duration);disk_round_stats (disk); disk->in_flight--; +block_histogram_req_cmplt (disk, req); }if (req->end_io) req->end_io (req, error);
drivers/scsi/scsi_lib.c +1 -0
@@ -1477,6 +1477,7 @@ static void scsi_request_fn(struct reque/* * Dispatch the command to the low-level driver. */ +block_histogram_start_time (req); rtn =scsi_dispatch_cmd (cmd);spin_lock_irq (q->queue_lock);if (rtn) {
include/linux/blkdev.h +12 -1
@@ -154,7 +154,10 @@ struct request {int rq_status;/* should split this into a few status bits */ int errors;struct gendisk *rq_disk; -unsigned long start_time; +unsigned long start_time;/* when request submitted */ +#ifdef CONFIG_BLOCK_HISTOGRAM +unsigned long io_start_time;/* when passed to hardware */ +#endif /* Number of scatter-gather DMA addr+len pairs after * physical address coalescing is performed.
@@ -840,5 +843,13 @@ void kblockd_flush(void);#define MODULE_ALIAS_BLOCKDEV_MAJOR (major) \ MODULE_ALIAS("block-major-" __stringify(major) "-*") +#ifdef CONFIG_BLOCK_HISTOGRAM +inline static void block_histogram_start_time (struct request *req) +{ + req->io_start_time = jiffies; +} +#else +#define block_histogram_start_time (req) +#endif #endif
include/linux/genhd.h +27 -0
@@ -11,6 +11,8 @@#include <linux/types.h> +struct request ; +enum {/* These three have identical behaviour; use the second one if DOS FDISK gets confused about extended/logical partitions starting past cylinder 1023. */
@@ -89,6 +91,10 @@ struct hd_struct {#define GENHD_FL_UP 16#define GENHD_FL_SUPPRESS_PARTITION_INFO 32 +#define BASE_HISTO_SIZE 4/* smallest transfer size, sectors */ +#define BASE_HISTO_TIME 10/* shortest transfer time, ms */ + +struct disk_stats {unsigned long sectors[2 ];/* READs and WRITEs */ unsigned long ios[2 ];
@@ -96,6 +102,12 @@ struct disk_stats {unsigned long ticks[2 ];unsigned long io_ticks;unsigned long time_in_queue; +#ifdef CONFIG_BLOCK_HISTOGRAM +int read_req_histo[CONFIG_HISTO_SIZE_BUCKETS ][CONFIG_HISTO_TIME_BUCKETS ]; +int read_dma_histo[CONFIG_HISTO_SIZE_BUCKETS ][CONFIG_HISTO_TIME_BUCKETS ]; +int write_req_histo[CONFIG_HISTO_SIZE_BUCKETS ][CONFIG_HISTO_TIME_BUCKETS ]; +int write_dma_histo[CONFIG_HISTO_SIZE_BUCKETS ][CONFIG_HISTO_TIME_BUCKETS ]; +#endif };struct gendisk {
@@ -230,6 +242,21 @@ extern struct gendisk *get_gendisk(dev_textern void set_device_ro (struct block_device *bdev,int flag);extern void set_disk_ro (struct gendisk *disk,int flag); +#ifdef CONFIG_BLOCK_HISTOGRAM +extern void block_histogram_init (struct gendisk *disk); +extern void block_histogram_completion (struct gendisk *disk, +unsigned long flags, +int sectors, +int jiffies, +int jiffies_dma); +extern void block_histogram_req_cmplt (struct gendisk *disk,struct request *); +#else +#define block_histogram_init (disk) +#define block_histogram_completion (disk, flags, sectors, jiffies, jiffies_dma) +#define block_histogram_req_cmplt (disk, req) +#endif + +/* drivers/char/random.c */ extern void add_disk_randomness (struct gendisk *disk);extern void rand_initialize_disk (struct gendisk *disk);
Quoted 5 lines · Edward Falk
This patch introduces performance histogram record keeping for block I/O, used for performance tuning. It is turned off by default.
When turned on, you simply do something like:
Quoted 9 lines
# cat /sys/block/sda/read_request_histo
rows = bytes columns = ms
10 20 50 100 200 500 1000 2000
2048 5 0 0 0 0 0 0 0
4096 0 0 0 0 0 0 0 0
8192 17231 135 41 10 0 0 0 0
16384 4400 24 6 2 0 0 0 0
32768 2897 34 4 4 0 0 0 0
65536 7089 87 5 1 2 0 0 0I don't see the point at all for including this piece of code in the kernel. You can do the same from user space. Your help entry said it even grows the kernel size about 21k, that's pretty nasty.
So NAK.
Signature · 1 line
Jens Axboe
Quoted 3 lines · Jens Axboe
I don't see the point at all for including this piece of code in the kernel. You can do the same from user space. Your help entry said it even grows the kernel size about 21k, that's pretty nasty.
How would you do this from user space? Also, the 21k increase is only in effect if the feature is turned on in the config, and it's off by default.
-ed falk
Quoted 9 lines · Edward Falk
Quoted 3 lines · Jens Axboe
I don't see the point at all for including this piece of code in the kernel. You can do the same from user space. Your help entry said it even grows the kernel size about 21k, that's pretty nasty.
How would you do this from user space? Also, the 21k increase is only in effect if the feature is turned on in the config, and it's off by default.
You can use blktrace to do it. I realize that the 21k is only if it's turned out, it's still quite a huge big (why does it turn out so big?). The source is always there to maintain, though. The main point is that you don't have to do this in the kernel, though.
Signature · 1 line
Jens Axboe
Quoted 5 lines · Edward Falk
This patch introduces performance histogram record keeping for block I/O, used for performance tuning. It is turned off by default.
When turned on, you simply do something like:
Quoted 9 lines
# cat /sys/block/sda/read_request_histo
rows = bytes columns = ms
10 20 50 100 200 500 1000 2000
2048 5 0 0 0 0 0 0 0
4096 0 0 0 0 0 0 0 0
8192 17231 135 41 10 0 0 0 0
16384 4400 24 6 2 0 0 0 0
32768 2897 34 4 4 0 0 0 0
65536 7089 87 5 1 2 0 0 0Eeek, no, sysfs is for ONE VALUE PER FILE please.
Yes, I know there are some other sysfs files that do not follow this rule, and we are working on fixing some of them, but please, don't add new ones that do violate this rule.
thanks,
greg k-h