From patchwork Mon Sep 10 20:49:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10594769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A128920 for ; Mon, 10 Sep 2018 20:49:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2848F2933C for ; Mon, 10 Sep 2018 20:49:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C74A2933F; Mon, 10 Sep 2018 20:49:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B10D62933C for ; Mon, 10 Sep 2018 20:49:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726795AbeIKBp3 (ORCPT ); Mon, 10 Sep 2018 21:45:29 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:46268 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbeIKBp3 (ORCPT ); Mon, 10 Sep 2018 21:45:29 -0400 Received: by mail-qt0-f194.google.com with SMTP id l42-v6so592383qtf.13 for ; Mon, 10 Sep 2018 13:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=eNUbdBOi2Xavy3NzQlbS2LAhHU+z6BEBPjelYt/pLas=; b=ZFs3IQGw64IcGfQTsZF7vebqFYWvj8UJS6B/b0k6hvlr6QeFPhjXjfJdeXZjkrV7Oh itpwA3VSn8iIoggQRd8VoFzNv+b/Ml7jvyWZoTaU5pmBY8T/VpzALh8OZR7OVZS6oroN hT4DFmGwCnAEJkLIFZNptTl/3vlijPrkva9aq2lzlU16/H1idLi3hsYHyXRuHBDe3jJl HQ7dchRlx3IU+Qt1O5vGrQdC/q9x9ZsDchufUuEHBFUkWe68X1r2BUZNSiLLfXsSRcAO bmzfP1p2793p7EgK72YQKfZJhKkSyiv3OubW7SSq4bMNSa6vCO//7Irbwxkh7nuyMv1r a/dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=eNUbdBOi2Xavy3NzQlbS2LAhHU+z6BEBPjelYt/pLas=; b=Tj+xfQc640qgfKnjP+U6GOQH7Q9Y30uekrMRIMu7p0cOoUOJxIa+Els46VIXqVIxh8 WhlAzWpDy6dhwO4ZB9G+k+mRzHIZnxxv6iT+O8qL484rUj2zaKxeh0cpti56n2A+BnxS qq9YPo6nh99vcZwSmjj/9FIr+HUSu7+BELwhf7Sk+Zw4EVwBAw9LCl2YOT+Ex3V9fOrW pc6DMXyIRBndrWaF8PT4EVyOxy1GymbXko6iDVD4RIBGuf/K2QM7YReg3Gz+m9R+VBqH /P7T0d4l4qv9IywQ8WMgdxBp7LAc25vuPCs/ECeWjr67qKELvtZg5SF/auEI19OKuWOm xpug== X-Gm-Message-State: APzg51AeBfuCF3zewo7uF/awIMmWbtKZ2Pd3Bu9hHgAEuB6MOPyRA+Rn nPrLuFzz9L01bKKVmlB+WkwKQw== X-Google-Smtp-Source: ANB0VdasccWiRvY4tjieQ0bzbjRD9ABCVX+b213+DXq9p6CUCAsFU4ESlBAYi6eNB8SMfs2lHK1mQg== X-Received: by 2002:ac8:5216:: with SMTP id r22-v6mr17474360qtn.78.1536612576842; Mon, 10 Sep 2018 13:49:36 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id t17-v6sm11670330qtj.50.2018.09.10.13.49.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Sep 2018 13:49:35 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, kernel-team@fb.com, linux-block@vger.kernel.org Subject: [PATCH 1/6] blk-iolatency: use q->nr_requests directly Date: Mon, 10 Sep 2018 16:49:27 -0400 Message-Id: <20180910204932.14323-2-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180910204932.14323-1-josef@toxicpanda.com> References: <20180910204932.14323-1-josef@toxicpanda.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We were using blk_queue_depth() assuming that it would return nr_requests, but we hit a case in production on drives that had to have NCQ turned off in order for them to not shit the bed which resulted in a qd of 1, even though the nr_requests was much larger. iolatency really only cares about requests we are allowed to queue up, as any io that get's onto the request list is going to be serviced soonish, so we want to be throttling before the bio gets onto the request list. To make iolatency work as expected, simply use q->nr_requests instead of blk_queue_depth() as that is what we actually care about. Signed-off-by: Josef Bacik --- block/blk-iolatency.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index 19923f8a029d..9b8d2012ea88 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -255,7 +255,7 @@ static void scale_cookie_change(struct blk_iolatency *blkiolat, struct child_latency_info *lat_info, bool up) { - unsigned long qd = blk_queue_depth(blkiolat->rqos.q); + unsigned long qd = blkiolat->rqos.q->nr_requests; unsigned long scale = scale_amount(qd, up); unsigned long old = atomic_read(&lat_info->scale_cookie); unsigned long max_scale = qd << 1; @@ -295,7 +295,7 @@ static void scale_cookie_change(struct blk_iolatency *blkiolat, */ static void scale_change(struct iolatency_grp *iolat, bool up) { - unsigned long qd = blk_queue_depth(iolat->blkiolat->rqos.q); + unsigned long qd = iolat->blkiolat->rqos.q->nr_requests; unsigned long scale = scale_amount(qd, up); unsigned long old = iolat->rq_depth.max_depth; bool changed = false; @@ -884,7 +884,7 @@ static void iolatency_pd_init(struct blkg_policy_data *pd) rq_wait_init(&iolat->rq_wait); spin_lock_init(&iolat->child_lat.lock); - iolat->rq_depth.queue_depth = blk_queue_depth(blkg->q); + iolat->rq_depth.queue_depth = blkg->q->nr_requests; iolat->rq_depth.max_depth = UINT_MAX; iolat->rq_depth.default_depth = iolat->rq_depth.queue_depth; iolat->blkiolat = blkiolat; From patchwork Mon Sep 10 20:49:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10594771 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1280920 for ; Mon, 10 Sep 2018 20:49:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E225E2933C for ; Mon, 10 Sep 2018 20:49:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D61D12933F; Mon, 10 Sep 2018 20:49:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 886522933C for ; Mon, 10 Sep 2018 20:49:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726800AbeIKBpb (ORCPT ); Mon, 10 Sep 2018 21:45:31 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:33002 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbeIKBpb (ORCPT ); Mon, 10 Sep 2018 21:45:31 -0400 Received: by mail-qt0-f195.google.com with SMTP id r37-v6so25905280qtc.0 for ; Mon, 10 Sep 2018 13:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=mdb+zhmKePGqRxzXN1yXTDUiFJgfKxt1Fifg1WJguyE=; b=IWkt5gzPdmuLN7TuzwsPFdL/91uMUPQrxoWLGqXaN2UTaMfyEG9pHa9qbuLP3MO1oU ywDdnvKJn/z/B6FTO49f5XUd7pWwpLYMXvZJ4/hE394y5jm1mUZ3Hp/ZBRldcdBFGlbN Jd/FdWo1TxBWkmwqVLlkREBprsk5fL6dt9y7fIVwalYdjsDr3S2XhaGDEqwhJiEZZEQY WP2RpKybl51gID1W3Cwm9WC2isPZT+2ATrLoDLRY1giSq4vtA87pfwL3G3Xept6M6Rq9 xGly+8Rp2q6Avz9Q0cNf4KA8mK32EEqX4HWuSy180N6H0jJfOArOuxyIEvi+PLaUlB7N Ju6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=mdb+zhmKePGqRxzXN1yXTDUiFJgfKxt1Fifg1WJguyE=; b=V7zJ93a0Ryo0t8+OKimOdlpV8TJwchX2tUWJm8acTYSvveC2X4LRcyMoEgnIu/W8hX FnqFuLvqkz4jTfzUBP4YtXzW7DYptrKK0MQFs5bI0Wv5oeWdURgnbQEEdVF3VjsHuM1y cGnUt1oWoGlk+PfF++If8j6dHqu5x9cpUZ9hhcVDJlzYe/hBLXp/E7k4go1CvdbFCujN jIbeaFcoj5cGZ3KcGIEuAwHQQYMAVyrRa3HZAx5Yimyc0Ww3Ca8DeBv0SzeHxWVCQYRh zHPiZPHhUgbdNDkd1acdy9ASl0K7ZwdbuRauIlmqlbbd1HlW4gEZhvOSMJ5xGsnqoSi6 ozgg== X-Gm-Message-State: APzg51D+agfNgd8gPczXbPu3CVm/AScWaaQfFoEgoL4TS9laKtTIC1vG Xh84+5HY3oecVA/UyuEk6ajidg== X-Google-Smtp-Source: ANB0VdZyCrtNc0Jer62E+z+pfgPEFev73/auYJCwMiG/UEADqrUG/dorkxlrvtfnoTIwAGrM29G4Bg== X-Received: by 2002:ac8:1c89:: with SMTP id f9-v6mr17784750qtl.265.1536612578833; Mon, 10 Sep 2018 13:49:38 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id 62-v6sm10255033qkx.66.2018.09.10.13.49.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Sep 2018 13:49:37 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, kernel-team@fb.com, linux-block@vger.kernel.org Subject: [PATCH 2/6] blk-iolatency: delete changed variable Date: Mon, 10 Sep 2018 16:49:28 -0400 Message-Id: <20180910204932.14323-3-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180910204932.14323-1-josef@toxicpanda.com> References: <20180910204932.14323-1-josef@toxicpanda.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This was from a previous iteration when we returned whether or not we changed the scale. It is unused so remove it. Signed-off-by: Josef Bacik --- block/blk-iolatency.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index 9b8d2012ea88..8f32aa1817f8 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -298,7 +298,6 @@ static void scale_change(struct iolatency_grp *iolat, bool up) unsigned long qd = iolat->blkiolat->rqos.q->nr_requests; unsigned long scale = scale_amount(qd, up); unsigned long old = iolat->rq_depth.max_depth; - bool changed = false; if (old > qd) old = qd; @@ -308,7 +307,6 @@ static void scale_change(struct iolatency_grp *iolat, bool up) return; if (old < qd) { - changed = true; old += scale; old = min(old, qd); iolat->rq_depth.max_depth = old; @@ -316,7 +314,6 @@ static void scale_change(struct iolatency_grp *iolat, bool up) } } else if (old > 1) { old >>= 1; - changed = true; iolat->rq_depth.max_depth = max(old, 1UL); } } From patchwork Mon Sep 10 20:49:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10594773 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67735920 for ; Mon, 10 Sep 2018 20:49:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56AE02933E for ; Mon, 10 Sep 2018 20:49:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B41E29348; Mon, 10 Sep 2018 20:49:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F404F2933E for ; Mon, 10 Sep 2018 20:49:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726811AbeIKBpd (ORCPT ); Mon, 10 Sep 2018 21:45:33 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:33007 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbeIKBpd (ORCPT ); Mon, 10 Sep 2018 21:45:33 -0400 Received: by mail-qt0-f195.google.com with SMTP id r37-v6so25905412qtc.0 for ; Mon, 10 Sep 2018 13:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=bGm/kb/2sQboIQdXNK6Af8m1JWQFRFqyz4BMP+GYUg8=; b=hAFxPHD67sbRUQdK7l7PNni+/CkdwglJ2uO5vBZAGCcJUoK6sHK5Awy69N82iKQ46D k5yJ0ctR0MThtbvC2MzonY8MnONSyMbezETbfkLbA5P+ncQm/DW+LJxL5YoCgF4OG1S/ 2at+shF9JJ96TNAHFsqeKkcoEoIJw6p5uW7j+wyymIZw5Sckg3s1RxIB8JzNsUO9Jnrn r7Y6YDquxvUlqqgjT56c6s2Hm7AvTP9mKGqn03v2vqUJ65cIBvNAJgnrK/uTsNA9R0OU ir7V/UScJCXRTopPX7kM8iQ4z7ERQsKbvVGOeEbIuz3SbkT+BV0BAulg7sD58UligETw 56Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=bGm/kb/2sQboIQdXNK6Af8m1JWQFRFqyz4BMP+GYUg8=; b=mQMp+QHB47cWNsQe4Nmm3kXM8G+OAm/cH7tPaR8/7iL/QqJD478sfogF/jX4oamXQP 8D2UF+6VlkQawnckl2A6AfAW830tE3ZVvmtvSDlc+HF0FwEAg0AEWZ+r7SHJWjgt/AjF beomR3XDSCDrl6gPc0G/SKpr+TpVIcSO1/ynd2RoPjSqmvofSwOjAucxx4c11gQhFEp+ 5k2UmcRpphQtRa3xS1oK7XyM0xbYth0T+MfawIprl5/J9lnQy76UotT7A3kl8pYBw31R YJhL22Bkoh84meZUq+A7vG9QZwOMkqP8gbF/o0uDXatdme/uIpMkTc07yUJws0QzD0gP KxBA== X-Gm-Message-State: APzg51BfEzsX4pBKF9HIy1loZeE7t0D7NJgrwNea2xPsE/lZGv/bICYV +ysgbuJ7KlRRUoBhnw/nA1MysbJYQTsZ1A== X-Google-Smtp-Source: ANB0VdZXQZoRkyzR8InwJQ1IuCST/HuxlfzGWATlmo59BavqDfwQiCJygbGKmXVh3ULZ4kOTIfAzkg== X-Received: by 2002:ac8:13c3:: with SMTP id i3-v6mr18023091qtj.54.1536612580635; Mon, 10 Sep 2018 13:49:40 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id k15-v6sm13039398qtf.95.2018.09.10.13.49.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Sep 2018 13:49:39 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, kernel-team@fb.com, linux-block@vger.kernel.org Subject: [PATCH 3/6] blk-iolatency: deal with nr_requests == 1 Date: Mon, 10 Sep 2018 16:49:29 -0400 Message-Id: <20180910204932.14323-4-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180910204932.14323-1-josef@toxicpanda.com> References: <20180910204932.14323-1-josef@toxicpanda.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hitting the case where blk_queue_depth() returned 1 uncovered the fact that iolatency doesn't actually handle this case properly, it simply doesn't scale down anybody. For this case we should go straight into applying the time delay, which we weren't doing. Since we already limit the floor at 1 request this if statement is not needed, and this allows us to set our depth to 1 which allows us to apply the delay if needed. Signed-off-by: Josef Bacik --- block/blk-iolatency.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index 8f32aa1817f8..4ed05d09a69e 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -312,7 +312,7 @@ static void scale_change(struct iolatency_grp *iolat, bool up) iolat->rq_depth.max_depth = old; wake_up_all(&iolat->rq_wait.wait); } - } else if (old > 1) { + } else { old >>= 1; iolat->rq_depth.max_depth = max(old, 1UL); } From patchwork Mon Sep 10 20:49:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10594775 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 891C113B8 for ; Mon, 10 Sep 2018 20:49:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 785BC2933C for ; Mon, 10 Sep 2018 20:49:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CF3D2933F; Mon, 10 Sep 2018 20:49:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1EBA72933C for ; Mon, 10 Sep 2018 20:49:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726816AbeIKBpf (ORCPT ); Mon, 10 Sep 2018 21:45:35 -0400 Received: from mail-qk1-f174.google.com ([209.85.222.174]:43675 "EHLO mail-qk1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbeIKBpf (ORCPT ); Mon, 10 Sep 2018 21:45:35 -0400 Received: by mail-qk1-f174.google.com with SMTP id 130-v6so15364049qkd.10 for ; Mon, 10 Sep 2018 13:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=Uf4CTQmf00QlbJ2l5r3kflmxEntcHqk8KbXKgTr9kiw=; b=AY+P6Kz3ca4oiC2qtCUMuAryU3TDYKrd4KyJkKBH3UqiaO8aSv7hnUMU8aYyb3BhGY P1+apB5ppdjlur8CkRFHksVfetAVlTf8kwdRCgNhahPo8jdkHWGa9wcuhj+TaleoQo78 ro7m7s4KGKBLm1PVtDLMgg+Kxqe1UcolJEhbXjr5v5STmSjrdQyKeUDklTz008wc21Y3 VaiAwzeL9YhUtNVXhxzNq64V5C556QzTNl4PGRzK0UkNI1n0GpbO2ZRvU1vR7tsvZFjI twx9GcMtUpsXSTQyTcXDQJyAjdaopNXIHPIog8z/YL8y0bpluhBNsCqnz3zqLTJUBLje c3HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Uf4CTQmf00QlbJ2l5r3kflmxEntcHqk8KbXKgTr9kiw=; b=QV+RNKniwyp3rFiv1mZYcj/1iByf5QHFP4RqchTdYpxOpAVQWEqi+lErfPQHdKy05w DEkoTykBnAQdqb/NC0kvOSAWxcKIryde9xQQ5C/5dUAbnV92hDVnlUprrthVUy925iF+ Iw4eFUUvbTigyjrIJUqff8D3+K6rDGtSYY1daUly4mscv4lYabedk7idEEyuGs/Jrawh DTBBkzTdeCuT05TK0hNFsDo4gydSl4/hn8fA8Sjzrx3AMveZzvDl3cXHvxkm9w0FLWcR PlkWjYkKyTZJgfWO8rhu3KwGm5pEEVm5ZJFxiQICS/KPMcX2C3gWAjJS480UL/tWTI1X yuHw== X-Gm-Message-State: APzg51BJ/NQkiKZDErKZ+Hnjg/e+3ZzsK9bCq32+b6ZB1aLB122u+VBV 1Yu8Smga6GvehDMOTLTCaWqIvlfon+fD8g== X-Google-Smtp-Source: ANB0VdbSc4GL90Dfx1EpS46moAr39X99cFEblKkhk2dAj3ZecqbKvtB8dL+7pSAo0tT0peaIYAGeZQ== X-Received: by 2002:a37:c993:: with SMTP id m19-v6mr689613qkl.248.1536612582395; Mon, 10 Sep 2018 13:49:42 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id i125-v6sm9462979qke.36.2018.09.10.13.49.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Sep 2018 13:49:41 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, kernel-team@fb.com, linux-block@vger.kernel.org Subject: [PATCH 4/6] blk-iolatency: deal with small samples Date: Mon, 10 Sep 2018 16:49:30 -0400 Message-Id: <20180910204932.14323-5-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180910204932.14323-1-josef@toxicpanda.com> References: <20180910204932.14323-1-josef@toxicpanda.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is logic to keep cgroups that haven't done a lot of IO in the most recent scale window from being punished for over-active higher priority groups. However for things like ssd's where the windows are pretty short we'll end up with small numbers of samples, so 5% of samples will come out to 0 if there aren't enough. Make the floor 1 sample to keep us from improperly bailing out of scaling down. Signed-off-by: Josef Bacik --- block/blk-iolatency.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index 4ed05d09a69e..ca545991df83 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -366,7 +366,7 @@ static void check_scale_change(struct iolatency_grp *iolat) * scale down event. */ samples_thresh = lat_info->nr_samples * 5; - samples_thresh = div64_u64(samples_thresh, 100); + samples_thresh = max(1ULL, div64_u64(samples_thresh, 100)); if (iolat->nr_samples <= samples_thresh) return; } From patchwork Mon Sep 10 20:49:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10594777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E34113B8 for ; Mon, 10 Sep 2018 20:49:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C7CF2933C for ; Mon, 10 Sep 2018 20:49:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EAAA2933F; Mon, 10 Sep 2018 20:49:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43D832933C for ; Mon, 10 Sep 2018 20:49:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726735AbeIKBph (ORCPT ); Mon, 10 Sep 2018 21:45:37 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:34172 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbeIKBph (ORCPT ); Mon, 10 Sep 2018 21:45:37 -0400 Received: by mail-qt0-f196.google.com with SMTP id m13-v6so25970341qth.1 for ; Mon, 10 Sep 2018 13:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=kR0ojdbVKj4N0tYPEYhRiCZN1NOOHeFfJT1eqf5ZRZM=; b=ABpOnrW0FCxTn/fKxbcWi5/9UBrddxoLojoe/I6dLY8KI+wXHaWZBAqtPkfV09z0IY gtP6E5dml9Ps9vIO4TUqrGO14MHFQg14Sg+wvpE2XCiTWhHb4VGTvPTk0s/8tBYSUfq4 hJIZE0fezAlMf7z4ST6yTDs+m6h3n1AjaU8vwiPPR35Bk33CzeXEZo4iY+ktiMyyVmWH WmJBQLWkwsiHvyLTSuUgeEP8nqMNEaNS8vy8SCGrrea5q/B0IQ6D4LQyWeh3kCUsZVim EB2JceBoNGA1gAzVvzNzn5041Ype5IWrKeFp/VRjn9+v8smLS/Xp1Jl/Fa8BGqY0ohGE 8o3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=kR0ojdbVKj4N0tYPEYhRiCZN1NOOHeFfJT1eqf5ZRZM=; b=g+vWAuy2XAHm2wJGA1KuCKPIRk53Fg8IBpI3od7/VCGvA70vxoKU6eLLXCnh7SQRsy WJYWaQqhtb7dKAvBsmQTOy5NSWDj5fz9FDkjqERccOQVt9HYavQW3mIR9srbPYCtHf1i +rzkE8zowQQcbLpET3ynpea0srjaZmF55rwPS/J0+TH15KHeI02KaC2076Ybil+kxhBp j+ZE/qtiASbWaUACXLwL5tH0EX9IfbuzDkUrvJpIW6NQgDuEMmMkubF6sIe/Z2l+NGoL FRzsQlhZxbrSb8bxuuF7zuEaiAcBVpIYpqeWNnDPNicdj3p7mf0rkLVGEtes/Kp9CZA9 ycEw== X-Gm-Message-State: APzg51C6hKllnT+XWOlKXe/yylf96+HbzEGN7OQL5+WIUnCTa+xjvxCZ pkPj7zyvb9NXiTSA17FbAAblnQ== X-Google-Smtp-Source: ANB0VdbsORZ7Vkf9ams+YcZIROmMe5lfaeUOSBfwjP+gfX6NCM7yvtfkYdIkMOfjSdAWF99jo25Utg== X-Received: by 2002:ac8:3983:: with SMTP id v3-v6mr5598571qte.246.1536612584181; Mon, 10 Sep 2018 13:49:44 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id u129-v6sm9401579qkd.45.2018.09.10.13.49.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Sep 2018 13:49:43 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, kernel-team@fb.com, linux-block@vger.kernel.org Subject: [PATCH 5/6] blk-iolatency: use a percentile approache for ssd's Date: Mon, 10 Sep 2018 16:49:31 -0400 Message-Id: <20180910204932.14323-6-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180910204932.14323-1-josef@toxicpanda.com> References: <20180910204932.14323-1-josef@toxicpanda.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We use an average latency approach for determining if we're missing our latency target. This works well for rotational storage where we have generally consistent latencies, but for ssd's and other low latency devices you have more of a spikey behavior, which means we often won't throttle misbehaving groups because a lot of IO completes at drastically faster times than our latency target. Instead keep track of how many IO's miss our target and how many IO's are done in our time window. If the p(90) latency is above our target then we know we need to throttle. With this change in place we are seeing the same throttling behavior with our testcase on ssd's as we see with rotational drives. Signed-off-by: Josef Bacik --- block/blk-iolatency.c | 179 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 145 insertions(+), 34 deletions(-) diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index ca545991df83..e36b949a5696 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -115,9 +115,21 @@ struct child_latency_info { atomic_t scale_cookie; }; +struct percentile_stats { + u64 total; + u64 missed; +}; + +struct latency_stat { + union { + struct percentile_stats ps; + struct blk_rq_stat rqs; + }; +}; + struct iolatency_grp { struct blkg_policy_data pd; - struct blk_rq_stat __percpu *stats; + struct latency_stat __percpu *stats; struct blk_iolatency *blkiolat; struct rq_depth rq_depth; struct rq_wait rq_wait; @@ -132,6 +144,7 @@ struct iolatency_grp { /* Our current number of IO's for the last summation. */ u64 nr_samples; + bool ssd; struct child_latency_info child_lat; }; @@ -172,6 +185,80 @@ static inline struct blkcg_gq *lat_to_blkg(struct iolatency_grp *iolat) return pd_to_blkg(&iolat->pd); } +static inline void latency_stat_init(struct iolatency_grp *iolat, + struct latency_stat *stat) +{ + if (iolat->ssd) { + stat->ps.total = 0; + stat->ps.missed = 0; + } else + blk_rq_stat_init(&stat->rqs); +} + +static inline void latency_stat_sum(struct iolatency_grp *iolat, + struct latency_stat *sum, + struct latency_stat *stat) +{ + if (iolat->ssd) { + sum->ps.total += stat->ps.total; + sum->ps.missed += stat->ps.missed; + } else + blk_rq_stat_sum(&sum->rqs, &stat->rqs); +} + +static inline void latency_stat_record_time(struct iolatency_grp *iolat, + u64 req_time) +{ + struct latency_stat *stat = get_cpu_ptr(iolat->stats); + if (iolat->ssd) { + if (req_time >= iolat->min_lat_nsec) + stat->ps.missed++; + stat->ps.total++; + } else + blk_rq_stat_add(&stat->rqs, req_time); + put_cpu_ptr(stat); +} + +static inline bool latency_sum_ok(struct iolatency_grp *iolat, + struct latency_stat *stat) +{ + if (iolat->ssd) { + u64 thresh = div64_u64(stat->ps.total, 10); + thresh = max(thresh, 1ULL); + return stat->ps.missed < thresh; + } + return stat->rqs.mean <= iolat->min_lat_nsec; +} + +static inline u64 latency_stat_samples(struct iolatency_grp *iolat, + struct latency_stat *stat) +{ + if (iolat->ssd) + return stat->ps.total; + return stat->rqs.nr_samples; +} + +static inline void iolat_update_total_lat_avg(struct iolatency_grp *iolat, + struct latency_stat *stat) +{ + int exp_idx; + + if (iolat->ssd) + return; + + /* + * CALC_LOAD takes in a number stored in fixed point representation. + * Because we are using this for IO time in ns, the values stored + * are significantly larger than the FIXED_1 denominator (2048). + * Therefore, rounding errors in the calculation are negligible and + * can be ignored. + */ + exp_idx = min_t(int, BLKIOLATENCY_NR_EXP_FACTORS - 1, + div64_u64(iolat->cur_win_nsec, + BLKIOLATENCY_EXP_BUCKET_SIZE)); + CALC_LOAD(iolat->lat_avg, iolatency_exp_factors[exp_idx], stat->rqs.mean); +} + static inline bool iolatency_may_queue(struct iolatency_grp *iolat, wait_queue_entry_t *wait, bool first_block) @@ -440,7 +527,6 @@ static void iolatency_record_time(struct iolatency_grp *iolat, struct bio_issue *issue, u64 now, bool issue_as_root) { - struct blk_rq_stat *rq_stat; u64 start = bio_issue_time(issue); u64 req_time; @@ -466,9 +552,7 @@ static void iolatency_record_time(struct iolatency_grp *iolat, return; } - rq_stat = get_cpu_ptr(iolat->stats); - blk_rq_stat_add(rq_stat, req_time); - put_cpu_ptr(rq_stat); + latency_stat_record_time(iolat, req_time); } #define BLKIOLATENCY_MIN_ADJUST_TIME (500 * NSEC_PER_MSEC) @@ -479,17 +563,17 @@ static void iolatency_check_latencies(struct iolatency_grp *iolat, u64 now) struct blkcg_gq *blkg = lat_to_blkg(iolat); struct iolatency_grp *parent; struct child_latency_info *lat_info; - struct blk_rq_stat stat; + struct latency_stat stat; unsigned long flags; - int cpu, exp_idx; + int cpu; - blk_rq_stat_init(&stat); + latency_stat_init(iolat, &stat); preempt_disable(); for_each_online_cpu(cpu) { - struct blk_rq_stat *s; + struct latency_stat *s; s = per_cpu_ptr(iolat->stats, cpu); - blk_rq_stat_sum(&stat, s); - blk_rq_stat_init(s); + latency_stat_sum(iolat, &stat, s); + latency_stat_init(iolat, s); } preempt_enable(); @@ -499,41 +583,33 @@ static void iolatency_check_latencies(struct iolatency_grp *iolat, u64 now) lat_info = &parent->child_lat; - /* - * CALC_LOAD takes in a number stored in fixed point representation. - * Because we are using this for IO time in ns, the values stored - * are significantly larger than the FIXED_1 denominator (2048). - * Therefore, rounding errors in the calculation are negligible and - * can be ignored. - */ - exp_idx = min_t(int, BLKIOLATENCY_NR_EXP_FACTORS - 1, - div64_u64(iolat->cur_win_nsec, - BLKIOLATENCY_EXP_BUCKET_SIZE)); - CALC_LOAD(iolat->lat_avg, iolatency_exp_factors[exp_idx], stat.mean); + iolat_update_total_lat_avg(iolat, &stat); /* Everything is ok and we don't need to adjust the scale. */ - if (stat.mean <= iolat->min_lat_nsec && + if (latency_sum_ok(iolat, &stat) && atomic_read(&lat_info->scale_cookie) == DEFAULT_SCALE_COOKIE) return; /* Somebody beat us to the punch, just bail. */ spin_lock_irqsave(&lat_info->lock, flags); lat_info->nr_samples -= iolat->nr_samples; - lat_info->nr_samples += stat.nr_samples; - iolat->nr_samples = stat.nr_samples; + lat_info->nr_samples += latency_stat_samples(iolat, &stat); + iolat->nr_samples = latency_stat_samples(iolat, &stat); if ((lat_info->last_scale_event >= now || now - lat_info->last_scale_event < BLKIOLATENCY_MIN_ADJUST_TIME) && lat_info->scale_lat <= iolat->min_lat_nsec) goto out; - if (stat.mean <= iolat->min_lat_nsec && - stat.nr_samples >= BLKIOLATENCY_MIN_GOOD_SAMPLES) { + if (latency_sum_ok(iolat, &stat)) { + if (latency_stat_samples(iolat, &stat) < + BLKIOLATENCY_MIN_GOOD_SAMPLES) + goto out; if (lat_info->scale_grp == iolat) { lat_info->last_scale_event = now; scale_cookie_change(iolat->blkiolat, lat_info, true); } - } else if (stat.mean > iolat->min_lat_nsec) { + } else { lat_info->last_scale_event = now; if (!lat_info->scale_grp || lat_info->scale_lat > iolat->min_lat_nsec) { @@ -832,13 +908,43 @@ static int iolatency_print_limit(struct seq_file *sf, void *v) return 0; } +static size_t iolatency_ssd_stat(struct iolatency_grp *iolat, char *buf, + size_t size) +{ + struct latency_stat stat; + int cpu; + + latency_stat_init(iolat, &stat); + preempt_disable(); + for_each_online_cpu(cpu) { + struct latency_stat *s; + s = per_cpu_ptr(iolat->stats, cpu); + latency_stat_sum(iolat, &stat, s); + } + preempt_enable(); + + if (iolat->rq_depth.max_depth == UINT_MAX) + return scnprintf(buf, size, " missed=%llu total=%llu depth=max", + (unsigned long long)stat.ps.missed, + (unsigned long long)stat.ps.total); + return scnprintf(buf, size, " missed=%llu total=%llu depth=%u", + (unsigned long long)stat.ps.missed, + (unsigned long long)stat.ps.total, + iolat->rq_depth.max_depth); +} + static size_t iolatency_pd_stat(struct blkg_policy_data *pd, char *buf, size_t size) { struct iolatency_grp *iolat = pd_to_lat(pd); - unsigned long long avg_lat = div64_u64(iolat->lat_avg, NSEC_PER_USEC); - unsigned long long cur_win = div64_u64(iolat->cur_win_nsec, NSEC_PER_MSEC); + unsigned long long avg_lat; + unsigned long long cur_win; + + if (iolat->ssd) + return iolatency_ssd_stat(iolat, buf, size); + avg_lat = div64_u64(iolat->lat_avg, NSEC_PER_USEC); + cur_win = div64_u64(iolat->cur_win_nsec, NSEC_PER_MSEC); if (iolat->rq_depth.max_depth == UINT_MAX) return scnprintf(buf, size, " depth=max avg_lat=%llu win=%llu", avg_lat, cur_win); @@ -855,8 +961,8 @@ static struct blkg_policy_data *iolatency_pd_alloc(gfp_t gfp, int node) iolat = kzalloc_node(sizeof(*iolat), gfp, node); if (!iolat) return NULL; - iolat->stats = __alloc_percpu_gfp(sizeof(struct blk_rq_stat), - __alignof__(struct blk_rq_stat), gfp); + iolat->stats = __alloc_percpu_gfp(sizeof(struct latency_stat), + __alignof__(struct latency_stat), gfp); if (!iolat->stats) { kfree(iolat); return NULL; @@ -873,10 +979,15 @@ static void iolatency_pd_init(struct blkg_policy_data *pd) u64 now = ktime_to_ns(ktime_get()); int cpu; + if (blk_queue_nonrot(blkg->q)) + iolat->ssd = true; + else + iolat->ssd = false; + for_each_possible_cpu(cpu) { - struct blk_rq_stat *stat; + struct latency_stat *stat; stat = per_cpu_ptr(iolat->stats, cpu); - blk_rq_stat_init(stat); + latency_stat_init(iolat, stat); } rq_wait_init(&iolat->rq_wait); From patchwork Mon Sep 10 20:49:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10594781 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B7C514DB for ; Mon, 10 Sep 2018 20:49:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A1772933C for ; Mon, 10 Sep 2018 20:49:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E8452933E; Mon, 10 Sep 2018 20:49:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBFF929348 for ; Mon, 10 Sep 2018 20:49:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726839AbeIKBpj (ORCPT ); Mon, 10 Sep 2018 21:45:39 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:38847 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbeIKBpi (ORCPT ); Mon, 10 Sep 2018 21:45:38 -0400 Received: by mail-qt0-f194.google.com with SMTP id x7-v6so25869481qtk.5 for ; Mon, 10 Sep 2018 13:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=49/3kBvQgmRKTou2gOv3RZG/cAwAbGsJau0m7o7h5AU=; b=f8ptuRF7FZ8IpSs89OUAQqs2S4yuV1tnjW8m1V4TOSEy5ElQfn433kK96tS9A/hbEp Kzk0IpBpEM22fuhB3mCMkPOkHBpIIJNiUJXUPLeHiOJvt73szJ8eYSL46G2kGW4lDwKW XRUhWH2pc3bi4oPsI5CAMz1CAIW6yojfTra9Bv83V+2GvE+trgSy0A7G1JSHYRIBL6Va /FBQAIWoh82PN7FcZ9U2EK69Gh1lZDdpcULvfgXf2Mntgw5rT1J3NM4Ty3wJkrOSSG6/ 3qcEV/fMqTQpTiU0nAhHjWOjBxbIJQcYjaKsV7KvIjlSqYQbKwCZPEmPZI9laBd7LywZ FC7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=49/3kBvQgmRKTou2gOv3RZG/cAwAbGsJau0m7o7h5AU=; b=cKBrca3ijM0tmPQIjCAviYJmxDmB/cZ14sKBpQgOlZgM8e27lW8CkvSusFJHW1V/34 iZBN6boRrVBTVl7PJzJ3EI53QtTGVBQ8Hd+3JhypasKihj2t9Ee0FE9zCJVCTDfd/iwG B1qHfl4F4zrYIrsSQPr929np9azYhSIVEiU895+JBBFUTdTrTbPc93yvWxhQ8kEbqrW4 9SJV9QClKqr2/3QeTUCr3h8ijtIz+1DqsXj8AaCtoPPFrXRsW7uH86xDIuI1Ielkyaav 5u0WC3IgLketndsK//4E6FjJgKaxmbQT60az8PBTIjDYpEKjVA7akgICYSG+/Q0C1AjV XlGg== X-Gm-Message-State: APzg51CAJT2rwRVVJfARYKhnvM5s42yD70U3wbhZrFNApcATDij4kV9n GADUfb4z9YL5YPBDh4QVVtnLsQ== X-Google-Smtp-Source: ANB0Vda1imdU/brrlfl/1vUyjXFa7LUlFhRc5z/5EFkEBcSdcwiCjFY65CNTqeqpP8Q9sr17mQJsVQ== X-Received: by 2002:a0c:e205:: with SMTP id q5-v6mr15542657qvl.224.1536612585984; Mon, 10 Sep 2018 13:49:45 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id v31-v6sm8635319qta.96.2018.09.10.13.49.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Sep 2018 13:49:45 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, kernel-team@fb.com, linux-block@vger.kernel.org Subject: [PATCH 6/6] blk-iolatency: keep track of previous windows stats Date: Mon, 10 Sep 2018 16:49:32 -0400 Message-Id: <20180910204932.14323-7-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180910204932.14323-1-josef@toxicpanda.com> References: <20180910204932.14323-1-josef@toxicpanda.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We apply a smoothing to the scale changes in order to keep sawtoothy behavior from occurring. However our window for checking if we've missed our target can sometimes be lower than the smoothing interval (500ms), especially on faster drives like ssd's. In order to deal with this keep track of the running tally of the previous intervals that we threw away because we had already done a scale event recently. This is needed for the ssd case as these low latency drives will have bursts of latency, and if it happens to be ok for the window that directly follows the opening of the scale window we could unthrottle when previous windows we were missing our target. Signed-off-by: Josef Bacik --- block/blk-iolatency.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index e36b949a5696..14c30e01ecc7 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -130,6 +130,7 @@ struct latency_stat { struct iolatency_grp { struct blkg_policy_data pd; struct latency_stat __percpu *stats; + struct latency_stat cur_stat; struct blk_iolatency *blkiolat; struct rq_depth rq_depth; struct rq_wait rq_wait; @@ -592,24 +593,27 @@ static void iolatency_check_latencies(struct iolatency_grp *iolat, u64 now) /* Somebody beat us to the punch, just bail. */ spin_lock_irqsave(&lat_info->lock, flags); + + latency_stat_sum(iolat, &iolat->cur_stat, &stat); lat_info->nr_samples -= iolat->nr_samples; - lat_info->nr_samples += latency_stat_samples(iolat, &stat); - iolat->nr_samples = latency_stat_samples(iolat, &stat); + lat_info->nr_samples += latency_stat_samples(iolat, &iolat->cur_stat); + iolat->nr_samples = latency_stat_samples(iolat, &iolat->cur_stat); if ((lat_info->last_scale_event >= now || - now - lat_info->last_scale_event < BLKIOLATENCY_MIN_ADJUST_TIME) && - lat_info->scale_lat <= iolat->min_lat_nsec) + now - lat_info->last_scale_event < BLKIOLATENCY_MIN_ADJUST_TIME)) goto out; - if (latency_sum_ok(iolat, &stat)) { - if (latency_stat_samples(iolat, &stat) < + if (latency_sum_ok(iolat, &iolat->cur_stat) && + latency_sum_ok(iolat, &stat)) { + if (latency_stat_samples(iolat, &iolat->cur_stat) < BLKIOLATENCY_MIN_GOOD_SAMPLES) goto out; if (lat_info->scale_grp == iolat) { lat_info->last_scale_event = now; scale_cookie_change(iolat->blkiolat, lat_info, true); } - } else { + } else if (lat_info->scale_lat == 0 || + lat_info->scale_lat >= iolat->min_lat_nsec) { lat_info->last_scale_event = now; if (!lat_info->scale_grp || lat_info->scale_lat > iolat->min_lat_nsec) { @@ -618,6 +622,7 @@ static void iolatency_check_latencies(struct iolatency_grp *iolat, u64 now) } scale_cookie_change(iolat->blkiolat, lat_info, false); } + latency_stat_init(iolat, &iolat->cur_stat); out: spin_unlock_irqrestore(&lat_info->lock, flags); } @@ -990,6 +995,7 @@ static void iolatency_pd_init(struct blkg_policy_data *pd) latency_stat_init(iolat, stat); } + latency_stat_init(iolat, &iolat->cur_stat); rq_wait_init(&iolat->rq_wait); spin_lock_init(&iolat->child_lat.lock); iolat->rq_depth.queue_depth = blkg->q->nr_requests;