Skip to content

Commit ff6814b

Browse files
committed
Merge tag 'for-5.5/block-20191121' of git://git.kernel.dk/linux-block
Pull core block updates from Jens Axboe: "Due to more granular branches, this one is small and will be followed with other core branches that add specific features. I meant to just have a core and drivers branch, but external dependencies we ended up adding a few more that are also core. The changes are: - Fixes and improvements for the zoned device support (Ajay, Damien) - sed-opal table writing and datastore UID (Revanth) - blk-cgroup (and bfq) blk-cgroup stat fixes (Tejun) - Improvements to the block stats tracking (Pavel) - Fix for overruning sysfs buffer for large number of CPUs (Ming) - Optimization for small IO (Ming, Christoph) - Fix typo in RWH lifetime hint (Eugene) - Dead code removal and documentation (Bart) - Reduction in memory usage for queue and tag set (Bart) - Kerneldoc header documentation (André) - Device/partition revalidation fixes (Jan) - Stats tracking for flush requests (Konstantin) - Various other little fixes here and there (et al)" * tag 'for-5.5/block-20191121' of git://git.kernel.dk/linux-block: (48 commits) Revert "block: split bio if the only bvec's length is > SZ_4K" block: add iostat counters for flush requests block,bfq: Skip tracing hooks if possible block: sed-opal: Introduce SUM_SET_LIST parameter and append it using 'add_token_u64' blk-cgroup: cgroup_rstat_updated() shouldn't be called on cgroup1 block: Don't disable interrupts in trigger_softirq() sbitmap: Delete sbitmap_any_bit_clear() blk-mq: Delete blk_mq_has_free_tags() and blk_mq_can_queue() block: split bio if the only bvec's length is > SZ_4K block: still try to split bio if the bvec crosses pages blk-cgroup: separate out blkg_rwstat under CONFIG_BLK_CGROUP_RWSTAT blk-cgroup: reimplement basic IO stats using cgroup rstat blk-cgroup: remove now unused blkg_print_stat_{bytes|ios}_recursive() blk-throtl: stop using blkg->stat_bytes and ->stat_ios bfq-iosched: stop using blkg->stat_bytes and ->stat_ios bfq-iosched: relocate bfqg_*rwstat*() helpers block: add zone open, close and finish ioctl support block: add zone open, close and finish operations block: Simplify REQ_OP_ZONE_RESET_ALL handling block: Remove REQ_OP_ZONE_RESET plugging ...
2 parents 6e7b06a + 1e27915 commit ff6814b

51 files changed

Lines changed: 1398 additions & 800 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/ABI/testing/procfs-diskstats‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@ Description:
2929
17 - sectors discarded
3030
18 - time spent discarding
3131

32+
Kernel 5.5+ appends two more fields for flush requests:
33+
34+
19 - flush requests completed successfully
35+
20 - time spent flushing
36+
3237
For more details refer to Documentation/admin-guide/iostats.rst

‎Documentation/ABI/testing/sysfs-block‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ Description:
1515
9 - I/Os currently in progress
1616
10 - time spent doing I/Os (ms)
1717
11 - weighted time spent doing I/Os (ms)
18+
12 - discards completed
19+
13 - discards merged
20+
14 - sectors discarded
21+
15 - time spent discarding (ms)
22+
16 - flush requests completed
23+
17 - time spent flushing (ms)
1824
For more details refer Documentation/admin-guide/iostats.rst
1925

2026

‎Documentation/admin-guide/iostats.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ Field 15 -- # of milliseconds spent discarding
121121
This is the total number of milliseconds spent by all discards (as
122122
measured from __make_request() to end_that_request_last()).
123123

