public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ge Yang <yangge1116@126.com>
To: David Hildenbrand <david@redhat.com>, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, 21cnbao@gmail.com,
	baolin.wang@linux.alibaba.com, liuzixing@hygon.cn
Subject: Re: [PATCH V2] mm/gup: Clear the LRU flag of a page before adding to LRU batch
Date: Thu, 4 Jul 2024 14:24:14 +0800	[thread overview]
Message-ID: <ef7eee42-ebee-477c-83f5-d2103886ccd5@126.com> (raw)
In-Reply-To: <26efe5f2-0cad-404c-82ca-a556469ba9c7@redhat.com>



在 2024/7/3 20:02, David Hildenbrand 写道:
> On 22.06.24 08:48, 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, 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.
>>
> 
> I think we need to describe the impact of this change in a better way. 
> This example here is certainly interesting, but if pages are new they 
> are also not candidate for immediate reclaim (tail of the LRU).
> 
> The positive thing is that we can more reliably identify pages that are 
> on an LRU batch.
> 
> Further, a page can now only be on exactly one LRU batch.
> 
> But, as long as a page is on a LRU batch, we cannot isolate it, and we 
> cannot check if it's an LRU page. The latter can currently already 
> happen for a shorter time when moving LRU pages, and temporarily 
> clearing the flag.
> 
> I shared some examples where we don't care, because we'd check for 
> additional folio references either way (and the one from the LRU batch).
> 
> But I think we have to identify if there are any LRU folio/page checks 
> that could now be impacted "more". At least we should document it 
> properly to better understand the possible impact (do we maybe have to 
> flush more often?).
> 

Thanks.
I have reviewed a lot of paths using LRU folio/page checks and haven't 
seen more impact. I will documnt possible impact in next version, thanks.



  reply	other threads:[~2024-07-04  6:25 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-22  6:48 [PATCH V2] mm/gup: Clear the LRU flag of a page before adding to LRU batch yangge1116
2024-07-03  9:46 ` Barry Song
2024-07-03 11:15   ` Ge Yang
2024-07-03 12:02 ` David Hildenbrand
2024-07-04  6:24   ` Ge Yang [this message]
2024-07-27 22:33 ` Chris Li
2024-07-29  0:34   ` Ge Yang
2024-07-29  3:49   ` Ge Yang
2024-07-29 22:06     ` Chris Li
2024-08-02  1:51       ` Ge Yang
2024-08-02 20:18         ` Chris Li
2024-08-03  8:25           ` Ge Yang
2024-08-03 17:08             ` Yu Zhao
2024-08-03 20:03               ` Kairui Song
2024-08-04 12:21                 ` Kairui Song
2024-08-04 17:51                   ` Chris Li
2024-08-04 19:11                     ` Chris Li
2024-09-02 12:53                       ` Linux regression tracking (Thorsten Leemhuis)
2024-09-05  5:00                         ` Chris Li
2024-07-29 14:04 ` David Hildenbrand
2024-07-30  0:57   ` Ge Yang
2024-07-30  7:45     ` David Hildenbrand
2024-07-30  9:36       ` Ge Yang
2024-07-30  9:41         ` David Hildenbrand
2024-07-30  9:56           ` Ge Yang
2024-07-30  9:58             ` David Hildenbrand
2024-07-30 10:01               ` Ge Yang

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=ef7eee42-ebee-477c-83f5-d2103886ccd5@126.com \
    --to=yangge1116@126.com \
    --cc=21cnbao@gmail.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=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