On Tue, Sep 26, 2023 at 03:07:18PM -0700, Yang Shi wrote: > On Fri, Sep 22, 2023 at 9:33 PM Vishal Moola (Oracle) > <vishal.moola@xxxxxxxxx> wrote: > > > > Currently, khugepaged builds a compound_pagelist while scanning, which > > is used to properly account for compound pages. We can now account > > for a compound page as a singular folio instead, so remove this list. > > > > Large folios are guaranteed to have consecutive ptes and addresses, so > > once the first pte of a large folio is found skip over the rest. > > The address space may just map a partial folio, for example, in the > extreme case the HUGE_PMD size range may have HUGE_PMD_NR folios with > mapping one subpage from each folio per PTE. So assuming the PTE > mapped folio is mapped consecutively may be wrong. How? You can do that with two VMAs, but this is limited to scanning within a single VMA. If we've COWed a large folio, we currently do so as a single page folio, and I'm not seeing any demand to change that. If we did COW as a large folio, we'd COW every page in that folio. How do we interleave two large folios in the same VMA? > Please refer to collapse_compound_extreme() in > tools/testing/selftests/mm/khugepaged.c. I agree that running that part of the test-suite would be useful, but could you point to which test specifically would create a problem here?