linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ge Yang <yangge1116@126.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, 21cnbao@gmail.com, david@redhat.com,
	baolin.wang@linux.alibaba.com, aneesh.kumar@linux.ibm.com,
	liuzixing@hygon.cn
Subject: Re: [PATCH V3] mm/gup: Clear the LRU flag of a page before adding to LRU batch
Date: Thu, 4 Jul 2024 08:57:48 +0800	[thread overview]
Message-ID: <dea5afcf-be7d-4377-8b95-754c2f0245c4@126.com> (raw)
In-Reply-To: <20240703130843.ad421344a0f3f05564a7f706@linux-foundation.org>



在 2024/7/4 4:08, Andrew Morton 写道:
> On Wed,  3 Jul 2024 20:02:33 +0800 yangge1116@126.com wrote:
> 
>> From: yangge <yangge1116@126.com>
>>
>> If a large number of CMA memory are configured in system (for example, the
>> CMA memory accounts for 50% of the system memory), starting a virtual
>> virtual machine with device passthrough, it will
>> call pin_user_pages_remote(..., FOLL_LONGTERM, ...) to pin memory.
>> Normally if a page is present and in CMA area, pin_user_pages_remote()
>> will migrate the page from CMA area to non-CMA area because of
>> FOLL_LONGTERM flag. But the current code will cause the migration failure
>> due to unexpected page refcounts, and eventually cause the virtual machine
>> fail to start.
>>
>> If a page is added in LRU batch, its refcount increases one, remove the
>> page from LRU batch decreases one. Page migration requires the page is not
>> referenced by others except page mapping. Before migrating a page, we
>> should try to drain the page from LRU batch in case the page is in it,
>> however, folio_test_lru() is not sufficient to tell whether the page is
>> in LRU batch or not, if the page is in LRU batch, the migration will fail.
>>
>> To solve the problem above, we modify the logic of adding to LRU batch.
>> Before adding a page to LRU batch, we clear the LRU flag of the page so
>> that we can check whether the page is in LRU batch by folio_test_lru(page).
>> Seems making the LRU flag of the page invisible a long time is no problem,
>> because a new page is allocated from buddy and added to the lru batch,
>> its LRU flag is also not visible for a long time.
>>
> 
> Thanks.
> 
> I'll add this to the mm-hotfixes branch for additional testing.  Please
> continue to work with David on the changelog enhancements.
> 
> In mm-hotfixes I'd expect to send it to Linus next week.  I could move
> it into mm-unstable (then mm-stable) for merging into 6.11-rc1.  This
> is for additional testing time - it will still be backported into
> earlier kernels.  We can do this with any patch.

Ok, thanks.



      reply	other threads:[~2024-07-04  0:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-03 12:02 yangge1116
2024-07-03 20:08 ` Andrew Morton
2024-07-04  0:57   ` Ge Yang [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=dea5afcf-be7d-4377-8b95-754c2f0245c4@126.com \
    --to=yangge1116@126.com \
    --cc=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liuzixing@hygon.cn \
    --cc=stable@vger.kernel.org \
    /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