block/throttle: remove redundant type transition
Subsystems (2)
PATCH v4 1/2 block/throttle: remove redundant type transition
From: Robin Dong <[email protected]>
We don't need to convert tg to blkg and then convert it back in throtl_update_dispatch_stats().
--- block/blk-throttle.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
block/blk-throttle.c +3 -4
@@ -674,10 +674,9 @@ static bool tg_may_dispatch(struct throtl_data *td, struct throtl_grp *tg,return 0 ; } -static void throtl_update_dispatch_stats (struct blkcg_gq *blkg,u64 bytes, +static void throtl_update_dispatch_stats (struct throtl_grp *tg,u64 bytes,int rw) { -struct throtl_grp *tg =blkg_to_tg (blkg);struct tg_stats_cpu *stats_cpu;unsigned long flags;
@@ -708,7 +707,7 @@ static void throtl_charge_bio(struct throtl_grp *tg, struct bio *bio) tg->bytes_disp[rw] += bio->bi_size; tg->io_disp[rw]++; -throtl_update_dispatch_stats (tg_to_blkg (tg), bio->bi_size, bio->bi_rw); +throtl_update_dispatch_stats (tg, bio->bi_size, bio->bi_rw); } static void throtl_add_bio_tg(struct throtl_data *td, struct throtl_grp *tg,
@@ -1127,7 +1126,7 @@ bool blk_throtl_bio(struct request_queue *q, struct bio *bio) tg =throtl_lookup_tg (td, blkcg);if (tg) {if (tg_no_rule_group (tg, rw)) { -throtl_update_dispatch_stats (tg_to_blkg (tg), +throtl_update_dispatch_stats (tg, bio->bi_size, bio->bi_rw); goto out_unlock_rcu; }
Signature · 1 line
1.7.1
PATCH v4 2/2 block/throttle: Add IO queued information in blkio.throttle
From: Robin Dong <[email protected]>
Currently, if the IO is throttled by io-throttle, the system admin has no idea of the situation and can't report it to the real application user about that he/she has to do something.
So this patch adds a new interface named blkio.throttle.io_queued which exposes the number of bios that have been sent to blk-throttle therefore the user could calculate the difference from throttle.io_serviced to see how many IOs are currently throttled.
---
v3 <-- v2:
- Use nr-queued[] of struct throtl_grp for stats instaed of adding new blkg_rwstat.
v4 <-- v3:
- Add two new blkg_rwstat arguments to count total bios be sent in blk_throttle.
block/blk-throttle.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-)
block/blk-throttle.c +44 -0
@@ -70,6 +70,10 @@ struct throtl_grp {/* Number of queued bios on READ and WRITE lists */ unsigned int nr_queued[2 ]; +/* The stats of total number queued in blk-throtlle */ +struct blkg_rwstat io_queue_bytes; +struct blkg_rwstat io_queued; +/* bytes per second rate limits */ uint64_t bps[2 ];
@@ -267,6 +271,8 @@ static void throtl_pd_reset_stats(struct blkcg_gq *blkg)blkg_rwstat_reset (&sc->service_bytes);blkg_rwstat_reset (&sc->serviced); } +blkg_rwstat_reset (&tg->io_queued); +blkg_rwstat_reset (&tg->io_queue_bytes); } static struct throtl_grp *throtl_lookup_tg(struct throtl_data *td,
@@ -699,6 +705,12 @@ static void throtl_update_dispatch_stats(struct throtl_grp *tg, u64 bytes,local_irq_restore (flags); } +static void throtl_update_queued_stats (struct throtl_grp *tg,u64 bytes,int rw) +{ +blkg_rwstat_add (&tg->io_queued, rw,1 ); +blkg_rwstat_add (&tg->io_queue_bytes, rw, bytes); +} +static void throtl_charge_bio (struct throtl_grp *tg,struct bio *bio) {bool rw =bio_data_dir (bio);
@@ -952,6 +964,15 @@ static u64 tg_prfill_cpu_rwstat(struct seq_file *sf,return __blkg_prfill_rwstat (sf, pd, &rwstat); } +static u64 tg_prfill_io_queued (struct seq_file *sf, +struct blkg_policy_data *pd,int off) +{ +struct throtl_grp *tg =pd_to_tg (pd); +struct blkg_rwstat *rwstat = (void *)tg + off; + +return __blkg_prfill_rwstat (sf, pd, rwstat); +} +static int tg_print_cpu_rwstat (struct cgroup *cgrp,struct cftype *cft,struct seq_file *sf) {
@@ -962,6 +983,16 @@ static int tg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft,return 0 ; } +static int tg_print_io_queued (struct cgroup *cgrp,struct cftype *cft, +struct seq_file *sf) +{ +struct blkcg *blkcg =cgroup_to_blkcg (cgrp); + +blkcg_print_blkgs (sf, blkcg, tg_prfill_io_queued, &blkcg_policy_throtl, + cft->private, true); +return 0 ; +} +static u64 tg_prfill_conf_u64 (struct seq_file *sf,struct blkg_policy_data *pd,int off) {
@@ -1084,6 +1115,16 @@ static struct cftype throtl_files[] = { .private = offsetof(struct tg_stats_cpu, serviced), .read_seq_string = tg_print_cpu_rwstat, }, + { + .name = "throttle.io_queue_bytes", + .private = offsetof(struct throtl_grp, io_queue_bytes), + .read_seq_string = tg_print_io_queued, + }, + { + .name = "throttle.io_queued", + .private = offsetof(struct throtl_grp, io_queued), + .read_seq_string = tg_print_io_queued, + }, { }/* terminate */ };
@@ -1128,6 +1169,8 @@ bool blk_throtl_bio(struct request_queue *q, struct bio *bio)if (tg_no_rule_group (tg, rw)) {throtl_update_dispatch_stats (tg, bio->bi_size, bio->bi_rw); +throtl_update_queued_stats (tg, + bio->bi_size, bio->bi_rw); goto out_unlock_rcu; } }
@@ -1141,6 +1184,7 @@ bool blk_throtl_bio(struct request_queue *q, struct bio *bio)if (unlikely (!tg)) goto out_unlock; +throtl_update_queued_stats (tg, bio->bi_size, bio->bi_rw);if (tg->nr_queued[rw]) {/* * There is already another bio queued in same dir. No
Signature · 1 line
1.7.1