]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.157/cfq-give-a-chance-for-arming-slice-idle-timer-in-case-of-group_idle.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.157 / cfq-give-a-chance-for-arming-slice-idle-timer-in-case-of-group_idle.patch
1 From b3193bc0dca9bb69c8ba1ec1a318105c76eb4172 Mon Sep 17 00:00:00 2001
2 From: Ritesh Harjani <riteshh@codeaurora.org>
3 Date: Wed, 9 Aug 2017 18:28:32 +0530
4 Subject: cfq: Give a chance for arming slice idle timer in case of group_idle
5
6 From: Ritesh Harjani <riteshh@codeaurora.org>
7
8 commit b3193bc0dca9bb69c8ba1ec1a318105c76eb4172 upstream.
9
10 In below scenario blkio cgroup does not work as per their assigned
11 weights :-
12 1. When the underlying device is nonrotational with a single HW queue
13 with depth of >= CFQ_HW_QUEUE_MIN
14 2. When the use case is forming two blkio cgroups cg1(weight 1000) &
15 cg2(wight 100) and two processes(file1 and file2) doing sync IO in
16 their respective blkio cgroups.
17
18 For above usecase result of fio (without this patch):-
19 file1: (groupid=0, jobs=1): err= 0: pid=685: Thu Jan 1 19:41:49 1970
20 write: IOPS=1315, BW=41.1MiB/s (43.1MB/s)(1024MiB/24906msec)
21 <...>
22 file2: (groupid=0, jobs=1): err= 0: pid=686: Thu Jan 1 19:41:49 1970
23 write: IOPS=1295, BW=40.5MiB/s (42.5MB/s)(1024MiB/25293msec)
24 <...>
25 // both the process BW is equal even though they belong to diff.
26 cgroups with weight of 1000(cg1) and 100(cg2)
27
28 In above case (for non rotational NCQ devices),
29 as soon as the request from cg1 is completed and even
30 though it is provided with higher set_slice=10, because of CFQ
31 algorithm when the driver tries to fetch the request, CFQ expires
32 this group without providing any idle time nor weight priority
33 and schedules another cfq group (in this case cg2).
34 And thus both cfq groups(cg1 & cg2) keep alternating to get the
35 disk time and hence loses the cgroup weight based scheduling.
36
37 Below patch gives a chance to cfq algorithm (cfq_arm_slice_timer)
38 to arm the slice timer in case group_idle is enabled.
39 In case if group_idle is also not required (including for nonrotational
40 NCQ drives), we need to explicitly set group_idle = 0 from sysfs for
41 such cases.
42
43 With this patch result of fio(for above usecase) :-
44 file1: (groupid=0, jobs=1): err= 0: pid=690: Thu Jan 1 00:06:08 1970
45 write: IOPS=1706, BW=53.3MiB/s (55.9MB/s)(1024MiB/19197msec)
46 <..>
47 file2: (groupid=0, jobs=1): err= 0: pid=691: Thu Jan 1 00:06:08 1970
48 write: IOPS=1043, BW=32.6MiB/s (34.2MB/s)(1024MiB/31401msec)
49 <..>
50 // In this processes BW is as per their respective cgroups weight.
51
52 Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
53 Signed-off-by: Jens Axboe <axboe@kernel.dk>
54 Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
55 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
56
57 ---
58 block/cfq-iosched.c | 3 ++-
59 1 file changed, 2 insertions(+), 1 deletion(-)
60
61 --- a/block/cfq-iosched.c
62 +++ b/block/cfq-iosched.c
63 @@ -2905,7 +2905,8 @@ static void cfq_arm_slice_timer(struct c
64 * for devices that support queuing, otherwise we still have a problem
65 * with sync vs async workloads.
66 */
67 - if (blk_queue_nonrot(cfqd->queue) && cfqd->hw_tag)
68 + if (blk_queue_nonrot(cfqd->queue) && cfqd->hw_tag &&
69 + !cfqd->cfq_group_idle)
70 return;
71
72 WARN_ON(!RB_EMPTY_ROOT(&cfqq->sort_list));