Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1723894pxb; Thu, 4 Mar 2021 20:19:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJyC0qapbrKUHUekVJ3ef62ZeB74EDz04UkBOQ0QPGYf8QkOFUyvWvucb5mTwtgTk+/2mMWq X-Received: by 2002:a02:7f8c:: with SMTP id r134mr7726022jac.95.1614917999048; Thu, 04 Mar 2021 20:19:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614917999; cv=none; d=google.com; s=arc-20160816; b=OTU8fjMnTC3jdLeUrrZmgTAsctLIcfyPijaJ3BtdBGMtsA5AsN1q/qW3jqQj0kleE7 QglrxryJHOEKLMCcmi5u+JvJ+dTxNpnyF936VC8hw2czRb/DkL+z6Zy8h3zFOSQAqIQ/ ZDQM8ADXjH7o1v18/qcfBykBlnx0FoLHlua6rEqPhpjolsbuwd0cMVqvEslnJQAsqctY /3HMUfShz8RFUpeWMo9MjXkEUHHRzpFcmOIDGCM0wHO295Zm1qPQS9pjnvsm/lT8IyFy Ei8ahuy17z/b6RIhU5I+zeAgfkmvbIYhnyHaYyG73d9Qr6ampMOHWm9pOlwOHy8Scnj1 FYcQ== 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=TfEJs96Ck13Yfn0mZfn2F+YPOt+7EPnxf8ur6JTtW6I=; b=lzJ+zxoguUXLD75jaKyosv5st58OYxrC+0Fd36YtHB6Z7pRBbEKi4knIyOGTKbCFF8 HAMFN05vL1H2tdKw/8ZxDmcrceacS6CcHrMvFGp2d4CKxn7InGU+OfJEdoXr+fe10NP0 GzGCizXEm1m03XN2kFD0BiHf7y8NAAUt10jI9TTpwyfcnYekEj+JVQGlIfF0ZVD7xgul AEnxsyTmZQkyX5fFT13qRittH/JFMa9/M2+e9BGnCdGRbnQCyDG7GkZBraFjw7gbvklZ h3ylJ0fj431hRZ8eOcVOMj0hOMQMGRtXwmFDz7OdbZnKAQBJx0fcoARECP9WCeyzujC/ jpag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cRV61d0e; 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 o24si1434518jah.41.2021.03.04.20.19.45; Thu, 04 Mar 2021 20:19:59 -0800 (PST) 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=cRV61d0e; 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 S229729AbhCEETU (ORCPT + 99 others); Thu, 4 Mar 2021 23:19:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbhCEETT (ORCPT ); Thu, 4 Mar 2021 23:19:19 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C17A3C061574; Thu, 4 Mar 2021 20:19:18 -0800 (PST) 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=TfEJs96Ck13Yfn0mZfn2F+YPOt+7EPnxf8ur6JTtW6I=; b=cRV61d0eP1fedPSGYC6ZnAUwFS XtfS+nf5eiaZmnEnJSVbX/ArI+5Jxk4D+PP4MaR41DXmEWpdpey/mm30HlcSeETtWWuYeCA8MLaPg vrhI2uhim3+Xmu/JZGTttjrD3I2rzxICJciJ3vB4y25C2Z+aDaRaLkMoxEzThBoiVyY954V/Yzj+V BXK5Qtmh7STyqh3UcPJZ5KB7amOvBhsWy/UFdiszD8jv787MW7fjQAn7uYvaCopZwEQK2GMQD/uEc 7+qkSU7PI4XATdFC1B0rxyMxmhHveknKkQe7TB9YKMeNvgykMpnX8pLipQMskxj/eJ678h2IB4QLx MvfEas1Q==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lI1vk-00A3Sg-4R; Fri, 05 Mar 2021 04:19:12 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v4 03/25] mm/vmstat: Add functions to account folio statistics Date: Fri, 5 Mar 2021 04:18:39 +0000 Message-Id: <20210305041901.2396498-4-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210305041901.2396498-1-willy@infradead.org> References: <20210305041901.2396498-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) --- include/linux/vmstat.h | 83 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 506d625163a1..dff5342df07b 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -402,6 +402,54 @@ static inline void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset) { } #endif /* CONFIG_SMP */ +static inline +void __inc_zone_folio_stat(struct folio *folio, enum zone_stat_item item) +{ + __mod_zone_page_state(folio_zone(folio), item, folio_nr_pages(folio)); +} + +static inline +void __dec_zone_folio_stat(struct folio *folio, enum zone_stat_item item) +{ + __mod_zone_page_state(folio_zone(folio), item, -folio_nr_pages(folio)); +} + +static inline +void inc_zone_folio_stat(struct folio *folio, enum zone_stat_item item) +{ + mod_zone_page_state(folio_zone(folio), item, folio_nr_pages(folio)); +} + +static inline +void dec_zone_folio_stat(struct folio *folio, enum zone_stat_item item) +{ + mod_zone_page_state(folio_zone(folio), item, -folio_nr_pages(folio)); +} + +static inline +void __inc_node_folio_stat(struct folio *folio, enum node_stat_item item) +{ + __mod_node_page_state(folio_pgdat(folio), item, folio_nr_pages(folio)); +} + +static inline +void __dec_node_folio_stat(struct folio *folio, enum node_stat_item item) +{ + __mod_node_page_state(folio_pgdat(folio), item, -folio_nr_pages(folio)); +} + +static inline +void inc_node_folio_stat(struct folio *folio, enum node_stat_item item) +{ + mod_node_page_state(folio_pgdat(folio), item, folio_nr_pages(folio)); +} + +static inline +void dec_node_folio_stat(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) { @@ -536,6 +584,24 @@ static inline void __dec_lruvec_page_state(struct page *page, __mod_lruvec_page_state(page, idx, -1); } +static inline void __mod_lruvec_folio_stat(struct folio *folio, + enum node_stat_item idx, int val) +{ + __mod_lruvec_page_state(&folio->page, idx, val); +} + +static inline void __inc_lruvec_folio_stat(struct folio *folio, + enum node_stat_item idx) +{ + __mod_lruvec_folio_stat(folio, idx, folio_nr_pages(folio)); +} + +static inline void __dec_lruvec_folio_stat(struct folio *folio, + enum node_stat_item idx) +{ + __mod_lruvec_folio_stat(folio, idx, -folio_nr_pages(folio)); +} + static inline void inc_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx) { @@ -560,4 +626,21 @@ static inline void dec_lruvec_page_state(struct page *page, mod_lruvec_page_state(page, idx, -1); } +static inline void mod_lruvec_folio_stat(struct folio *folio, + enum node_stat_item idx, int val) +{ + mod_lruvec_page_state(&folio->page, idx, val); +} + +static inline void inc_lruvec_folio_stat(struct folio *folio, + enum node_stat_item idx) +{ + mod_lruvec_folio_stat(folio, idx, folio_nr_pages(folio)); +} + +static inline void dec_lruvec_folio_stat(struct folio *folio, + enum node_stat_item idx) +{ + mod_lruvec_folio_stat(folio, idx, -folio_nr_pages(folio)); +} #endif /* _LINUX_VMSTAT_H */ -- 2.30.0