Message ID | alpine.LSU.2.11.2106011415430.2148@eggly.anvils (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mm/thp: fix THP splitting unmap BUGs and related | expand |
On Tue, Jun 1, 2021 at 2:17 PM Hugh Dickins <hughd@google.com> wrote: > > THP splitting's unmap_page() only sets TTU_SPLIT_FREEZE when PageAnon, > and migration entries are only inserted when TTU_MIGRATION (unused here) > or TTU_SPLIT_FREEZE is set: so it's just a waste of time for remap_page() > to search for migration entries to remove when !PageAnon. > > Fixes: baa355fd3314 ("thp: file pages support for split_huge_page()") > Signed-off-by: Hugh Dickins <hughd@google.com> Reviewed-by: Yang Shi <shy828301@gmail.com> > --- > mm/huge_memory.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index 305f709a7aca..e4a83e310452 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -2354,6 +2354,7 @@ static void unmap_page(struct page *page) > > VM_BUG_ON_PAGE(!PageHead(page), page); > > + /* If TTU_SPLIT_FREEZE is ever extended to file, update remap_page() */ > if (PageAnon(page)) > ttu_flags |= TTU_SPLIT_FREEZE; > > @@ -2368,6 +2369,10 @@ static void unmap_page(struct page *page) > static void remap_page(struct page *page, unsigned int nr) > { > int i; > + > + /* If TTU_SPLIT_FREEZE is ever extended to file, remove this check */ > + if (!PageAnon(page)) > + return; > if (PageTransHuge(page)) { > remove_migration_ptes(page, page, true); > } else { > -- > 2.32.0.rc0.204.g9fa02ecfa5-goog >
On Tue, Jun 01, 2021 at 02:17:19PM -0700, Hugh Dickins wrote: > THP splitting's unmap_page() only sets TTU_SPLIT_FREEZE when PageAnon, > and migration entries are only inserted when TTU_MIGRATION (unused here) > or TTU_SPLIT_FREEZE is set: so it's just a waste of time for remap_page() > to search for migration entries to remove when !PageAnon. > > Fixes: baa355fd3314 ("thp: file pages support for split_huge_page()") > Signed-off-by: Hugh Dickins <hughd@google.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 305f709a7aca..e4a83e310452 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2354,6 +2354,7 @@ static void unmap_page(struct page *page) VM_BUG_ON_PAGE(!PageHead(page), page); + /* If TTU_SPLIT_FREEZE is ever extended to file, update remap_page() */ if (PageAnon(page)) ttu_flags |= TTU_SPLIT_FREEZE; @@ -2368,6 +2369,10 @@ static void unmap_page(struct page *page) static void remap_page(struct page *page, unsigned int nr) { int i; + + /* If TTU_SPLIT_FREEZE is ever extended to file, remove this check */ + if (!PageAnon(page)) + return; if (PageTransHuge(page)) { remove_migration_ptes(page, page, true); } else {
THP splitting's unmap_page() only sets TTU_SPLIT_FREEZE when PageAnon, and migration entries are only inserted when TTU_MIGRATION (unused here) or TTU_SPLIT_FREEZE is set: so it's just a waste of time for remap_page() to search for migration entries to remove when !PageAnon. Fixes: baa355fd3314 ("thp: file pages support for split_huge_page()") Signed-off-by: Hugh Dickins <hughd@google.com> --- mm/huge_memory.c | 5 +++++ 1 file changed, 5 insertions(+)