From patchwork Tue Nov 14 21:56:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10058423 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 30F41602A7 for ; Tue, 14 Nov 2017 21:57:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2303528609 for ; Tue, 14 Nov 2017 21:57:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 167E729A74; Tue, 14 Nov 2017 21:57:16 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 8476428609 for ; Tue, 14 Nov 2017 21:57:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757237AbdKNV5N (ORCPT ); Tue, 14 Nov 2017 16:57:13 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:44889 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757076AbdKNV5F (ORCPT ); Tue, 14 Nov 2017 16:57:05 -0500 Received: by mail-qt0-f195.google.com with SMTP id 8so29725538qtv.1 for ; Tue, 14 Nov 2017 13:57:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MWQlWPR4He77CSezJYlI0FGVSY/3ZIm3IZlssYrGqsQ=; b=knv7z86djCLv8ufp/WFCYodf+gHqJ0lh1ywXdieFm62RSfzy3Gr2Jh7uLs7pK4NE8r /0SeOf2K8rmCd3mlErACGNE8dqcrsPVllnMEGfAJc9AWQlNrbFrrbosw+sqyj3Iure3m 3p1fH7UnnoJA88/UUo+oFqaJ8md6AuuWBhAdof9yfJhQTGZZjZQyraU5Z0lgO6vHJIEU GDi4lfopF+3zux85G0dnHcJvrWgLYodKua8cASFMYdxNwCzeqKyZqwEB1PUclV1/Wn7v XJKUVNe3JLrpkn+pi6iAf8K6SI5AGCVgytczXGDBJEbse2hx7sT6uyLG7PG7IbV+aCze W0bQ== 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=MWQlWPR4He77CSezJYlI0FGVSY/3ZIm3IZlssYrGqsQ=; b=Pk4D0ezGZn8RuPN9Laj9Zk2PdwrxT++BqIBEwSqdCsDCdjjfKchZGHWTgLhL+kJgN8 Nc8+N/dKGnYJbzmnI4dciQ+XMI88gINLWLkWz9MbKmSlQWxXI7TlSfvoXk2gJEIYJHo2 1Fs1GsobxG7J3T5BLFllKVsVGetGFfbK1/MP3F9/a9FVu/+o2YEgojT8B842aVPQUkR+ gv7qCFPdxNOSKk7oUBDrpZFCYPx377YrQxGhfEPcuFphz2ZpE1370n6rk/2hsPWK9FUP qri0xzUkwUuvLal0TksNVZQPhlD8mFisjs7cAwQpTkhtcMOJnwyeaNMXRpyhqPYhme/r 1NKw== X-Gm-Message-State: AJaThX72NVxDktipN25XSOwkZa1x5ZD++dZyShKMvqF97Dy9ZsPyZHTi USMO3u5DgvskbtSeONkQTsNZKQ== X-Google-Smtp-Source: AGs4zMZdAGGgdFp1GQ0fxBdpj7GVLOTtNarawVcUu/pDxVHX80BYv/RHD3sPa+uR5UFjFgqlAv8TLQ== X-Received: by 10.200.41.90 with SMTP id z26mr20890989qtz.47.1510696623981; Tue, 14 Nov 2017 13:57:03 -0800 (PST) Received: from localhost (cpe-2606-A000-4381-1201-225-22FF-FEB3-E51A.dyn6.twc.com. [2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id p74sm11192028qkl.22.2017.11.14.13.57.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Nov 2017 13:57:03 -0800 (PST) From: Josef Bacik To: hannes@cmpxchg.org, linux-mm@kvack.org, akpm@linux-foundation.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, kernel-team@fb.com, linux-btrfs@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 05/10] writeback: convert the flexible prop stuff to bytes Date: Tue, 14 Nov 2017 16:56:51 -0500 Message-Id: <1510696616-8489-5-git-send-email-josef@toxicpanda.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1510696616-8489-1-git-send-email-josef@toxicpanda.com> References: <1510696616-8489-1-git-send-email-josef@toxicpanda.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Bacik The flexible proportions were all page based, but now that we are doing metadata writeout that can be smaller or larger than page size we need to account for this in bytes instead of number of pages. Signed-off-by: Josef Bacik --- mm/backing-dev.c | 2 +- mm/page-writeback.c | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 62a332a91b38..e0d7c62dc0ad 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -832,7 +832,7 @@ static int bdi_init(struct backing_dev_info *bdi) kref_init(&bdi->refcnt); bdi->min_ratio = 0; bdi->max_ratio = 100; - bdi->max_prop_frac = FPROP_FRAC_BASE; + bdi->max_prop_frac = FPROP_FRAC_BASE * PAGE_SIZE; INIT_LIST_HEAD(&bdi->bdi_list); INIT_LIST_HEAD(&bdi->wb_list); init_waitqueue_head(&bdi->wb_waitq); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index e4563645749a..c491dee711a8 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -574,11 +574,11 @@ static unsigned long wp_next_time(unsigned long cur_time) return cur_time; } -static void wb_domain_writeout_inc(struct wb_domain *dom, +static void wb_domain_writeout_add(struct wb_domain *dom, struct fprop_local_percpu *completions, - unsigned int max_prop_frac) + long bytes, unsigned int max_prop_frac) { - __fprop_inc_percpu_max(&dom->completions, completions, + __fprop_add_percpu_max(&dom->completions, completions, bytes, max_prop_frac); /* First event after period switching was turned off? */ if (unlikely(!dom->period_time)) { @@ -602,12 +602,12 @@ static inline void __wb_writeout_add(struct bdi_writeback *wb, long bytes) struct wb_domain *cgdom; __add_wb_stat(wb, WB_WRITTEN_BYTES, bytes); - wb_domain_writeout_inc(&global_wb_domain, &wb->completions, + wb_domain_writeout_add(&global_wb_domain, &wb->completions, bytes, wb->bdi->max_prop_frac); cgdom = mem_cgroup_wb_domain(wb); if (cgdom) - wb_domain_writeout_inc(cgdom, wb_memcg_completions(wb), + wb_domain_writeout_add(cgdom, wb_memcg_completions(wb), bytes, wb->bdi->max_prop_frac); } @@ -646,6 +646,7 @@ static void writeout_period(unsigned long t) int wb_domain_init(struct wb_domain *dom, gfp_t gfp) { + int ret; memset(dom, 0, sizeof(*dom)); spin_lock_init(&dom->lock); @@ -655,7 +656,10 @@ int wb_domain_init(struct wb_domain *dom, gfp_t gfp) dom->dirty_limit_tstamp = jiffies; - return fprop_global_init(&dom->completions, gfp); + ret = fprop_global_init(&dom->completions, gfp); + if (!ret) + dom->completions.batch_size *= PAGE_SIZE; + return ret; } #ifdef CONFIG_CGROUP_WRITEBACK @@ -706,7 +710,8 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned max_ratio) ret = -EINVAL; } else { bdi->max_ratio = max_ratio; - bdi->max_prop_frac = (FPROP_FRAC_BASE * max_ratio) / 100; + bdi->max_prop_frac = ((FPROP_FRAC_BASE * max_ratio) / 100) * + PAGE_SIZE; } spin_unlock_bh(&bdi_lock);