linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zi Yan <ziy@nvidia.com>
To: "\"Huang, Ying\"" <ying.huang@intel.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	"\"Matthew Wilcox (Oracle)\"" <willy@infradead.org>,
	David Hildenbrand <david@redhat.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>
Subject: Re: [PATCH 1/1] mm/migrate: correct nr_failed in migrate_pages_sync()
Date: Tue, 10 Oct 2023 11:53:07 -0400	[thread overview]
Message-ID: <CE866D48-D92B-4E06-84F4-7330AE47CBD9@nvidia.com> (raw)
In-Reply-To: <87wmvvi1x9.fsf@yhuang6-desk2.ccr.corp.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2016 bytes --]

On 9 Oct 2023, at 23:36, Huang, Ying wrote:

> Zi Yan <zi.yan@sent.com> writes:
>
>> From: Zi Yan <ziy@nvidia.com>
>>
>> nr_failed was missing the rc value from migrate_pages_batch() and can
>> cause a mismatch between migrate_pages() return value and the number of
>> not migrated pages, i.e., when the return value of migrate_pages() is 0,
>> there are still pages left in the from page list. It will happen when a
>> non-PMD THP large folio fails to migrate due to -ENOMEM and is split
>> successfully but not all the split pages are not migrated,
>> migrate_pages_batch() would return non-zero, but astats.nr_thp_split = 0.
>> nr_failed would be 0 and returned to the caller of migrate_pages(), but
>> the not migrated pages are left in the from page list without being added
>> back to LRU lists.
>>
>> Fixes: 2ef7dbb26990 ("migrate_pages: try migrate in batch asynchronously firstly")
>> Signed-off-by: Zi Yan <ziy@nvidia.com>
>> ---
>>  mm/migrate.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/migrate.c b/mm/migrate.c
>> index c602bf6dec97..5348827bd958 100644
>> --- a/mm/migrate.c
>> +++ b/mm/migrate.c
>> @@ -1834,7 +1834,7 @@ static int migrate_pages_sync(struct list_head *from, new_folio_t get_new_folio,
>>  		return rc;
>>  	}
>>  	stats->nr_thp_failed += astats.nr_thp_split;
>> -	nr_failed += astats.nr_thp_split;
>> +	nr_failed += rc + astats.nr_thp_split;
>>  	/*
>>  	 * Fall back to migrate all failed folios one by one synchronously. All
>>  	 * failed folios except split THPs will be retried, so their failure
>
> I don't think this is a correct fix.  The failed folios will be retried
> in the following synchronous migration below.
>
> To fix the issue, we should track nr_split for all large folios (not
> only THP), then use
>
>         nr_failed += astats.nr_split;

You are suggesting a new stats "nr_split" in addition to nr_thp_split? And
nr_split includes nr_thp_split?

--
Best Regards,
Yan, Zi

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 854 bytes --]

      reply	other threads:[~2023-10-10 15:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09 20:32 [PATCH 0/1] Large folio migration fix and questions on migration stats Zi Yan
2023-10-09 20:32 ` [PATCH 1/1] mm/migrate: correct nr_failed in migrate_pages_sync() Zi Yan
2023-10-10  3:36   ` Huang, Ying
2023-10-10 15:53     ` Zi Yan [this message]

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=CE866D48-D92B-4E06-84F4-7330AE47CBD9@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    --cc=ying.huang@intel.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