From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BA91C433DB for ; Mon, 1 Mar 2021 22:16:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3167960202 for ; Mon, 1 Mar 2021 22:16:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3167960202 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 760EF8D00AB; Mon, 1 Mar 2021 17:16:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 70F858D0063; Mon, 1 Mar 2021 17:16:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 624B98D00AB; Mon, 1 Mar 2021 17:16:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id 4D4618D0063 for ; Mon, 1 Mar 2021 17:16:19 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E81806100 for ; Mon, 1 Mar 2021 22:16:18 +0000 (UTC) X-FDA: 77872714836.11.172CD1B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id 7BF1FA06E408 for ; Mon, 1 Mar 2021 22:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=zxZIlcc7PFkSOXfb8Azdcpif4NIGsuIagSgxJ7r+Dx0=; b=INpsQoCF19J5S1IqbMocDI7zho DbkuSxFu6JX1zFwJYXpA3CAYN56R+uVcSOfzBGeIT1zBIaRJfNoL1+T59hKtSfbcFiKeVL2NE4PvP iJ737y3mQso609/FgDStoFIHnZzo+dSbGnfGYjCPTJRmoKdUGRCxwRmMftQC1Lw4SpBTalZX2SgGU aqXPq1lmkhgG8Vi86a7UmBdfiwfwxRhNY31P9nu1ow0Wjkh2wz29dwiKjeBwP2K45VGZcs3ic0yDQ OFpb6nXGP4cw/njjSj+ZC6ZwnUsB6DKAbqlCKFp5zfF1jQlMocI8WoklflXnJQThFtqVAA1QG+Nhz R8ahroeg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lGqpN-00GIQj-PG; Mon, 01 Mar 2021 22:16:01 +0000 Date: Mon, 1 Mar 2021 22:15:45 +0000 From: Matthew Wilcox To: Zi Yan Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 03/25] mm/vmstat: Add folio stat wrappers Message-ID: <20210301221545.GV2723601@casper.infradead.org> References: <20210128070404.1922318-1-willy@infradead.org> <20210128070404.1922318-4-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7BF1FA06E408 X-Stat-Signature: tij34y4xyza8rjrq6zpqww7mb6p9sjjf Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf07; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614636975-408438 Content-Transfer-Encoding: quoted-printable 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: On Mon, Mar 01, 2021 at 04:17:39PM -0500, Zi Yan wrote: > On 28 Jan 2021, at 2:03, Matthew Wilcox (Oracle) wrote: > > Allow page counters to be more readily modified by callers which have > > a folio. Name these wrappers with 'stat' instead of 'state' as reque= sted > > Shouldn=E2=80=99t we change the stats with folio_nr_pages(folio) here? = And all > changes below. Otherwise one folio is always counted as a single page. That's a good point. Looking through the changes in my current folio tree (which doesn't get as far as the thp tree did; ie doesn't yet alloca= te multi-page folios, so hasn't been tested with anything larger than a single page), the callers are ... @@ -2698,3 +2698,3 @@ int clear_page_dirty_for_io(struct page *page) - if (TestClearPageDirty(page)) { - dec_lruvec_page_state(page, NR_FILE_DIRTY); - dec_zone_page_state(page, NR_ZONE_WRITE_PENDING); + if (TestClearFolioDirty(folio)) { + dec_lruvec_folio_stat(folio, NR_FILE_DIRTY); + dec_zone_folio_stat(folio, NR_ZONE_WRITE_PENDING)= ; @@ -2432,3 +2433,3 @@ void account_page_dirtied(struct page *page, struct= addres s_space *mapping) - __inc_lruvec_page_state(page, NR_FILE_DIRTY); - __inc_zone_page_state(page, NR_ZONE_WRITE_PENDING); - __inc_node_page_state(page, NR_DIRTIED); + __inc_lruvec_folio_stat(folio, NR_FILE_DIRTY); + __inc_zone_folio_stat(folio, NR_ZONE_WRITE_PENDING); + __inc_node_folio_stat(folio, NR_DIRTIED); @@ -891 +890 @@ noinline int __add_to_page_cache_locked(struct page *page= , - __inc_lruvec_page_state(page, NR_FILE_PAGES); + __inc_lruvec_folio_stat(folio, NR_FILE_PAGES); @@ -2759,2 +2759,2 @@ int test_clear_page_writeback(struct page *page) - dec_zone_page_state(page, NR_ZONE_WRITE_PENDING); - inc_node_page_state(page, NR_WRITTEN); + dec_zone_folio_stat(folio, NR_ZONE_WRITE_PENDING); + inc_node_folio_stat(folio, NR_WRITTEN); I think it's clear from this that I haven't found all the places that I need to change yet ;-) Looking at the places I did change in the thp tree, there are changes like this: @@ -860,27 +864,30 @@ noinline int __add_to_page_cache_locked(struct page= *page, - if (!huge) - __inc_lruvec_page_state(page, NR_FILE_PAGES); + if (!huge) { + __mod_lruvec_page_state(page, NR_FILE_PAGES, nr); + if (nr > 1) + __mod_node_page_state(page_pgdat(page), + NR_FILE_THPS, nr); + } ... but I never did do some of the changes which the above changes imply are needed. So the thp tree probably had all kinds of bad statistics that I never noticed. So ... at least some of the users are definitely going to want to cache the 'nr_pages' and use it multiple times, including calling __mod_node_folio_state(), but others should do what you suggested. Thanks! I'll make that change.