124+
Field 16 -- # of flush requests completed
125+
This is the total number of flush requests completed successfully.
126+
127+
Block layer combines flush requests and executes at most one at a time.
128+
This counts flush requests executed by disk. Not tracked for partitions.
129+
130+
Field 17 -- # of milliseconds spent flushing
131+
This is the total number of milliseconds spent by all flush requests.
132+
124133
To avoid introducing performance bottlenecks, no locks are held while
125134
modifying these counters. This implies that minor inaccuracies may be
126135
introduced when changes collide, so (for instance) adding up all the

‎Documentation/block/stat.rst‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,23 @@ discard I/Os requests number of discard I/Os processed
4141
discard merges requests number of discard I/Os merged with in-queue I/O
4242
discard sectors sectors number of sectors discarded
4343
discard ticks milliseconds total wait time for discard requests
44+
flush I/Os requests number of flush I/Os processed
45+
flush ticks milliseconds total wait time for flush requests
4446
=============== ============= =================================================
4547

4648
read I/Os, write I/Os, discard I/0s
4749
===================================
4850

4951
These values increment when an I/O request completes.
5052

53+
flush I/Os
54+
==========
55+
56+
These values increment when an flush I/O request completes.
57+
58+
Block layer combines flush requests and executes at most one at a time.
59+
This counts flush requests executed by disk. Not tracked for partitions.
60+
5161
read merges, write merges, discard merges
5262
=========================================
5363

@@ -62,8 +72,8 @@ discarded from this block device. The "sectors" in question are the
6272
standard UNIX 512-byte sectors, not any device- or filesystem-specific
6373
block size. The counters are incremented when the I/O completes.
6474

65-
read ticks, write ticks, discard ticks
66-
======================================
75+
read ticks, write ticks, discard ticks, flush ticks
76+
===================================================
6777

6878
These values count the number of milliseconds that I/O requests have
6979
waited on this block device. If there are multiple I/O requests waiting,

‎block/Kconfig‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ config BLK_RQ_ALLOC_TIME
3232
config BLK_SCSI_REQUEST
3333
bool
3434

35+
config BLK_CGROUP_RWSTAT
36+
bool
37+
3538
config BLK_DEV_BSG
3639
bool "Block layer SG support v4"
3740
default y
@@ -86,6 +89,7 @@ config BLK_DEV_ZONED
8689
config BLK_DEV_THROTTLING
8790
bool "Block layer bio throttling support"
8891
depends on BLK_CGROUP=y
92+
select BLK_CGROUP_RWSTAT
8993
---help---
9094
Block layer bio throttling support. It can be used to limit
9195
the IO rate to a device. IO rate policies are per cgroup and

‎block/Kconfig.iosched‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ config IOSCHED_BFQ
3131
config BFQ_GROUP_IOSCHED
3232
bool "BFQ hierarchical scheduling support"
3333
depends on IOSCHED_BFQ && BLK_CGROUP
34+
select BLK_CGROUP_RWSTAT
3435
---help---
3536

3637
Enable hierarchical scheduling in BFQ, using the blkio

‎block/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ obj-$(CONFIG_BLK_SCSI_REQUEST) += scsi_ioctl.o
1616
obj-$(CONFIG_BLK_DEV_BSG) += bsg.o
1717
obj-$(CONFIG_BLK_DEV_BSGLIB) += bsg-lib.o
1818
obj-$(CONFIG_BLK_CGROUP) += blk-cgroup.o
19+
obj-$(CONFIG_BLK_CGROUP_RWSTAT) += blk-cgroup-rwstat.o
1920
obj-$(CONFIG_BLK_DEV_THROTTLING) += blk-throttle.o
2021
obj-$(CONFIG_BLK_CGROUP_IOLATENCY) += blk-iolatency.o
2122
obj-$(CONFIG_BLK_CGROUP_IOCOST) += blk-iocost.o

‎block/bfq-cgroup.c‎

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,14 @@ void bfqg_and_blkg_put(struct bfq_group *bfqg)
347347
bfqg_put(bfqg);
348348
}
349349

