The patch titled Subject: swap-reduce-lock-contention-on-swap-cache-from-swap-slots-allocation-v4 has been added to the -mm tree. Its filename is swap-reduce-lock-contention-on-swap-cache-from-swap-slots-allocation-v4.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/swap-reduce-lock-contention-on-swap-cache-from-swap-slots-allocation-v4.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/swap-reduce-lock-contention-on-swap-cache-from-swap-slots-allocation-v4.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: Huang Ying <ying.huang@xxxxxxxxx> Subject: swap-reduce-lock-contention-on-swap-cache-from-swap-slots-allocation-v4 - Fix wrong ALIGN() usage with ALIGN_DOWN(). Thanks Daniel's comments! - Add some comments. Thanks Daniel's comments! Link: http://lkml.kernel.org/r/20200529010840.928819-1-ying.huang@xxxxxxxxx Signed-off-by: "Huang, Ying" <ying.huang@xxxxxxxxx> Reviewed-by: Daniel Jordan <daniel.m.jordan@xxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Minchan Kim <minchan@xxxxxxxxxx> Cc: Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/swapfile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/mm/swapfile.c~swap-reduce-lock-contention-on-swap-cache-from-swap-slots-allocation-v4 +++ a/mm/swapfile.c @@ -613,7 +613,8 @@ new_cluster: } else if (!cluster_list_empty(&si->discard_clusters)) { /* * we don't have free cluster but have some clusters in - * discarding, do discard now and reclaim them + * discarding, do discard now and reclaim them, then + * reread cluster_next_cpu since we dropped si->lock */ swap_do_scheduled_discard(si); *scan_base = this_cpu_read(*si->cluster_next_cpu); @@ -745,7 +746,7 @@ static void set_cluster_next(struct swap return; next = si->lowest_bit + prandom_u32_max(si->highest_bit - si->lowest_bit + 1); - next = ALIGN(next, SWAP_ADDRESS_SPACE_PAGES); + next = ALIGN_DOWN(next, SWAP_ADDRESS_SPACE_PAGES); next = max_t(unsigned int, next, si->lowest_bit); } this_cpu_write(*si->cluster_next_cpu, next); _ Patches currently in -mm which might be from ying.huang@xxxxxxxxx are swap-try-to-scan-more-free-slots-even-when-fragmented.patch mm-swap-use-prandom_u32_max.patch swap-reduce-lock-contention-on-swap-cache-from-swap-slots-allocation.patch swap-reduce-lock-contention-on-swap-cache-from-swap-slots-allocation-v3.patch swap-reduce-lock-contention-on-swap-cache-from-swap-slots-allocation-v4.patch proc-pid-smaps-add-pmd-migration-entry-parsing.patch