[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e0bb6713-67b6-e9cb-70c3-66b27aef72ed@suse.cz>
Date: Fri, 14 May 2021 12:36:50 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: "Matthew Wilcox (Oracle)" <willy@...radead.org>,
akpm@...ux-foundation.org
Cc: linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Christoph Hellwig <hch@....de>,
Jeff Layton <jlayton@...nel.org>
Subject: Re: [PATCH v10 03/33] mm/vmstat: Add functions to account folio
statistics
On 5/11/21 11:47 PM, 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 requested
> by Linus here:
> https://lore.kernel.org/linux-mm/CAHk-=wj847SudR-kt+46fT3+xFFgiwpgThvm7DJWGdi4cVrbnQ@mail.gmail.com/
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
> Reviewed-by: Christoph Hellwig <hch@....de>
> Acked-by: Jeff Layton <jlayton@...nel.org>
Acked-by: Vlastimil Babka <vbabka@...e.cz>
> ---
> 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 */
>
Powered by blists - more mailing lists