From patchwork Mon Oct 9 07:37:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 9992227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 79CE960244 for ; Mon, 9 Oct 2017 07:37:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C8C91FF28 for ; Mon, 9 Oct 2017 07:37:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 615BE269E2; Mon, 9 Oct 2017 07:37:52 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 515F01FF28 for ; Mon, 9 Oct 2017 07:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754026AbdJIHhu (ORCPT ); Mon, 9 Oct 2017 03:37:50 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36082 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753856AbdJIHht (ORCPT ); Mon, 9 Oct 2017 03:37:49 -0400 Received: by mail-pf0-f195.google.com with SMTP id z11so8256514pfk.3 for ; Mon, 09 Oct 2017 00:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyle-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kko2aLfpNv0SB+sSA36lTUdMWFBmXEz1vBdxoawSPJY=; b=ayuxVs0rMcLxS+kenhXG7dnqQS46VIoQ18qEGhMjUt1Nw7WXCUPHagACn72yGV8Rcg XE0Tfv6EaT/wfS8+oGCalrGf8RYa9ZWeb57aKqvWkPHwGo9mInVLrVcjrAKkdURLz+g/ DVW5cuuo9SMcseWZK0CKDPhpygHdBfPCMEXrs+mr6HOy506YhZObFEyK3hoUVzI6UZ7b soCLHPeP9lU5E7z6dHb20hAbnozFJePP93PI6h6rv0+CAU08PhAnewn8atV5/3iurEmj VVXcbKKfaZaQxE9+RWgG/pMpL4s8Qw5soaULDPTwzk9MISqNykVsyaUQm5H3HutaZVkw UIPw== 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=kko2aLfpNv0SB+sSA36lTUdMWFBmXEz1vBdxoawSPJY=; b=kCXpVST3yQpiZl4yV0xE0Kf7RRE54U3hP9KseakTNOWlsMP5YKeFWKTQ0RA5netNZZ 6gcoyn1QM0UVjSz3NrziLIO2zMh3JffiM8d++WryFKz6JE2sRKXeY/9gGtlcT3IGfAQo 3GX9ZbGdQdF92e5jgvpzmqrumJxXvQ3yAlcE2G3kcOBUKWu/JRspLn6fI+xhKfRItGVI itxyWWH0sus+sTlmqIbhDy/cQnoKmR9MQHPvfHkontr0VAMe3MV1C1hQ+POEvuSbn5JP KaB2800CD5Mm+TTzkIvc3R9MHF9jgsJ5BUIZM1C7XTY0pzGyvyf1FFWed9DLyG2wQtRZ GRNg== X-Gm-Message-State: AMCzsaUGDwd7sCwovNHqGM3uNgei2DrifI1/bSGWvTMuUrI0JC2UES3S z599LHxPMP59wy6BXotIcB+3mA== X-Google-Smtp-Source: AOwi7QBnSKtDObrEaMAe+hMnD7blywl5kxdMcUuIc91wPNKC+rsE9Lx/GSQ4asIN6gf3U+IPYp2GaQ== X-Received: by 10.98.242.13 with SMTP id m13mr3659275pfh.306.1507534669011; Mon, 09 Oct 2017 00:37:49 -0700 (PDT) Received: from localhost.localdomain (68-189-67-104.dhcp.prtv.ca.charter.com. [68.189.67.104]) by smtp.gmail.com with ESMTPSA id l5sm5823082pfi.165.2017.10.09.00.37.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 00:37:48 -0700 (PDT) From: Michael Lyle To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: colyli@suse.de, Michael Lyle Subject: [PATCH v2 2/2] bcache: rearrange writeback main thread ratelimit Date: Mon, 9 Oct 2017 00:37:30 -0700 Message-Id: <20171009073730.8939-3-mlyle@lyle.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171009073730.8939-1-mlyle@lyle.org> References: <20171009073730.8939-1-mlyle@lyle.org> 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 The time spent searching for things to write back "counts" for the actual rate achieved, so don't flush the accumulated rate with each chunk. This will maintain better fidelity to user-commanded rates, but it may slightly increase the burstiness of writeback. The writeback lock needs improvement to help mitigate this. Signed-off-by: Michael Lyle Reviewed-by: Kent Overstreet --- drivers/md/bcache/writeback.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c index 42d087b9fb56..719b104db0cc 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c @@ -526,6 +526,8 @@ static int bch_writeback_thread(void *arg) struct cached_dev *dc = arg; bool searched_full_index; + bch_ratelimit_reset(&dc->writeback_rate); + while (!kthread_should_stop()) { down_write(&dc->writeback_lock); if (!atomic_read(&dc->has_dirty) || @@ -553,7 +555,6 @@ static int bch_writeback_thread(void *arg) up_write(&dc->writeback_lock); - bch_ratelimit_reset(&dc->writeback_rate); read_dirty(dc); if (searched_full_index) { @@ -563,6 +564,8 @@ static int bch_writeback_thread(void *arg) !kthread_should_stop() && !test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags)) delay = schedule_timeout_interruptible(delay); + + bch_ratelimit_reset(&dc->writeback_rate); } }