From patchwork Tue Aug 9 19:08:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9272083 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 9E0126075A for ; Tue, 9 Aug 2016 19:08:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8849C2833A for ; Tue, 9 Aug 2016 19:08:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CE63283DF; Tue, 9 Aug 2016 19:08:57 +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=unavailable 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 B210B2833A for ; Tue, 9 Aug 2016 19:08:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932280AbcHITIw (ORCPT ); Tue, 9 Aug 2016 15:08:52 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:33062 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751919AbcHITIu (ORCPT ); Tue, 9 Aug 2016 15:08:50 -0400 Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u79J6fJf016966; Tue, 9 Aug 2016 12:08:43 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=fvzwgjdVslZoSqFfmD3/dqogeiU3hqr6NIChWYHwPXU=; b=mWcUc1Xzn7dhNGjtIGKPzpO7wDbgjrmJDboo2rNnN3xk6HWlooMSgX9qNymXIe3Yzs88 X38AfbpYPxFY6WpHw3EV9Vt3l/nlWLKkB1U5EbVKpG5eHWesTOjIpx4lQYj5JJfJ/h39 n5ETUpfqVhgQ3OmHLUBy31zJmElqKcMP87k= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 24qmf806k4-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 09 Aug 2016 12:08:43 -0700 Received: from NAM03-CO1-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.19) with Microsoft SMTP Server (TLS) id 14.3.294.0; Tue, 9 Aug 2016 12:08:40 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=7vWvvHIq3fEBCUHReqWJYkwDna89tO/9q6hUxTMvAjo=; b=LOWrdA0VOcI8ZejO77+0wMrJ7lj+hSiNftkFp8ErMjPn9t881+8cOMIfg5t28efFDZM5O95DPt36V/mf3Quce2squJubMRjvupKb5rJuF9A2ALoQooRFjDnyEvhM2iISbYBa1eC3OISeLS4lhQR1xyYoM9jeyZftvt6omcRGecQ= Received: from localhost (107.15.72.49) by CY4PR15MB1319.namprd15.prod.outlook.com (10.172.182.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.15; Tue, 9 Aug 2016 19:08:38 +0000 From: Josef Bacik To: , , , , , , Subject: [PATCH 1/2] remove mapping from balance_dirty_pages*() Date: Tue, 9 Aug 2016 15:08:26 -0400 Message-ID: <1470769707-26079-2-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1470769707-26079-1-git-send-email-jbacik@fb.com> References: <1470769707-26079-1-git-send-email-jbacik@fb.com> MIME-Version: 1.0 X-Originating-IP: [107.15.72.49] X-ClientProxiedBy: BN6PR01CA0057.prod.exchangelabs.com (10.172.194.147) To CY4PR15MB1319.namprd15.prod.outlook.com (10.172.182.7) X-MS-Office365-Filtering-Correlation-Id: bb06b0ed-d0cf-478e-0c45-08d3c08891ea X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1319; 2:Skbekac8HR2MB9nWKEd6LwMWlOYJltkeTHDQogFLCJElp+QDVQ0BvBMUtqop8+qnPNFEBkIvVMkCwmdOyD7HTmGfirFBYQ07o4Q7qtRFYsxLllGnDG00m0RAFyDFfJDaRDVYPqNB7Bu9Z7rTbg2yMQ1lWc8y3YYf2IhfG36uqxwwb2BzgjPMWoGSvHp/2Hkd; 3:kaM8Cc9gxDhWpHiJiC+T3yzufTm3v13jvd/z872IocMNXPo4TXiShnGMyZ180CNJtNLniNhUzyEpZ5OyK+Snn1qk2RvanMU1gR6s0/v9oKwHs5RTJ3veRaXMrPmN2TN0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY4PR15MB1319; X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1319; 25:yL6JFNeboe39/wqwtqMiO9Mriyc9AE3FVy5VmKRX0W4bVPFFF6JnORzcf8WvRSivsIoSLMIf9gvW89wpW222/ceo+M9gMYfmQ32KPhXh+1bSKTVfUsUO4r9kaQIaUg4dKYbbfip6jHa9G5levJeas8FmeYf8sGKQECWJ2o0Hj85k73v0bb4Xbji9facqGAyvh+nYl7wOiUrKbwW9DADZqXJZ+ITmb2ixzDqQ1ScrAv/CRe13632hn7PlGfM/adu8eqhidEFUWmXkLyyLznIsae0WJavOckgwzEjhzTBElDv0BYmg7MVnYwa9K9w5916hAqX9FNttTrR+a8ZQQWM2tDFtA8FaJ8cCNj2mS6x6kzaqb4o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uEGu/HmjU0G0W4ZH5fR/5vuDY/EmLZVKdEa6l34l/0Lce8VEE7lRXsn9YHQxWWDRqoDkkXEyYHHtFEBR3fOzO7oJ37FcDQk6zqdprrXt8+PVUEX2ztnk2YuVmv3mp6k1rjaO5QMopW7Gyv6WgphsQtgq2v0J3H+QO52rjv4Vk1JkBoPRKUlShN2yZ3ZnfxSe81nrYWQWe/htLVoPHisAqxAvCxVkFAJMSi3LNJy5xotKxgfbq2i33LXjQ+YqkBaq8dNSghA8u4yjg/ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040161)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:CY4PR15MB1319; BCL:0; PCL:0; RULEID:; SRVR:CY4PR15MB1319; X-Forefront-PRVS: 0029F17A3F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(199003)(189002)(586003)(105586002)(2906002)(76176999)(5003940100001)(66066001)(2201001)(68736007)(50986999)(305945005)(48376002)(7846002)(50466002)(7736002)(19580395003)(92566002)(19580405001)(3846002)(2950100001)(189998001)(50226002)(42186005)(77096005)(33646002)(8676002)(229853001)(6116002)(575784001)(86362001)(81166006)(101416001)(107886002)(76506005)(81156014)(47776003)(97736004)(5001770100001)(36756003)(106356001)(14143004)(4720700001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR15MB1319; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR15MB1319; 23:Waz2MCdAeGcysNfgAYI5nDqooUNPAfzoMtmA5FKBO?= =?us-ascii?Q?d5pehTZDJGsJWYmmIXi5HV8KcXI7XjU8hVnNc+y9I895GRCpHy35YECFlRn8?= =?us-ascii?Q?WuCWgtbs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TPkj2+fOhL0PRtsqQasgjAbgTFzSdE/PEOYcONYTwT7Z7LH/yi0mbVG6Oi+ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1319; 20:jMu5dHAGHyF3t+Zw7SZaTBgxB33rPiOebxGsSDZA1iFEk7fIS4F0jDntdHnI0lkKfcb2+xH3PdZOsycJV6lQ4mFV+LNydPFSExPtJB5EjZJMpD6r2yPJRetlCeZd9+k2Cd/0Dvo9kBGMrdAvbaZQgMVp53JQ+Ro1fK+ok38AYbI= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2016 19:08:38.3780 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1319 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-08-09_07:, , signatures=0 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 The only reason we pass in the mapping is to get the inode in order to see if writeback cgroups is enabled, and even then it only checks the bdi and a super block flag. balance_dirty_pages() doesn't even use the mapping. Since balance_dirty_pages*() works on a bdi level, just pass in the bdi and super block directly so we can avoid using mapping. This will allow us to still use balance_dirty_pages for dirty metadata pages that are not backed by an address_mapping. Signed-off-by: Josef Bacik Reviewed-by: Jan Kara Acked-by: Tejun Heo --- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/file.c | 3 ++- fs/btrfs/ioctl.c | 3 ++- fs/btrfs/relocation.c | 3 ++- fs/buffer.c | 3 ++- fs/iomap.c | 3 ++- include/linux/backing-dev.h | 23 +++++++++++++++++------ include/linux/writeback.h | 3 ++- mm/filemap.c | 4 +++- mm/memory.c | 9 +++++++-- mm/page-writeback.c | 15 +++++++-------- 11 files changed, 48 insertions(+), 25 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 17346f7..c1d951a 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4024,8 +4024,8 @@ static void __btrfs_btree_balance_dirty(struct btrfs_root *root, ret = percpu_counter_compare(&root->fs_info->dirty_metadata_bytes, BTRFS_DIRTY_METADATA_THRESH); if (ret > 0) { - balance_dirty_pages_ratelimited( - root->fs_info->btree_inode->i_mapping); + balance_dirty_pages_ratelimited(&root->fs_info->bdi, + root->fs_info->sb); } } diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 9404121..f060b08 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1686,7 +1686,8 @@ again: cond_resched(); - balance_dirty_pages_ratelimited(inode->i_mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); if (dirty_pages < (root->nodesize >> PAGE_SHIFT) + 1) btrfs_btree_balance_dirty(root); diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 14ed1e9..a222bad 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1410,7 +1410,8 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, } defrag_count += ret; - balance_dirty_pages_ratelimited(inode->i_mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); inode_unlock(inode); if (newer_than) { diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 4598e29..7fc6ea7 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -3202,7 +3202,8 @@ static int relocate_file_extent_cluster(struct inode *inode, put_page(page); index++; - balance_dirty_pages_ratelimited(inode->i_mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); btrfs_throttle(BTRFS_I(inode)->root); } WARN_ON(nr != cluster->nr); diff --git a/fs/buffer.c b/fs/buffer.c index 9c8eb9b..9bbe30d 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2386,7 +2386,8 @@ static int cont_expand_zero(struct file *file, struct address_space *mapping, BUG_ON(err != len); err = 0; - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); if (unlikely(fatal_signal_pending(current))) { err = -EINTR; diff --git a/fs/iomap.c b/fs/iomap.c index 48141b8..937e266 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -226,7 +226,8 @@ again: written += copied; length -= copied; - balance_dirty_pages_ratelimited(inode->i_mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); } while (iov_iter_count(i) && length); return written ? written : status; diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 491a917..3b76eeb 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -252,8 +252,9 @@ void wb_blkcg_offline(struct blkcg *blkcg); int inode_congested(struct inode *inode, int cong_bits); /** - * inode_cgwb_enabled - test whether cgroup writeback is enabled on an inode - * @inode: inode of interest + * bdi_cgwb_enabled - test wether cgroup writeback is enabled on a filesystem + * @bdi: the bdi we care about + * @sb: the super for the bdi * * cgroup writeback requires support from both the bdi and filesystem. * Also, both memcg and iocg have to be on the default hierarchy. Test @@ -262,15 +263,25 @@ int inode_congested(struct inode *inode, int cong_bits); * Note that the test result may change dynamically on the same inode * depending on how memcg and iocg are configured. */ -static inline bool inode_cgwb_enabled(struct inode *inode) +static inline bool bdi_cgwb_enabled(struct backing_dev_info *bdi, + struct super_block *sb) { - struct backing_dev_info *bdi = inode_to_bdi(inode); - return cgroup_subsys_on_dfl(memory_cgrp_subsys) && cgroup_subsys_on_dfl(io_cgrp_subsys) && bdi_cap_account_dirty(bdi) && (bdi->capabilities & BDI_CAP_CGROUP_WRITEBACK) && - (inode->i_sb->s_iflags & SB_I_CGROUPWB); + (sb->s_iflags & SB_I_CGROUPWB); +} + +/** + * inode_cgwb_enabled - test whether cgroup writeback is enabled on an inode + * @inode: inode of interest + * + * Does the inode have cgroup writeback support. + */ +static inline bool inode_cgwb_enabled(struct inode *inode) +{ + return bdi_cgwb_enabled(inode_to_bdi(inode), inode->i_sb); } /** diff --git a/include/linux/writeback.h b/include/linux/writeback.h index fc1e16c..256ffc3 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -364,7 +364,8 @@ unsigned long wb_calc_thresh(struct bdi_writeback *wb, unsigned long thresh); void wb_update_bandwidth(struct bdi_writeback *wb, unsigned long start_time); void page_writeback_init(void); -void balance_dirty_pages_ratelimited(struct address_space *mapping); +void balance_dirty_pages_ratelimited(struct backing_dev_info *bdi, + struct super_block *sb); bool wb_over_bg_thresh(struct bdi_writeback *wb); typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc, diff --git a/mm/filemap.c b/mm/filemap.c index 3083ded..abb0e98 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2667,6 +2667,7 @@ ssize_t generic_perform_write(struct file *file, struct iov_iter *i, loff_t pos) { struct address_space *mapping = file->f_mapping; + struct inode *inode = mapping->host; const struct address_space_operations *a_ops = mapping->a_ops; long status = 0; ssize_t written = 0; @@ -2746,7 +2747,8 @@ again: pos += copied; written += copied; - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); } while (iov_iter_count(i)); return written ? written : status; diff --git a/mm/memory.c b/mm/memory.c index 83be99d..d43e73b 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -2105,11 +2106,13 @@ static inline int wp_page_reuse(struct fault_env *fe, pte_t orig_pte, put_page(page); if ((dirtied || page_mkwrite) && mapping) { + struct inode *inode = mapping->host; /* * Some device drivers do not set page.mapping * but still dirty their pages */ - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); } if (!page_mkwrite) @@ -3291,11 +3294,13 @@ static int do_shared_fault(struct fault_env *fe, pgoff_t pgoff) mapping = page_rmapping(fault_page); unlock_page(fault_page); if ((dirtied || vma->vm_ops->page_mkwrite) && mapping) { + struct inode *inode = mapping->host; /* * Some device drivers do not set page.mapping but still * dirty their pages */ - balance_dirty_pages_ratelimited(mapping); + balance_dirty_pages_ratelimited(inode_to_bdi(inode), + inode->i_sb); } if (!vma->vm_ops->page_mkwrite) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index f4cd7d8..121a6e3 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1559,8 +1559,7 @@ static inline void wb_dirty_limits(struct dirty_throttle_control *dtc) * If we're over `background_thresh' then the writeback threads are woken to * perform some writeout. */ -static void balance_dirty_pages(struct address_space *mapping, - struct bdi_writeback *wb, +static void balance_dirty_pages(struct bdi_writeback *wb, unsigned long pages_dirtied) { struct dirty_throttle_control gdtc_stor = { GDTC_INIT(wb) }; @@ -1849,7 +1848,8 @@ DEFINE_PER_CPU(int, dirty_throttle_leaks) = 0; /** * balance_dirty_pages_ratelimited - balance dirty memory state - * @mapping: address_space which was dirtied + * @bdi: the bdi that was dirtied + * @sb: the super block that was dirtied * * Processes which are dirtying memory should call in here once for each page * which was newly dirtied. The function will periodically check the system's @@ -1860,10 +1860,9 @@ DEFINE_PER_CPU(int, dirty_throttle_leaks) = 0; * limit we decrease the ratelimiting by a lot, to prevent individual processes * from overshooting the limit by (ratelimit_pages) each. */ -void balance_dirty_pages_ratelimited(struct address_space *mapping) +void balance_dirty_pages_ratelimited(struct backing_dev_info *bdi, + struct super_block *sb) { - struct inode *inode = mapping->host; - struct backing_dev_info *bdi = inode_to_bdi(inode); struct bdi_writeback *wb = NULL; int ratelimit; int *p; @@ -1871,7 +1870,7 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping) if (!bdi_cap_account_dirty(bdi)) return; - if (inode_cgwb_enabled(inode)) + if (bdi_cgwb_enabled(bdi, sb)) wb = wb_get_create_current(bdi, GFP_KERNEL); if (!wb) wb = &bdi->wb; @@ -1909,7 +1908,7 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping) preempt_enable(); if (unlikely(current->nr_dirtied >= ratelimit)) - balance_dirty_pages(mapping, wb, current->nr_dirtied); + balance_dirty_pages(wb, current->nr_dirtied); wb_put(wb); }