All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH next] mm/migrate: fix remove_migration_pte() of hugetlb entry
@ 2022-02-27  2:25 Hugh Dickins
  2022-02-28 20:49 ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Hugh Dickins @ 2022-02-27  2:25 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Andrew Morton, linux-kernel, linux-mm

The foliation of remove_migration_pte() is currently wrong on hugetlb
anon entries, causing LTP move_pages12 to crash on BUG_ON(!PageLocked)
in hugepage_add_anon_rmap().

Fixes: b4010e88f071 ("mm/migrate: Convert remove_migration_ptes() to folios")
Signed-off-by: Hugh Dickins <hughd@google.com>
---
Please just fold in if you agree.

 mm/migrate.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- mmotm/mm/migrate.c
+++ linux/mm/migrate.c
@@ -182,7 +182,8 @@ static bool remove_migration_pte(struct
 		struct page *new;
 		unsigned long idx = 0;
 
-		if (!folio_test_ksm(folio))
+		/* Skip call in common case, plus .pgoff is invalid for KSM */
+		if (pvmw.nr_pages != 1 && !folio_test_hugetlb(folio))
 			idx = linear_page_index(vma, pvmw.address) - pvmw.pgoff;
 		new = folio_page(folio, idx);
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH next] mm/migrate: fix remove_migration_pte() of hugetlb entry
  2022-02-27  2:25 [PATCH next] mm/migrate: fix remove_migration_pte() of hugetlb entry Hugh Dickins
@ 2022-02-28 20:49 ` Matthew Wilcox
  2022-02-28 22:18   ` Hugh Dickins
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2022-02-28 20:49 UTC (permalink / raw)
  To: Hugh Dickins; +Cc: Andrew Morton, linux-kernel, linux-mm

On Sat, Feb 26, 2022 at 06:25:15PM -0800, Hugh Dickins wrote:
> -		if (!folio_test_ksm(folio))
> +		/* Skip call in common case, plus .pgoff is invalid for KSM */
> +		if (pvmw.nr_pages != 1 && !folio_test_hugetlb(folio))
>  			idx = linear_page_index(vma, pvmw.address) - pvmw.pgoff;

How do you feel about this instead?

-               if (!folio_test_ksm(folio))
+               /* pgoff is invalid for ksm pages, but they are never large */
+               if (folio_test_large(folio) && !folio_test_hugetlb(folio))
                        idx = linear_page_index(vma, pvmw.address) - pvmw.pgoff;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH next] mm/migrate: fix remove_migration_pte() of hugetlb entry
  2022-02-28 20:49 ` Matthew Wilcox
@ 2022-02-28 22:18   ` Hugh Dickins
  0 siblings, 0 replies; 3+ messages in thread
From: Hugh Dickins @ 2022-02-28 22:18 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Hugh Dickins, Andrew Morton, linux-kernel, linux-mm

On Mon, 28 Feb 2022, Matthew Wilcox wrote:
> On Sat, Feb 26, 2022 at 06:25:15PM -0800, Hugh Dickins wrote:
> > -		if (!folio_test_ksm(folio))
> > +		/* Skip call in common case, plus .pgoff is invalid for KSM */
> > +		if (pvmw.nr_pages != 1 && !folio_test_hugetlb(folio))
> >  			idx = linear_page_index(vma, pvmw.address) - pvmw.pgoff;
> 
> How do you feel about this instead?
> 
> -               if (!folio_test_ksm(folio))
> +               /* pgoff is invalid for ksm pages, but they are never large */
> +               if (folio_test_large(folio) && !folio_test_hugetlb(folio))
>                         idx = linear_page_index(vma, pvmw.address) - pvmw.pgoff;
> 

That looks nicer to me too.  I'll assume that's what you will add
or squash in your tree, and no need for me to resend - thanks.

Hugh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-28 22:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-27  2:25 [PATCH next] mm/migrate: fix remove_migration_pte() of hugetlb entry Hugh Dickins
2022-02-28 20:49 ` Matthew Wilcox
2022-02-28 22:18   ` Hugh Dickins

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.