350+
void bfqg_stats_update_legacy_io(struct request_queue *q, struct request *rq)
351+
{
352+
struct bfq_group *bfqg = blkg_to_bfqg(rq->bio->bi_blkg);
353+
354+
blkg_rwstat_add(&bfqg->stats.bytes, rq->cmd_flags, blk_rq_bytes(rq));
355+
blkg_rwstat_add(&bfqg->stats.ios, rq->cmd_flags, 1);
356+
}
357+
350358
/* @stats = 0 */
351359
static void bfqg_stats_reset(struct bfqg_stats *stats)
352360
{
@@ -431,6 +439,8 @@ void bfq_init_entity(struct bfq_entity *entity, struct bfq_group *bfqg)
431439

432440
static void bfqg_stats_exit(struct bfqg_stats *stats)
433441
{
442+
blkg_rwstat_exit(&stats->bytes);
443+
blkg_rwstat_exit(&stats->ios);
434444
#ifdef CONFIG_BFQ_CGROUP_DEBUG
435445
blkg_rwstat_exit(&stats->merged);
436446
blkg_rwstat_exit(&stats->service_time);
@@ -448,6 +458,10 @@ static void bfqg_stats_exit(struct bfqg_stats *stats)
448458

449459
static int bfqg_stats_init(struct bfqg_stats *stats, gfp_t gfp)
450460
{
461+
if (blkg_rwstat_init(&stats->bytes, gfp) ||
462+
blkg_rwstat_init(&stats->ios, gfp))
463+
return -ENOMEM;
464+
451465
#ifdef CONFIG_BFQ_CGROUP_DEBUG
452466
if (blkg_rwstat_init(&stats->merged, gfp) ||
453467
blkg_rwstat_init(&stats->service_time, gfp) ||
@@ -1057,18 +1071,35 @@ static ssize_t bfq_io_set_weight(struct kernfs_open_file *of,
10571071
return bfq_io_set_device_weight(of, buf, nbytes, off);
10581072
}
10591073

1060-
#ifdef CONFIG_BFQ_CGROUP_DEBUG
1061-
static int bfqg_print_stat(struct seq_file *sf, void *v)
1074+
static int bfqg_print_rwstat(struct seq_file *sf, void *v)
10621075
{
1063-
blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), blkg_prfill_stat,
1064-
&blkcg_policy_bfq, seq_cft(sf)->private, false);
1076+
blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), blkg_prfill_rwstat,
1077+
&blkcg_policy_bfq, seq_cft(sf)->private, true);
10651078
return 0;
10661079
}
10671080

1068-
static int bfqg_print_rwstat(struct seq_file *sf, void *v)
1081+
static u64 bfqg_prfill_rwstat_recursive(struct seq_file *sf,
1082+
struct blkg_policy_data *pd, int off)
10691083
{
1070-
blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), blkg_prfill_rwstat,
1071-
&blkcg_policy_bfq, seq_cft(sf)->private, true);
1084+
struct blkg_rwstat_sample sum;
1085+
1086+
blkg_rwstat_recursive_sum(pd_to_blkg(pd), &blkcg_policy_bfq, off, &sum);
1087+
return __blkg_prfill_rwstat(sf, pd, &sum);
1088+
}
1089+
1090+
static int bfqg_print_rwstat_recursive(struct seq_file *sf, void *v)
1091+
{
1092+
blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)),
1093+
bfqg_prfill_rwstat_recursive, &blkcg_policy_bfq,
1094+
seq_cft(sf)->private, true);
1095+
return 0;
1096+
}
1097+
1098+
#ifdef CONFIG_BFQ_CGROUP_DEBUG
1099+
static int bfqg_print_stat(struct seq_file *sf, void *v)
1100+
{
1101+
blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), blkg_prfill_stat,
1102+
&blkcg_policy_bfq, seq_cft(sf)->private, false);
10721103
return 0;
10731104
}
10741105

