Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1580132pxf; Fri, 9 Apr 2021 11:58:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhfA/TcFuXac2Yvl4KbX24kBMs2Wdj6fzHxoDdA5mEgKlyQ4ornk/hIQOdukU11qs/0jkT X-Received: by 2002:a17:906:fcc4:: with SMTP id qx4mr8492586ejb.42.1617994711067; Fri, 09 Apr 2021 11:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617994711; cv=none; d=google.com; s=arc-20160816; b=1Gp4DPNN/kML371DGX2qvaQy+Xu2bF1hUH1NmzvNGlic69WBAo2qy3n2uyQ7pnOARD yvzKI9zA/wAv5DFSMX/8t0gv4fJ5QTuiIAa6P7xWw1e9e5zxkOBnLbmSIiPj+gKP3PcK /9ROJkpEM98aDcmc05DdY6/cF/JueOo0/IPotHe93sNRqM8/3x4wc2ZWJr+O42WtlVDa cFfk6kCcZraHcEoBtfbppLq1NioOigsim5TtInC8ovIwellPc6P7yCG/EEDk36S92AOk Rt5QqI/nJebMAWiiZDqboXe4u59syFp4S8Dkt5Y/gdpCqDzstgElrWTq6y4y1/eQEDQC uSmA== 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=r90mtSioPB9UcKNT6Rnzzil4xndwmqmNbGk9sDR1/6M=; b=dphRWu4IVyxm9hRk2Q/faUjSjRwtD715VJRoG31Do7Rf2q4okLmrQdPOgE9E7EZqeK w79N4kwvOQwJ0MfHrBrh5fE5JvtfdKFZpUvYcxt8/hxJ0iXMCiIQqAhrulrtr/PdeTVi zOFl6moiu+aMyCPzscbAG5CW1beHmYOP9qFPhIOLb0WwsJhiiumoVzLKikZ43AhjMJNv y3lyRnl0sauG5NMLToBMaADR99YS5Zmx67l6obismaIctm7nf2l0LNn6sSRizRrS13Be B/Oa1F2fiXjmkipTZT47vqm2jvNsHdqGrU5o8WxVYEcYUI66OXlFsXfew6OrzW0AH1xK A6pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cZiKuQoy; 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 dn18si2558924ejc.590.2021.04.09.11.58.06; Fri, 09 Apr 2021 11:58:31 -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=cZiKuQoy; 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 S234759AbhDISzW (ORCPT + 99 others); Fri, 9 Apr 2021 14:55:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234378AbhDISzV (ORCPT ); Fri, 9 Apr 2021 14:55:21 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49B7BC061762; Fri, 9 Apr 2021 11:55:08 -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=r90mtSioPB9UcKNT6Rnzzil4xndwmqmNbGk9sDR1/6M=; b=cZiKuQoyvvEdpoA3aWQU65R+Ry g2UJvVW2QGxdoJW45OmJDc+LqOZG8C0Edq4xcE/1Z2z8SqpoQnOfPDJUIij8GWEHAIonZXkEzIt5E pT2fo9ms8107sBFhHHd2jUVWrF7/zLrr7B0uBvrvW3HXmsYD7ChEO4DaH0Yfs5kBvQIxY+oU3lXzs QnYzWtDzLV4OeScMWg+LMpoKMjJe7C/MxQoa8zmMAhEx2lPNBPrsd+auld1y0jyLyaAgkXBK2q3Qz kQIlWETnAOx9+vf3i2wDVyzvkrKwcl/Z4oE29cvd5zXaOofe1c6PCFN5saYyWtQYlYKlyvNBouAFC plFbHyJg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lUwG0-000n8t-Pm; Fri, 09 Apr 2021 18:53:35 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, Christoph Hellwig , Jeff Layton Subject: [PATCH v7 04/28] mm/vmstat: Add functions to account folio statistics Date: Fri, 9 Apr 2021 19:50:41 +0100 Message-Id: <20210409185105.188284-5-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210409185105.188284-1-willy@infradead.org> References: <20210409185105.188284-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/ Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig Acked-by: Jeff Layton --- include/linux/vmstat.h | 107 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 3299cd69e4ca..d287d7c31b8f 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -402,6 +402,78 @@ static inline void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset) { } #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) { @@ -530,6 +602,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) { @@ -542,4 +632,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