From patchwork Fri Oct 13 23:35:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 10006137 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 7AAD660230 for ; Fri, 13 Oct 2017 23:36:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 689882918B for ; Fri, 13 Oct 2017 23:36:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D7CF29190; Fri, 13 Oct 2017 23:36:19 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 16A7C2918B for ; Fri, 13 Oct 2017 23:36:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753260AbdJMXgQ (ORCPT ); Fri, 13 Oct 2017 19:36:16 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:48315 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753232AbdJMXgO (ORCPT ); Fri, 13 Oct 2017 19:36:14 -0400 Received: by mail-pg0-f65.google.com with SMTP id v78so2336965pgb.5 for ; Fri, 13 Oct 2017 16:36:13 -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=zGyfUecHLsq7cN+qleRjwPTmXKYJeh6E012Dxk99F4s=; b=OhskTyBAwBmn6dkAUww79vfOSyl0Dh4t1chYiYwog29NWsvuOD2GGj/dIqGKsgYuV3 mMUeTZYTqVfre1ug3qicOUofhe6Ft8xOA8vRSsLf3eesn2JFVLxBWdDwa4+25gUKq8+X V72OkJ5iqgz2gvyi1liuuBOtgIMPIxfnIw7okM+uJUrmYOjieLamnTHxRIi6SG+4Pzpu Fk75JgHRLMKK/N6NgI7JShrldpQATje6t6hgbmVL6QNXxGj3eikbbkbrK8kwy5ISGK+r cc5CxVETp5rIjhJUONJpSmPMk9wXxc2xivp6p3N7JOwFmdspYUqwy3BAlFduHmcfmKG5 RtoA== 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=zGyfUecHLsq7cN+qleRjwPTmXKYJeh6E012Dxk99F4s=; b=HgiAWOZHL2Y43fe4WrHuTvl3Ar/EnBIizkgYFdmPhLIvZZujdH5Tzc1R+G7KWTr9TB zFX+s/qRZB1M9Jxo6rmexM12sN+HSKxGhLmFUNY/sOoxyw6r6X1qBqsrPy1Cgyxz5XH7 ovxF7Ur2MmaR4b+5HBtDjYzHMMAR9+ZnSNEqpwCcqp58blcIKnyb2xi7fqdgg2PjA08T chXYs7Ur2WBQEo38XNfQw2u5TokiZDRflUiQ4Yn/OaD5+C4+vHciFIehOylCm9vqDYrZ h5eHf6GRy4LO9BihJBKhA3ZeCLqIi2pjvWzwgskxqUf15VOOchF+rnajB+EZsHIOfNnY 9zEA== X-Gm-Message-State: AMCzsaXTvILyAGzXoVOneMJJEqipIrPg0D1cXb4EMCeejjieM87TBglY cf7ypHMt70cRSCg0sFNWodj6ww== X-Google-Smtp-Source: AOwi7QCPZrdNyfZd8B/G8kVd+8vhcKVDG/GCFjOPCtTvYoXVNFo5GP+XJimv/9Qh5abwPvu0R41fAQ== X-Received: by 10.84.240.6 with SMTP id y6mr1377326plk.78.1507937773448; Fri, 13 Oct 2017 16:36:13 -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 74sm4950718pft.184.2017.10.13.16.36.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 16:36:12 -0700 (PDT) From: Michael Lyle To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: axboe@fb.com, Michael Lyle Subject: [PATCH 12/15] bcache: rearrange writeback main thread ratelimit Date: Fri, 13 Oct 2017 16:35:39 -0700 Message-Id: <20171013233542.20938-13-mlyle@lyle.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171013233542.20938-1-mlyle@lyle.org> References: <20171013233542.20938-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 897d28050656..9b770b13bdf6 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c @@ -440,6 +440,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) || @@ -467,7 +469,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) { @@ -477,6 +478,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); } }