blob: a2050a0a5314bba690cfe6b1f6526e285c892f0d [file] [log] [blame]
Jens Axboecf43e6b2016-11-07 21:32:37 -07001#ifndef BLK_STAT_H
2#define BLK_STAT_H
3
4/*
5 * ~0.13s window as a power-of-2 (2^27 nsecs)
6 */
7#define BLK_STAT_NSEC 134217728ULL
8#define BLK_STAT_NSEC_MASK ~(BLK_STAT_NSEC - 1)
9
10/*
11 * Upper 3 bits can be used elsewhere
12 */
13#define BLK_STAT_RES_BITS 3
14#define BLK_STAT_SHIFT (64 - BLK_STAT_RES_BITS)
15#define BLK_STAT_TIME_MASK ((1ULL << BLK_STAT_SHIFT) - 1)
16#define BLK_STAT_MASK ~BLK_STAT_TIME_MASK
17
18enum {
19 BLK_STAT_READ = 0,
20 BLK_STAT_WRITE,
21};
22
23void blk_stat_add(struct blk_rq_stat *, struct request *);
24void blk_hctx_stat_get(struct blk_mq_hw_ctx *, struct blk_rq_stat *);
25void blk_queue_stat_get(struct request_queue *, struct blk_rq_stat *);
26void blk_stat_clear(struct request_queue *);
27void blk_stat_init(struct blk_rq_stat *);
28bool blk_stat_is_current(struct blk_rq_stat *);
29void blk_stat_set_issue_time(struct blk_issue_stat *);
30bool blk_stat_enable(struct request_queue *);
31
32static inline u64 __blk_stat_time(u64 time)
33{
34 return time & BLK_STAT_TIME_MASK;
35}
36
37static inline u64 blk_stat_time(struct blk_issue_stat *stat)
38{
39 return __blk_stat_time(stat->time);
40}
41
42#endif