[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <alpine.LSU.2.11.1901101748550.3146@eggly.anvils>
Date: Thu, 10 Jan 2019 18:08:37 -0800 (PST)
From: Hugh Dickins <hughd@...gle.com>
To: Vlastimil Babka <vbabka@...e.cz>
cc: Hugh Dickins <hughd@...gle.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Baoquan He <bhe@...hat.com>, Michal Hocko <mhocko@...e.com>,
Andrea Arcangeli <aarcange@...hat.com>,
David Hildenbrand <david@...hat.com>,
Mel Gorman <mgorman@...hsingularity.net>,
David Herrmann <dh.herrmann@...il.com>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Kan Liang <kan.liang@...el.com>,
Andi Kleen <ak@...ux.intel.com>,
Davidlohr Bueso <dave@...olabs.net>,
Peter Zijlstra <peterz@...radead.org>,
Christoph Lameter <cl@...ux.com>,
Nick Piggin <npiggin@...il.com>, pifang@...hat.com,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
Subject: Re: [PATCHi v2] mm: put_and_wait_on_page_locked() while page is
migrated
On Thu, 10 Jan 2019, Vlastimil Babka wrote:
>
> For the record, anyone backporting this to older kernels should make
> sure to also include 605ca5ede764 ("mm/huge_memory.c: reorder operations
> in __split_huge_page_tail()") or they are in for a lot of fun, like me.
Thanks a lot for alerting us all to this, Vlastimil. Yes, I consider
Konstantin's 605ca5ede764 a must-have, and so had it already in all
the trees on which I was testing put_and_wait_on_page_locked(),
without being aware of the critical role it was playing.
But you do enjoy fun, don't you? So I shouldn't apologize :)
>
> Long story [1] short, Konstantin was correct in 605ca5ede764 changelog,
> although it wasn't the main known issue he was fixing:
>
> clear_compound_head() also must be called before unfreezing page
> reference because after successful get_page_unless_zero() might follow
> put_page() which needs correct compound_head().
>
> Which is exactly what happens in __migration_entry_wait():
>
> if (!get_page_unless_zero(page))
> goto out;
> pte_unmap_unlock(ptep, ptl);
> put_and_wait_on_page_locked(page); -> does put_page(page)
>
> while waiting on the THP split (which inserts those migration entries)
> to finish. Before put_and_wait_on_page_locked() it would wait first, and
> only then do put_page() on a page that's no longer tail page, so it
> would work out despite the dangerous get_page_unless_zero() on a tail
> page. Now it doesn't :)
It took me a while to follow there, but yes, agreed.
>
> Now if only 605ca5ede764 had a CC:stable and a Fixes: tag... Machine
> Learning won this round though, because 605ca5ede764 was added to 4.14
> stable by Sasha...
I'm proud to have passed the Turing test in reverse, but actually
that was me, not ML. My 173d9d9fd3dd ("mm/huge_memory: splitting set
mapping+index before unfreeze") in 4.20 built upon Konstantin's, so I
included his as a precursor when sending the stable guys pre-XArray
backports. So Konstantin's is even in 4.9 stable now.
Hugh
Powered by blists - more mailing lists