From patchwork Fri Oct 13 23:35:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 10006135 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 87C0260230 for ; Fri, 13 Oct 2017 23:36:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7871D29009 for ; Fri, 13 Oct 2017 23:36:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D82F2918E; Fri, 13 Oct 2017 23:36:17 +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 DE03D29009 for ; Fri, 13 Oct 2017 23:36:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753255AbdJMXgO (ORCPT ); Fri, 13 Oct 2017 19:36:14 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:50575 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752468AbdJMXgM (ORCPT ); Fri, 13 Oct 2017 19:36:12 -0400 Received: by mail-pg0-f67.google.com with SMTP id y7so2337872pgb.7 for ; Fri, 13 Oct 2017 16:36:12 -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=aHoJsDEE5ev0qLWxHC7EtDtWBeAGOaGjo5ln1pJJDzQ=; b=Ej9oFb4lZGu5rmvvjjbjxnH6aoqElnfA55yMg7OrcirptSFqNbb4u6BOMbT+gvNAGj TphoczG1+X8Wacu/yS703KdS5G+xGfHL0YYwPKATX6d7YAuJSalHbnKRm3dBqZ1q1tQr IKhexgtil0PThZnCsmBIo9ko4+g/vLsjiLXWDOw/s5OlA3HvYbbRl38nVrOokmhfW9cM 74Z8Be65I48Ng2nDETPSyQlUZ6goJnXU6DAq2H7N+t50ptoIHjK7kvyMUZKvwH1FNw3o VHH9l4hwfiGe3VBcTJ8+IIKtmbxoYT4qsEj/Nng5YbDQSIDuvb62Fn305Nox3sLfQR88 YACQ== 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=aHoJsDEE5ev0qLWxHC7EtDtWBeAGOaGjo5ln1pJJDzQ=; b=j34W/PXkP25ItWCNbkBudSwE+uK+bLsW/tnDGjiLY6YPNo8o3DUWgpR04eZq8CuOsL S+LJvSMFmaSwrPoSn+AU8jcPDUKXCnJGDAVXPRK9beq3/XKaS3LgB8wD5oR+TSeR2djJ oo2X/mfNc2Jy+2QVFMmnwOUFuPsXwUMjuf/R2GNoHO8V7krMvJgZsSDDjYFCkJiOSjrO 13zmf3ednlR9fSJ2/edPz2flR+68KsiZQc+2SibyytPoi40bRT5mHc8SD34E6BCv8SEr xZdddiRsDAyB4cDutfFjQEskkjt02rjqz+WXSYbxWrQO2G+lC6A05jx2fTUPOyjCV75a HCSA== X-Gm-Message-State: AMCzsaWNXi6CwHeQX7nxJMLKz9Yt0NpvvLczRzPJsfpzlsjkfMV+19vK 5ddrCw02NooyfKwqxE/wpGzRMA== X-Google-Smtp-Source: AOwi7QDpFsM4KJSVNGk+pXfHCzERaFc8DvF6JMuOTni0cub+Egu6Ao2nvC6LhFEqE4ylhTakuWiKpA== X-Received: by 10.84.235.75 with SMTP id g11mr2685424plt.155.1507937772080; Fri, 13 Oct 2017 16:36:12 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 16:36:11 -0700 (PDT) From: Michael Lyle To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: axboe@fb.com, Michael Lyle Subject: [PATCH 11/15] bcache: writeback rate shouldn't artifically clamp Date: Fri, 13 Oct 2017 16:35:38 -0700 Message-Id: <20171013233542.20938-12-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 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 Reviewed-by: Coly Li --- drivers/md/bcache/bcache.h | 2 +- drivers/md/bcache/util.h | 4 ++-- drivers/md/bcache/writeback.c | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index eb83be693d60..d77c4829c497 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -361,7 +361,7 @@ struct cached_dev { int64_t writeback_rate_proportional; int64_t writeback_rate_integral; int64_t writeback_rate_integral_scaled; - int64_t writeback_rate_change; + int32_t writeback_rate_change; unsigned writeback_rate_update_seconds; unsigned writeback_rate_i_term_inverse; 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 8deb721c355e..897d28050656 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c @@ -52,7 +52,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) || (error > 0 && time_before64(local_clock(), @@ -74,8 +75,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(int32_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;