2019-04-30 18:42:43 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
/*
|
|
|
|
* buffered writeback throttling. loosely based on CoDel. We can't drop
|
|
|
|
* packets for IO scheduling, so the logic is something like this:
|
|
|
|
*
|
|
|
|
* - Monitor latencies in a defined window of time.
|
|
|
|
* - If the minimum latency in the above window exceeds some target, increment
|
|
|
|
* scaling step and scale down queue depth by a factor of 2x. The monitoring
|
|
|
|
* window is then shrunk to 100 / sqrt(scaling step + 1).
|
|
|
|
* - For any window where we don't have solid data on what the latencies
|
|
|
|
* look like, retain status quo.
|
|
|
|
* - If latencies look good, decrement scaling step.
|
|
|
|
* - If we're only doing writes, allow the scaling step to go negative. This
|
|
|
|
* will temporarily boost write performance, snapping back to a stable
|
|
|
|
* scaling step of 0 if reads show up or the heavy writers finish. Unlike
|
|
|
|
* positive scaling steps where we shrink the monitoring window, a negative
|
|
|
|
* scaling step retains the default step==0 window size.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Jens Axboe
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/blk_types.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/backing-dev.h>
|
|
|
|
#include <linux/swap.h>
|
|
|
|
|
2023-02-03 15:03:51 +00:00
|
|
|
#include "blk-stat.h"
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
#include "blk-wbt.h"
|
2018-07-03 15:32:35 +00:00
|
|
|
#include "blk-rq-qos.h"
|
2022-10-19 12:15:18 +00:00
|
|
|
#include "elevator.h"
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
|
|
|
#define CREATE_TRACE_POINTS
|
|
|
|
#include <trace/events/wbt.h>
|
|
|
|
|
2023-02-03 15:03:51 +00:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If current state is WBT_STATE_ON/OFF_DEFAULT, it can be covered to any other
|
|
|
|
* state, if current state is WBT_STATE_ON/OFF_MANUAL, it can only be covered
|
|
|
|
* to WBT_STATE_OFF/ON_MANUAL.
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
WBT_STATE_ON_DEFAULT = 1, /* on by default */
|
|
|
|
WBT_STATE_ON_MANUAL = 2, /* on manually by sysfs */
|
|
|
|
WBT_STATE_OFF_DEFAULT = 3, /* off by default */
|
|
|
|
WBT_STATE_OFF_MANUAL = 4, /* off manually by sysfs */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rq_wb {
|
|
|
|
/*
|
|
|
|
* Settings that govern how we throttle
|
|
|
|
*/
|
|
|
|
unsigned int wb_background; /* background writeback */
|
|
|
|
unsigned int wb_normal; /* normal writeback */
|
|
|
|
|
|
|
|
short enable_state; /* WBT_STATE_* */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
2018-05-09 09:08:48 +00:00
|
|
|
static inline void wbt_clear_state(struct request *rq)
|
2018-05-09 09:08:47 +00:00
|
|
|
{
|
2018-05-09 09:08:50 +00:00
|
|
|
rq->wbt_flags = 0;
|
2018-05-09 09:08:47 +00:00
|
|
|
}
|
|
|
|
|
2018-05-09 09:08:48 +00:00
|
|
|
static inline enum wbt_flags wbt_flags(struct request *rq)
|
2018-05-09 09:08:47 +00:00
|
|
|
{
|
2018-05-09 09:08:50 +00:00
|
|
|
return rq->wbt_flags;
|
2018-05-09 09:08:47 +00:00
|
|
|
}
|
|
|
|
|
2018-05-09 09:08:48 +00:00
|
|
|
static inline bool wbt_is_tracked(struct request *rq)
|
2018-05-09 09:08:47 +00:00
|
|
|
{
|
2018-05-09 09:08:50 +00:00
|
|
|
return rq->wbt_flags & WBT_TRACKED;
|
2018-05-09 09:08:47 +00:00
|
|
|
}
|
|
|
|
|
2018-05-09 09:08:48 +00:00
|
|
|
static inline bool wbt_is_read(struct request *rq)
|
2018-05-09 09:08:47 +00:00
|
|
|
{
|
2018-05-09 09:08:50 +00:00
|
|
|
return rq->wbt_flags & WBT_READ;
|
2018-05-09 09:08:47 +00:00
|
|
|
}
|
|
|
|
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
enum {
|
|
|
|
/*
|
|
|
|
* Default setting, we'll scale up (to 75% of QD max) or down (min 1)
|
|
|
|
* from here depending on device stats
|
|
|
|
*/
|
|
|
|
RWB_DEF_DEPTH = 16,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 100msec window
|
|
|
|
*/
|
|
|
|
RWB_WINDOW_NSEC = 100 * 1000 * 1000ULL,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disregard stats, if we don't meet this minimum
|
|
|
|
*/
|
|
|
|
RWB_MIN_WRITE_SAMPLES = 3,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we have this number of consecutive windows with not enough
|
|
|
|
* information to scale up or down, scale up.
|
|
|
|
*/
|
|
|
|
RWB_UNKNOWN_BUMP = 5,
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline bool rwb_enabled(struct rq_wb *rwb)
|
|
|
|
{
|
2021-06-19 09:36:59 +00:00
|
|
|
return rwb && rwb->enable_state != WBT_STATE_OFF_DEFAULT &&
|
2023-05-27 01:06:42 +00:00
|
|
|
rwb->enable_state != WBT_STATE_OFF_MANUAL;
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void wb_timestamp(struct rq_wb *rwb, unsigned long *var)
|
|
|
|
{
|
|
|
|
if (rwb_enabled(rwb)) {
|
|
|
|
const unsigned long cur = jiffies;
|
|
|
|
|
|
|
|
if (cur != *var)
|
|
|
|
*var = cur;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If a task was rate throttled in balance_dirty_pages() within the last
|
|
|
|
* second or so, use that to indicate a higher cleaning rate.
|
|
|
|
*/
|
|
|
|
static bool wb_recent_wait(struct rq_wb *rwb)
|
|
|
|
{
|
2023-02-03 15:03:56 +00:00
|
|
|
struct bdi_writeback *wb = &rwb->rqos.disk->bdi->wb;
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
|
|
|
return time_before(jiffies, wb->dirty_sleep + HZ);
|
|
|
|
}
|
|
|
|
|
2018-05-07 15:57:08 +00:00
|
|
|
static inline struct rq_wait *get_rq_wait(struct rq_wb *rwb,
|
|
|
|
enum wbt_flags wb_acct)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
2018-05-07 15:57:08 +00:00
|
|
|
if (wb_acct & WBT_KSWAPD)
|
|
|
|
return &rwb->rq_wait[WBT_RWQ_KSWAPD];
|
2018-05-07 16:03:23 +00:00
|
|
|
else if (wb_acct & WBT_DISCARD)
|
|
|
|
return &rwb->rq_wait[WBT_RWQ_DISCARD];
|
2018-05-07 15:57:08 +00:00
|
|
|
|
|
|
|
return &rwb->rq_wait[WBT_RWQ_BG];
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rwb_wake_all(struct rq_wb *rwb)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < WBT_NUM_RWQ; i++) {
|
|
|
|
struct rq_wait *rqw = &rwb->rq_wait[i];
|
|
|
|
|
2018-08-20 19:20:50 +00:00
|
|
|
if (wq_has_sleeper(&rqw->wait))
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
wake_up_all(&rqw->wait);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-26 16:09:06 +00:00
|
|
|
static void wbt_rqw_done(struct rq_wb *rwb, struct rq_wait *rqw,
|
|
|
|
enum wbt_flags wb_acct)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
|
|
|
int inflight, limit;
|
|
|
|
|
|
|
|
inflight = atomic_dec_return(&rqw->inflight);
|
|
|
|
|
|
|
|
/*
|
2018-05-07 16:03:23 +00:00
|
|
|
* For discards, our limit is always the background. For writes, if
|
|
|
|
* the device does write back caching, drop further down before we
|
|
|
|
* wake people up.
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
*/
|
2018-05-07 16:03:23 +00:00
|
|
|
if (wb_acct & WBT_DISCARD)
|
|
|
|
limit = rwb->wb_background;
|
|
|
|
else if (rwb->wc && !wb_recent_wait(rwb))
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
limit = 0;
|
|
|
|
else
|
|
|
|
limit = rwb->wb_normal;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't wake anyone up if we are above the normal limit.
|
|
|
|
*/
|
|
|
|
if (inflight && inflight >= limit)
|
|
|
|
return;
|
|
|
|
|
2018-08-20 19:20:50 +00:00
|
|
|
if (wq_has_sleeper(&rqw->wait)) {
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
int diff = limit - inflight;
|
|
|
|
|
|
|
|
if (!inflight || diff >= rwb->wb_background / 2)
|
2018-08-26 16:10:05 +00:00
|
|
|
wake_up_all(&rqw->wait);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-26 16:09:06 +00:00
|
|
|
static void __wbt_done(struct rq_qos *rqos, enum wbt_flags wb_acct)
|
|
|
|
{
|
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
|
|
|
struct rq_wait *rqw;
|
|
|
|
|
|
|
|
if (!(wb_acct & WBT_TRACKED))
|
|
|
|
return;
|
|
|
|
|
|
|
|
rqw = get_rq_wait(rwb, wb_acct);
|
|
|
|
wbt_rqw_done(rwb, rqw, wb_acct);
|
|
|
|
}
|
|
|
|
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
/*
|
|
|
|
* Called on completion of a request. Note that it's also called when
|
|
|
|
* a request is merged, when the request gets freed.
|
|
|
|
*/
|
2018-07-03 15:32:35 +00:00
|
|
|
static void wbt_done(struct rq_qos *rqos, struct request *rq)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
2018-07-03 15:32:35 +00:00
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
2018-05-09 09:08:48 +00:00
|
|
|
if (!wbt_is_tracked(rq)) {
|
|
|
|
if (rwb->sync_cookie == rq) {
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
rwb->sync_issue = 0;
|
|
|
|
rwb->sync_cookie = NULL;
|
|
|
|
}
|
|
|
|
|
2018-05-09 09:08:48 +00:00
|
|
|
if (wbt_is_read(rq))
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
wb_timestamp(rwb, &rwb->last_comp);
|
|
|
|
} else {
|
2018-05-09 09:08:48 +00:00
|
|
|
WARN_ON_ONCE(rq == rwb->sync_cookie);
|
2018-07-03 15:32:35 +00:00
|
|
|
__wbt_done(rqos, wbt_flags(rq));
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
2018-05-09 09:08:48 +00:00
|
|
|
wbt_clear_state(rq);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
|
2016-11-16 15:29:57 +00:00
|
|
|
static inline bool stat_sample_valid(struct blk_rq_stat *stat)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* We need at least one read sample, and a minimum of
|
|
|
|
* RWB_MIN_WRITE_SAMPLES. We require some write samples to know
|
|
|
|
* that it's writes impacting us, and not just some sole read on
|
|
|
|
* a device that is in a lower power state.
|
|
|
|
*/
|
2017-03-21 15:56:06 +00:00
|
|
|
return (stat[READ].nr_samples >= 1 &&
|
|
|
|
stat[WRITE].nr_samples >= RWB_MIN_WRITE_SAMPLES);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u64 rwb_sync_issue_lat(struct rq_wb *rwb)
|
|
|
|
{
|
locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE()
Please do not apply this to mainline directly, instead please re-run the
coccinelle script shown below and apply its output.
For several reasons, it is desirable to use {READ,WRITE}_ONCE() in
preference to ACCESS_ONCE(), and new code is expected to use one of the
former. So far, there's been no reason to change most existing uses of
ACCESS_ONCE(), as these aren't harmful, and changing them results in
churn.
However, for some features, the read/write distinction is critical to
correct operation. To distinguish these cases, separate read/write
accessors must be used. This patch migrates (most) remaining
ACCESS_ONCE() instances to {READ,WRITE}_ONCE(), using the following
coccinelle script:
----
// Convert trivial ACCESS_ONCE() uses to equivalent READ_ONCE() and
// WRITE_ONCE()
// $ make coccicheck COCCI=/home/mark/once.cocci SPFLAGS="--include-headers" MODE=patch
virtual patch
@ depends on patch @
expression E1, E2;
@@
- ACCESS_ONCE(E1) = E2
+ WRITE_ONCE(E1, E2)
@ depends on patch @
expression E;
@@
- ACCESS_ONCE(E)
+ READ_ONCE(E)
----
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: davem@davemloft.net
Cc: linux-arch@vger.kernel.org
Cc: mpe@ellerman.id.au
Cc: shuah@kernel.org
Cc: snitzer@redhat.com
Cc: thor.thayer@linux.intel.com
Cc: tj@kernel.org
Cc: viro@zeniv.linux.org.uk
Cc: will.deacon@arm.com
Link: http://lkml.kernel.org/r/1508792849-3115-19-git-send-email-paulmck@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-10-23 21:07:29 +00:00
|
|
|
u64 now, issue = READ_ONCE(rwb->sync_issue);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
|
|
|
if (!issue || !rwb->sync_cookie)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
now = ktime_to_ns(ktime_get());
|
|
|
|
return now - issue;
|
|
|
|
}
|
|
|
|
|
2023-02-03 15:03:51 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
enum {
|
|
|
|
LAT_OK = 1,
|
|
|
|
LAT_UNKNOWN,
|
|
|
|
LAT_UNKNOWN_WRITES,
|
|
|
|
LAT_EXCEEDED,
|
|
|
|
};
|
|
|
|
|
blk-stat: convert to callback-based statistics reporting
Currently, statistics are gathered in ~0.13s windows, and users grab the
statistics whenever they need them. This is not ideal for both in-tree
users:
1. Writeback throttling wants its own dynamically sized window of
statistics. Since the blk-stats statistics are reset after every
window and the wbt windows don't line up with the blk-stats windows,
wbt doesn't see every I/O.
2. Polling currently grabs the statistics on every I/O. Again, depending
on how the window lines up, we may miss some I/Os. It's also
unnecessary overhead to get the statistics on every I/O; the hybrid
polling heuristic would be just as happy with the statistics from the
previous full window.
This reworks the blk-stats infrastructure to be callback-based: users
register a callback that they want called at a given time with all of
the statistics from the window during which the callback was active.
Users can dynamically bucketize the statistics. wbt and polling both
currently use read vs. write, but polling can be extended to further
subdivide based on request size.
The callbacks are kept on an RCU list, and each callback has percpu
stats buffers. There will only be a few users, so the overhead on the
I/O completion side is low. The stats flushing is also simplified
considerably: since the timer function is responsible for clearing the
statistics, we don't have to worry about stale statistics.
wbt is a trivial conversion. After the conversion, the windowing problem
mentioned above is fixed.
For polling, we register an extra callback that caches the previous
window's statistics in the struct request_queue for the hybrid polling
heuristic to use.
Since we no longer have a single stats buffer for the request queue,
this also removes the sysfs and debugfs stats entries. To replace those,
we add a debugfs entry for the poll statistics.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-03-21 15:56:08 +00:00
|
|
|
static int latency_exceeded(struct rq_wb *rwb, struct blk_rq_stat *stat)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
2023-02-03 15:03:56 +00:00
|
|
|
struct backing_dev_info *bdi = rwb->rqos.disk->bdi;
|
2018-07-03 15:32:35 +00:00
|
|
|
struct rq_depth *rqd = &rwb->rq_depth;
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
u64 thislat;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If our stored sync issue exceeds the window size, or it
|
|
|
|
* exceeds our min target AND we haven't logged any entries,
|
|
|
|
* flag the latency as exceeded. wbt works off completion latencies,
|
|
|
|
* but for a flooded device, a single sync IO can take a long time
|
|
|
|
* to complete after being issued. If this time exceeds our
|
|
|
|
* monitoring window AND we didn't see any other completions in that
|
|
|
|
* window, then count that sync IO as a violation of the latency.
|
|
|
|
*/
|
|
|
|
thislat = rwb_sync_issue_lat(rwb);
|
|
|
|
if (thislat > rwb->cur_win_nsec ||
|
2017-03-21 15:56:06 +00:00
|
|
|
(thislat > rwb->min_lat_nsec && !stat[READ].nr_samples)) {
|
2016-11-11 04:52:53 +00:00
|
|
|
trace_wbt_lat(bdi, thislat);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
return LAT_EXCEEDED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* No read/write mix, if stat isn't valid
|
|
|
|
*/
|
|
|
|
if (!stat_sample_valid(stat)) {
|
|
|
|
/*
|
|
|
|
* If we had writes in this stat window and the window is
|
|
|
|
* current, we're only doing writes. If a task recently
|
|
|
|
* waited or still has writes in flights, consider us doing
|
|
|
|
* just writes as well.
|
|
|
|
*/
|
blk-stat: convert to callback-based statistics reporting
Currently, statistics are gathered in ~0.13s windows, and users grab the
statistics whenever they need them. This is not ideal for both in-tree
users:
1. Writeback throttling wants its own dynamically sized window of
statistics. Since the blk-stats statistics are reset after every
window and the wbt windows don't line up with the blk-stats windows,
wbt doesn't see every I/O.
2. Polling currently grabs the statistics on every I/O. Again, depending
on how the window lines up, we may miss some I/Os. It's also
unnecessary overhead to get the statistics on every I/O; the hybrid
polling heuristic would be just as happy with the statistics from the
previous full window.
This reworks the blk-stats infrastructure to be callback-based: users
register a callback that they want called at a given time with all of
the statistics from the window during which the callback was active.
Users can dynamically bucketize the statistics. wbt and polling both
currently use read vs. write, but polling can be extended to further
subdivide based on request size.
The callbacks are kept on an RCU list, and each callback has percpu
stats buffers. There will only be a few users, so the overhead on the
I/O completion side is low. The stats flushing is also simplified
considerably: since the timer function is responsible for clearing the
statistics, we don't have to worry about stale statistics.
wbt is a trivial conversion. After the conversion, the windowing problem
mentioned above is fixed.
For polling, we register an extra callback that caches the previous
window's statistics in the struct request_queue for the hybrid polling
heuristic to use.
Since we no longer have a single stats buffer for the request queue,
this also removes the sysfs and debugfs stats entries. To replace those,
we add a debugfs entry for the poll statistics.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-03-21 15:56:08 +00:00
|
|
|
if (stat[WRITE].nr_samples || wb_recent_wait(rwb) ||
|
|
|
|
wbt_inflight(rwb))
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
return LAT_UNKNOWN_WRITES;
|
|
|
|
return LAT_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the 'min' latency exceeds our target, step down.
|
|
|
|
*/
|
2017-03-21 15:56:06 +00:00
|
|
|
if (stat[READ].min > rwb->min_lat_nsec) {
|
|
|
|
trace_wbt_lat(bdi, stat[READ].min);
|
2016-11-11 04:52:53 +00:00
|
|
|
trace_wbt_stat(bdi, stat);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
return LAT_EXCEEDED;
|
|
|
|
}
|
|
|
|
|
2018-07-03 15:32:35 +00:00
|
|
|
if (rqd->scale_step)
|
2016-11-11 04:52:53 +00:00
|
|
|
trace_wbt_stat(bdi, stat);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
|
|
|
return LAT_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rwb_trace_step(struct rq_wb *rwb, const char *msg)
|
|
|
|
{
|
2023-02-03 15:03:56 +00:00
|
|
|
struct backing_dev_info *bdi = rwb->rqos.disk->bdi;
|
2018-07-03 15:32:35 +00:00
|
|
|
struct rq_depth *rqd = &rwb->rq_depth;
|
2016-11-11 04:52:53 +00:00
|
|
|
|
2018-07-03 15:32:35 +00:00
|
|
|
trace_wbt_step(bdi, msg, rqd->scale_step, rwb->cur_win_nsec,
|
|
|
|
rwb->wb_background, rwb->wb_normal, rqd->max_depth);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
|
2018-07-03 15:32:35 +00:00
|
|
|
static void calc_wb_limits(struct rq_wb *rwb)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
2018-07-03 15:32:35 +00:00
|
|
|
if (rwb->min_lat_nsec == 0) {
|
|
|
|
rwb->wb_normal = rwb->wb_background = 0;
|
|
|
|
} else if (rwb->rq_depth.max_depth <= 2) {
|
|
|
|
rwb->wb_normal = rwb->rq_depth.max_depth;
|
|
|
|
rwb->wb_background = 1;
|
|
|
|
} else {
|
|
|
|
rwb->wb_normal = (rwb->rq_depth.max_depth + 1) / 2;
|
|
|
|
rwb->wb_background = (rwb->rq_depth.max_depth + 3) / 4;
|
|
|
|
}
|
|
|
|
}
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
2018-07-03 15:32:35 +00:00
|
|
|
static void scale_up(struct rq_wb *rwb)
|
|
|
|
{
|
2019-10-05 18:59:27 +00:00
|
|
|
if (!rq_depth_scale_up(&rwb->rq_depth))
|
|
|
|
return;
|
2018-07-03 15:32:35 +00:00
|
|
|
calc_wb_limits(rwb);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
rwb->unknown_cnt = 0;
|
2018-10-11 19:29:30 +00:00
|
|
|
rwb_wake_all(rwb);
|
2020-04-17 13:00:22 +00:00
|
|
|
rwb_trace_step(rwb, tracepoint_string("scale up"));
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void scale_down(struct rq_wb *rwb, bool hard_throttle)
|
|
|
|
{
|
2019-10-05 18:59:27 +00:00
|
|
|
if (!rq_depth_scale_down(&rwb->rq_depth, hard_throttle))
|
|
|
|
return;
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
calc_wb_limits(rwb);
|
2018-07-03 15:32:35 +00:00
|
|
|
rwb->unknown_cnt = 0;
|
2020-04-17 13:00:22 +00:00
|
|
|
rwb_trace_step(rwb, tracepoint_string("scale down"));
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rwb_arm_timer(struct rq_wb *rwb)
|
|
|
|
{
|
2018-07-03 15:32:35 +00:00
|
|
|
struct rq_depth *rqd = &rwb->rq_depth;
|
|
|
|
|
|
|
|
if (rqd->scale_step > 0) {
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
/*
|
|
|
|
* We should speed this up, using some variant of a fast
|
|
|
|
* integer inverse square root calculation. Since we only do
|
|
|
|
* this for every window expiration, it's not a huge deal,
|
|
|
|
* though.
|
|
|
|
*/
|
|
|
|
rwb->cur_win_nsec = div_u64(rwb->win_nsec << 4,
|
2018-07-03 15:32:35 +00:00
|
|
|
int_sqrt((rqd->scale_step + 1) << 8));
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* For step < 0, we don't want to increase/decrease the
|
|
|
|
* window size.
|
|
|
|
*/
|
|
|
|
rwb->cur_win_nsec = rwb->win_nsec;
|
|
|
|
}
|
|
|
|
|
blk-stat: convert to callback-based statistics reporting
Currently, statistics are gathered in ~0.13s windows, and users grab the
statistics whenever they need them. This is not ideal for both in-tree
users:
1. Writeback throttling wants its own dynamically sized window of
statistics. Since the blk-stats statistics are reset after every
window and the wbt windows don't line up with the blk-stats windows,
wbt doesn't see every I/O.
2. Polling currently grabs the statistics on every I/O. Again, depending
on how the window lines up, we may miss some I/Os. It's also
unnecessary overhead to get the statistics on every I/O; the hybrid
polling heuristic would be just as happy with the statistics from the
previous full window.
This reworks the blk-stats infrastructure to be callback-based: users
register a callback that they want called at a given time with all of
the statistics from the window during which the callback was active.
Users can dynamically bucketize the statistics. wbt and polling both
currently use read vs. write, but polling can be extended to further
subdivide based on request size.
The callbacks are kept on an RCU list, and each callback has percpu
stats buffers. There will only be a few users, so the overhead on the
I/O completion side is low. The stats flushing is also simplified
considerably: since the timer function is responsible for clearing the
statistics, we don't have to worry about stale statistics.
wbt is a trivial conversion. After the conversion, the windowing problem
mentioned above is fixed.
For polling, we register an extra callback that caches the previous
window's statistics in the struct request_queue for the hybrid polling
heuristic to use.
Since we no longer have a single stats buffer for the request queue,
this also removes the sysfs and debugfs stats entries. To replace those,
we add a debugfs entry for the poll statistics.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-03-21 15:56:08 +00:00
|
|
|
blk_stat_activate_nsecs(rwb->cb, rwb->cur_win_nsec);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
|
blk-stat: convert to callback-based statistics reporting
Currently, statistics are gathered in ~0.13s windows, and users grab the
statistics whenever they need them. This is not ideal for both in-tree
users:
1. Writeback throttling wants its own dynamically sized window of
statistics. Since the blk-stats statistics are reset after every
window and the wbt windows don't line up with the blk-stats windows,
wbt doesn't see every I/O.
2. Polling currently grabs the statistics on every I/O. Again, depending
on how the window lines up, we may miss some I/Os. It's also
unnecessary overhead to get the statistics on every I/O; the hybrid
polling heuristic would be just as happy with the statistics from the
previous full window.
This reworks the blk-stats infrastructure to be callback-based: users
register a callback that they want called at a given time with all of
the statistics from the window during which the callback was active.
Users can dynamically bucketize the statistics. wbt and polling both
currently use read vs. write, but polling can be extended to further
subdivide based on request size.
The callbacks are kept on an RCU list, and each callback has percpu
stats buffers. There will only be a few users, so the overhead on the
I/O completion side is low. The stats flushing is also simplified
considerably: since the timer function is responsible for clearing the
statistics, we don't have to worry about stale statistics.
wbt is a trivial conversion. After the conversion, the windowing problem
mentioned above is fixed.
For polling, we register an extra callback that caches the previous
window's statistics in the struct request_queue for the hybrid polling
heuristic to use.
Since we no longer have a single stats buffer for the request queue,
this also removes the sysfs and debugfs stats entries. To replace those,
we add a debugfs entry for the poll statistics.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-03-21 15:56:08 +00:00
|
|
|
static void wb_timer_fn(struct blk_stat_callback *cb)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
blk-stat: convert to callback-based statistics reporting
Currently, statistics are gathered in ~0.13s windows, and users grab the
statistics whenever they need them. This is not ideal for both in-tree
users:
1. Writeback throttling wants its own dynamically sized window of
statistics. Since the blk-stats statistics are reset after every
window and the wbt windows don't line up with the blk-stats windows,
wbt doesn't see every I/O.
2. Polling currently grabs the statistics on every I/O. Again, depending
on how the window lines up, we may miss some I/Os. It's also
unnecessary overhead to get the statistics on every I/O; the hybrid
polling heuristic would be just as happy with the statistics from the
previous full window.
This reworks the blk-stats infrastructure to be callback-based: users
register a callback that they want called at a given time with all of
the statistics from the window during which the callback was active.
Users can dynamically bucketize the statistics. wbt and polling both
currently use read vs. write, but polling can be extended to further
subdivide based on request size.
The callbacks are kept on an RCU list, and each callback has percpu
stats buffers. There will only be a few users, so the overhead on the
I/O completion side is low. The stats flushing is also simplified
considerably: since the timer function is responsible for clearing the
statistics, we don't have to worry about stale statistics.
wbt is a trivial conversion. After the conversion, the windowing problem
mentioned above is fixed.
For polling, we register an extra callback that caches the previous
window's statistics in the struct request_queue for the hybrid polling
heuristic to use.
Since we no longer have a single stats buffer for the request queue,
this also removes the sysfs and debugfs stats entries. To replace those,
we add a debugfs entry for the poll statistics.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-03-21 15:56:08 +00:00
|
|
|
struct rq_wb *rwb = cb->data;
|
2018-07-03 15:32:35 +00:00
|
|
|
struct rq_depth *rqd = &rwb->rq_depth;
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
unsigned int inflight = wbt_inflight(rwb);
|
|
|
|
int status;
|
|
|
|
|
2023-02-03 15:03:56 +00:00
|
|
|
if (!rwb->rqos.disk)
|
2021-10-19 09:20:26 +00:00
|
|
|
return;
|
|
|
|
|
blk-stat: convert to callback-based statistics reporting
Currently, statistics are gathered in ~0.13s windows, and users grab the
statistics whenever they need them. This is not ideal for both in-tree
users:
1. Writeback throttling wants its own dynamically sized window of
statistics. Since the blk-stats statistics are reset after every
window and the wbt windows don't line up with the blk-stats windows,
wbt doesn't see every I/O.
2. Polling currently grabs the statistics on every I/O. Again, depending
on how the window lines up, we may miss some I/Os. It's also
unnecessary overhead to get the statistics on every I/O; the hybrid
polling heuristic would be just as happy with the statistics from the
previous full window.
This reworks the blk-stats infrastructure to be callback-based: users
register a callback that they want called at a given time with all of
the statistics from the window during which the callback was active.
Users can dynamically bucketize the statistics. wbt and polling both
currently use read vs. write, but polling can be extended to further
subdivide based on request size.
The callbacks are kept on an RCU list, and each callback has percpu
stats buffers. There will only be a few users, so the overhead on the
I/O completion side is low. The stats flushing is also simplified
considerably: since the timer function is responsible for clearing the
statistics, we don't have to worry about stale statistics.
wbt is a trivial conversion. After the conversion, the windowing problem
mentioned above is fixed.
For polling, we register an extra callback that caches the previous
window's statistics in the struct request_queue for the hybrid polling
heuristic to use.
Since we no longer have a single stats buffer for the request queue,
this also removes the sysfs and debugfs stats entries. To replace those,
we add a debugfs entry for the poll statistics.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-03-21 15:56:08 +00:00
|
|
|
status = latency_exceeded(rwb, cb->stat);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
2023-02-03 15:03:56 +00:00
|
|
|
trace_wbt_timer(rwb->rqos.disk->bdi, status, rqd->scale_step, inflight);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If we exceeded the latency target, step down. If we did not,
|
|
|
|
* step one level up. If we don't know enough to say either exceeded
|
|
|
|
* or ok, then don't do anything.
|
|
|
|
*/
|
|
|
|
switch (status) {
|
|
|
|
case LAT_EXCEEDED:
|
|
|
|
scale_down(rwb, true);
|
|
|
|
break;
|
|
|
|
case LAT_OK:
|
|
|
|
scale_up(rwb);
|
|
|
|
break;
|
|
|
|
case LAT_UNKNOWN_WRITES:
|
|
|
|
/*
|
|
|
|
* We started a the center step, but don't have a valid
|
|
|
|
* read/write sample, but we do have writes going on.
|
|
|
|
* Allow step to go negative, to increase write perf.
|
|
|
|
*/
|
|
|
|
scale_up(rwb);
|
|
|
|
break;
|
|
|
|
case LAT_UNKNOWN:
|
|
|
|
if (++rwb->unknown_cnt < RWB_UNKNOWN_BUMP)
|
|
|
|
break;
|
|
|
|
/*
|
|
|
|
* We get here when previously scaled reduced depth, and we
|
|
|
|
* currently don't have a valid read/write sample. For that
|
|
|
|
* case, slowly return to center state (step == 0).
|
|
|
|
*/
|
2018-07-03 15:32:35 +00:00
|
|
|
if (rqd->scale_step > 0)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
scale_up(rwb);
|
2018-07-03 15:32:35 +00:00
|
|
|
else if (rqd->scale_step < 0)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
scale_down(rwb, false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Re-arm timer, if we have IO in flight
|
|
|
|
*/
|
2018-07-03 15:32:35 +00:00
|
|
|
if (rqd->scale_step || inflight)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
rwb_arm_timer(rwb);
|
|
|
|
}
|
|
|
|
|
2020-05-08 22:00:15 +00:00
|
|
|
static void wbt_update_limits(struct rq_wb *rwb)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
2018-07-03 15:32:35 +00:00
|
|
|
struct rq_depth *rqd = &rwb->rq_depth;
|
|
|
|
|
|
|
|
rqd->scale_step = 0;
|
|
|
|
rqd->scaled_max = false;
|
|
|
|
|
|
|
|
rq_depth_calc_max_depth(rqd);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
calc_wb_limits(rwb);
|
|
|
|
|
|
|
|
rwb_wake_all(rwb);
|
|
|
|
}
|
|
|
|
|
2022-10-19 12:15:16 +00:00
|
|
|
bool wbt_disabled(struct request_queue *q)
|
|
|
|
{
|
|
|
|
struct rq_qos *rqos = wbt_rq_qos(q);
|
|
|
|
|
2023-05-27 01:06:42 +00:00
|
|
|
return !rqos || !rwb_enabled(RQWB(rqos));
|
2022-10-19 12:15:16 +00:00
|
|
|
}
|
|
|
|
|
2018-07-03 15:32:35 +00:00
|
|
|
u64 wbt_get_min_lat(struct request_queue *q)
|
|
|
|
{
|
|
|
|
struct rq_qos *rqos = wbt_rq_qos(q);
|
|
|
|
if (!rqos)
|
|
|
|
return 0;
|
|
|
|
return RQWB(rqos)->min_lat_nsec;
|
|
|
|
}
|
|
|
|
|
|
|
|
void wbt_set_min_lat(struct request_queue *q, u64 val)
|
|
|
|
{
|
|
|
|
struct rq_qos *rqos = wbt_rq_qos(q);
|
|
|
|
if (!rqos)
|
|
|
|
return;
|
2022-10-19 12:15:15 +00:00
|
|
|
|
2018-07-03 15:32:35 +00:00
|
|
|
RQWB(rqos)->min_lat_nsec = val;
|
2022-10-19 12:15:15 +00:00
|
|
|
if (val)
|
|
|
|
RQWB(rqos)->enable_state = WBT_STATE_ON_MANUAL;
|
|
|
|
else
|
|
|
|
RQWB(rqos)->enable_state = WBT_STATE_OFF_MANUAL;
|
|
|
|
|
2020-05-08 22:00:15 +00:00
|
|
|
wbt_update_limits(RQWB(rqos));
|
2018-07-03 15:32:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
static bool close_io(struct rq_wb *rwb)
|
|
|
|
{
|
|
|
|
const unsigned long now = jiffies;
|
|
|
|
|
|
|
|
return time_before(now, rwb->last_issue + HZ / 10) ||
|
|
|
|
time_before(now, rwb->last_comp + HZ / 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define REQ_HIPRIO (REQ_SYNC | REQ_META | REQ_PRIO)
|
|
|
|
|
2022-07-14 18:06:32 +00:00
|
|
|
static inline unsigned int get_limit(struct rq_wb *rwb, blk_opf_t opf)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
|
|
|
unsigned int limit;
|
|
|
|
|
2022-07-14 18:06:32 +00:00
|
|
|
if ((opf & REQ_OP_MASK) == REQ_OP_DISCARD)
|
2018-05-07 16:03:23 +00:00
|
|
|
return rwb->wb_background;
|
|
|
|
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
/*
|
|
|
|
* At this point we know it's a buffered write. If this is
|
2017-11-23 13:40:10 +00:00
|
|
|
* kswapd trying to free memory, or REQ_SYNC is set, then
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
* it's WB_SYNC_ALL writeback, and we'll use the max limit for
|
|
|
|
* that. If the write is marked as a background write, then use
|
|
|
|
* the idle limit, or go to normal if we haven't had competing
|
|
|
|
* IO for a bit.
|
|
|
|
*/
|
2022-07-14 18:06:32 +00:00
|
|
|
if ((opf & REQ_HIPRIO) || wb_recent_wait(rwb) || current_is_kswapd())
|
2018-07-03 15:32:35 +00:00
|
|
|
limit = rwb->rq_depth.max_depth;
|
2022-07-14 18:06:32 +00:00
|
|
|
else if ((opf & REQ_BACKGROUND) || close_io(rwb)) {
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
/*
|
|
|
|
* If less than 100ms since we completed unrelated IO,
|
|
|
|
* limit us to half the depth for background writeback.
|
|
|
|
*/
|
|
|
|
limit = rwb->wb_background;
|
|
|
|
} else
|
|
|
|
limit = rwb->wb_normal;
|
|
|
|
|
|
|
|
return limit;
|
|
|
|
}
|
|
|
|
|
2018-08-26 16:10:05 +00:00
|
|
|
struct wbt_wait_data {
|
|
|
|
struct rq_wb *rwb;
|
2018-12-04 17:59:03 +00:00
|
|
|
enum wbt_flags wb_acct;
|
2022-07-14 18:06:32 +00:00
|
|
|
blk_opf_t opf;
|
2018-08-26 16:10:05 +00:00
|
|
|
};
|
|
|
|
|
2018-12-04 17:59:03 +00:00
|
|
|
static bool wbt_inflight_cb(struct rq_wait *rqw, void *private_data)
|
2018-08-26 16:10:05 +00:00
|
|
|
{
|
2018-12-04 17:59:03 +00:00
|
|
|
struct wbt_wait_data *data = private_data;
|
2022-07-14 18:06:32 +00:00
|
|
|
return rq_wait_inc_below(rqw, get_limit(data->rwb, data->opf));
|
2018-12-04 17:59:03 +00:00
|
|
|
}
|
2018-08-26 16:10:05 +00:00
|
|
|
|
2018-12-04 17:59:03 +00:00
|
|
|
static void wbt_cleanup_cb(struct rq_wait *rqw, void *private_data)
|
|
|
|
{
|
|
|
|
struct wbt_wait_data *data = private_data;
|
|
|
|
wbt_rqw_done(data->rwb, rqw, data->wb_acct);
|
2018-08-26 16:10:05 +00:00
|
|
|
}
|
|
|
|
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
/*
|
|
|
|
* Block if we will exceed our limit, or if we are currently waiting for
|
|
|
|
* the timer to kick off queuing again.
|
|
|
|
*/
|
2018-05-07 15:57:08 +00:00
|
|
|
static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct,
|
2022-07-14 18:06:32 +00:00
|
|
|
blk_opf_t opf)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
2018-05-07 15:57:08 +00:00
|
|
|
struct rq_wait *rqw = get_rq_wait(rwb, wb_acct);
|
2018-08-26 16:10:05 +00:00
|
|
|
struct wbt_wait_data data = {
|
|
|
|
.rwb = rwb,
|
2018-12-04 17:59:03 +00:00
|
|
|
.wb_acct = wb_acct,
|
2022-07-14 18:06:32 +00:00
|
|
|
.opf = opf,
|
2018-08-26 16:10:05 +00:00
|
|
|
};
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
2018-12-04 17:59:03 +00:00
|
|
|
rq_qos_wait(rqw, &data, wbt_inflight_cb, wbt_cleanup_cb);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
|
2021-01-25 11:27:04 +00:00
|
|
|
static inline bool wbt_should_throttle(struct bio *bio)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
2018-05-07 16:03:23 +00:00
|
|
|
switch (bio_op(bio)) {
|
|
|
|
case REQ_OP_WRITE:
|
|
|
|
/*
|
|
|
|
* Don't throttle WRITE_ODIRECT
|
|
|
|
*/
|
|
|
|
if ((bio->bi_opf & (REQ_SYNC | REQ_IDLE)) ==
|
|
|
|
(REQ_SYNC | REQ_IDLE))
|
|
|
|
return false;
|
2020-08-23 22:36:59 +00:00
|
|
|
fallthrough;
|
2018-05-07 16:03:23 +00:00
|
|
|
case REQ_OP_DISCARD:
|
|
|
|
return true;
|
|
|
|
default:
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
return false;
|
2018-05-07 16:03:23 +00:00
|
|
|
}
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
|
2018-07-03 15:14:59 +00:00
|
|
|
static enum wbt_flags bio_to_wbt_flags(struct rq_wb *rwb, struct bio *bio)
|
|
|
|
{
|
|
|
|
enum wbt_flags flags = 0;
|
|
|
|
|
2018-08-23 15:34:46 +00:00
|
|
|
if (!rwb_enabled(rwb))
|
|
|
|
return 0;
|
|
|
|
|
2018-07-03 15:14:59 +00:00
|
|
|
if (bio_op(bio) == REQ_OP_READ) {
|
|
|
|
flags = WBT_READ;
|
2021-01-25 11:27:04 +00:00
|
|
|
} else if (wbt_should_throttle(bio)) {
|
2018-07-03 15:14:59 +00:00
|
|
|
if (current_is_kswapd())
|
|
|
|
flags |= WBT_KSWAPD;
|
|
|
|
if (bio_op(bio) == REQ_OP_DISCARD)
|
|
|
|
flags |= WBT_DISCARD;
|
|
|
|
flags |= WBT_TRACKED;
|
|
|
|
}
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wbt_cleanup(struct rq_qos *rqos, struct bio *bio)
|
|
|
|
{
|
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
|
|
|
enum wbt_flags flags = bio_to_wbt_flags(rwb, bio);
|
|
|
|
__wbt_done(rqos, flags);
|
|
|
|
}
|
|
|
|
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
/*
|
|
|
|
* May sleep, if we have exceeded the writeback limits. Caller can pass
|
|
|
|
* in an irq held spinlock, if it holds one when calling this function.
|
|
|
|
* If we do sleep, we'll release and re-grab it.
|
|
|
|
*/
|
2018-11-14 16:02:09 +00:00
|
|
|
static void wbt_wait(struct rq_qos *rqos, struct bio *bio)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
2018-07-03 15:32:35 +00:00
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
2018-07-03 15:14:59 +00:00
|
|
|
enum wbt_flags flags;
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
2018-07-03 15:14:59 +00:00
|
|
|
flags = bio_to_wbt_flags(rwb, bio);
|
2018-08-14 15:57:49 +00:00
|
|
|
if (!(flags & WBT_TRACKED)) {
|
2018-07-03 15:14:59 +00:00
|
|
|
if (flags & WBT_READ)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
wb_timestamp(rwb, &rwb->last_issue);
|
2018-07-03 15:14:59 +00:00
|
|
|
return;
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
|
2018-11-14 16:02:09 +00:00
|
|
|
__wbt_wait(rwb, flags, bio->bi_opf);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
blk-stat: convert to callback-based statistics reporting
Currently, statistics are gathered in ~0.13s windows, and users grab the
statistics whenever they need them. This is not ideal for both in-tree
users:
1. Writeback throttling wants its own dynamically sized window of
statistics. Since the blk-stats statistics are reset after every
window and the wbt windows don't line up with the blk-stats windows,
wbt doesn't see every I/O.
2. Polling currently grabs the statistics on every I/O. Again, depending
on how the window lines up, we may miss some I/Os. It's also
unnecessary overhead to get the statistics on every I/O; the hybrid
polling heuristic would be just as happy with the statistics from the
previous full window.
This reworks the blk-stats infrastructure to be callback-based: users
register a callback that they want called at a given time with all of
the statistics from the window during which the callback was active.
Users can dynamically bucketize the statistics. wbt and polling both
currently use read vs. write, but polling can be extended to further
subdivide based on request size.
The callbacks are kept on an RCU list, and each callback has percpu
stats buffers. There will only be a few users, so the overhead on the
I/O completion side is low. The stats flushing is also simplified
considerably: since the timer function is responsible for clearing the
statistics, we don't have to worry about stale statistics.
wbt is a trivial conversion. After the conversion, the windowing problem
mentioned above is fixed.
For polling, we register an extra callback that caches the previous
window's statistics in the struct request_queue for the hybrid polling
heuristic to use.
Since we no longer have a single stats buffer for the request queue,
this also removes the sysfs and debugfs stats entries. To replace those,
we add a debugfs entry for the poll statistics.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-03-21 15:56:08 +00:00
|
|
|
if (!blk_stat_is_active(rwb->cb))
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
rwb_arm_timer(rwb);
|
2018-07-03 15:14:59 +00:00
|
|
|
}
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
2018-07-03 15:14:59 +00:00
|
|
|
static void wbt_track(struct rq_qos *rqos, struct request *rq, struct bio *bio)
|
|
|
|
{
|
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
|
|
|
rq->wbt_flags |= bio_to_wbt_flags(rwb, bio);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
|
2019-01-23 19:05:57 +00:00
|
|
|
static void wbt_issue(struct rq_qos *rqos, struct request *rq)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
2018-07-03 15:32:35 +00:00
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
|
|
|
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
if (!rwb_enabled(rwb))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
2018-05-09 09:08:48 +00:00
|
|
|
* Track sync issue, in case it takes a long time to complete. Allows us
|
|
|
|
* to react quicker, if a sync IO takes a long time to complete. Note
|
|
|
|
* that this is just a hint. The request can go away when it completes,
|
|
|
|
* so it's important we never dereference it. We only use the address to
|
|
|
|
* compare with, which is why we store the sync_issue time locally.
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
*/
|
2018-05-09 09:08:48 +00:00
|
|
|
if (wbt_is_read(rq) && !rwb->sync_issue) {
|
|
|
|
rwb->sync_cookie = rq;
|
2018-05-09 09:08:50 +00:00
|
|
|
rwb->sync_issue = rq->io_start_time_ns;
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-23 19:05:57 +00:00
|
|
|
static void wbt_requeue(struct rq_qos *rqos, struct request *rq)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
2018-07-03 15:32:35 +00:00
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
if (!rwb_enabled(rwb))
|
|
|
|
return;
|
2018-05-09 09:08:48 +00:00
|
|
|
if (rq == rwb->sync_cookie) {
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
rwb->sync_issue = 0;
|
|
|
|
rwb->sync_cookie = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-03 15:32:35 +00:00
|
|
|
void wbt_set_write_cache(struct request_queue *q, bool write_cache_on)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
2018-07-03 15:32:35 +00:00
|
|
|
struct rq_qos *rqos = wbt_rq_qos(q);
|
|
|
|
if (rqos)
|
|
|
|
RQWB(rqos)->wc = write_cache_on;
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 09:33:27 +00:00
|
|
|
/*
|
|
|
|
* Enable wbt if defaults are configured that way
|
|
|
|
*/
|
2023-02-03 15:03:49 +00:00
|
|
|
void wbt_enable_default(struct gendisk *disk)
|
2017-04-19 09:33:27 +00:00
|
|
|
{
|
2023-02-03 15:03:49 +00:00
|
|
|
struct request_queue *q = disk->queue;
|
2022-10-19 12:15:18 +00:00
|
|
|
struct rq_qos *rqos;
|
2023-05-22 12:18:54 +00:00
|
|
|
bool enable = IS_ENABLED(CONFIG_BLK_WBT_MQ);
|
|
|
|
|
|
|
|
if (q->elevator &&
|
|
|
|
test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags))
|
|
|
|
enable = false;
|
2021-06-19 09:37:00 +00:00
|
|
|
|
2017-04-19 09:33:27 +00:00
|
|
|
/* Throttling already enabled? */
|
2022-10-19 12:15:18 +00:00
|
|
|
rqos = wbt_rq_qos(q);
|
2021-06-19 09:37:00 +00:00
|
|
|
if (rqos) {
|
2023-05-22 12:18:54 +00:00
|
|
|
if (enable && RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT)
|
2021-06-19 09:37:00 +00:00
|
|
|
RQWB(rqos)->enable_state = WBT_STATE_ON_DEFAULT;
|
2017-04-19 09:33:27 +00:00
|
|
|
return;
|
2021-06-19 09:37:00 +00:00
|
|
|
}
|
2017-04-19 09:33:27 +00:00
|
|
|
|
|
|
|
/* Queue not registered? Maybe shutting down... */
|
2019-08-27 11:01:47 +00:00
|
|
|
if (!blk_queue_registered(q))
|
2017-04-19 09:33:27 +00:00
|
|
|
return;
|
|
|
|
|
2023-05-22 12:18:54 +00:00
|
|
|
if (queue_is_mq(q) && enable)
|
2023-02-03 15:03:50 +00:00
|
|
|
wbt_init(disk);
|
2017-04-19 09:33:27 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(wbt_enable_default);
|
|
|
|
|
2016-11-28 16:22:47 +00:00
|
|
|
u64 wbt_default_latency_nsec(struct request_queue *q)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* We default to 2msec for non-rotational storage, and 75msec
|
|
|
|
* for rotational storage.
|
|
|
|
*/
|
|
|
|
if (blk_queue_nonrot(q))
|
|
|
|
return 2000000ULL;
|
|
|
|
else
|
|
|
|
return 75000000ULL;
|
|
|
|
}
|
|
|
|
|
2017-04-21 13:55:42 +00:00
|
|
|
static int wbt_data_dir(const struct request *rq)
|
|
|
|
{
|
2022-07-14 18:06:28 +00:00
|
|
|
const enum req_op op = req_op(rq);
|
2018-02-05 20:16:56 +00:00
|
|
|
|
|
|
|
if (op == REQ_OP_READ)
|
|
|
|
return READ;
|
2018-05-03 15:14:57 +00:00
|
|
|
else if (op_is_write(op))
|
2018-02-05 20:16:56 +00:00
|
|
|
return WRITE;
|
|
|
|
|
|
|
|
/* don't account */
|
|
|
|
return -1;
|
2017-04-21 13:55:42 +00:00
|
|
|
}
|
|
|
|
|
2019-08-28 22:05:55 +00:00
|
|
|
static void wbt_queue_depth_changed(struct rq_qos *rqos)
|
|
|
|
{
|
2023-02-03 15:03:56 +00:00
|
|
|
RQWB(rqos)->rq_depth.queue_depth = blk_queue_depth(rqos->disk->queue);
|
2020-05-08 22:00:15 +00:00
|
|
|
wbt_update_limits(RQWB(rqos));
|
2019-08-28 22:05:55 +00:00
|
|
|
}
|
|
|
|
|
2018-07-03 15:32:35 +00:00
|
|
|
static void wbt_exit(struct rq_qos *rqos)
|
|
|
|
{
|
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
|
|
|
|
2023-02-03 15:03:56 +00:00
|
|
|
blk_stat_remove_callback(rqos->disk->queue, rwb->cb);
|
2018-07-03 15:32:35 +00:00
|
|
|
blk_stat_free_callback(rwb->cb);
|
|
|
|
kfree(rwb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable wbt, if enabled by default.
|
|
|
|
*/
|
2023-02-03 15:03:49 +00:00
|
|
|
void wbt_disable_default(struct gendisk *disk)
|
2018-07-03 15:32:35 +00:00
|
|
|
{
|
2023-02-03 15:03:49 +00:00
|
|
|
struct rq_qos *rqos = wbt_rq_qos(disk->queue);
|
2018-07-03 15:32:35 +00:00
|
|
|
struct rq_wb *rwb;
|
|
|
|
if (!rqos)
|
|
|
|
return;
|
|
|
|
rwb = RQWB(rqos);
|
2018-12-12 11:44:34 +00:00
|
|
|
if (rwb->enable_state == WBT_STATE_ON_DEFAULT) {
|
|
|
|
blk_stat_deactivate(rwb->cb);
|
2021-06-19 09:36:59 +00:00
|
|
|
rwb->enable_state = WBT_STATE_OFF_DEFAULT;
|
2018-12-12 11:44:34 +00:00
|
|
|
}
|
2018-07-03 15:32:35 +00:00
|
|
|
}
|
2018-11-15 19:31:27 +00:00
|
|
|
EXPORT_SYMBOL_GPL(wbt_disable_default);
|
2018-07-03 15:32:35 +00:00
|
|
|
|
2018-12-17 01:46:01 +00:00
|
|
|
#ifdef CONFIG_BLK_DEBUG_FS
|
|
|
|
static int wbt_curr_win_nsec_show(void *data, struct seq_file *m)
|
|
|
|
{
|
|
|
|
struct rq_qos *rqos = data;
|
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
|
|
|
|
|
|
|
seq_printf(m, "%llu\n", rwb->cur_win_nsec);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wbt_enabled_show(void *data, struct seq_file *m)
|
|
|
|
{
|
|
|
|
struct rq_qos *rqos = data;
|
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
|
|
|
|
|
|
|
seq_printf(m, "%d\n", rwb->enable_state);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wbt_id_show(void *data, struct seq_file *m)
|
|
|
|
{
|
|
|
|
struct rq_qos *rqos = data;
|
|
|
|
|
|
|
|
seq_printf(m, "%u\n", rqos->id);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wbt_inflight_show(void *data, struct seq_file *m)
|
|
|
|
{
|
|
|
|
struct rq_qos *rqos = data;
|
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < WBT_NUM_RWQ; i++)
|
|
|
|
seq_printf(m, "%d: inflight %d\n", i,
|
|
|
|
atomic_read(&rwb->rq_wait[i].inflight));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wbt_min_lat_nsec_show(void *data, struct seq_file *m)
|
|
|
|
{
|
|
|
|
struct rq_qos *rqos = data;
|
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
|
|
|
|
|
|
|
seq_printf(m, "%lu\n", rwb->min_lat_nsec);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wbt_unknown_cnt_show(void *data, struct seq_file *m)
|
|
|
|
{
|
|
|
|
struct rq_qos *rqos = data;
|
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
|
|
|
|
|
|
|
seq_printf(m, "%u\n", rwb->unknown_cnt);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wbt_normal_show(void *data, struct seq_file *m)
|
|
|
|
{
|
|
|
|
struct rq_qos *rqos = data;
|
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
|
|
|
|
|
|
|
seq_printf(m, "%u\n", rwb->wb_normal);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wbt_background_show(void *data, struct seq_file *m)
|
|
|
|
{
|
|
|
|
struct rq_qos *rqos = data;
|
|
|
|
struct rq_wb *rwb = RQWB(rqos);
|
|
|
|
|
|
|
|
seq_printf(m, "%u\n", rwb->wb_background);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct blk_mq_debugfs_attr wbt_debugfs_attrs[] = {
|
|
|
|
{"curr_win_nsec", 0400, wbt_curr_win_nsec_show},
|
|
|
|
{"enabled", 0400, wbt_enabled_show},
|
|
|
|
{"id", 0400, wbt_id_show},
|
|
|
|
{"inflight", 0400, wbt_inflight_show},
|
|
|
|
{"min_lat_nsec", 0400, wbt_min_lat_nsec_show},
|
|
|
|
{"unknown_cnt", 0400, wbt_unknown_cnt_show},
|
|
|
|
{"wb_normal", 0400, wbt_normal_show},
|
|
|
|
{"wb_background", 0400, wbt_background_show},
|
|
|
|
{},
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2023-02-03 15:03:55 +00:00
|
|
|
static const struct rq_qos_ops wbt_rqos_ops = {
|
2018-07-03 15:32:35 +00:00
|
|
|
.throttle = wbt_wait,
|
|
|
|
.issue = wbt_issue,
|
2018-07-03 15:14:59 +00:00
|
|
|
.track = wbt_track,
|
2018-07-03 15:32:35 +00:00
|
|
|
.requeue = wbt_requeue,
|
|
|
|
.done = wbt_done,
|
2018-07-03 15:14:59 +00:00
|
|
|
.cleanup = wbt_cleanup,
|
2019-08-28 22:05:55 +00:00
|
|
|
.queue_depth_changed = wbt_queue_depth_changed,
|
2018-07-03 15:32:35 +00:00
|
|
|
.exit = wbt_exit,
|
2018-12-17 01:46:01 +00:00
|
|
|
#ifdef CONFIG_BLK_DEBUG_FS
|
|
|
|
.debugfs_attrs = wbt_debugfs_attrs,
|
|
|
|
#endif
|
2018-07-03 15:32:35 +00:00
|
|
|
};
|
|
|
|
|
2023-02-03 15:03:50 +00:00
|
|
|
int wbt_init(struct gendisk *disk)
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
{
|
2023-02-03 15:03:50 +00:00
|
|
|
struct request_queue *q = disk->queue;
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
struct rq_wb *rwb;
|
|
|
|
int i;
|
2022-07-20 09:36:16 +00:00
|
|
|
int ret;
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
|
|
|
rwb = kzalloc(sizeof(*rwb), GFP_KERNEL);
|
|
|
|
if (!rwb)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2017-04-21 13:55:42 +00:00
|
|
|
rwb->cb = blk_stat_alloc_callback(wb_timer_fn, wbt_data_dir, 2, rwb);
|
blk-stat: convert to callback-based statistics reporting
Currently, statistics are gathered in ~0.13s windows, and users grab the
statistics whenever they need them. This is not ideal for both in-tree
users:
1. Writeback throttling wants its own dynamically sized window of
statistics. Since the blk-stats statistics are reset after every
window and the wbt windows don't line up with the blk-stats windows,
wbt doesn't see every I/O.
2. Polling currently grabs the statistics on every I/O. Again, depending
on how the window lines up, we may miss some I/Os. It's also
unnecessary overhead to get the statistics on every I/O; the hybrid
polling heuristic would be just as happy with the statistics from the
previous full window.
This reworks the blk-stats infrastructure to be callback-based: users
register a callback that they want called at a given time with all of
the statistics from the window during which the callback was active.
Users can dynamically bucketize the statistics. wbt and polling both
currently use read vs. write, but polling can be extended to further
subdivide based on request size.
The callbacks are kept on an RCU list, and each callback has percpu
stats buffers. There will only be a few users, so the overhead on the
I/O completion side is low. The stats flushing is also simplified
considerably: since the timer function is responsible for clearing the
statistics, we don't have to worry about stale statistics.
wbt is a trivial conversion. After the conversion, the windowing problem
mentioned above is fixed.
For polling, we register an extra callback that caches the previous
window's statistics in the struct request_queue for the hybrid polling
heuristic to use.
Since we no longer have a single stats buffer for the request queue,
this also removes the sysfs and debugfs stats entries. To replace those,
we add a debugfs entry for the poll statistics.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-03-21 15:56:08 +00:00
|
|
|
if (!rwb->cb) {
|
|
|
|
kfree(rwb);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2018-07-03 15:32:35 +00:00
|
|
|
for (i = 0; i < WBT_NUM_RWQ; i++)
|
|
|
|
rq_wait_init(&rwb->rq_wait[i]);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
|
|
|
rwb->last_comp = rwb->last_issue = jiffies;
|
|
|
|
rwb->win_nsec = RWB_WINDOW_NSEC;
|
2016-11-28 16:40:34 +00:00
|
|
|
rwb->enable_state = WBT_STATE_ON_DEFAULT;
|
2022-10-09 10:10:38 +00:00
|
|
|
rwb->wc = test_bit(QUEUE_FLAG_WC, &q->queue_flags);
|
2018-07-03 15:32:35 +00:00
|
|
|
rwb->rq_depth.default_depth = RWB_DEF_DEPTH;
|
blk-wbt: call rq_qos_add() after wb_normal is initialized
Our test found a problem that wbt inflight counter is negative, which
will cause io hang(noted that this problem doesn't exist in mainline):
t1: device create t2: issue io
add_disk
blk_register_queue
wbt_enable_default
wbt_init
rq_qos_add
// wb_normal is still 0
/*
* in mainline, disk can't be opened before
* bdev_add(), however, in old kernels, disk
* can be opened before blk_register_queue().
*/
blkdev_issue_flush
// disk size is 0, however, it's not checked
submit_bio_wait
submit_bio
blk_mq_submit_bio
rq_qos_throttle
wbt_wait
bio_to_wbt_flags
rwb_enabled
// wb_normal is 0, inflight is not increased
wbt_queue_depth_changed(&rwb->rqos);
wbt_update_limits
// wb_normal is initialized
rq_qos_track
wbt_track
rq->wbt_flags |= bio_to_wbt_flags(rwb, bio);
// wb_normal is not 0,wbt_flags will be set
t3: io completion
blk_mq_free_request
rq_qos_done
wbt_done
wbt_is_tracked
// return true
__wbt_done
wbt_rqw_done
atomic_dec_return(&rqw->inflight);
// inflight is decreased
commit 8235b5c1e8c1 ("block: call bdev_add later in device_add_disk") can
avoid this problem, however it's better to fix this problem in wbt:
1) Lower kernel can't backport this patch due to lots of refactor.
2) Root cause is that wbt call rq_qos_add() before wb_normal is
initialized.
Fixes: e34cbd307477 ("blk-wbt: add general throttling mechanism")
Cc: <stable@vger.kernel.org>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20220913105749.3086243-1-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2022-09-13 10:57:49 +00:00
|
|
|
rwb->min_lat_nsec = wbt_default_latency_nsec(q);
|
2023-02-03 15:03:52 +00:00
|
|
|
rwb->rq_depth.queue_depth = blk_queue_depth(q);
|
|
|
|
wbt_update_limits(rwb);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
|
|
|
/*
|
blk-stat: convert to callback-based statistics reporting
Currently, statistics are gathered in ~0.13s windows, and users grab the
statistics whenever they need them. This is not ideal for both in-tree
users:
1. Writeback throttling wants its own dynamically sized window of
statistics. Since the blk-stats statistics are reset after every
window and the wbt windows don't line up with the blk-stats windows,
wbt doesn't see every I/O.
2. Polling currently grabs the statistics on every I/O. Again, depending
on how the window lines up, we may miss some I/Os. It's also
unnecessary overhead to get the statistics on every I/O; the hybrid
polling heuristic would be just as happy with the statistics from the
previous full window.
This reworks the blk-stats infrastructure to be callback-based: users
register a callback that they want called at a given time with all of
the statistics from the window during which the callback was active.
Users can dynamically bucketize the statistics. wbt and polling both
currently use read vs. write, but polling can be extended to further
subdivide based on request size.
The callbacks are kept on an RCU list, and each callback has percpu
stats buffers. There will only be a few users, so the overhead on the
I/O completion side is low. The stats flushing is also simplified
considerably: since the timer function is responsible for clearing the
statistics, we don't have to worry about stale statistics.
wbt is a trivial conversion. After the conversion, the windowing problem
mentioned above is fixed.
For polling, we register an extra callback that caches the previous
window's statistics in the struct request_queue for the hybrid polling
heuristic to use.
Since we no longer have a single stats buffer for the request queue,
this also removes the sysfs and debugfs stats entries. To replace those,
we add a debugfs entry for the poll statistics.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-03-21 15:56:08 +00:00
|
|
|
* Assign rwb and add the stats callback.
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
*/
|
block/rq_qos: protect rq_qos apis with a new lock
commit 50e34d78815e ("block: disable the elevator int del_gendisk")
move rq_qos_exit() from disk_release() to del_gendisk(), this will
introduce some problems:
1) If rq_qos_add() is triggered by enabling iocost/iolatency through
cgroupfs, then it can concurrent with del_gendisk(), it's not safe to
write 'q->rq_qos' concurrently.
2) Activate cgroup policy that is relied on rq_qos will call
rq_qos_add() and blkcg_activate_policy(), and if rq_qos_exit() is
called in the middle, null-ptr-dereference will be triggered in
blkcg_activate_policy().
3) blkg_conf_open_bdev() can call blkdev_get_no_open() first to find the
disk, then if rq_qos_exit() from del_gendisk() is done before
rq_qos_add(), then memory will be leaked.
This patch add a new disk level mutex 'rq_qos_mutex':
1) The lock will protect rq_qos_exit() directly.
2) For wbt that doesn't relied on blk-cgroup, rq_qos_add() can only be
called from disk initialization for now because wbt can't be
destructed until rq_qos_exit(), so it's safe not to protect wbt for
now. Hoever, in case that rq_qos dynamically destruction is supported
in the furture, this patch also protect rq_qos_add() from wbt_init()
directly, this is enough because blk-sysfs already synchronize
writers with disk removal.
3) For iocost and iolatency, in order to synchronize disk removal and
cgroup configuration, the lock is held after blkdev_get_no_open()
from blkg_conf_open_bdev(), and is released in blkg_conf_exit().
In order to fix the above memory leak, disk_live() is checked after
holding the new lock.
Fixes: 50e34d78815e ("block: disable the elevator int del_gendisk")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20230414084008.2085155-1-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-04-14 08:40:08 +00:00
|
|
|
mutex_lock(&q->rq_qos_mutex);
|
2023-02-03 15:03:54 +00:00
|
|
|
ret = rq_qos_add(&rwb->rqos, disk, RQ_QOS_WBT, &wbt_rqos_ops);
|
block/rq_qos: protect rq_qos apis with a new lock
commit 50e34d78815e ("block: disable the elevator int del_gendisk")
move rq_qos_exit() from disk_release() to del_gendisk(), this will
introduce some problems:
1) If rq_qos_add() is triggered by enabling iocost/iolatency through
cgroupfs, then it can concurrent with del_gendisk(), it's not safe to
write 'q->rq_qos' concurrently.
2) Activate cgroup policy that is relied on rq_qos will call
rq_qos_add() and blkcg_activate_policy(), and if rq_qos_exit() is
called in the middle, null-ptr-dereference will be triggered in
blkcg_activate_policy().
3) blkg_conf_open_bdev() can call blkdev_get_no_open() first to find the
disk, then if rq_qos_exit() from del_gendisk() is done before
rq_qos_add(), then memory will be leaked.
This patch add a new disk level mutex 'rq_qos_mutex':
1) The lock will protect rq_qos_exit() directly.
2) For wbt that doesn't relied on blk-cgroup, rq_qos_add() can only be
called from disk initialization for now because wbt can't be
destructed until rq_qos_exit(), so it's safe not to protect wbt for
now. Hoever, in case that rq_qos dynamically destruction is supported
in the furture, this patch also protect rq_qos_add() from wbt_init()
directly, this is enough because blk-sysfs already synchronize
writers with disk removal.
3) For iocost and iolatency, in order to synchronize disk removal and
cgroup configuration, the lock is held after blkdev_get_no_open()
from blkg_conf_open_bdev(), and is released in blkg_conf_exit().
In order to fix the above memory leak, disk_live() is checked after
holding the new lock.
Fixes: 50e34d78815e ("block: disable the elevator int del_gendisk")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20230414084008.2085155-1-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-04-14 08:40:08 +00:00
|
|
|
mutex_unlock(&q->rq_qos_mutex);
|
2022-07-20 09:36:16 +00:00
|
|
|
if (ret)
|
|
|
|
goto err_free;
|
|
|
|
|
blk-stat: convert to callback-based statistics reporting
Currently, statistics are gathered in ~0.13s windows, and users grab the
statistics whenever they need them. This is not ideal for both in-tree
users:
1. Writeback throttling wants its own dynamically sized window of
statistics. Since the blk-stats statistics are reset after every
window and the wbt windows don't line up with the blk-stats windows,
wbt doesn't see every I/O.
2. Polling currently grabs the statistics on every I/O. Again, depending
on how the window lines up, we may miss some I/Os. It's also
unnecessary overhead to get the statistics on every I/O; the hybrid
polling heuristic would be just as happy with the statistics from the
previous full window.
This reworks the blk-stats infrastructure to be callback-based: users
register a callback that they want called at a given time with all of
the statistics from the window during which the callback was active.
Users can dynamically bucketize the statistics. wbt and polling both
currently use read vs. write, but polling can be extended to further
subdivide based on request size.
The callbacks are kept on an RCU list, and each callback has percpu
stats buffers. There will only be a few users, so the overhead on the
I/O completion side is low. The stats flushing is also simplified
considerably: since the timer function is responsible for clearing the
statistics, we don't have to worry about stale statistics.
wbt is a trivial conversion. After the conversion, the windowing problem
mentioned above is fixed.
For polling, we register an extra callback that caches the previous
window's statistics in the struct request_queue for the hybrid polling
heuristic to use.
Since we no longer have a single stats buffer for the request queue,
this also removes the sysfs and debugfs stats entries. To replace those,
we add a debugfs entry for the poll statistics.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2017-03-21 15:56:08 +00:00
|
|
|
blk_stat_add_callback(q, rwb->cb);
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
|
|
|
|
return 0;
|
2022-07-20 09:36:16 +00:00
|
|
|
|
|
|
|
err_free:
|
|
|
|
blk_stat_free_callback(rwb->cb);
|
|
|
|
kfree(rwb);
|
|
|
|
return ret;
|
|
|
|
|
blk-wbt: add general throttling mechanism
We can hook this up to the block layer, to help throttle buffered
writes.
wbt registers a few trace points that can be used to track what is
happening in the system:
wbt_lat: 259:0: latency 2446318
wbt_stat: 259:0: rmean=2446318, rmin=2446318, rmax=2446318, rsamples=1,
wmean=518866, wmin=15522, wmax=5330353, wsamples=57
wbt_step: 259:0: step down: step=1, window=72727272, background=8, normal=16, max=32
This shows a sync issue event (wbt_lat) that exceeded it's time. wbt_stat
dumps the current read/write stats for that window, and wbt_step shows a
step down event where we now scale back writes. Each trace includes the
device, 259:0 in this case.
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-11-09 19:36:15 +00:00
|
|
|
}
|