From patchwork Tue Aug 28 20:13:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 145357 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp1589047ljw; Tue, 28 Aug 2018 13:13:34 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY+L7rK43BCwtjA/eU6qr7FEZiJdmVe0nj7M8YUm/S/TY5AZBadOzAq1wf6vc6+7z5TqxMG X-Received: by 2002:aa7:82c3:: with SMTP id f3-v6mr3018821pfn.136.1535487214645; Tue, 28 Aug 2018 13:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535487214; cv=none; d=google.com; s=arc-20160816; b=yOWv3cpCF7QNZVuW1B9hxd2ENvKXxy8IkDvFl8rab3xq0ByW6LBAhR8lluetF95TPX rtbkEy7RCLoc16t4arN+RiLtyF1BAE+6S+Aq+S72VpI3NlcLrDeZTA8QvLjkNGLbHURL HdinTyct2ms45LKMzl3dXvxXYC3w42VUrj5SUsWhvIuS4y/6jmCjh/mtgrgLH4Z4AAZI UGH2btteqKZtaxJfZb/x86oGClHIY2Zkiib6NP34JY4/pNLncR2DfX3hRyflHgAtKIsi yCxIW6mJz9n3cG9BqMa9cRj4IeUre8GqVzSzAHye/zFBAXUcwp+PYgzm+8S0IWQ4dMmh 6VnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=uTxbwUJmgHgwa7qp/t6pD6Zjr61gDIpQmZVcGnDL6DQ=; b=ukEtuYaeGNP5gJa6Mu4CxtbdDDTu6yC7gq7E8a1jYPRb/SV10dXaa/7SgqCh1/9djD yYDTODyk5GIV6D0NpLDSx/EDzLsWduqw4FqG2mE+e0PuabD+aSHMphdgyWTYzAn3GD+H YuRnGWaOtMHld68V+rRERV+uGdbBpnnfJAwNH71GQlQwZjNAntdDaT3L+gSyl4HcHv6p mHFDRAwUoSaYBA2VkqlVwXXvPtQVbGG9+g/8LkBZPwiMpj26mDsS3lNJvYOsKAc1lfuJ 74p/4+M68x0LVoxSMD705v2B9pyYI6TM/cHQXRHfUScl5vC3RbtNnmoBE2oWDGPaytme 2+Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dvMGoOCI; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10-v6si1906969pgf.312.2018.08.28.13.13.34; Tue, 28 Aug 2018 13:13:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dvMGoOCI; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727054AbeH2AGr (ORCPT + 13 others); Tue, 28 Aug 2018 20:06:47 -0400 Received: from mail-pg1-f179.google.com ([209.85.215.179]:33736 "EHLO mail-pg1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726961AbeH2AGr (ORCPT ); Tue, 28 Aug 2018 20:06:47 -0400 Received: by mail-pg1-f179.google.com with SMTP id y3-v6so21784pgv.0 for ; Tue, 28 Aug 2018 13:13:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uTxbwUJmgHgwa7qp/t6pD6Zjr61gDIpQmZVcGnDL6DQ=; b=dvMGoOCIwF9JUk0E+18pCiYrK/i5PuY6bYenMAYYwvX+fk54WVdTMzbO1W79ncshTM qrq2/ywHoAj0rtVp//0+uvZFBf00n72RjiOUcGJ4trrRi8FMtf+AC45kNwkEt7n07sU2 op7tGy9nElWruzK9mqrqlFis2LZ4BQBK70AqM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uTxbwUJmgHgwa7qp/t6pD6Zjr61gDIpQmZVcGnDL6DQ=; b=pHPE5uN7vsMCSJVlPJLyemXBuIAjtMkMQg9wlBsjqri5T0yG9exnv63/iYup28hiBQ wCng1TOEJTka5mqrA1vyaEVN/p4aRd+aI0rtLHgmHX3vl1PpQ6RJw/5jd/nV67h+qKmH Px0TbZkZaTciyN1BXSs4s+oI/NdEOMzpjBVQ5zkMoP2bmgqTLKQULiUTGI8fJ5k1IJmV m+ZG9L4qppsdwzSwyXt29qp1rlQHnfwh7t6i4j5uguRZbhGYkv1PmQ9Fr8zDK2bOg78j xGJ4li0sxAEkTTwEcdL4LMkwviFPDKvlwLjAhmfllPIAcDSKLtcbFQFMW50KdKIw/sF7 XBaA== X-Gm-Message-State: APzg51CKESbjAb47lApIL9XjVrkn8FLrb1enUbCWkDtA/ryXjbirS0c2 ERcGVvLbvoebMeVTDiIn9Cf6IqYhU6s= X-Received: by 2002:a62:444d:: with SMTP id r74-v6mr2961078pfa.96.1535487212509; Tue, 28 Aug 2018 13:13:32 -0700 (PDT) Received: from localhost.localdomain ([49.207.48.21]) by smtp.gmail.com with ESMTPSA id t86-v6sm3098181pfe.109.2018.08.28.13.13.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Aug 2018 13:13:31 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Ritesh Harjani , Jens Axboe Subject: [PATCH for-4.9.y 01/14] cfq: Give a chance for arming slice idle timer in case of group_idle Date: Wed, 29 Aug 2018 01:43:12 +0530 Message-Id: <1535487205-26280-2-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535487205-26280-1-git-send-email-amit.pundir@linaro.org> References: <1535487205-26280-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Ritesh Harjani commit b3193bc0dca9bb69c8ba1ec1a318105c76eb4172 upstream. In below scenario blkio cgroup does not work as per their assigned weights :- 1. When the underlying device is nonrotational with a single HW queue with depth of >= CFQ_HW_QUEUE_MIN 2. When the use case is forming two blkio cgroups cg1(weight 1000) & cg2(wight 100) and two processes(file1 and file2) doing sync IO in their respective blkio cgroups. For above usecase result of fio (without this patch):- file1: (groupid=0, jobs=1): err= 0: pid=685: Thu Jan 1 19:41:49 1970 write: IOPS=1315, BW=41.1MiB/s (43.1MB/s)(1024MiB/24906msec) <...> file2: (groupid=0, jobs=1): err= 0: pid=686: Thu Jan 1 19:41:49 1970 write: IOPS=1295, BW=40.5MiB/s (42.5MB/s)(1024MiB/25293msec) <...> // both the process BW is equal even though they belong to diff. cgroups with weight of 1000(cg1) and 100(cg2) In above case (for non rotational NCQ devices), as soon as the request from cg1 is completed and even though it is provided with higher set_slice=10, because of CFQ algorithm when the driver tries to fetch the request, CFQ expires this group without providing any idle time nor weight priority and schedules another cfq group (in this case cg2). And thus both cfq groups(cg1 & cg2) keep alternating to get the disk time and hence loses the cgroup weight based scheduling. Below patch gives a chance to cfq algorithm (cfq_arm_slice_timer) to arm the slice timer in case group_idle is enabled. In case if group_idle is also not required (including for nonrotational NCQ drives), we need to explicitly set group_idle = 0 from sysfs for such cases. With this patch result of fio(for above usecase) :- file1: (groupid=0, jobs=1): err= 0: pid=690: Thu Jan 1 00:06:08 1970 write: IOPS=1706, BW=53.3MiB/s (55.9MB/s)(1024MiB/19197msec) <..> file2: (groupid=0, jobs=1): err= 0: pid=691: Thu Jan 1 00:06:08 1970 write: IOPS=1043, BW=32.6MiB/s (34.2MB/s)(1024MiB/31401msec) <..> // In this processes BW is as per their respective cgroups weight. Signed-off-by: Ritesh Harjani Signed-off-by: Jens Axboe Signed-off-by: Amit Pundir --- To be applied on 4.4.y and 3.18.y as well. Build tested on v4.4.153 and v3.18.120. block/cfq-iosched.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index c7c3d4e6bc27..b2dc1c1f08c6 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -2951,7 +2951,8 @@ static void cfq_arm_slice_timer(struct cfq_data *cfqd) * for devices that support queuing, otherwise we still have a problem * with sync vs async workloads. */ - if (blk_queue_nonrot(cfqd->queue) && cfqd->hw_tag) + if (blk_queue_nonrot(cfqd->queue) && cfqd->hw_tag && + !cfqd->cfq_group_idle) return; WARN_ON(!RB_EMPTY_ROOT(&cfqq->sort_list));