[PATCH -next 2/2] blk-throttle: fix lower control under super low iops limit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Yu Kuai <yukuai3@xxxxxxxxxx>

User will configure allowed iops limit in 1s, and calculate_io_allowed()
will calculate allowed iops in the slice by:

limit * HZ / throtl_slice

However, if limit is quite low, the result can be 0, then
allowed IO in the slice is 0, this will cause missing dispatch and
control will be lower than limit.

For example, set iops_limit to 5 with HD disk, and test will found that
iops will be 3.

This is usually not a big deal, because user will unlikely to configure
such low iops limit, however, this is still a problem in the extreme
scene.

Fix the problem by using MAX_THROTL_SLICE in this case, so that
calculate_io_allowed() is guaranteed not to return 0, since we don't care
about more smoother control effect in this case.

Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
---
 block/blk-throttle.c | 18 ++++++++++++++++++
 block/blk-throttle.h |  6 ++++++
 2 files changed, 24 insertions(+)

diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 69f1bb91ea78..69429288b50b 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -491,6 +491,8 @@ static bool throtl_schedule_next_dispatch(struct throtl_service_queue *sq,
 
 static unsigned int tg_throtl_slice(struct throtl_grp *tg, int rw)
 {
+	if (tg->throtl_slice[rw])
+		return tg->throtl_slice[rw];
 	return tg->td->throtl_slice;
 }
 
@@ -1169,6 +1171,21 @@ static int tg_print_conf_uint(struct seq_file *sf, void *v)
 	return 0;
 }
 
+static void tg_set_throtl_slice(struct throtl_grp *tg)
+{
+	int rw;
+
+	for (rw = READ; rw <= WRITE; rw++) {
+		u32 limit = tg_iops_limit(tg, rw);
+
+		if (limit == UINT_MAX ||
+		    calculate_io_allowed(limit, tg->td->throtl_slice) != 0)
+			tg->throtl_slice[rw] = tg->td->throtl_slice;
+		else
+			tg->throtl_slice[rw] = MAX_THROTL_SLICE;
+	}
+}
+
 static void tg_conf_updated(struct throtl_grp *tg, bool global)
 {
 	struct throtl_service_queue *sq = &tg->service_queue;
@@ -1200,6 +1217,7 @@ static void tg_conf_updated(struct throtl_grp *tg, bool global)
 	}
 	rcu_read_unlock();
 
+	tg_set_throtl_slice(tg);
 	/*
 	 * We're already holding queue_lock and know @tg is valid.  Let's
 	 * apply the new config directly.
diff --git a/block/blk-throttle.h b/block/blk-throttle.h
index 393c3d134b96..0424d2be90ff 100644
--- a/block/blk-throttle.h
+++ b/block/blk-throttle.h
@@ -126,6 +126,12 @@ struct throtl_grp {
 
 	unsigned long last_check_time;
 
+	/*
+	 * This is usually td->throtl_slice, however, if iops limit is quite
+	 * low that allowed io in that slice is 0, throtl_slice in this tg will
+	 * be set to MAX_THROTL_SLICE.
+	 */
+	unsigned int throtl_slice[2];
 	/* When did we start a new slice */
 	unsigned long slice_start[2];
 	unsigned long slice_end[2];
-- 
2.39.2





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux