mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ryan Roberts <ryan.roberts@arm.com>
To: Barry Song <21cnbao@gmail.com>,
	david@redhat.com, akpm@linux-foundation.org, linux-mm@kvack.org
Cc: cerasuolodomenico@gmail.com, chrisl@kernel.org,
	kasong@tencent.com, peterx@redhat.com, surenb@google.com,
	v-songbaohua@oppo.com, willy@infradead.org,
	yosryahmed@google.com, yuzhao@google.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/2] mm: add per-order mTHP anon_swpout and anon_swpout_fallback counters
Date: Thu, 11 Apr 2024 17:43:51 +0100	[thread overview]
Message-ID: <f56d3f42-c7c9-4c0a-9e1a-b89e92a3cc97@arm.com> (raw)
In-Reply-To: <20240405102704.77559-3-21cnbao@gmail.com>

On 05/04/2024 11:27, 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>
> ---
>  include/linux/huge_mm.h | 2 ++
>  mm/huge_memory.c        | 4 ++++
>  mm/page_io.c            | 6 +++++-
>  mm/vmscan.c             | 3 +++
>  4 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> index c5d33017a4dd..1d893a358df6 100644
> --- a/include/linux/huge_mm.h
> +++ b/include/linux/huge_mm.h
> @@ -267,6 +267,8 @@ unsigned long thp_vma_allowable_orders(struct vm_area_struct *vma,
>  enum mthp_stat_item {
>  	MTHP_STAT_ANON_ALLOC,
>  	MTHP_STAT_ANON_ALLOC_FALLBACK,
> +	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 5b875f0fc923..28113f8fdf18 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -554,10 +554,14 @@ static struct kobj_attribute _name##_attr = __ATTR_RO(_name)
>  
>  DEFINE_MTHP_STAT_ATTR(anon_alloc, MTHP_STAT_ANON_ALLOC);
>  DEFINE_MTHP_STAT_ATTR(anon_alloc_fallback, MTHP_STAT_ANON_ALLOC_FALLBACK);
> +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_alloc_attr.attr,
>  	&anon_alloc_fallback_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..7669452e8b4d 100644
> --- a/mm/page_io.c
> +++ b/mm/page_io.c
> @@ -212,13 +212,17 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
>  
>  static inline void count_swpout_vm_event(struct folio *folio)
>  {
> +	long nr_pages = folio_nr_pages(folio);
> +
>  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>  	if (unlikely(folio_test_pmd_mappable(folio))) {
>  		count_memcg_folio_events(folio, THP_SWPOUT, 1);
>  		count_vm_event(THP_SWPOUT);
>  	}
> +	if (nr_pages > 0)
> +		count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_SWPOUT);

I think you mean "nr_pages > 1"? Although as established in my comments against
patch 1, its safe to call for order-0, so could just unconditionally call this
(as you effectively are at the moment).

>  #endif
> -	count_vm_events(PSWPOUT, folio_nr_pages(folio));
> +	count_vm_events(PSWPOUT, nr_pages);
>  }
>  
>  #if defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP)
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index ffc4553c8615..b30e6294f82a 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1247,6 +1247,9 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
>  						count_vm_event(
>  							THP_SWPOUT_FALLBACK);
>  					}
> +					if (nr_pages > 0)
> +						count_mthp_stat(get_order(nr_pages * PAGE_SIZE),
> +							MTHP_STAT_ANON_SWPOUT_FALLBACK);

Same comment.

>  #endif
>  					if (!add_to_swap(folio))
>  						goto activate_locked_split;


  reply	other threads:[~2024-04-11 16:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05 10:27 [PATCH v4 0/2] mm: add per-order mTHP alloc and swpout counters Barry Song
2024-04-05 10:27 ` [PATCH v4 1/2] mm: add per-order mTHP anon_alloc and anon_alloc_fallback counters Barry Song
2024-04-11 16:38   ` Ryan Roberts
2024-04-11 22:40     ` Barry Song
2024-04-12  9:16       ` Ryan Roberts
2024-04-12  9:27         ` Barry Song
2024-04-05 10:27 ` [PATCH v4 2/2] mm: add per-order mTHP anon_swpout and anon_swpout_fallback counters Barry Song
2024-04-11 16:43   ` Ryan Roberts [this message]
2024-04-11 21:52     ` Barry Song
2024-04-05 20:11 ` [PATCH v4 0/2] mm: add per-order mTHP alloc and swpout counters Andrew Morton
2024-04-05 22:04   ` Barry Song
2024-04-11 16:45     ` 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=f56d3f42-c7c9-4c0a-9e1a-b89e92a3cc97@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=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

all inboxes | Powered by JetHome®