In mmu_gather code, the final table free in __tlb_remove_table_free() executes a loop, calling arch hook __tlb_remove_table() to free each table individually. Several architectures use free_page_and_swap_cache() as their __tlb_remove_table() implementation. Calling that in loop results into individual calls to put_page() for each page being freed. This patchset refactors the code to issue a single release_pages() call in this case. This is expected to have better performance, especially when memcg accounting is enabled. Nikita Yushchenko (3): tlb: mmu_gather: introduce CONFIG_MMU_GATHER_TABLE_FREE_COMMON mm/swap: introduce free_pages_and_swap_cache_nolru() tlb: mmu_gather: use batched table free if possible arch/Kconfig | 3 +++ arch/arm/Kconfig | 1 + arch/arm/include/asm/tlb.h | 5 ----- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/tlb.h | 5 ----- arch/x86/Kconfig | 1 + arch/x86/include/asm/tlb.h | 14 -------------- include/asm-generic/tlb.h | 5 +++++ include/linux/swap.h | 5 ++++- mm/mmu_gather.c | 25 ++++++++++++++++++++++--- mm/swap_state.c | 29 ++++++++++++++++++++++------- 11 files changed, 59 insertions(+), 35 deletions(-) -- 2.30.2