linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ryan Roberts <ryan.roberts@arm.com>
To: Barry Song <21cnbao@gmail.com>,
	akpm@linux-foundation.org, linux-mm@kvack.org
Cc: cerasuolodomenico@gmail.com, chrisl@kernel.org, david@redhat.com,
	kasong@tencent.com, linux-kernel@vger.kernel.org,
	peterx@redhat.com, surenb@google.com, v-songbaohua@oppo.com,
	willy@infradead.org, yosryahmed@google.com, yuzhao@google.com,
	corbet@lwn.net
Subject: Re: [PATCH v5 2/4] mm: add per-order mTHP anon_swpout and anon_swpout_fallback counters
Date: Fri, 12 Apr 2024 10:43:23 +0100	[thread overview]
Message-ID: <ebcd40f1-9bc6-4ae4-8b12-deedf9b8b450@arm.com> (raw)
In-Reply-To: <20240412073740.294272-3-21cnbao@gmail.com>

On 12/04/2024 08:37, Barry Song wrote:
> From: Barry Song <v-songbaohua@oppo.com>
> 
> This helps to display the fragmentation situation of the swapfile, knowing
> the proportion of how much we haven't split large folios.  So far, we only
> support non-split swapout for anon memory, with the possibility of
> expanding to shmem in the future.  So, we add the "anon" prefix to the
> counter names.
> 
> Signed-off-by: Barry Song <v-songbaohua@oppo.com>
> Cc: Chris Li <chrisl@kernel.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Domenico Cerasuolo <cerasuolodomenico@gmail.com>
> Cc: Kairui Song <kasong@tencent.com>
> Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Suren Baghdasaryan <surenb@google.com>
> Cc: Yosry Ahmed <yosryahmed@google.com>
> Cc: Yu Zhao <yuzhao@google.com>


LGTM!

Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>


> ---
>  include/linux/huge_mm.h | 2 ++
>  mm/huge_memory.c        | 4 ++++
>  mm/page_io.c            | 1 +
>  mm/vmscan.c             | 3 +++
>  4 files changed, 10 insertions(+)
> 
> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> index c5beb54b97cb..b69c3b3e1436 100644
> --- a/include/linux/huge_mm.h
> +++ b/include/linux/huge_mm.h
> @@ -268,6 +268,8 @@ enum mthp_stat_item {
>  	MTHP_STAT_ANON_FAULT_ALLOC,
>  	MTHP_STAT_ANON_FAULT_FALLBACK,
>  	MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE,
> +	MTHP_STAT_ANON_SWPOUT,
> +	MTHP_STAT_ANON_SWPOUT_FALLBACK,
>  	__MTHP_STAT_COUNT
>  };
>  
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 21c4ac74b484..13e74724d0c3 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -557,11 +557,15 @@ static struct kobj_attribute _name##_attr = __ATTR_RO(_name)
>  DEFINE_MTHP_STAT_ATTR(anon_fault_alloc, MTHP_STAT_ANON_FAULT_ALLOC);
>  DEFINE_MTHP_STAT_ATTR(anon_fault_fallback, MTHP_STAT_ANON_FAULT_FALLBACK);
>  DEFINE_MTHP_STAT_ATTR(anon_fault_fallback_charge, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE);
> +DEFINE_MTHP_STAT_ATTR(anon_swpout, MTHP_STAT_ANON_SWPOUT);
> +DEFINE_MTHP_STAT_ATTR(anon_swpout_fallback, MTHP_STAT_ANON_SWPOUT_FALLBACK);
>  
>  static struct attribute *stats_attrs[] = {
>  	&anon_fault_alloc_attr.attr,
>  	&anon_fault_fallback_attr.attr,
>  	&anon_fault_fallback_charge_attr.attr,
> +	&anon_swpout_attr.attr,
> +	&anon_swpout_fallback_attr.attr,
>  	NULL,
>  };
>  
> diff --git a/mm/page_io.c b/mm/page_io.c
> index a9a7c236aecc..46c603dddf04 100644
> --- a/mm/page_io.c
> +++ b/mm/page_io.c
> @@ -217,6 +217,7 @@ static inline void count_swpout_vm_event(struct folio *folio)
>  		count_memcg_folio_events(folio, THP_SWPOUT, 1);
>  		count_vm_event(THP_SWPOUT);
>  	}
> +	count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_SWPOUT);
>  #endif
>  	count_vm_events(PSWPOUT, folio_nr_pages(folio));
>  }
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index bca2d9981c95..49bd94423961 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1231,6 +1231,8 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
>  						goto activate_locked;
>  				}
>  				if (!add_to_swap(folio)) {
> +					int __maybe_unused order = folio_order(folio);
> +
>  					if (!folio_test_large(folio))
>  						goto activate_locked_split;
>  					/* Fallback to swap normal pages */
> @@ -1242,6 +1244,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
>  							THP_SWPOUT_FALLBACK, 1);
>  						count_vm_event(THP_SWPOUT_FALLBACK);
>  					}
> +					count_mthp_stat(order, MTHP_STAT_ANON_SWPOUT_FALLBACK);
>  #endif
>  					if (!add_to_swap(folio))
>  						goto activate_locked_split;



  reply	other threads:[~2024-04-12  9:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-12  7:37 [PATCH v5 0/4] mm: add per-order mTHP alloc and swpout counters Barry Song
2024-04-12  7:37 ` [PATCH v5 1/4] mm: add per-order mTHP anon_fault_alloc and anon_fault_fallback counters Barry Song
2024-04-12  9:26   ` Ryan Roberts
2024-04-12  9:43     ` Barry Song
2024-04-12  9:56       ` Ryan Roberts
2024-04-12 10:17         ` Barry Song
2024-04-12 10:25           ` Ryan Roberts
2024-04-12 10:29             ` Barry Song
2024-04-12 10:38               ` Ryan Roberts
2024-04-12 10:53                 ` Barry Song
2024-04-12 11:05                   ` Ryan Roberts
2024-04-12  7:37 ` [PATCH v5 2/4] mm: add per-order mTHP anon_swpout and anon_swpout_fallback counters Barry Song
2024-04-12  9:43   ` Ryan Roberts [this message]
2024-04-12  7:37 ` [PATCH v5 3/4] mm: add docs for per-order mTHP counters and transhuge_page ABI Barry Song
2024-04-12 10:19   ` Ryan Roberts
2024-04-12  7:37 ` [PATCH v5 4/4] mm: correct the docs for thp_fault_alloc and thp_fault_fallback Barry Song
2024-04-12 10:21   ` Ryan Roberts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ebcd40f1-9bc6-4ae4-8b12-deedf9b8b450@arm.com \
    --to=ryan.roberts@arm.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cerasuolodomenico@gmail.com \
    --cc=chrisl@kernel.org \
    --cc=corbet@lwn.net \
    --cc=david@redhat.com \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterx@redhat.com \
    --cc=surenb@google.com \
    --cc=v-songbaohua@oppo.com \
    --cc=willy@infradead.org \
    --cc=yosryahmed@google.com \
    --cc=yuzhao@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox