From patchwork Wed Dec 8 04:22:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 12663817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE3D8C433EF for ; Wed, 8 Dec 2021 07:08:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E22D6B0071; Wed, 8 Dec 2021 02:08:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 391296B0073; Wed, 8 Dec 2021 02:08:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 259F66B0075; Wed, 8 Dec 2021 02:08:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay037.a.hostedemail.com [64.99.140.37]) by kanga.kvack.org (Postfix) with ESMTP id 158256B0071 for ; Wed, 8 Dec 2021 02:08:37 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id AE18A801AE for ; Wed, 8 Dec 2021 04:48:17 +0000 (UTC) X-FDA: 78893395434.17.9897E31 Received: from relay.hostedemail.com (relay037.a.hostedemail.com [64.99.140.37]) by imf04.hostedemail.com (Postfix) with ESMTP id 5139340002 for ; Wed, 8 Dec 2021 04:48:17 +0000 (UTC) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E440F20785 for ; Wed, 8 Dec 2021 04:28:54 +0000 (UTC) X-FDA: 78893346588.24.6466BF0 Received: from relay.hostedemail.com (relay027.a.hostedemail.com [64.99.140.27]) by imf20.hostedemail.com (Postfix) with ESMTP id 7C99ED0000A6 for ; Wed, 8 Dec 2021 04:28:54 +0000 (UTC) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 8536A801BA for ; Wed, 8 Dec 2021 04:23:20 +0000 (UTC) X-FDA: 78893332560.08.701E62E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id 00E48100006 for ; Wed, 8 Dec 2021 04:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=FUlAUp7w5xOWEu0PBG82mMLCrwUhe7kQ/xncNJzLm7U=; b=DMjJSFYmluQlnIkBFHPWvaW/RB QxqgFCqgI6c3NhA8TNGyRGJNIK6BrYGeKi0OVz5nC1mCMdAJB2ydtcTMCGw6qTqjhB4SAGc/v3tnH e7BkZc4soBQwtzDPUjnFJ1dq9KyClXXV8jfpKYwJ5SNhV9rguJfYhXiCmDZKARvyq+oAg42AeVUNb e6Tm2vjQR3eeaOLk5AWKuZa2AJA2Sy9wjt7LTyNbdTZkUVoJ9cIS+XoK9j07I0fpNhwpOYtbz9nPu oxbmMJbEz/SZAddCuat0VwV33ETMY40O/rP73Ft0E5u/PZ0hSOAhDLHOYE4FajiyoYylLcRXYrVF0 O4tYchDA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1muoU1-0084Wj-Ki; Wed, 08 Dec 2021 04:23:09 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 02/48] fs/writeback: Convert inode_switch_wbs_work_fn to folios Date: Wed, 8 Dec 2021 04:22:10 +0000 Message-Id: <20211208042256.1923824-3-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211208042256.1923824-1-willy@infradead.org> References: <20211208042256.1923824-1-willy@infradead.org> MIME-Version: 1.0 X-HE-Tag-Orig: 1638937399-906384 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=DMjJSFYm; dmarc=none; spf=none (imf04.hostedemail.com: domain of FILTER%FILTER%willy@infradead.org has no SPF policy when checking 64.99.140.37) smtp.mailfrom=FILTER%FILTER%willy@infradead.org X-HE-Tag-Orig: 1638937734-86095 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 5139340002 X-Stat-Signature: pffnomtw89utwua7ps5oznbo44kcc1mw X-HE-Tag: 1638938897-757844 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This gets the statistics correct by modifying the counters by the number of pages in the folio instead of by 1. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig --- fs/fs-writeback.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 67f0e88eed01..4f680f848c8b 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -372,7 +372,7 @@ static bool inode_do_switch_wbs(struct inode *inode, { struct address_space *mapping = inode->i_mapping; XA_STATE(xas, &mapping->i_pages, 0); - struct page *page; + struct folio *folio; bool switched = false; spin_lock(&inode->i_lock); @@ -389,21 +389,23 @@ static bool inode_do_switch_wbs(struct inode *inode, /* * Count and transfer stats. Note that PAGECACHE_TAG_DIRTY points - * to possibly dirty pages while PAGECACHE_TAG_WRITEBACK points to - * pages actually under writeback. + * to possibly dirty folios while PAGECACHE_TAG_WRITEBACK points to + * folios actually under writeback. */ - xas_for_each_marked(&xas, page, ULONG_MAX, PAGECACHE_TAG_DIRTY) { - if (PageDirty(page)) { - dec_wb_stat(old_wb, WB_RECLAIMABLE); - inc_wb_stat(new_wb, WB_RECLAIMABLE); + xas_for_each_marked(&xas, folio, ULONG_MAX, PAGECACHE_TAG_DIRTY) { + if (folio_test_dirty(folio)) { + long nr = folio_nr_pages(folio); + wb_stat_mod(old_wb, WB_RECLAIMABLE, -nr); + wb_stat_mod(new_wb, WB_RECLAIMABLE, nr); } } xas_set(&xas, 0); - xas_for_each_marked(&xas, page, ULONG_MAX, PAGECACHE_TAG_WRITEBACK) { - WARN_ON_ONCE(!PageWriteback(page)); - dec_wb_stat(old_wb, WB_WRITEBACK); - inc_wb_stat(new_wb, WB_WRITEBACK); + xas_for_each_marked(&xas, folio, ULONG_MAX, PAGECACHE_TAG_WRITEBACK) { + long nr = folio_nr_pages(folio); + WARN_ON_ONCE(!folio_test_writeback(folio)); + wb_stat_mod(old_wb, WB_WRITEBACK, -nr); + wb_stat_mod(new_wb, WB_WRITEBACK, nr); } if (mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) {