From patchwork Sun Oct 8 05:25:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 9991727 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 3672F60364 for ; Sun, 8 Oct 2017 05:25:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 223BE28698 for ; Sun, 8 Oct 2017 05:25:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1689128702; Sun, 8 Oct 2017 05:25: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=-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 7FFF728698 for ; Sun, 8 Oct 2017 05:25:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751228AbdJHFZq (ORCPT ); Sun, 8 Oct 2017 01:25:46 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:32777 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750892AbdJHFZp (ORCPT ); Sun, 8 Oct 2017 01:25:45 -0400 Received: by mail-pf0-f193.google.com with SMTP id m28so20630334pfi.0 for ; Sat, 07 Oct 2017 22:25:45 -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; bh=xyi93qSwYHDsFkpODcmORAbXZhB5OaMdDi8K5ZmDth4=; b=VEXujz5C8pUh4jFxx2+r8bgEfVhcjjvX+ESEgubhPG3y5+8mZVGe+OBvxq1fiSjiEO vynob9IFiW8MwP24GAOajDnppjBkEwSjGv++sIy3ZQZDa1nRH/lh7IA0y9dx3jpvS/+c VOywCDZX+3Dg0C9oPXLUCoiERkmHmEGmRPiiakjlKESfctBcMhYuqfF0nt4gucD3ABxV 5rngwmnbPblnle62u9e+rHCbkHYCpEzkeBQvXbxQ7eRVhUCMQCPQdg0HJSLYTPUp2FnJ FI6PugRRB4jzkKwwYA7vYHIqzIdJQ+ln3IGQnj5/nSPxcgzlmD0oYw+Qr8tzW0DUiLK/ 8Qvw== 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; bh=xyi93qSwYHDsFkpODcmORAbXZhB5OaMdDi8K5ZmDth4=; b=K19KhoTiDixS0CJXcWPkwuUgavPy4R2wyAzybrT4vR2q2/cHH6CMK9eS96l/Xr5KWV dr2xbEL9muII5U/yFRaQ6f0nnVEc/f5xbCt0QCxglqSx2xNjnD3tqVQBuYbR9DpCfjI/ XO15VXduk6RRHwDNUKPUIZAGq6aZlB/rsidz1ZifQlVOCD5cXBmR8Hsh0dGDMBn0LPjG cUgZ64xTko8Bl5sGz2asHqG9cYTkX+Whsk3tEc3YudmU5i31C3FpvPBtv7Okxu40uCBX yZ73LeyD5aw2J4tGQdeiVY1na1btRv59/Z9SqGAPeCa4ULkPPOt7KvdGLokbUxhVPLGA QcHA== X-Gm-Message-State: AMCzsaUK1SzYoclwzgRELGCHKGF5toQpt6J10hx14oW0SOXrwj+a6gsw nUr7e2DloHMf3eokigS2egSJwa2Yffo= X-Google-Smtp-Source: AOwi7QCF1ok2q8+dcH/1FrTKSV4PS2nf14H9eyT5wqV2rRvtS+n57PUrC4l4UdXptUr6Aq1AdVQ9Zg== X-Received: by 10.84.133.131 with SMTP id f3mr6126833plf.446.1507440344533; Sat, 07 Oct 2017 22:25:44 -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 204sm9640275pgf.59.2017.10.07.22.25.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Oct 2017 22:25:43 -0700 (PDT) From: Michael Lyle To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: colyli@suse.de, Michael Lyle Subject: [PATCH] bcache: writeback rate shouldn't artifically clamp Date: Sat, 7 Oct 2017 22:25:20 -0700 Message-Id: <20171008052520.17068-1-mlyle@lyle.org> X-Mailer: git-send-email 2.11.0 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 previous code artificially limited writeback rate to 1000000 blocks/second (NSEC_PER_MSEC), which is a rate that can be met on fast hardware. The rate limiting code works fine (though with decreased precision) up to 3 orders of magnitude faster, so use NSEC_PER_SEC. Additionally, ensure that uint32_t is used as a type for rate throughout the rate management so that type checking/clamp_t can work properly. bch_next_delay should be rewritten for increased precision and better handling of high rates and long sleep periods, but this is adequate for now. Signed-off-by: Michael Lyle Reported-by: Coly Li --- drivers/md/bcache/util.h | 4 ++-- drivers/md/bcache/writeback.c | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h index cb8d2ccbb6c6..8f509290bb02 100644 --- a/drivers/md/bcache/util.h +++ b/drivers/md/bcache/util.h @@ -441,10 +441,10 @@ struct bch_ratelimit { uint64_t next; /* - * Rate at which we want to do work, in units per nanosecond + * Rate at which we want to do work, in units per second * The units here correspond to the units passed to bch_next_delay() */ - unsigned rate; + uint32_t rate; }; static inline void bch_ratelimit_reset(struct bch_ratelimit *d) diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c index 3f8c4c6bee03..a1608c45bb12 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c @@ -46,7 +46,8 @@ static void __update_writeback_rate(struct cached_dev *dc) int64_t error = dirty - target; int64_t proportional_scaled = div_s64(error, dc->writeback_rate_p_term_inverse); - int64_t integral_scaled, new_rate; + int64_t integral_scaled; + uint32_t new_rate; if ((error < 0 && dc->writeback_rate_integral > 0) || time_before64(local_clock(), @@ -67,8 +68,8 @@ static void __update_writeback_rate(struct cached_dev *dc) integral_scaled = div_s64(dc->writeback_rate_integral, dc->writeback_rate_i_term_inverse); - new_rate = clamp_t(int64_t, (proportional_scaled + integral_scaled), - dc->writeback_rate_minimum, NSEC_PER_MSEC); + new_rate = clamp_t(uint32_t, (proportional_scaled + integral_scaled), + dc->writeback_rate_minimum, NSEC_PER_SEC); dc->writeback_rate_proportional = proportional_scaled; dc->writeback_rate_integral_scaled = integral_scaled;