Skip to content

Commit 63a4cc2

Browse files
Mike Christieaxboe
authored andcommitted
blkg_rwstat: separate op from flags
The bio and request operation and flags are going to be separate definitions, so we cannot pass them in as a bitmap. This patch converts the blkg_rwstat code and its caller, cfq, to pass in the values separately. Signed-off-by: Mike Christie <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent ba568ea commit 63a4cc2

File tree

2 files changed

+36
-26
lines changed

2 files changed

+36
-26
lines changed

block/cfq-iosched.c

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,10 @@ static inline void cfqg_put(struct cfq_group *cfqg)
667667
} while (0)
668668

669669
static inline void cfqg_stats_update_io_add(struct cfq_group *cfqg,
670-
struct cfq_group *curr_cfqg, int rw)
670+
struct cfq_group *curr_cfqg, int op,
671+
int op_flags)
671672
{
672-
blkg_rwstat_add(&cfqg->stats.queued, rw, 1);
673+
blkg_rwstat_add(&cfqg->stats.queued, op, op_flags, 1);
673674
cfqg_stats_end_empty_time(&cfqg->stats);
674675
cfqg_stats_set_start_group_wait_time(cfqg, curr_cfqg);
675676
}
@@ -683,26 +684,30 @@ static inline void cfqg_stats_update_timeslice_used(struct cfq_group *cfqg,
683684
#endif
684685
}
685686

686-
static inline void cfqg_stats_update_io_remove(struct cfq_group *cfqg, int rw)
687+
static inline void cfqg_stats_update_io_remove(struct cfq_group *cfqg, int op,
688+
int op_flags)
687689
{
688-
blkg_rwstat_add(&cfqg->stats.queued, rw, -1);
690+
blkg_rwstat_add(&cfqg->stats.queued, op, op_flags, -1);
689691
}
690692

691-
static inline void cfqg_stats_update_io_merged(struct cfq_group *cfqg, int rw)
693+
static inline void cfqg_stats_update_io_merged(struct cfq_group *cfqg, int op,
694+
int op_flags)
692695
{
693-
blkg_rwstat_add(&cfqg->stats.merged, rw, 1);
696+
blkg_rwstat_add(&cfqg->stats.merged, op, op_flags, 1);
694697
}
695698

696699
static inline void cfqg_stats_update_completion(struct cfq_group *cfqg,
697-
uint64_t start_time, uint64_t io_start_time, int rw)
700+
uint64_t start_time, uint64_t io_start_time, int op,
701+
int op_flags)
698702
{
699703
struct cfqg_stats *stats = &cfqg->stats;
700704
unsigned long long now = sched_clock();
701705

702706
if (time_after64(now, io_start_time))
703-
blkg_rwstat_add(&stats->service_time, rw, now - io_start_time);
707+
blkg_rwstat_add(&stats->service_time, op, op_flags,
708+
now - io_start_time);
704709
if (time_after64(io_start_time, start_time))
705-
blkg_rwstat_add(&stats->wait_time, rw,
710+
blkg_rwstat_add(&stats->wait_time, op, op_flags,
706711
io_start_time - start_time);
707712
}
708713

@@ -781,13 +786,16 @@ static inline void cfqg_put(struct cfq_group *cfqg) { }
781786
#define cfq_log_cfqg(cfqd, cfqg, fmt, args...) do {} while (0)
782787

783788
static inline void cfqg_stats_update_io_add(struct cfq_group *cfqg,
784-
struct cfq_group *curr_cfqg, int rw) { }
789+
struct cfq_group *curr_cfqg, int op, int op_flags) { }
785790
static inline void cfqg_stats_update_timeslice_used(struct cfq_group *cfqg,
786791
unsigned long time, unsigned long unaccounted_time) { }
787-
static inline void cfqg_stats_update_io_remove(struct cfq_group *cfqg, int rw) { }
788-
static inline void cfqg_stats_update_io_merged(struct cfq_group *cfqg, int rw) { }
792+
static inline void cfqg_stats_update_io_remove(struct cfq_group *cfqg, int op,
793+
int op_flags) { }
794+
static inline void cfqg_stats_update_io_merged(struct cfq_group *cfqg, int op,
795+
int op_flags) { }
789796
static inline void cfqg_stats_update_completion(struct cfq_group *cfqg,
790-
uint64_t start_time, uint64_t io_start_time, int rw) { }
797+
uint64_t start_time, uint64_t io_start_time, int op,
798+
int op_flags) { }
791799

792800
#endif /* CONFIG_CFQ_GROUP_IOSCHED */
793801

@@ -2461,10 +2469,10 @@ static void cfq_reposition_rq_rb(struct cfq_queue *cfqq, struct request *rq)
24612469
{
24622470
elv_rb_del(&cfqq->sort_list, rq);
24632471
cfqq->queued[rq_is_sync(rq)]--;
2464-
cfqg_stats_update_io_remove(RQ_CFQG(rq), rq->cmd_flags);
2472+
cfqg_stats_update_io_remove(RQ_CFQG(rq), req_op(rq), rq->cmd_flags);
24652473
cfq_add_rq_rb(rq);
24662474
cfqg_stats_update_io_add(RQ_CFQG(rq), cfqq->cfqd->serving_group,
2467-
rq->cmd_flags);
2475+
req_op(rq), rq->cmd_flags);
24682476
}
24692477

