From: "Yin, Fengwei" <fengwei.yin@intel.com>
To: Yu Zhao <yuzhao@google.com>, Minchan Kim <minchan@kernel.org>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
<akpm@linux-foundation.org>, <willy@infradead.org>,
<david@redhat.com>, <ryan.roberts@arm.com>, <shy828301@gmail.com>
Subject: Re: [RFC PATCH] madvise: make madvise_cold_or_pageout_pte_range() support large folio
Date: Fri, 14 Jul 2023 11:09:45 +0800 [thread overview]
Message-ID: <8547495c-9051-faab-a47d-1962f2e0b1da@intel.com> (raw)
In-Reply-To: <CAOUHufb0zxKvmvEXfG4kySenxyPtagnr_cf4Ms-6si3bQTybGQ@mail.gmail.com>
On 7/14/2023 10:08 AM, Yu Zhao wrote:
> On Thu, Jul 13, 2023 at 9:06 AM Yin Fengwei <fengwei.yin@intel.com> wrote:
>>
>> Current madvise_cold_or_pageout_pte_range() has two problems for
>> large folio support:
>> - Using folio_mapcount() with large folio prevent large folio from
>> picking up.
>> - If large folio is in the range requested, shouldn't split it
>> in madvise_cold_or_pageout_pte_range().
>>
>> Fix them by:
>> - Use folio_estimated_sharers() with large folio
>> - If large folio is in the range requested, don't split it. Leave
>> to page reclaim phase.
>>
>> For large folio cross boundaries of requested range, skip it if it's
>> page cache. Try to split it if it's anonymous folio. If splitting
>> fails, skip it.
>
> For now, we may not want to change the existing semantic (heuristic).
> IOW, we may want to stick to the "only owner" condition:
>
> - if (folio_mapcount(folio) != 1)
> + if (folio_entire_mapcount(folio) ||
> + (any_page_within_range_has_mapcount > 1))
>
> +Minchan Kim
The folio_estimated_sharers() was discussed here:
https://lore.kernel.org/linux-mm/20230118232219.27038-6-vishal.moola@gmail.com/
https://lore.kernel.org/linux-mm/20230124012210.13963-2-vishal.moola@gmail.com/
Yes. It's accurate to check each page of large folio. But it may be over killed in
some cases (And I think madvise is one of the cases not necessary to be accurate.
So folio_estimated_sharers() is enough. Correct me if I am wrong).
>
> Also there is an existing bug here: the later commit 07e8c82b5eff8
> ("madvise: convert madvise_cold_or_pageout_pte_range() to use folios")
> is incorrect for sure; the original commit 9c276cc65a58f ("mm:
> introduce MADV_COLD") seems incorrect too.
>
> +Vishal Moola (Oracle)
>
> The "any_page_within_range_has_mapcount" test above seems to be the
> only correct to meet condition claimed by the comments, before or
> after the folio conversion, assuming here a THP page means the
> compound page without PMD mappings (PMD-split). Otherwise the test is
> always false (if it's also PMD mapped somewhere else).
>
> /*
> * Creating a THP page is expensive so split it only if we
> * are sure it's worth. Split it if we are only owner.
> */
>
>> The main reason to call folio_referenced() is to clear the yong of
>> conresponding PTEs. So in page reclaim phase, there is good chance
>> the folio can be reclaimed.
>>
>> Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
>> ---
>> This patch is based on mlock large folio support rfc2 as it depends
>> on the folio_in_range() added by that patchset
>>
>> Also folio_op_size() can be unitfied with get_folio_mlock_step().
>>
>> Testing done:
>> - kselftest: No new regression introduced.
>>
>> mm/madvise.c | 133 ++++++++++++++++++++++++++++++++-------------------
>> 1 file changed, 84 insertions(+), 49 deletions(-)
>
> Also the refactor looks fine to me but it'd be better if it's a separate patch.
OK. I will split the bug fix and refactor to two different patches. Thanks.
Regards
Yin, Fengwei
next prev parent reply other threads:[~2023-07-14 3:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-13 15:05 Yin Fengwei
2023-07-14 2:08 ` Yu Zhao
2023-07-14 3:09 ` Yin, Fengwei [this message]
2023-07-14 3:23 ` Yu Zhao
2023-07-14 7:31 ` David Hildenbrand
2023-07-14 8:34 ` Yin, Fengwei
2023-07-14 9:25 ` David Hildenbrand
2023-07-14 13:58 ` Yin, Fengwei
2023-07-14 14:12 ` David Hildenbrand
2023-07-14 14:41 ` Zi Yan
2023-07-14 15:35 ` David Hildenbrand
2023-07-17 0:15 ` Yin, Fengwei
2023-07-17 14:38 ` Zi Yan
2023-07-17 23:38 ` Yin Fengwei
2023-07-14 3:57 ` Yu Zhao
2023-07-14 5:57 ` Yin, Fengwei
2023-07-14 15:41 ` Yu Zhao
2023-07-16 23:52 ` Yin, Fengwei
2023-07-17 16:29 ` Yu Zhao
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=8547495c-9051-faab-a47d-1962f2e0b1da@intel.com \
--to=fengwei.yin@intel.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=shy828301@gmail.com \
--cc=willy@infradead.org \
--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