The patch titled Subject: mm:swap: do not check readahead flag with THP anon has been added to the -mm tree. Its filename is mm-swap-clean-up-swap-readahead-fix.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-swap-clean-up-swap-readahead-fix.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-swap-clean-up-swap-readahead-fix.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/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Minchan Kim <minchan@xxxxxxxxxx> Subject: mm:swap: do not check readahead flag with THP anon Huang reported that the PG_readahead flag uses PF_NO_COMPOUND so that we cannot use the flag for THP page. So, we need to check first whether the page is THP before using TestClearPageReadahead in lookup_swap_cache(). This patch fixes it. Furthermore, swap_[cluster|vma]_readahead cannot mark PG_readahead for newly allocated page because the allocated page is always a normal page, not THP at this moment. So let's clean it up, too. Link: http://lkml.kernel.org/r/874lm83zho.fsf@xxxxxxxxxxxxxxxxxxxx Link: http://lkml.kernel.org/r/20180227232611.169883-1-minchan@xxxxxxxxxx Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: "Huang, Ying" <ying.huang@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/swap_state.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff -puN mm/swap_state.c~mm-swap-clean-up-swap-readahead-fix mm/swap_state.c --- a/mm/swap_state.c~mm-swap-clean-up-swap-readahead-fix +++ a/mm/swap_state.c @@ -338,12 +338,17 @@ struct page *lookup_swap_cache(swp_entry INC_CACHE_INFO(find_total); if (page) { bool vma_ra = swap_use_vma_readahead(); - bool readahead = TestClearPageReadahead(page); + bool readahead; INC_CACHE_INFO(find_success); + /* + * At the moment, we don't support PG_readahead for anon THP + * so let's bail out rather than confusing the readahead stat. + */ if (unlikely(PageTransCompound(page))) return page; + readahead = TestClearPageReadahead(page); if (vma && vma_ra) { unsigned long ra_val; int win, hits; @@ -592,8 +597,7 @@ struct page *swapin_readahead(swp_entry_ continue; if (page_allocated) { swap_readpage(page, false); - if (offset != entry_offset && - likely(!PageTransCompound(page))) { + if (offset != entry_offset) { SetPageReadahead(page); count_vm_event(SWAP_RA); } @@ -756,8 +760,7 @@ struct page *do_swap_page_readahead(swp_ continue; if (page_allocated) { swap_readpage(page, false); - if (i != ra_info.offset && - likely(!PageTransCompound(page))) { + if (i != ra_info.offset) { SetPageReadahead(page); count_vm_event(SWAP_RA); } _ Patches currently in -mm which might be from minchan@xxxxxxxxxx are mm-swap-clean-up-swap-readahead.patch mm-swap-clean-up-swap-readahead-fix.patch mm-swap-unify-cluster-based-and-vma-based-swap-readahead.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