From 8bea60901974ad44b06b08d52e1dd421ea8c6e9c Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 7 May 2018 09:57:08 -0600 Subject: blk-wbt: pass in enum wbt_flags to get_rq_wait() This is in preparation for having more write queues, in which case we would have needed to pass in more information than just a simple 'is_kswapd' boolean. Reviewed-by: Darrick J. Wong Reviewed-by: Omar Sandoval Signed-off-by: Jens Axboe --- block/blk-wbt.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'block/blk-wbt.h') diff --git a/block/blk-wbt.h b/block/blk-wbt.h index a232c98..8038b4a 100644 --- a/block/blk-wbt.h +++ b/block/blk-wbt.h @@ -19,7 +19,9 @@ enum wbt_flags { }; enum { - WBT_NUM_RWQ = 2, + WBT_RWQ_BG = 0, + WBT_RWQ_KSWAPD, + WBT_NUM_RWQ, }; /* -- cgit v1.1 From 782f569774d7000e54ae9d680b0e4cd29b1c7ca3 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 7 May 2018 10:03:23 -0600 Subject: blk-wbt: throttle discards like background writes Throttle discards like we would any background write. Discards should be background activity, so if they are impacting foreground IO, then we will throttle them down. Reviewed-by: Darrick J. Wong Reviewed-by: Omar Sandoval Signed-off-by: Jens Axboe --- block/blk-wbt.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'block/blk-wbt.h') diff --git a/block/blk-wbt.h b/block/blk-wbt.h index 8038b4a..d6a125e 100644 --- a/block/blk-wbt.h +++ b/block/blk-wbt.h @@ -14,13 +14,15 @@ enum wbt_flags { WBT_TRACKED = 1, /* write, tracked for throttling */ WBT_READ = 2, /* read */ WBT_KSWAPD = 4, /* write, from kswapd */ + WBT_DISCARD = 8, /* discard */ - WBT_NR_BITS = 3, /* number of bits */ + WBT_NR_BITS = 4, /* number of bits */ }; enum { WBT_RWQ_BG = 0, WBT_RWQ_KSWAPD, + WBT_RWQ_DISCARD, WBT_NUM_RWQ, }; -- cgit v1.1 From 934031a12980511c020acf7d91f9035e34d0b5b8 Mon Sep 17 00:00:00 2001 From: Omar Sandoval Date: Wed, 9 May 2018 02:08:47 -0700 Subject: block: move some wbt helpers to blk-wbt.c A few helpers are only used from blk-wbt.c, so move them there, and put wbt_track() behind the CONFIG_BLK_WBT typedef. This is in preparation for changing how the wbt flags are tracked. Signed-off-by: Omar Sandoval Signed-off-by: Jens Axboe --- block/blk-wbt.h | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'block/blk-wbt.h') diff --git a/block/blk-wbt.h b/block/blk-wbt.h index d6a125e..5bdae20 100644 --- a/block/blk-wbt.h +++ b/block/blk-wbt.h @@ -35,31 +35,6 @@ enum { WBT_STATE_ON_MANUAL = 2, }; -static inline void wbt_clear_state(struct blk_issue_stat *stat) -{ - stat->stat &= ~BLK_STAT_RES_MASK; -} - -static inline enum wbt_flags wbt_stat_to_mask(struct blk_issue_stat *stat) -{ - return (stat->stat & BLK_STAT_RES_MASK) >> BLK_STAT_RES_SHIFT; -} - -static inline void wbt_track(struct blk_issue_stat *stat, enum wbt_flags wb_acct) -{ - stat->stat |= ((u64) wb_acct) << BLK_STAT_RES_SHIFT; -} - -static inline bool wbt_is_tracked(struct blk_issue_stat *stat) -{ - return (stat->stat >> BLK_STAT_RES_SHIFT) & WBT_TRACKED; -} - -static inline bool wbt_is_read(struct blk_issue_stat *stat) -{ - return (stat->stat >> BLK_STAT_RES_SHIFT) & WBT_READ; -} - struct rq_wait { wait_queue_head_t wait; atomic_t inflight; @@ -113,6 +88,11 @@ static inline unsigned int wbt_inflight(struct rq_wb *rwb) #ifdef CONFIG_BLK_WBT +static inline void wbt_track(struct blk_issue_stat *stat, enum wbt_flags flags) +{ + stat->stat |= ((u64)flags) << BLK_STAT_RES_SHIFT; +} + void __wbt_done(struct rq_wb *, enum wbt_flags); void wbt_done(struct rq_wb *, struct blk_issue_stat *); enum wbt_flags wbt_wait(struct rq_wb *, struct bio *, spinlock_t *); @@ -131,6 +111,9 @@ u64 wbt_default_latency_nsec(struct request_queue *); #else +static inline void wbt_track(struct blk_issue_stat *stat, enum wbt_flags flags) +{ +} static inline void __wbt_done(struct rq_wb *rwb, enum wbt_flags flags) { } -- cgit v1.1 From a8a45941706bca05ef9234a17f5e4a50b9835a44 Mon Sep 17 00:00:00 2001 From: Omar Sandoval Date: Wed, 9 May 2018 02:08:48 -0700 Subject: block: pass struct request instead of struct blk_issue_stat to wbt issue_stat is going to go away, so first make writeback throttling take the containing request, update the internal wbt helpers accordingly, and change rwb->sync_cookie to be the request pointer instead of the issue_stat pointer. No functional change. Signed-off-by: Omar Sandoval Signed-off-by: Jens Axboe --- block/blk-wbt.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'block/blk-wbt.h') diff --git a/block/blk-wbt.h b/block/blk-wbt.h index 5bdae20..85fbccc 100644 --- a/block/blk-wbt.h +++ b/block/blk-wbt.h @@ -88,19 +88,19 @@ static inline unsigned int wbt_inflight(struct rq_wb *rwb) #ifdef CONFIG_BLK_WBT -static inline void wbt_track(struct blk_issue_stat *stat, enum wbt_flags flags) +static inline void wbt_track(struct request *rq, enum wbt_flags flags) { - stat->stat |= ((u64)flags) << BLK_STAT_RES_SHIFT; + rq->issue_stat.stat |= ((u64)flags) << BLK_STAT_RES_SHIFT; } void __wbt_done(struct rq_wb *, enum wbt_flags); -void wbt_done(struct rq_wb *, struct blk_issue_stat *); +void wbt_done(struct rq_wb *, struct request *); enum wbt_flags wbt_wait(struct rq_wb *, struct bio *, spinlock_t *); int wbt_init(struct request_queue *); void wbt_exit(struct request_queue *); void wbt_update_limits(struct rq_wb *); -void wbt_requeue(struct rq_wb *, struct blk_issue_stat *); -void wbt_issue(struct rq_wb *, struct blk_issue_stat *); +void wbt_requeue(struct rq_wb *, struct request *); +void wbt_issue(struct rq_wb *, struct request *); void wbt_disable_default(struct request_queue *); void wbt_enable_default(struct request_queue *); @@ -111,13 +111,13 @@ u64 wbt_default_latency_nsec(struct request_queue *); #else -static inline void wbt_track(struct blk_issue_stat *stat, enum wbt_flags flags) +static inline void wbt_track(struct request *rq, enum wbt_flags flags) { } static inline void __wbt_done(struct rq_wb *rwb, enum wbt_flags flags) { } -static inline void wbt_done(struct rq_wb *rwb, struct blk_issue_stat *stat) +static inline void wbt_done(struct rq_wb *rwb, struct request *rq) { } static inline enum wbt_flags wbt_wait(struct rq_wb *rwb, struct bio *bio, @@ -135,10 +135,10 @@ static inline void wbt_exit(struct request_queue *q) static inline void wbt_update_limits(struct rq_wb *rwb) { } -static inline void wbt_requeue(struct rq_wb *rwb, struct blk_issue_stat *stat) +static inline void wbt_requeue(struct rq_wb *rwb, struct request *rq) { } -static inline void wbt_issue(struct rq_wb *rwb, struct blk_issue_stat *stat) +static inline void wbt_issue(struct rq_wb *rwb, struct request *rq) { } static inline void wbt_disable_default(struct request_queue *q) -- cgit v1.1 From 544ccc8dc904db55d4576c27a1eb66a888ffacea Mon Sep 17 00:00:00 2001 From: Omar Sandoval Date: Wed, 9 May 2018 02:08:50 -0700 Subject: block: get rid of struct blk_issue_stat struct blk_issue_stat squashes three things into one u64: - The time the driver started working on a request - The original size of the request (for the io.low controller) - Flags for writeback throttling It turns out that on x86_64, we have a 4 byte hole in struct request which we can fill with the non-timestamp fields from blk_issue_stat, simplifying things quite a bit. Signed-off-by: Omar Sandoval Signed-off-by: Jens Axboe --- block/blk-wbt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'block/blk-wbt.h') diff --git a/block/blk-wbt.h b/block/blk-wbt.h index 85fbccc..300df53 100644 --- a/block/blk-wbt.h +++ b/block/blk-wbt.h @@ -63,7 +63,7 @@ struct rq_wb { struct blk_stat_callback *cb; - s64 sync_issue; + u64 sync_issue; void *sync_cookie; unsigned int wc; @@ -90,7 +90,7 @@ static inline unsigned int wbt_inflight(struct rq_wb *rwb) static inline void wbt_track(struct request *rq, enum wbt_flags flags) { - rq->issue_stat.stat |= ((u64)flags) << BLK_STAT_RES_SHIFT; + rq->wbt_flags |= flags; } void __wbt_done(struct rq_wb *, enum wbt_flags); -- cgit v1.1