The patch titled Subject: mm/page_alloc: minor clean up for memmap_init_compound() has been added to the -mm mm-unstable branch. Its filename is mm-page_alloc-minor-clean-up-for-memmap_init_compound.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-page_alloc-minor-clean-up-for-memmap_init_compound.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm 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 via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Miaohe Lin <linmiaohe@xxxxxxxxxx> Subject: mm/page_alloc: minor clean up for memmap_init_compound() Date: Sat, 11 Jun 2022 10:13:52 +0800 Since commit 5232c63f46fd ("mm: Make compound_pincount always available"), compound_pincount_ptr is stored at first tail page now. So we should call prep_compound_head() after the first tail page is initialized to take advantage of the likelihood of that tail struct page being cached given that we will read them right after in prep_compound_head(). Link: https://lkml.kernel.org/r/20220611021352.13529-1-linmiaohe@xxxxxxxxxx Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx> Cc: Joao Martins <joao.m.martins@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/page_alloc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) --- a/mm/page_alloc.c~mm-page_alloc-minor-clean-up-for-memmap_init_compound +++ a/mm/page_alloc.c @@ -6771,13 +6771,18 @@ static void __ref memmap_init_compound(s set_page_count(page, 0); /* - * The first tail page stores compound_mapcount_ptr() and - * compound_order() and the second tail page stores - * compound_pincount_ptr(). Call prep_compound_head() after - * the first and second tail pages have been initialized to - * not have the data overwritten. + * The first tail page stores compound_mapcount_ptr(), + * compound_order() and compound_pincount_ptr(). Call + * prep_compound_head() after the first tail page have + * been initialized to not have the data overwritten. + * + * Note the idea to make this right after we initialize + * the offending tail pages is trying to take advantage + * of the likelihood of those tail struct pages being + * cached given that we will read them right after in + * prep_compound_head(). */ - if (pfn == head_pfn + 2) + if (unlikely(pfn == head_pfn + 1)) prep_compound_head(head, order); } } _ Patches currently in -mm which might be from linmiaohe@xxxxxxxxxx are maintainers-add-myself-as-a-memory-failure-reviewer.patch mm-shmemc-clean-up-comment-of-shmem_swapin_folio.patch mm-reduce-the-rcu-lock-duration.patch mm-migration-remove-unneeded-lock-page-and-pagemovable-check.patch mm-migration-return-errno-when-isolate_huge_page-failed.patch mm-migration-fix-potential-pte_unmap-on-an-not-mapped-pte.patch mm-memremap-fix-wrong-function-name-above-memremap_pages.patch mm-swapfile-make-security_vm_enough_memory_mm-work-as-expected.patch mm-swapfile-fix-possible-data-races-of-inuse_pages.patch mm-swap-remove-swap_cache_info-statistics.patch mm-vmscan-dont-try-to-reclaim-freed-folios.patch lib-test_hmm-avoid-accessing-uninitialized-pages.patch mm-memremap-fix-memunmap_pages-race-with-get_dev_pagemap.patch mm-khugepaged-remove-unneeded-shmem_huge_enabled-check.patch mm-khugepaged-stop-swapping-in-page-when-vm_fault_retry-occurs.patch mm-khugepaged-trivial-typo-and-codestyle-cleanup.patch mm-khugepaged-minor-cleanup-for-collapse_file.patch mm-khugepaged-use-helper-macro-__attr_rw.patch mm-khugepaged-remove-unneeded-return-value-of-khugepaged_add_pte_mapped_thp.patch mm-khugepaged-try-to-free-transhuge-swapcache-when-possible.patch mm-page_alloc-minor-clean-up-for-memmap_init_compound.patch