On Mon, Jun 24, 2024 at 11:33 AM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote: > > On Mon, Jun 24, 2024 at 05:05:56AM -0700, Yosry Ahmed wrote: > > On Mon, Jun 24, 2024 at 1:49 AM kernel test robot <oliver.sang@xxxxxxxxx> wrote: > > > kernel test robot noticed "WARNING:at_mm/page_alloc.c:#__alloc_pages_noprof" on: > > > > > > commit: 0fa2857d23aa170e5e28d13c467b303b0065aad8 ("mm: store zero pages to be swapped out in a bitmap") > > > https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git master > > > > This is coming from WARN_ON_ONCE_GFP(order > MAX_PAGE_ORDER, gfp), and > > is triggered by the new bitmap_zalloc() call in the swapon path. For a > > sufficiently large swapfile, bitmap_zalloc() (which uses kmalloc() > > under the hood) cannot be used to allocate the bitmap. > > Do we need to use a bitmap? > > We could place a special entry in the swapcache instead (there's > XA_ZERO_ENTRY already defined, and if we need a different entry that's > not XA_ZERO_ENTRY, there's room for a few hundred more special entries). After a page is swapped out during reclaim, __remove_mapping() will call __delete_from_swap_cache() to replace the swap cache entry with a shadow entry (which is an xa_value). So I believe we cannot use a special xarray value without making fundamental changes. We can, perhaps, try to pack an extra bit in the shadow entry. In this case, we will need to change the swapin code to check for this magic bit when looking up a folio in the swap cache, and extra synchronization to make sure concurrent lookups do not allocate and zero separate folios. IOW, I think it's possible but probably with more complexity, and perhaps not worth it.