From: Vishal Moola <vishal.moola@gmail.com>
To: Alexandre Ghiti <alex@ghiti.fr>
Cc: Matthew Wilcox <willy@infradead.org>,
Marek Szyprowski <m.szyprowski@samsung.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 12:38:56 -0800 [thread overview]
Message-ID: <CAOzc2pxqTRRfopZuxmTvvMhvS33DLfs_Yijss0wb8idKUVyV_g@mail.gmail.com> (raw)
In-Reply-To: <707cd2b6-4350-4171-1e0c-f63ea5db7ece@ghiti.fr>
On Mon, Feb 13, 2023 at 7:55 AM Alexandre Ghiti <alex@ghiti.fr> wrote:
>
> 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.
Thanks for debugging this! I'll send a fix patch using Matthew's
approach later today.
> 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
prev parent reply other threads:[~2023-02-13 20:39 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
2023-02-13 20:38 ` Vishal Moola [this message]
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=CAOzc2pxqTRRfopZuxmTvvMhvS33DLfs_Yijss0wb8idKUVyV_g@mail.gmail.com \
--to=vishal.moola@gmail.com \
--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=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