linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>, linux-mm@kvack.org
Cc: Daniel Jordan <daniel.m.jordan@oracle.com>,
	Zi Yan <ziy@nvidia.com>, John Hubbard <jhubbard@nvidia.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC] mm/vmstat: Add events for HugeTLB migration
Date: Mon, 28 Sep 2020 15:04:39 -0700	[thread overview]
Message-ID: <78e77883-9ba9-159c-200a-e8303bbfc206@oracle.com> (raw)
In-Reply-To: <1601025149-13311-1-git-send-email-anshuman.khandual@arm.com>

On 9/25/20 2:12 AM, Anshuman Khandual wrote:
> Add following new vmstat events which will track HugeTLB page migration.
> 
> 1. HUGETLB_MIGRATION_SUCCESS
> 2. HUGETLB_MIGRATION_FAILURE
> 
> It follows the existing semantics to accommodate HugeTLB subpages in total
> page migration statistics. While here, this updates current trace event
> "mm_migrate_pages" to accommodate now available HugeTLB based statistics.

Thanks.  This makes sense with recent THP changes.

> diff --git a/mm/migrate.c b/mm/migrate.c
> index 3ab965f83029..d53dd101ffff 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1415,13 +1415,17 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
>  {
>  	int retry = 1;
>  	int thp_retry = 1;
> +	int hugetlb_retry = 1;
>  	int nr_failed = 0;
>  	int nr_succeeded = 0;
>  	int nr_thp_succeeded = 0;
>  	int nr_thp_failed = 0;
>  	int nr_thp_split = 0;
> +	int nr_hugetlb_succeeded = 0;
> +	int nr_hugetlb_failed = 0;
>  	int pass = 0;
>  	bool is_thp = false;
> +	bool is_hugetlb = false;
>  	struct page *page;
>  	struct page *page2;
>  	int swapwrite = current->flags & PF_SWAPWRITE;
> @@ -1433,6 +1437,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
>  	for (pass = 0; pass < 10 && (retry || thp_retry); pass++) {
>  		retry = 0;
>  		thp_retry = 0;
> +		hugetlb_retry = 0;
>  
>  		list_for_each_entry_safe(page, page2, from, lru) {
>  retry:
> @@ -1442,7 +1447,12 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
>  			 * during migration.
>  			 */
>  			is_thp = PageTransHuge(page) && !PageHuge(page);
> +			is_hugetlb = PageTransHuge(page) && PageHuge(page);

PageHuge does not depend on PageTransHuge.  So, this could just be
			is_hugetlb = PageHuge(page);

Actually, the current version of PageHuge is more expensive than PageTransHuge.
So, the most optimal way to set these would be something like.
			if (PageTransHuge(page))
				if (PageHuge(page))
					is_hugetlb = true;
				else
					is_thp = true;

Although, the compiler may be able to optimize.  I did not check.

> +
>  			nr_subpages = thp_nr_pages(page);
> +			if (is_hugetlb)
> +				nr_subpages = pages_per_huge_page(page_hstate(page));

Can we just use compound_order() here for all cases?

-- 
Mike Kravetz


  parent reply	other threads:[~2020-09-28 22:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25  9:12 [RFC] mm/vmstat: Add events for HugeTLB migration Anshuman Khandual
2020-09-25  9:49 ` Oscar Salvador
2020-09-28  3:32   ` Anshuman Khandual
2020-09-28 22:04 ` Mike Kravetz [this message]
2020-09-29  6:02   ` Anshuman Khandual

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=78e77883-9ba9-159c-200a-e8303bbfc206@oracle.com \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=daniel.m.jordan@oracle.com \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ziy@nvidia.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;
as well as URLs for NNTP newsgroup(s).