From: Matthew Wilcox <willy@infradead.org>
To: Alexandre Ghiti <alex@ghiti.fr>
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 15:50:03 +0000 [thread overview]
Message-ID: <Y+pcK41bagzzhgj+@casper.infradead.org> (raw)
In-Reply-To: <3a3457b1-60bc-a97b-0042-432790d3bbbe@ghiti.fr>
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?
> 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:50 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 [this message]
2023-02-13 15:55 ` Alexandre Ghiti
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=Y+pcK41bagzzhgj+@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--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 \
/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;
as well as URLs for NNTP newsgroup(s).