There is not any wbt functions that need to be external, cleanup the blk-wbt.h Signed-off-by: Wang Jianchao (Kuaishou) <jianchao.wan9@xxxxxxxxx> --- block/blk-iocost.c | 1 - block/blk-mq-sched.c | 1 - block/blk-wbt.c | 64 ++++++++++++++++++++++++++++- block/blk-wbt.h | 83 -------------------------------------- include/trace/events/wbt.h | 3 +- 5 files changed, 65 insertions(+), 87 deletions(-) delete mode 100644 block/blk-wbt.h diff --git a/block/blk-iocost.c b/block/blk-iocost.c index ad1d4d9762bd..c7142b60bb1a 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -183,7 +183,6 @@ #include <asm/local64.h> #include "blk-rq-qos.h" #include "blk-stat.h" -#include "blk-wbt.h" #ifdef CONFIG_TRACEPOINTS diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index 55488ba97823..25f65a5d5bb7 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -16,7 +16,6 @@ #include "blk-mq-debugfs.h" #include "blk-mq-sched.h" #include "blk-mq-tag.h" -#include "blk-wbt.h" /* * Mark a hardware queue as needing a restart. For shared queues, maintain diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 83e05417e25f..33072118929f 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -27,14 +27,76 @@ #include <linux/sysfs.h> #include "blk.h" -#include "blk-wbt.h" +#include "blk-stat.h" #include "blk-rq-qos.h" #define CREATE_TRACE_POINTS #include <trace/events/wbt.h> +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 = 4, /* number of bits */ +}; + +enum { + WBT_RWQ_BG = 0, + WBT_RWQ_KSWAPD, + WBT_RWQ_DISCARD, + WBT_NUM_RWQ, +}; + +struct rq_wb { + /* + * Settings that govern how we throttle + */ + unsigned int wb_background; /* background writeback */ + unsigned int wb_normal; /* normal writeback */ + + /* + * Number of consecutive periods where we don't have enough + * information to make a firm scale up/down decision. + */ + unsigned int unknown_cnt; + + u64 win_nsec; /* default window size */ + u64 cur_win_nsec; /* current window size */ + + struct blk_stat_callback *cb; + + u64 sync_issue; + void *sync_cookie; + + unsigned int wc; + + unsigned long last_issue; /* last non-throttled issue */ + unsigned long last_comp; /* last non-throttled comp */ + unsigned long min_lat_nsec; + struct rq_qos rqos; + struct rq_wait rq_wait[WBT_NUM_RWQ]; + struct rq_depth rq_depth; +}; + static struct rq_qos_ops wbt_rqos_ops; +static inline struct rq_wb *RQWB(struct rq_qos *rqos) +{ + return container_of(rqos, struct rq_wb, rqos); +} + +static inline unsigned int wbt_inflight(struct rq_wb *rwb) +{ + unsigned int i, ret = 0; + + for (i = 0; i < WBT_NUM_RWQ; i++) + ret += atomic_read(&rwb->rq_wait[i].inflight); + + return ret; +} + static inline struct rq_qos *wbt_rq_qos(struct request_queue *q) { return rq_qos_get(q, wbt_rqos_ops.id); diff --git a/block/blk-wbt.h b/block/blk-wbt.h deleted file mode 100644 index eb837dfd0ace..000000000000 --- a/block/blk-wbt.h +++ /dev/null @@ -1,83 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef WB_THROTTLE_H -#define WB_THROTTLE_H - -#include <linux/kernel.h> -#include <linux/atomic.h> -#include <linux/wait.h> -#include <linux/timer.h> -#include <linux/ktime.h> - -#include "blk-stat.h" -#include "blk-rq-qos.h" - -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 = 4, /* number of bits */ -}; - -enum { - WBT_RWQ_BG = 0, - WBT_RWQ_KSWAPD, - WBT_RWQ_DISCARD, - WBT_NUM_RWQ, -}; - -struct rq_wb { - /* - * Settings that govern how we throttle - */ - unsigned int wb_background; /* background writeback */ - unsigned int wb_normal; /* normal writeback */ - - /* - * Number of consecutive periods where we don't have enough - * information to make a firm scale up/down decision. - */ - unsigned int unknown_cnt; - - u64 win_nsec; /* default window size */ - u64 cur_win_nsec; /* current window size */ - - struct blk_stat_callback *cb; - - u64 sync_issue; - void *sync_cookie; - - unsigned int wc; - - unsigned long last_issue; /* last non-throttled issue */ - unsigned long last_comp; /* last non-throttled comp */ - unsigned long min_lat_nsec; - struct rq_qos rqos; - struct rq_wait rq_wait[WBT_NUM_RWQ]; - struct rq_depth rq_depth; -}; - -static inline struct rq_wb *RQWB(struct rq_qos *rqos) -{ - return container_of(rqos, struct rq_wb, rqos); -} - -static inline unsigned int wbt_inflight(struct rq_wb *rwb) -{ - unsigned int i, ret = 0; - - for (i = 0; i < WBT_NUM_RWQ; i++) - ret += atomic_read(&rwb->rq_wait[i].inflight); - - return ret; -} - -#ifdef CONFIG_BLK_WBT -#else -static inline void wbt_track(struct request *rq, enum wbt_flags flags) -{ -} -#endif /* CONFIG_BLK_WBT */ - -#endif diff --git a/include/trace/events/wbt.h b/include/trace/events/wbt.h index 9c66e59d859c..b62e623ed067 100644 --- a/include/trace/events/wbt.h +++ b/include/trace/events/wbt.h @@ -6,7 +6,8 @@ #define _TRACE_WBT_H #include <linux/tracepoint.h> -#include "../../../block/blk-wbt.h" +#include "../../../block/blk-stat.h" +#include "../../../block/blk-rq-qos.h" /** * wbt_stat - trace stats for blk_wb -- 2.17.1