24702478
static struct request *
@@ -2517,7 +2525,7 @@ static void cfq_remove_request(struct request *rq)
25172525
cfq_del_rq_rb(rq);
25182526

25192527
cfqq->cfqd->rq_queued--;
2520-
cfqg_stats_update_io_remove(RQ_CFQG(rq), rq->cmd_flags);
2528+
cfqg_stats_update_io_remove(RQ_CFQG(rq), req_op(rq), rq->cmd_flags);
25212529
if (rq->cmd_flags & REQ_PRIO) {
25222530
WARN_ON(!cfqq->prio_pending);
25232531
cfqq->prio_pending--;
@@ -2552,7 +2560,7 @@ static void cfq_merged_request(struct request_queue *q, struct request *req,
25522560
static void cfq_bio_merged(struct request_queue *q, struct request *req,
25532561
struct bio *bio)
25542562
{
2555-
cfqg_stats_update_io_merged(RQ_CFQG(req), bio->bi_rw);
2563+
cfqg_stats_update_io_merged(RQ_CFQG(req), bio_op(bio), bio->bi_rw);
25562564
}
25572565

25582566
static void
@@ -2575,7 +2583,7 @@ cfq_merged_requests(struct request_queue *q, struct request *rq,
25752583
if (cfqq->next_rq == next)
25762584
cfqq->next_rq = rq;
25772585
cfq_remove_request(next);
2578-
cfqg_stats_update_io_merged(RQ_CFQG(rq), next->cmd_flags);
2586+
cfqg_stats_update_io_merged(RQ_CFQG(rq), req_op(next), next->cmd_flags);
25792587

25802588
cfqq = RQ_CFQQ(next);
25812589
/*
@@ -4108,7 +4116,7 @@ static void cfq_insert_request(struct request_queue *q, struct request *rq)
41084116
rq->fifo_time = jiffies + cfqd->cfq_fifo_expire[rq_is_sync(rq)];
41094117
list_add_tail(&rq->queuelist, &cfqq->fifo);
41104118
cfq_add_rq_rb(rq);
4111-
cfqg_stats_update_io_add(RQ_CFQG(rq), cfqd->serving_group,
4119+
cfqg_stats_update_io_add(RQ_CFQG(rq), cfqd->serving_group, req_op(rq),
41124120
rq->cmd_flags);
41134121
cfq_rq_enqueued(cfqd, cfqq, rq);
41144122
}
@@ -4206,7 +4214,8 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
42064214
cfqq->dispatched--;
42074215
(RQ_CFQG(rq))->dispatched--;
42084216
cfqg_stats_update_completion(cfqq->cfqg, rq_start_time_ns(rq),
4209-
rq_io_start_time_ns(rq), rq->cmd_flags);
4217+
rq_io_start_time_ns(rq), req_op(rq),
4218+
rq->cmd_flags);
42104219

42114220
cfqd->rq_in_flight[cfq_cfqq_sync(cfqq)]--;
42124221

include/linux/blk-cgroup.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -590,25 +590,26 @@ static inline void blkg_rwstat_exit(struct blkg_rwstat *rwstat)
590590
/**
591591
* blkg_rwstat_add - add a value to a blkg_rwstat
592592
* @rwstat: target blkg_rwstat
593-
* @rw: mask of REQ_{WRITE|SYNC}
593+
* @op: REQ_OP
594+
* @op_flags: rq_flag_bits
594595
* @val: value to add
595596
*
596597
* Add @val to @rwstat. The counters are chosen according to @rw. The
597598
* caller is responsible for synchronizing calls to this function.
598599
*/
599600
static inline void blkg_rwstat_add(struct blkg_rwstat *rwstat,
600-
int rw, uint64_t val)
601+
int op, int op_flags, uint64_t val)
601602
{
602603
struct percpu_counter *cnt;
603604

604-
if (op_is_write(rw))
605+
if (op_is_write(op))
605606
cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_WRITE];
606607
else
607608
cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_READ];
608609

609610
__percpu_counter_add(cnt, val, BLKG_STAT_CPU_BATCH);
610611

611-
if (rw & REQ_SYNC)
612+
if (op_flags & REQ_SYNC)
612613
cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_SYNC];
613614
else
614615
cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_ASYNC];
@@ -713,9 +714,9 @@ static inline bool blkcg_bio_issue_check(struct request_queue *q,
713714

714715
if (!throtl) {
715716
blkg = blkg ?: q->root_blkg;
716-
blkg_rwstat_add(&blkg->stat_bytes, bio->bi_rw,
717+
blkg_rwstat_add(&blkg->stat_bytes, bio_op(bio), bio->bi_rw,
717718
bio->bi_iter.bi_size);
718-
blkg_rwstat_add(&blkg->stat_ios, bio->bi_rw, 1);
719+
blkg_rwstat_add(&blkg->stat_ios, bio_op(bio), bio->bi_rw, 1);
719720
}
720721

721722
rcu_read_unlock();

0 commit comments

Comments
 (0)