From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
<willy@infradead.org>
Subject: Re: [PATCH] mm: huge_memory: convert split_huge_pages_all() to use a folio
Date: Fri, 30 Dec 2022 09:36:25 +0800 [thread overview]
Message-ID: <b36820e2-7cbe-87a6-91e5-bdfaade76f90@huawei.com> (raw)
In-Reply-To: <20221229152822.a283198e5df331caaac88a55@linux-foundation.org>
On 2022/12/30 7:28, Andrew Morton wrote:
> On Thu, 29 Dec 2022 20:25:03 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
>> Straightforwardly convert split_huge_pages_all() to use a folio.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>> mm/huge_memory.c | 25 +++++++++++++++++--------
>> 1 file changed, 17 insertions(+), 8 deletions(-)
>>
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index 266c4b557946..c8cbe7f62eaa 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -2932,6 +2932,7 @@ static void split_huge_pages_all(void)
>> {
>> struct zone *zone;
>> struct page *page;
>> + struct folio *folio;
>> unsigned long pfn, max_zone_pfn;
>> unsigned long total = 0, split = 0;
>>
>> @@ -2944,24 +2945,32 @@ static void split_huge_pages_all(void)
>> int nr_pages;
>>
>> page = pfn_to_online_page(pfn);
>> - if (!page || !get_page_unless_zero(page))
>> + if (!page || PageTail(page))
>> + continue;
>
> Why is the PageTail() test added?
This function is trying to split huge pages, it traverse all the pfn,
the huge page already split when we met Head page, most importantly,
get_page_unless_zero() will do nothing on Tail page too.
>
>> + folio = page_folio(page);
>> + if (!folio_try_get(folio))
>> continue;
>>
>> - if (zone != page_zone(page))
>> + if (unlikely(page_folio(page) != folio))
>
> And this?
I think this is a double check in case of page is already changed by
someone else, suggested by Matthew[1]
[1]
https://lore.kernel.org/linux-mm/20221227195004.2809-1-sj@kernel.org/T/#m33047c152f6793bfebaa55cb1f4662fed73508d2
next prev parent reply other threads:[~2022-12-30 1:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-29 12:25 Kefeng Wang
2022-12-29 23:28 ` Andrew Morton
2022-12-30 1:36 ` Kefeng Wang [this message]
2022-12-30 8:14 ` Matthew Wilcox
2022-12-30 9:03 ` Kefeng Wang
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=b36820e2-7cbe-87a6-91e5-bdfaade76f90@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.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