Message ID | 20250227120645.812815-1-yukuai1@huaweicloud.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v2] blk-throttle: fix lower bps rate by throtl_trim_slice() | expand |
Context | Check | Description |
---|---|---|
shin/vmtest-linus-master-PR | success | PR summary |
shin/vmtest-linus-master-VM_Test-0 | success | Logs for build-kernel |
On Thu, 27 Feb 2025 20:06:45 +0800, Yu Kuai wrote: > The bio submission time may be a few jiffies more than the expected > waiting time, due to 'extra_bytes' can't be divided in > tg_within_bps_limit(), and also due to timer wakeup delay. > In this case, adjust slice_start to jiffies will discard the extra wait time, > causing lower rate than expected. > > Current in-tree code already covers deviation by rounddown(), but turns > out it is not enough, because jiffies - slice_start can be a multiple of > throtl_slice. > > [...] Applied, thanks! [1/1] blk-throttle: fix lower bps rate by throtl_trim_slice() commit: 29cb955934302a5da525db6b327c795572538426 Best regards,
diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 8d149aff9fd0..a52f0d6b40ad 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -599,14 +599,23 @@ static inline void throtl_trim_slice(struct throtl_grp *tg, bool rw) * sooner, then we need to reduce slice_end. A high bogus slice_end * is bad because it does not allow new slice to start. */ - throtl_set_slice_end(tg, rw, jiffies + tg->td->throtl_slice); time_elapsed = rounddown(jiffies - tg->slice_start[rw], tg->td->throtl_slice); - if (!time_elapsed) + /* Don't trim slice until at least 2 slices are used */ + if (time_elapsed < tg->td->throtl_slice * 2) return; + /* + * The bio submission time may be a few jiffies more than the expected + * waiting time, due to 'extra_bytes' can't be divided in + * tg_within_bps_limit(), and also due to timer wakeup delay. In this + * case, adjust slice_start will discard the extra wait time, causing + * lower rate than expected. Therefore, other than the above rounddown, + * one extra slice is preserved for deviation. + */ + time_elapsed -= tg->td->throtl_slice; bytes_trim = calculate_bytes_allowed(tg_bps_limit(tg, rw), time_elapsed) + tg->carryover_bytes[rw];