Re: [PATCH mm-stable] mm/khugepaged: avoid unnecessary checking for swap entries when collapsing a mTHP
From: Kiryl Shutsemau
Date: Wed Sep 02 2026 - 06:12:31 EST
On Mon, Aug 31, 2026 at 03:53:34PM -0300, Pedro Demarchi Gomes wrote:
> On Thu, Aug 27, 2026 at 03:07:10PM +0100, Kiryl Shutsemau wrote:
> > On Thu, Aug 27, 2026 at 08:11:51PM +0800, Lance Yang wrote:
> > > For the candidate above, the loop only reads its PTEs and returns
> > > SCAN_SUCCEED. Pedro's bitmap lets mthp_collapse() determine that upfront
> > > and skip the walk.
> > >
> > > Emm ... as I asked before[1], any numbers showing how much the extra scan
> > > costs?
> >
> > With the win being only some scan cost, I don't think it is going to be
> > measurable.
> >
> > It can open a path to future work. For example, we could find fully
> > populated mTHP windows in a PMD that is not eligible for collapse
> > because unmapped > max_ptes_swap. Right now we just give up on the whole
> > PMD in such cases.
> >
> > But there are more wins to gain there. Just saying :P
>
> Hi Kiryl,
>
> I devised a patch based on your proposed future work idea. If you think it
> makes sense, I can send it to the mailing list with a Suggested-by: tag.
I am not sure it is worth as the moment. There's lower handing fruits in
khugepaged that has to be addressed.
--
Kiryl Shutsemau / Kirill A. Shutemov