@@ -1097,15 +1128,6 @@ static u64 bfqg_prfill_stat_recursive(struct seq_file *sf,
10971128
return __blkg_prfill_u64(sf, pd, sum);
10981129
}
10991130

1100-
static u64 bfqg_prfill_rwstat_recursive(struct seq_file *sf,
1101-
struct blkg_policy_data *pd, int off)
1102-
{
1103-
struct blkg_rwstat_sample sum;
1104-
1105-
blkg_rwstat_recursive_sum(pd_to_blkg(pd), &blkcg_policy_bfq, off, &sum);
1106-
return __blkg_prfill_rwstat(sf, pd, &sum);
1107-
}
1108-
11091131
static int bfqg_print_stat_recursive(struct seq_file *sf, void *v)
11101132
{
11111133
blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)),
@@ -1114,18 +1136,11 @@ static int bfqg_print_stat_recursive(struct seq_file *sf, void *v)
11141136
return 0;
11151137
}
11161138

1117-
static int bfqg_print_rwstat_recursive(struct seq_file *sf, void *v)
1118-
{
1119-
blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)),
1120-
bfqg_prfill_rwstat_recursive, &blkcg_policy_bfq,
1121-
seq_cft(sf)->private, true);
1122-
return 0;
1123-
}
1124-
11251139
static u64 bfqg_prfill_sectors(struct seq_file *sf, struct blkg_policy_data *pd,
11261140
int off)
11271141
{
1128-
u64 sum = blkg_rwstat_total(&pd->blkg->stat_bytes);
1142+
struct bfq_group *bfqg = blkg_to_bfqg(pd->blkg);
1143+
u64 sum = blkg_rwstat_total(&bfqg->stats.bytes);
11291144

11301145
return __blkg_prfill_u64(sf, pd, sum >> 9);
11311146
}
@@ -1142,8 +1157,8 @@ static u64 bfqg_prfill_sectors_recursive(struct seq_file *sf,
11421157
{
11431158
struct blkg_rwstat_sample tmp;
11441159

1145-
blkg_rwstat_recursive_sum(pd->blkg, NULL,
1146-
offsetof(struct blkcg_gq, stat_bytes), &tmp);
1160+
blkg_rwstat_recursive_sum(pd->blkg, &blkcg_policy_bfq,
1161+
offsetof(struct bfq_group, stats.bytes), &tmp);
11471162

11481163
return __blkg_prfill_u64(sf, pd,
11491164
(tmp.cnt[BLKG_RWSTAT_READ] + tmp.cnt[BLKG_RWSTAT_WRITE]) >> 9);
@@ -1226,13 +1241,13 @@ struct cftype bfq_blkcg_legacy_files[] = {
12261241
/* statistics, covers only the tasks in the bfqg */
12271242
{
12281243
.name = "bfq.io_service_bytes",
1229-
.private = (unsigned long)&blkcg_policy_bfq,
1230-
.seq_show = blkg_print_stat_bytes,
1244+
.private = offsetof(struct bfq_group, stats.bytes),
1245+
.seq_show = bfqg_print_rwstat,
12311246
},
12321247
{
12331248
.name = "bfq.io_serviced",
1234-
.private = (unsigned long)&blkcg_policy_bfq,
1235-
.seq_show = blkg_print_stat_ios,
1249+
.private = offsetof(struct bfq_group, stats.ios),
1250+
.seq_show = bfqg_print_rwstat,
12361251
},
12371252
#ifdef CONFIG_BFQ_CGROUP_DEBUG
12381253
{
@@ -1269,13 +1284,13 @@ struct cftype bfq_blkcg_legacy_files[] = {
12691284
/* the same statistics which cover the bfqg and its descendants */
12701285
{
12711286
.name = "bfq.io_service_bytes_recursive",
1272-
.private = (unsigned long)&blkcg_policy_bfq,
1273-
.seq_show = blkg_print_stat_bytes_recursive,
1287+
.private = offsetof(struct bfq_group, stats.bytes),
1288+
.seq_show = bfqg_print_rwstat_recursive,
12741289
},
12751290
{
12761291
.name = "bfq.io_serviced_recursive",
1277-
.private = (unsigned long)&blkcg_policy_bfq,
1278-
.seq_show = blkg_print_stat_ios_recursive,
1292+
.private = offsetof(struct bfq_group, stats.ios),
1293+
.seq_show = bfqg_print_rwstat_recursive,
12791294
},
12801295
#ifdef CONFIG_BFQ_CGROUP_DEBUG
12811296
{

‎block/bfq-iosched.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5484,6 +5484,10 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
54845484
bool idle_timer_disabled = false;
54855485
unsigned int cmd_flags;
54865486

5487+
#ifdef CONFIG_BFQ_GROUP_IOSCHED
5488+
if (!cgroup_subsys_on_dfl(io_cgrp_subsys) && rq->bio)
5489+
bfqg_stats_update_legacy_io(q, rq);
5490+
#endif
54875491
spin_lock_irq(&bfqd->lock);
54885492
if (blk_mq_sched_try_insert_merge(q, rq)) {
54895493
spin_unlock_irq(&bfqd->lock);

‎block/bfq-iosched.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <linux/hrtimer.h>
1111
#include <linux/blk-cgroup.h>
1212

13+
#include "blk-cgroup-rwstat.h"
14+
1315
#define BFQ_IOPRIO_CLASSES 3
1416
#define BFQ_CL_IDLE_TIMEOUT (HZ/5)
1517

@@ -809,6 +811,9 @@ struct bfq_stat {
809811
};
810812

811813
struct bfqg_stats {
814+
/* basic stats */
815+
struct blkg_rwstat bytes;
816+
struct blkg_rwstat ios;
812817
#ifdef CONFIG_BFQ_CGROUP_DEBUG
813818
/* number of ios merged */
814819
struct blkg_rwstat merged;
@@ -956,6 +961,7 @@ void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg);
956961

957962
/* ---------------- cgroups-support interface ---------------- */
958963

964+
void bfqg_stats_update_legacy_io(struct request_queue *q, struct request *rq);
959965
void bfqg_stats_update_io_add(struct bfq_group *bfqg, struct bfq_queue *bfqq,
960966
unsigned int op);
961967
void bfqg_stats_update_io_remove(struct bfq_group *bfqg, unsigned int op);
@@ -1062,6 +1068,8 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq);
10621068

10631069
#define bfq_log_bfqq(bfqd, bfqq, fmt, args...) do { \
10641070
char pid_str[MAX_PID_STR_LENGTH]; \
1071+
if (likely(!blk_trace_note_message_enabled((bfqd)->queue))) \
1072+
break; \
10651073
bfq_pid_to_str((bfqq)->pid, pid_str, MAX_PID_STR_LENGTH); \
10661074
blk_add_cgroup_trace_msg((bfqd)->queue, \
10671075
bfqg_to_blkg(bfqq_group(bfqq))->blkcg, \
@@ -1078,6 +1086,8 @@ struct bfq_group *bfqq_group(struct bfq_queue *bfqq);
10781086

10791087
#define bfq_log_bfqq(bfqd, bfqq, fmt, args...) do { \
10801088
char pid_str[MAX_PID_STR_LENGTH]; \
1089+
if (likely(!blk_trace_note_message_enabled((bfqd)->queue))) \
1090+
break; \
10811091
bfq_pid_to_str((bfqq)->pid, pid_str, MAX_PID_STR_LENGTH); \
10821092
blk_add_trace_msg((bfqd)->queue, "bfq%s%c " fmt, pid_str, \
10831093
bfq_bfqq_sync((bfqq)) ? 'S' : 'A', \

0 commit comments

Comments
 (0)