From patchwork Mon Oct 9 07:37:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 9992225 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 1C5F960244 for ; Mon, 9 Oct 2017 07:37:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E99A1FF28 for ; Mon, 9 Oct 2017 07:37:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03303269E2; Mon, 9 Oct 2017 07:37:49 +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 77C501FF28 for ; Mon, 9 Oct 2017 07:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753937AbdJIHhr (ORCPT ); Mon, 9 Oct 2017 03:37:47 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33063 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753856AbdJIHhq (ORCPT ); Mon, 9 Oct 2017 03:37:46 -0400 Received: by mail-pf0-f193.google.com with SMTP id m28so25512377pfi.0 for ; Mon, 09 Oct 2017 00:37:46 -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=mMgPt9/+dbweQKOxT9UYEFdQvGly0cKExr4xAr1hPTQ=; b=Ua8DiHH6KhPEbbeHcNjjLxyy6DaDWzZh4+e3yZkoFDmLKMXPH0JDrm4N4Q8NnQ92xn vifS+PyMI+6t1BO1iq7Zg+fu2ymOjuZlJkaloLkxxRFPBMuonKpjSnhurktIztyC36oB mUb8QkoWs8cJI9M1xyKAOSLg1jrbeYPGASOrOIKdvsGEtugw9NMH2tf1vBRiDaTz4HPr VxMAOtwoQy6SETJM2OJKc5GB52f6xUa5Lfbye41U7BnAaIZY3UjThQ5wEDqbVpApAUBN Nta6fNvatAxFe9VfHtUGIYQbQYtmPB0HyLIfKaHc5S9m4osvi0QgCcEAMRXdoupFeynt y6Ng== 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=mMgPt9/+dbweQKOxT9UYEFdQvGly0cKExr4xAr1hPTQ=; b=hxfbM36y+5W8nrTnJ6rDmuFXRKAzSrnAlvM8f3t1hCiVFnjF/OcmarkoVVckNAWWei QQDlk56s7i9YA8hm2moZ/zC/gOAevvhcm+f4/V4uGDnF2b/GkYmWDAb/wkKurA25sj+z WwD0svNdxi/AZTFEI7L+ujjOfkAAtPatOwJB1owBW+K10+JhZD0DA1zA3/llAGy2Hg+n NrAyfZXeIibx230uDUkrSTMzLztWz/pcoUA0O/2sZvW+YN6aco5mFkBGK9A1UwJe3SKN Fazw+c0aeeulkrOD20BJYqIo4wOLB1NkSO2lHotIm66VVjTkj0TCrS8PTXI0sKJi2C9o 1ldw== X-Gm-Message-State: AMCzsaX4G+3sufs5J3WVRkM1SfN3THr4vNL4WvSEiLVdb0hoRqk+N0jW TjXgWYhjwwQ4N/Th6DGwlyFa2A== X-Google-Smtp-Source: AOwi7QABQeg6rNcYb5i6cim7ihLuivZ5ixqjZnde9vIvcrm/AW81IXqR5mdq6oWHWSSqalXZuuhBWw== X-Received: by 10.98.12.15 with SMTP id u15mr9274646pfi.266.1507534666185; Mon, 09 Oct 2017 00:37:46 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 00:37:45 -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 1/2] bcache: writeback rate shouldn't artifically clamp Date: Mon, 9 Oct 2017 00:37:29 -0700 Message-Id: <20171009073730.8939-2-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 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 df0b2ccfca8d..2f9c380c4692 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -363,7 +363,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 d63356a60001..42d087b9fb56 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;