The patch titled thp-tail-page-refcounting-fix-6 has been added to the -mm tree. Its filename is thp-tail-page-refcounting-fix-6.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: thp-tail-page-refcounting-fix-6 From: Andrea Arcangeli <aarcange@xxxxxxxxxx> Signed-off-by: Andrea Arcangeli <aarcange@xxxxxxxxxx> Cc: Michel Lespinasse <walken@xxxxxxxxxx> Cc: Michel Lespinasse <walken@xxxxxxxxxx> Cc: Minchan Kim <minchan.kim@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/mm.h | 2 +- mm/internal.h | 5 +++++ mm/swap.c | 12 +++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff -puN include/linux/mm.h~thp-tail-page-refcounting-fix-6 include/linux/mm.h --- a/include/linux/mm.h~thp-tail-page-refcounting-fix-6 +++ a/include/linux/mm.h @@ -377,7 +377,7 @@ static inline int page_count(struct page return atomic_read(&compound_head(page)->_count); } -extern int __get_page_tail(struct page *page); +extern bool __get_page_tail(struct page *page); static inline void get_page(struct page *page) { diff -puN mm/internal.h~thp-tail-page-refcounting-fix-6 mm/internal.h --- a/mm/internal.h~thp-tail-page-refcounting-fix-6 +++ a/mm/internal.h @@ -59,6 +59,11 @@ static inline void __get_page_tail_foll( atomic_inc(&page->_mapcount); } +/* + * This is meant to be called as the FOLL_GET operation of + * follow_page() and it must be called while holding the proper PT + * lock while the pte (or pmd_trans_huge) is still mapping the page. + */ static inline void get_page_foll(struct page *page) { if (unlikely(PageTail(page))) diff -puN mm/swap.c~thp-tail-page-refcounting-fix-6 mm/swap.c --- a/mm/swap.c~thp-tail-page-refcounting-fix-6 +++ a/mm/swap.c @@ -79,6 +79,7 @@ static void put_compound_page(struct pag if (unlikely(PageTail(page))) { /* __split_huge_page_refcount can run under us */ struct page *page_head = compound_trans_head(page); + if (likely(page != page_head && get_page_unless_zero(page_head))) { unsigned long flags; @@ -143,7 +144,11 @@ void put_page(struct page *page) } EXPORT_SYMBOL(put_page); -int __get_page_tail(struct page *page) +/* + * This function is exported but must not be called by anything other + * than get_page(). It implements the slow path of get_page(). + */ +bool __get_page_tail(struct page *page) { /* * This takes care of get_page() if run on a tail page @@ -154,8 +159,9 @@ int __get_page_tail(struct page *page) * split_huge_page(). */ unsigned long flags; - int got = 0; + bool got = false; struct page *page_head = compound_trans_head(page); + if (likely(page != page_head && get_page_unless_zero(page_head))) { /* * page_head wasn't a dangling pointer but it @@ -167,7 +173,7 @@ int __get_page_tail(struct page *page) /* here __split_huge_page_refcount won't run anymore */ if (likely(PageTail(page))) { __get_page_tail_foll(page, false); - got = 1; + got = true; } compound_unlock_irqrestore(page_head, flags); if (unlikely(!got)) _ Patches currently in -mm which might be from aarcange@xxxxxxxxxx are mm-compaction-trivial-clean-up-in-acct_isolated.patch mm-change-isolate-mode-from-define-to-bitwise-type.patch mm-compaction-make-isolate_lru_page-filter-aware.patch mm-compaction-make-isolate_lru_page-filter-aware-fix.patch mm-zone_reclaim-make-isolate_lru_page-filter-aware.patch mm-zone_reclaim-make-isolate_lru_page-filter-aware-fix.patch mm-migration-clean-up-unmap_and_move.patch mremap-check-for-overflow-using-deltas.patch mremap-avoid-sending-one-ipi-per-page.patch thp-mremap-support-and-tlb-optimization.patch thp-mremap-support-and-tlb-optimization-fix.patch thp-mremap-support-and-tlb-optimization-fix-fix.patch thp-mremap-support-and-tlb-optimization-fix-fix-fix.patch thp-tail-page-refcounting-fix-5.patch thp-tail-page-refcounting-fix-6.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html