The patch titled Subject: mm-store-zero-pages-to-be-swapped-out-in-a-bitmap-v7 has been added to the -mm mm-unstable branch. Its filename is mm-store-zero-pages-to-be-swapped-out-in-a-bitmap-v7.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-store-zero-pages-to-be-swapped-out-in-a-bitmap-v7.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: Usama Arif <usamaarif642@xxxxxxxxx> Subject: mm-store-zero-pages-to-be-swapped-out-in-a-bitmap-v7 Date: Thu, 27 Jun 2024 11:55:29 +0100 Change to kvmalloc_array for zeromap allocation instead of kvzalloc as it does an additional overflow check, and use sizeof(unsigned long) for allocation size calculation to take into account 32 bit kernels. Link: https://lkml.kernel.org/r/20240627105730.3110705-2-usamaarif642@xxxxxxxxx Signed-off-by: Usama Arif <usamaarif642@xxxxxxxxx> Cc: Chengming Zhou <chengming.zhou@xxxxxxxxx> Cc: Yosry Ahmed <yosryahmed@xxxxxxxxxx> Cc: Nhat Pham <nphamcs@xxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: "Huang, Ying" <ying.huang@xxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Cc: Shakeel Butt <shakeel.butt@xxxxxxxxx> Cc: Usama Arif <usamaarif642@xxxxxxxxx> Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/swapfile.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/mm/swapfile.c~mm-store-zero-pages-to-be-swapped-out-in-a-bitmap-v7 +++ a/mm/swapfile.c @@ -3170,7 +3170,12 @@ SYSCALL_DEFINE2(swapon, const char __use goto bad_swap_unlock_inode; } - p->zeromap = kvzalloc(DIV_ROUND_UP(maxpages, 8), GFP_KERNEL); + /* + * Use kvmalloc_array instead of bitmap_zalloc as the allocation order might + * be above MAX_PAGE_ORDER incase of a large swap file. + */ + p->zeromap = kvmalloc_array(BITS_TO_LONGS(maxpages), sizeof(unsigned long), + GFP_KERNEL | __GFP_ZERO); if (!p->zeromap) { error = -ENOMEM; goto bad_swap_unlock_inode; _ Patches currently in -mm which might be from usamaarif642@xxxxxxxxx are mm-store-zero-pages-to-be-swapped-out-in-a-bitmap.patch mm-store-zero-pages-to-be-swapped-out-in-a-bitmap-v6.patch mm-store-zero-pages-to-be-swapped-out-in-a-bitmap-v7.patch mm-remove-code-to-handle-same-filled-pages.patch