From: Alexandre Ghiti <alex@ghiti.fr>
To: Matthew Wilcox <willy@infradead.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
"Vishal Moola (Oracle)" <vishal.moola@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Mike Kravetz <mike.kravetz@oracle.com>
Subject: Re: [PATCH 2/2] mm/khugepaged: Convert release_pte_pages() to use folios
Date: Mon, 13 Feb 2023 16:55:06 +0100 [thread overview]
Message-ID: <707cd2b6-4350-4171-1e0c-f63ea5db7ece@ghiti.fr> (raw)
In-Reply-To: <Y+pcK41bagzzhgj+@casper.infradead.org>
Hi Matthew,
On 2/13/23 16:50, Matthew Wilcox wrote:
> On Mon, Feb 13, 2023 at 04:28:05PM +0100, Alexandre Ghiti wrote:
>> The issue lies here: before using pteval in pfn_folio(), we should test it.
>> The following patch fixes the issue for me:
> Thanks for debugging it. I'd rather see this written as ...
>
> pte_t pteval = *_pte;
> + unsigned long pfn;
>
> + if (pte_none(pteval))
> + continue;
> + pfn = pte_pfn(pteval);
> + if (is_zero_pfn(pfn))
> + continue;
> + folio = pfn_folio(pfn);
> + if (folio_test_large(folio))
> + continue;
> release_pte_folio(folio);
>
> makes sense?
Sure, that's fine by me, I can send that or I'll add my tested-by on
what you send, whatever suits you.
Alex
>
>> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>> index eb38bd1b1b2f..fef3414b481b 100644
>> --- a/mm/khugepaged.c
>> +++ b/mm/khugepaged.c
>> @@ -514,10 +514,12 @@ static void release_pte_pages(pte_t *pte, pte_t *_pte,
>> while (--_pte >= pte) {
>> pte_t pteval = *_pte;
>>
>> - folio = pfn_folio(pte_pfn(pteval));
>> - if (!pte_none(pteval) && !is_zero_pfn(pte_pfn(pteval)) &&
>> - !folio_test_large(folio))
>> - release_pte_folio(folio);
>> + if (!pte_none(pteval) && !is_zero_pfn(pte_pfn(pteval))) {
>> + folio = pfn_folio(pte_pfn(pteval));
>> +
>> + if (!folio_test_large(folio))
>> + release_pte_folio(folio);
>> + }
>> }
>>
>> list_for_each_entry_safe(folio, tmp, compound_pagelist, lru) {
>>
>>
>> @Marek: could you give it a try?
>>
>> I can send a separate patch if needed, let me know.
>>
>> Thanks,
>>
>> Alex
>>
>>
>>>> if (!pte_none(pteval) && !is_zero_pfn(pte_pfn(pteval)) &&
>>>> - !PageCompound(page))
>>>> - release_pte_page(page);
>>>> + !folio_test_large(folio))
>>>> + release_pte_folio(folio);
>>>> }
>>>> - list_for_each_entry_safe(page, tmp, compound_pagelist, lru) {
>>>> - list_del(&page->lru);
>>>> - release_pte_page(page);
>>>> + list_for_each_entry_safe(folio, tmp, compound_pagelist, lru) {
>>>> + list_del(&folio->lru);
>>>> + release_pte_folio(folio);
>>>> }
>>>> }
>>> Best regards
next prev parent reply other threads:[~2023-02-13 15:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-14 0:15 [PATCH 1/2] mm/khugepaged: Introduce release_pte_folio() to replace release_pte_page() Vishal Moola (Oracle)
2023-01-14 0:15 ` [PATCH 2/2] mm/khugepaged: Convert release_pte_pages() to use folios Vishal Moola (Oracle)
[not found] ` <CGME20230213085312eucas1p2252fe07e3eadea5e2a80dfdd3aa96507@eucas1p2.samsung.com>
2023-02-13 8:53 ` Marek Szyprowski
2023-02-13 15:28 ` Alexandre Ghiti
2023-02-13 15:50 ` Matthew Wilcox
2023-02-13 15:55 ` Alexandre Ghiti [this message]
2023-02-13 20:38 ` Vishal Moola
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=707cd2b6-4350-4171-1e0c-f63ea5db7ece@ghiti.fr \
--to=alex@ghiti.fr \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=m.szyprowski@samsung.com \
--cc=mike.kravetz@oracle.com \
--cc=vishal.moola@gmail.com \
--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