Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5978pxv; Wed, 14 Jul 2021 21:37:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAs7yZwGNKvbgQgEjFbSI51Tg2basvCMR7JA4oNT9/w9hvCWZwbzrYej+m2GBv6jGyVYC0 X-Received: by 2002:a6b:4412:: with SMTP id r18mr1558267ioa.120.1626323866429; Wed, 14 Jul 2021 21:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626323866; cv=none; d=google.com; s=arc-20160816; b=s/AKXt8f1r9R18ub4beBs4DSjkrkdmC14UHSR+YpprYReGGd5wynJO06yxT8O9hDUh 7i+7D4i99h64jzL3FYP1uVBjGI8dSTfcu4nhNp+nZzAyD7R64zUhFDTApS3S4HIOyhr5 8Y9oteYhPF0J8UMexrw0/pqqbnxkGCCupOlHjz876GUlCu3tzQKXqnY0Sa9rTrd06WYD /UIv4eqq7UnD6j++P0xNU5TOiIOdVNlxDmKR3V5QgwG1V00cp6/uXA3mFXoYdqM/jMxo JVs3VRsBWPm+xaeK2nDYi0sYTQcMXDt7VS2eOPQGbzQAR1iRKDNDb+QXTbQpjwQErstx snQA== 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=oho32fb4EndS/uwM41GnXhOxiT41S3Jw0vCTyJbW2Cc=; b=oVC235gy+0/h8ervw7XniYKL/jBM/YMSAiSS7+aoJP2cwVx0QdReNlcoUicEN+HKc1 MtPLkofpdxuXNGAtN18rH9fSvneE0V9PgJdipbBf2AJQGgnji+lzGEe/zvZaNDGkVtLH smRu6AUonYGLiLlz+7YE+NDQEd4+CWErrQBqQY+ypbq02G4wZWXxRvrtIKVaaW3uNmV8 LAChzn8xO58mp3X3Y2nvTzEEjp/vcK+Gqu5qwWbMd6tM0VNBBeGygU2mNSWmlV91c1Sv eGqhkn1jj+OT9dA04zsUcHkqYp0H6zqJJzjxJym1Y+CIrEbWvlqvCI1jT+GW8cvxC14l 4JQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=CME7NHTE; 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 t25si5309207ios.38.2021.07.14.21.37.34; Wed, 14 Jul 2021 21:37:46 -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=CME7NHTE; 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 S233390AbhGODnR (ORCPT + 99 others); Wed, 14 Jul 2021 23:43:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbhGODnR (ORCPT ); Wed, 14 Jul 2021 23:43:17 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2629CC06175F; Wed, 14 Jul 2021 20:40:25 -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=oho32fb4EndS/uwM41GnXhOxiT41S3Jw0vCTyJbW2Cc=; b=CME7NHTE+w0VifnL5QGvHSaHEf UgQNPt87Sl1QMdUZ9FIp+stZ92TfEYKAlZHL7smNvZKvzvb3KbPi+5HTDH+QJ1D6P/I1qXGhQr0sC v7DqQ8Baypr57AExtwzlQJiegeA5vgH6yA5ds4gbWe6/Kb1K0HHhHXzeni2WsTDyJO9GQWkkGYuSq V4JoM/415oxg7gkpnhuo9o6PvAYUdYV4fpNc1CUG2y1ngFiGH1YHzoMO8pfwlUFfu2DFLxnBbtLiT bBlMHF7gE4QiMhwq9PgpuUJMSOi1SrK28oaHsFg4Kfod41+xD5qZhZx3K/KHtXd0sTlLD/ZsQKPRo AacSoi8Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3sDS-002uOC-17; Thu, 15 Jul 2021 03:39:26 +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 , Jeff Layton , "Kirill A . Shutemov" , Vlastimil Babka , William Kucharski , David Howells Subject: [PATCH v14 004/138] mm/vmstat: Add functions to account folio statistics Date: Thu, 15 Jul 2021 04:34:50 +0100 Message-Id: <20210715033704.692967-5-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715033704.692967-1-willy@infradead.org> References: <20210715033704.692967-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow page counters to be more readily modified by callers which have a folio. Name these wrappers with 'stat' instead of 'state' as requested by Linus here: https://lore.kernel.org/linux-mm/CAHk-=wj847SudR-kt+46fT3+xFFgiwpgThvm7DJWGdi4cVrbnQ@mail.gmail.com/ No change to generated code. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig Acked-by: Jeff Layton Acked-by: Kirill A. Shutemov Acked-by: Vlastimil Babka Reviewed-by: William Kucharski Reviewed-by: David Howells --- include/linux/vmstat.h | 107 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index d6a6cf53b127..241bd0f53fb9 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -415,6 +415,78 @@ static inline void drain_zonestat(struct zone *zone, struct per_cpu_zonestat *pzstats) { } #endif /* CONFIG_SMP */ +static inline void __zone_stat_mod_folio(struct folio *folio, + enum zone_stat_item item, long nr) +{ + __mod_zone_page_state(folio_zone(folio), item, nr); +} + +static inline void __zone_stat_add_folio(struct folio *folio, + enum zone_stat_item item) +{ + __mod_zone_page_state(folio_zone(folio), item, folio_nr_pages(folio)); +} + +static inline void __zone_stat_sub_folio(struct folio *folio, + enum zone_stat_item item) +{ + __mod_zone_page_state(folio_zone(folio), item, -folio_nr_pages(folio)); +} + +static inline void zone_stat_mod_folio(struct folio *folio, + enum zone_stat_item item, long nr) +{ + mod_zone_page_state(folio_zone(folio), item, nr); +} + +static inline void zone_stat_add_folio(struct folio *folio, + enum zone_stat_item item) +{ + mod_zone_page_state(folio_zone(folio), item, folio_nr_pages(folio)); +} + +static inline void zone_stat_sub_folio(struct folio *folio, + enum zone_stat_item item) +{ + mod_zone_page_state(folio_zone(folio), item, -folio_nr_pages(folio)); +} + +static inline void __node_stat_mod_folio(struct folio *folio, + enum node_stat_item item, long nr) +{ + __mod_node_page_state(folio_pgdat(folio), item, nr); +} + +static inline void __node_stat_add_folio(struct folio *folio, + enum node_stat_item item) +{ + __mod_node_page_state(folio_pgdat(folio), item, folio_nr_pages(folio)); +} + +static inline void __node_stat_sub_folio(struct folio *folio, + enum node_stat_item item) +{ + __mod_node_page_state(folio_pgdat(folio), item, -folio_nr_pages(folio)); +} + +static inline void node_stat_mod_folio(struct folio *folio, + enum node_stat_item item, long nr) +{ + mod_node_page_state(folio_pgdat(folio), item, nr); +} + +static inline void node_stat_add_folio(struct folio *folio, + enum node_stat_item item) +{ + mod_node_page_state(folio_pgdat(folio), item, folio_nr_pages(folio)); +} + +static inline void node_stat_sub_folio(struct folio *folio, + enum node_stat_item item) +{ + mod_node_page_state(folio_pgdat(folio), item, -folio_nr_pages(folio)); +} + static inline void __mod_zone_freepage_state(struct zone *zone, int nr_pages, int migratetype) { @@ -543,6 +615,24 @@ static inline void __dec_lruvec_page_state(struct page *page, __mod_lruvec_page_state(page, idx, -1); } +static inline void __lruvec_stat_mod_folio(struct folio *folio, + enum node_stat_item idx, int val) +{ + __mod_lruvec_page_state(&folio->page, idx, val); +} + +static inline void __lruvec_stat_add_folio(struct folio *folio, + enum node_stat_item idx) +{ + __lruvec_stat_mod_folio(folio, idx, folio_nr_pages(folio)); +} + +static inline void __lruvec_stat_sub_folio(struct folio *folio, + enum node_stat_item idx) +{ + __lruvec_stat_mod_folio(folio, idx, -folio_nr_pages(folio)); +} + static inline void inc_lruvec_page_state(struct page *page, enum node_stat_item idx) { @@ -555,4 +645,21 @@ static inline void dec_lruvec_page_state(struct page *page, mod_lruvec_page_state(page, idx, -1); } +static inline void lruvec_stat_mod_folio(struct folio *folio, + enum node_stat_item idx, int val) +{ + mod_lruvec_page_state(&folio->page, idx, val); +} + +static inline void lruvec_stat_add_folio(struct folio *folio, + enum node_stat_item idx) +{ + lruvec_stat_mod_folio(folio, idx, folio_nr_pages(folio)); +} + +static inline void lruvec_stat_sub_folio(struct folio *folio, + enum node_stat_item idx) +{ + lruvec_stat_mod_folio(folio, idx, -folio_nr_pages(folio)); +} #endif /* _LINUX_VMSTAT_H */ -- 2.30.2