Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2631317pxv; Sun, 11 Jul 2021 20:47:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmKMHA9I/uHVsIWV3XZqgqBDJSfOoMI1tyQKv88CPPEL5WfizM/699imrM2ScleOg2NMNm X-Received: by 2002:a17:906:dc91:: with SMTP id cs17mr50863175ejc.389.1626061670026; Sun, 11 Jul 2021 20:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626061670; cv=none; d=google.com; s=arc-20160816; b=rlReqfm6ub35VZC8i1vAoGCCOf8DZ9H7pav8TSQVAURI6W72VO4c9yISgcnJmH8azF aaVOAuR0Ah3LiIv1XQpc5XVGR2NsBen/1qYKqO3RaNz4oB9k3T+P4cyyL9acG7tYVjTN yShy0QnY7xQkgwJ0NpGEbJ9Z5kYPpSgiOqyloDhFE2S0sBgIjQ9O2TnDT2QQKDHhiLKY D2FYQcZgo9TC+uPgtuD3/e7zpTYlvx1+5W5nhWlflv4u86S8l3GIx/c1f/aC+C+3SzS7 4npmJs3Dp/WzeOIFHbJYzI7qdEpSZvYrs7PPnZEIKmNZviTSiuNHAIP3ybMvMS6HhQq2 U/XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qdxqqOClobPMFXh6cqBgawrWEnT3Lsml+wAsdr77aQU=; b=tjhEGwL8asO0JqbEc3emuOX44W3RP4zQqnytWXNaK8EeBTuS1iRrepqa+aSdXOhbDP zHWR2kHnrZPdR2G5Zh4u+tt0rNU1K2xV0C2ZIhwxMD3oPNhvTu21g8YKxBsJNZ9kXO7P QR5SKPh1Ptt/hXVzHIGyxR5Gypd24jp2Huhr1zJE9VM6npZaehvMzxz+mg3obml/LM1L G7mc8r+zA5fsFdMYdNxOvN+cvJivyJun+XFSCtgin4u+dgvRP2tjmlpCa/j0YIXfn4e+ ajkps0mDzWcrSk8OUILH/DcNQq4206nhYZ7aIOjIT0W8dIa41RM50Qa+nzXRrhk0KdU9 98Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="N/Nv1enO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d26si15312011edx.496.2021.07.11.20.47.27; Sun, 11 Jul 2021 20:47:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="N/Nv1enO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233248AbhGLDtJ (ORCPT + 99 others); Sun, 11 Jul 2021 23:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229998AbhGLDtH (ORCPT ); Sun, 11 Jul 2021 23:49:07 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41D3AC0613DD; Sun, 11 Jul 2021 20:46:20 -0700 (PDT) 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=qdxqqOClobPMFXh6cqBgawrWEnT3Lsml+wAsdr77aQU=; b=N/Nv1enO0PWlFXhd9aw/Bu+lwV 2oITOjo8wzd/vgfJBdMslcsmsC8OG4FnbVWnpkhWYkhWdqNrLexnP51CtcSjkhIIX/sGy/Sc359mE agBdq03e0vz98ayPJgvcyxXTJIkoWZBGyOLv+LlyRizxrVxlqDQe/yEySzLtrQ3HRGkvxogSW7dE8 5fi2HwZElAuRa2jPzSHgEQSbUQeiqqOv6kqiVqxrpEoY2b9CoY+JF8TKh/1qkZ4/s7QOHnL+Y2v9E giUplMmOjEKgb68QDYTn2v4U2Cg4rPmkvl9hvLcuiOLlp9PkZcgbBTOGSepTImeIbKGmTTx7Yentl hKjYARxg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2msJ-00GpRI-1x; Mon, 12 Jul 2021 03:45:09 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig Subject: [PATCH v13 071/137] mm/writeback: Add folio_account_cleaned() Date: Mon, 12 Jul 2021 04:05:55 +0100 Message-Id: <20210712030701.4000097-72-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210712030701.4000097-1-willy@infradead.org> References: <20210712030701.4000097-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Get the statistics right; compound pages were being accounted as a single page. This didn't matter before now as no filesystem which supported compound pages did writeback. Also move the declaration to filemap.h since this is part of the page cache. Add a wrapper for account_page_cleaned(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig --- include/linux/mm.h | 3 --- include/linux/pagemap.h | 7 +++++++ mm/page-writeback.c | 11 ++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 069378a073a9..54fde920d8e0 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -39,7 +39,6 @@ struct anon_vma_chain; struct file_ra_state; struct user_struct; struct writeback_control; -struct bdi_writeback; struct pt_regs; extern int sysctl_page_lock_unfairness; @@ -2002,8 +2001,6 @@ extern void do_invalidatepage(struct page *page, unsigned int offset, int redirty_page_for_writepage(struct writeback_control *wbc, struct page *page); -void account_page_cleaned(struct page *page, struct address_space *mapping, - struct bdi_writeback *wb); bool folio_mark_dirty(struct folio *folio); bool set_page_dirty(struct page *page); int set_page_dirty_lock(struct page *page); diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 7e2f915dcb4d..3907244ed4a0 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -779,6 +779,13 @@ static inline void __set_page_dirty(struct page *page, { __folio_mark_dirty(page_folio(page), mapping, warn); } +void folio_account_cleaned(struct folio *folio, struct address_space *mapping, + struct bdi_writeback *wb); +static inline void account_page_cleaned(struct page *page, + struct address_space *mapping, struct bdi_writeback *wb) +{ + return folio_account_cleaned(page_folio(page), mapping, wb); +} int __set_page_dirty_nobuffers(struct page *page); int __set_page_dirty_no_writeback(struct page *page); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 35e998f064c2..3bbf15a7a60f 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2453,14 +2453,15 @@ static void folio_account_dirtied(struct folio *folio, * * Caller must hold lock_page_memcg(). */ -void account_page_cleaned(struct page *page, struct address_space *mapping, +void folio_account_cleaned(struct folio *folio, struct address_space *mapping, struct bdi_writeback *wb) { if (mapping_can_writeback(mapping)) { - dec_lruvec_page_state(page, NR_FILE_DIRTY); - dec_zone_page_state(page, NR_ZONE_WRITE_PENDING); - dec_wb_stat(wb, WB_RECLAIMABLE); - task_io_account_cancelled_write(PAGE_SIZE); + long nr = folio_nr_pages(folio); + lruvec_stat_mod_folio(folio, NR_FILE_DIRTY, -nr); + zone_stat_mod_folio(folio, NR_ZONE_WRITE_PENDING, -nr); + wb_stat_mod(wb, WB_RECLAIMABLE, -nr); + task_io_account_cancelled_write(folio_size(folio)); } } -- 2.30.2