Merge tag 'mm-stable-2024-03-13-20-04' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 15 Mar 2024 00:43:30 +0000 (17:43 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 15 Mar 2024 00:43:30 +0000 (17:43 -0700)
Pull MM updates from Andrew Morton:

 - Sumanth Korikkar has taught s390 to allocate hotplug-time page frames
   from hotplugged memory rather than only from main memory. Series
   "implement "memmap on memory" feature on s390".

 - More folio conversions from Matthew Wilcox in the series

"Convert memcontrol charge moving to use folios"
"mm: convert mm counter to take a folio"

 - Chengming Zhou has optimized zswap's rbtree locking, providing
   significant reductions in system time and modest but measurable
   reductions in overall runtimes. The series is "mm/zswap: optimize the
   scalability of zswap rb-tree".

 - Chengming Zhou has also provided the series "mm/zswap: optimize zswap
   lru list" which provides measurable runtime benefits in some
   swap-intensive situations.

 - And Chengming Zhou further optimizes zswap in the series "mm/zswap:
   optimize for dynamic zswap_pools". Measured improvements are modest.

 - zswap cleanups and simplifications from Yosry Ahmed in the series
   "mm: zswap: simplify zswap_swapoff()".

 - In the series "Add DAX ABI for memmap_on_memory", Vishal Verma has
   contributed several DAX cleanups as well as adding a sysfs tunable to
   control the memmap_on_memory setting when the dax device is
   hotplugged as system memory.

 - Johannes Weiner has added the large series "mm: zswap: cleanups",
   which does that.

 - More DAMON work from SeongJae Park in the series

"mm/damon: make DAMON debugfs interface deprecation unignorable"
"selftests/damon: add more tests for core functionalities and corner cases"
"Docs/mm/damon: misc readability improvements"
"mm/damon: let DAMOS feeds and tame/auto-tune itself"

 - In the series "mm/mempolicy: weighted interleave mempolicy and sysfs
   extension" Rakie Kim has developed a new mempolicy interleaving
   policy wherein we allocate memory across nodes in a weighted fashion
   rather than uniformly. This is beneficial in heterogeneous memory
   environments appearing with CXL.

 - Christophe Leroy has contributed some cleanup and consolidation work
   against the ARM pagetable dumping code in the series "mm: ptdump:
   Refactor CONFIG_DEBUG_WX and check_wx_pages debugfs attribute".

 - Luis Chamberlain has added some additional xarray selftesting in the
   series "test_xarray: advanced API multi-index tests".

 - Muhammad Usama Anjum has reworked the selftest code to make its
   human-readable output conform to the TAP ("Test Anything Protocol")
   format. Amongst other things, this opens up the use of third-party
   tools to parse and process out selftesting results.

 - Ryan Roberts has added fork()-time PTE batching of THP ptes in the
   series "mm/memory: optimize fork() with PTE-mapped THP". Mainly
   targeted at arm64, this significantly speeds up fork() when the
   process has a large number of pte-mapped folios.

 - David Hildenbrand also gets in on the THP pte batching game in his
   series "mm/memory: optimize unmap/zap with PTE-mapped THP". It
   implements batching during munmap() and other pte teardown
   situations. The microbenchmark improvements are nice.

 - And in the series "Transparent Contiguous PTEs for User Mappings"
   Ryan Roberts further utilizes arm's pte's contiguous bit ("contpte
   mappings"). Kernel build times on arm64 improved nicely. Ryan's
   series "Address some contpte nits" provides some followup work.

 - In the series "mm/hugetlb: Restore the reservation" Breno Leitao has
   fixed an obscure hugetlb race which was causing unnecessary page
   faults. He has also added a reproducer under the selftest code.

 - In the series "selftests/mm: Output cleanups for the compaction
   test", Mark Brown did what the title claims.

 - Kinsey Ho has added the series "mm/mglru: code cleanup and
   refactoring".

 - Even more zswap material from Nhat Pham. The series "fix and extend
   zswap kselftests" does as claimed.

 - In the series "Introduce cpu_dcache_is_aliasing() to fix DAX
   regression" Mathieu Desnoyers has cleaned up and fixed rather a mess
   in our handling of DAX on archiecctures which have virtually aliasing
   data caches. The arm architecture is the main beneficiary.

 - Lokesh Gidra's series "per-vma locks in userfaultfd" provides
   dramatic improvements in worst-case mmap_lock hold times during
   certain userfaultfd operations.

 - Some page_owner enhancements and maintenance work from Oscar Salvador
   in his series

"page_owner: print stacks and their outstanding allocations"
"page_owner: Fixup and cleanup"

 - Uladzislau Rezki has contributed some vmalloc scalability
   improvements in his series "Mitigate a vmap lock contention". It
   realizes a 12x improvement for a certain microbenchmark.

 - Some kexec/crash cleanup work from Baoquan He in the series "Split
   crash out from kexec and clean up related config items".

 - Some zsmalloc maintenance work from Chengming Zhou in the series

"mm/zsmalloc: fix and optimize objects/page migration"
"mm/zsmalloc: some cleanup for get/set_zspage_mapping()"

 - Zi Yan has taught the MM to perform compaction on folios larger than
   order=0. This a step along the path to implementaton of the merging
   of large anonymous folios. The series is named "Enable >0 order folio
   memory compaction".

 - Christoph Hellwig has done quite a lot of cleanup work in the
   pagecache writeback code in his series "convert write_cache_pages()
   to an iterator".

 - Some modest hugetlb cleanups and speedups in Vishal Moola's series
   "Handle hugetlb faults under the VMA lock".

 - Zi Yan has changed the page splitting code so we can split huge pages
   into sizes other than order-0 to better utilize large folios. The
   series is named "Split a folio to any lower order folios".

 - David Hildenbrand has contributed the series "mm: remove
   total_mapcount()", a cleanup.

 - Matthew Wilcox has sought to improve the performance of bulk memory
   freeing in his series "Rearrange batched folio freeing".

 - Gang Li's series "hugetlb: parallelize hugetlb page init on boot"
   provides large improvements in bootup times on large machines which
   are configured to use large numbers of hugetlb pages.

 - Matthew Wilcox's series "PageFlags cleanups" does that.

 - Qi Zheng's series "minor fixes and supplement for ptdesc" does that
   also. S390 is affected.

 - Cleanups to our pagemap utility functions from Peter Xu in his series
   "mm/treewide: Replace pXd_large() with pXd_leaf()".

 - Nico Pache has fixed a few things with our hugepage selftests in his
   series "selftests/mm: Improve Hugepage Test Handling in MM
   Selftests".

 - Also, of course, many singleton patches to many things. Please see
   the individual changelogs for details.

* tag 'mm-stable-2024-03-13-20-04' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (435 commits)
  mm/zswap: remove the memcpy if acomp is not sleepable
  crypto: introduce: acomp_is_async to expose if comp drivers might sleep
  memtest: use {READ,WRITE}_ONCE in memory scanning
  mm: prohibit the last subpage from reusing the entire large folio
  mm: recover pud_leaf() definitions in nopmd case
  selftests/mm: skip the hugetlb-madvise tests on unmet hugepage requirements
  selftests/mm: skip uffd hugetlb tests with insufficient hugepages
  selftests/mm: dont fail testsuite due to a lack of hugepages
  mm/huge_memory: skip invalid debugfs new_order input for folio split
  mm/huge_memory: check new folio order when split a folio
  mm, vmscan: retry kswapd's priority loop with cache_trim_mode off on failure
  mm: add an explicit smp_wmb() to UFFDIO_CONTINUE
  mm: fix list corruption in put_pages_list
  mm: remove folio from deferred split list before uncharging it
  filemap: avoid unnecessary major faults in filemap_fault()
  mm,page_owner: drop unnecessary check
  mm,page_owner: check for null stack_record before bumping its refcount
  mm: swap: fix race between free_swap_and_cache() and swapoff()
  mm/treewide: align up pXd_leaf() retval across archs
  mm/treewide: drop pXd_large()
  ...

75 files changed:
1  2 
Documentation/dev-tools/kasan.rst
MAINTAINERS
arch/arc/Kconfig
arch/arm/Kconfig
arch/arm64/Kconfig
arch/arm64/include/asm/pgtable.h
arch/arm64/kernel/Makefile
arch/arm64/mm/fault.c
arch/arm64/mm/fixmap.c
arch/arm64/mm/init.c
arch/arm64/mm/kasan_init.c
arch/arm64/mm/mmu.c
arch/arm64/mm/ptdump.c
arch/csky/Kconfig
arch/loongarch/kernel/setup.c
arch/m68k/Kconfig
arch/mips/Kconfig
arch/nios2/Kconfig
arch/parisc/Kconfig
arch/powerpc/Kconfig
arch/riscv/Kconfig
arch/riscv/include/asm/pgtable-64.h
arch/riscv/include/asm/pgtable.h
arch/riscv/kernel/Makefile
arch/s390/Kconfig
arch/s390/kernel/machine_kexec.c
arch/sparc/Kconfig
arch/x86/Kconfig
arch/x86/boot/compressed/ident_map_64.c
arch/x86/include/asm/pgtable.h
arch/x86/kernel/Makefile
arch/x86/kernel/alternative.c
arch/x86/kernel/cpu/mshyperv.c
arch/x86/kernel/kexec-bzimage64.c
arch/x86/kernel/kvm.c
arch/x86/kernel/setup.c
arch/x86/kernel/smp.c
arch/x86/kvm/mmu/mmu.c
arch/x86/mm/dump_pagetables.c
arch/x86/mm/fault.c
arch/x86/mm/mem_encrypt_identity.c
arch/x86/mm/pat/set_memory.c
arch/x86/mm/pgtable.c
arch/x86/mm/tlb.c
arch/x86/xen/enlighten_hvm.c
arch/xtensa/Kconfig
drivers/base/cpu.c
drivers/block/zram/zram_drv.c
drivers/dax/super.c
drivers/md/dm.c
drivers/nvdimm/pmem.c
drivers/s390/block/dcssblk.c
fs/Kconfig
include/linux/efi.h
include/linux/gfp.h
include/linux/sched.h
include/linux/swap.h
include/linux/vmalloc.h
init/initramfs.c
init/main.c
kernel/module/main.c
kernel/printk/printk.c
kernel/sched/fair.c
lib/maple_tree.c
mm/compaction.c
mm/filemap.c
mm/internal.h
mm/mmap.c
mm/page_alloc.c
mm/shmem.c
mm/swapfile.c
mm/userfaultfd.c
mm/util.c
mm/vmalloc.c
mm/vmscan.c

Simple merge
diff --cc MAINTAINERS
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index bf5b1c426ad0dd8137968f9484d90ae2e757d9f3,6208c7541f873233f6c8b4cc7267054a6ee21081..495b732d5af36f208291b28e1f1f167231b01e2d
@@@ -679,16 -630,13 +679,14 @@@ void mark_rodata_ro(void
         * to cover NOTES and EXCEPTION_TABLE.
         */
        section_size = (unsigned long)__init_begin - (unsigned long)__start_rodata;
 +      WRITE_ONCE(rodata_is_rw, false);
        update_mapping_prot(__pa_symbol(__start_rodata), (unsigned long)__start_rodata,
                            section_size, PAGE_KERNEL_RO);
-       debug_checkwx();
  }
  
 -static void __init map_kernel_segment(pgd_t *pgdp, void *va_start, void *va_end,
 -                                    pgprot_t prot, struct vm_struct *vma,
 -                                    int flags, unsigned long vm_flags)
 +static void __init declare_vma(struct vm_struct *vma,
 +                             void *va_start, void *va_end,
 +                             unsigned long vm_flags)
  {
        phys_addr_t pa_start = __pa_symbol(va_start);
        unsigned long size = va_end - va_start;
index 5b87f8d623f7a0a22a53687d00136a5a5612bcb6,696822f755827e4c72834154c9962e201a783fa9..6986827e0d64519bdddcb706bb36f7e0baf269ab
@@@ -318,11 -339,13 +318,11 @@@ static void __init ptdump_initialize(vo
                                pg_level[i].mask |= pg_level[i].bits[j].mask;
  }
  
 -static struct ptdump_info kernel_ptdump_info = {
 +static struct ptdump_info kernel_ptdump_info __ro_after_init = {
        .mm             = &init_mm,
 -      .markers        = address_markers,
 -      .base_addr      = PAGE_OFFSET,
  };
  
void ptdump_check_wx(void)
bool ptdump_check_wx(void)
  {
        struct pg_state st = {
                .seq = NULL,
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index df0f7d4a96f3284eb4ac9c0495b5a4ec8df27aa3,7621a5acb13ed56512b5efff9bc43d4ab3f91ca3..315535ffb2582c17edd8b1c41fdff17291e14704
@@@ -1419,12 -1412,12 +1412,12 @@@ static inline bool pgdp_maps_userspace(
        return (((ptr & ~PAGE_MASK) / sizeof(pgd_t)) < PGD_KERNEL_START);
  }
  
- #define pgd_leaf      pgd_large
- static inline int pgd_large(pgd_t pgd) { return 0; }
+ #define pgd_leaf      pgd_leaf
+ static inline bool pgd_leaf(pgd_t pgd) { return false; }
  
 -#ifdef CONFIG_PAGE_TABLE_ISOLATION
 +#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
  /*
 - * All top-level PAGE_TABLE_ISOLATION page tables are order-1 pages
 + * All top-level MITIGATION_PAGE_TABLE_ISOLATION page tables are order-1 pages
   * (8k-aligned and 8k in size).  The kernel one is at the beginning 4k and
   * the user one is in the last 4k.  To switch between them, you
   * just need to flip the 12th bit in their addresses.
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc drivers/md/dm.c
Simple merge
Simple merge
Simple merge
diff --cc fs/Kconfig
Simple merge
Simple merge
Simple merge
index 17cb0761ff658e6838aa4e04eb429d4155e55e81,998861865b844f46387389679c007c4b2d8fc5c1..94f0e618865ba23aa7a5b636569ec59684690adb
@@@ -1643,8 -1642,9 +1644,9 @@@ extern struct pid *cad_pid
  #define PF__HOLE__02000000    0x02000000
  #define PF_NO_SETAFFINITY     0x04000000      /* Userland is not allowed to meddle with cpus_mask */
  #define PF_MCE_EARLY          0x08000000      /* Early kill for mce process policy */
- #define PF_MEMALLOC_PIN               0x10000000      /* Allocation context constrained to zones which allow long term pinning. */
+ #define PF_MEMALLOC_PIN               0x10000000      /* Allocations constrained to zones which allow long term pinning.
+                                                * See memalloc_pin_save() */
 -#define PF__HOLE__20000000    0x20000000
 +#define PF_BLOCK_TS           0x20000000      /* plug has ts that needs updating */
  #define PF__HOLE__40000000    0x40000000
  #define PF_SUSPEND_TASK               0x80000000      /* This thread called freeze_processes() and should not be frozen */
  
Simple merge
Simple merge
Simple merge
diff --cc init/main.c
index d002f30f7f24c99e124149cea43f613c15818fbe,5ecd4e8cf6d323d85b026bc6cccde9c53c627557..390b3a16683940bff7cf0e3f65be52b42ce2b9bc
  #include <linux/init_syscalls.h>
  #include <linux/stackdepot.h>
  #include <linux/randomize_kstack.h>
 +#include <linux/pidfs.h>
+ #include <linux/ptdump.h>
  #include <net/net_namespace.h>
  
  #include <asm/io.h>
@@@ -1401,26 -1398,34 +1403,27 @@@ static int __init set_debug_rodata(cha
  early_param("rodata", set_debug_rodata);
  #endif
  
 -#ifdef CONFIG_STRICT_KERNEL_RWX
  static void mark_readonly(void)
  {
 -      if (rodata_enabled) {
 +      if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX) && rodata_enabled) {
                /*
                 * load_module() results in W+X mappings, which are cleaned
-                * up with call_rcu().  Let's make sure that queued work is
+                * up with init_free_wq. Let's make sure that queued work is
                 * flushed so that we don't hit false positives looking for
                 * insecure pages which are W+X.
                 */
-               rcu_barrier();
+               flush_module_init_free_work();
                mark_rodata_ro();
+               debug_checkwx();
                rodata_test();
 -      } else
 +      } else if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX)) {
                pr_info("Kernel memory protection disabled.\n");
 +      } else if (IS_ENABLED(CONFIG_ARCH_HAS_STRICT_KERNEL_RWX)) {
 +              pr_warn("Kernel memory protection not selected by kernel config.\n");
 +      } else {
 +              pr_warn("This architecture does not have kernel memory protection.\n");
 +      }
  }
 -#elif defined(CONFIG_ARCH_HAS_STRICT_KERNEL_RWX)
 -static inline void mark_readonly(void)
 -{
 -      pr_warn("Kernel memory protection not selected by kernel config.\n");
 -}
 -#else
 -static inline void mark_readonly(void)
 -{
 -      pr_warn("This architecture does not have kernel memory protection.\n");
 -}
 -#endif
  
  void __weak free_initmem(void)
  {
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc mm/compaction.c
Simple merge
diff --cc mm/filemap.c
Simple merge
diff --cc mm/internal.h
Simple merge
diff --cc mm/mmap.c
Simple merge
diff --cc mm/page_alloc.c
Simple merge
diff --cc mm/shmem.c
Simple merge
diff --cc mm/swapfile.c
Simple merge
Simple merge
diff --cc mm/util.c
Simple merge
diff --cc mm/vmalloc.c
index 1e36322d83d895ca8964240d8c5fa9dfb14868a9,25a8df49725544e0320d69cd33b46918f100e4a0..22aa63f4ef6322a71030c5dd163706c83ef5cd8d
@@@ -4430,70 -4755,81 +4827,84 @@@ static void show_numa_info(struct seq_f
  
  static void show_purge_info(struct seq_file *m)
  {
+       struct vmap_node *vn;
        struct vmap_area *va;
+       int i;
+       for (i = 0; i < nr_vmap_nodes; i++) {
+               vn = &vmap_nodes[i];
  
-       spin_lock(&purge_vmap_area_lock);
-       list_for_each_entry(va, &purge_vmap_area_list, list) {
-               seq_printf(m, "0x%pK-0x%pK %7ld unpurged vm_area\n",
-                       (void *)va->va_start, (void *)va->va_end,
-                       va->va_end - va->va_start);
+               spin_lock(&vn->lazy.lock);
+               list_for_each_entry(va, &vn->lazy.head, list) {
+                       seq_printf(m, "0x%pK-0x%pK %7ld unpurged vm_area\n",
+                               (void *)va->va_start, (void *)va->va_end,
+                               va->va_end - va->va_start);
+               }
+               spin_unlock(&vn->lazy.lock);
        }
-       spin_unlock(&purge_vmap_area_lock);
  }
  
- static int s_show(struct seq_file *m, void *p)
+ static int vmalloc_info_show(struct seq_file *m, void *p)
  {
+       struct vmap_node *vn;
        struct vmap_area *va;
        struct vm_struct *v;
+       int i;
  
-       va = list_entry(p, struct vmap_area, list);
+       for (i = 0; i < nr_vmap_nodes; i++) {
+               vn = &vmap_nodes[i];
  
-       if (!va->vm) {
-               if (va->flags & VMAP_RAM)
-                       seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n",
-                               (void *)va->va_start, (void *)va->va_end,
-                               va->va_end - va->va_start);
+               spin_lock(&vn->busy.lock);
+               list_for_each_entry(va, &vn->busy.head, list) {
+                       if (!va->vm) {
+                               if (va->flags & VMAP_RAM)
+                                       seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n",
+                                               (void *)va->va_start, (void *)va->va_end,
+                                               va->va_end - va->va_start);
  
-               goto final;
-       }
+                               continue;
+                       }
  
-       v = va->vm;
+                       v = va->vm;
  
-       seq_printf(m, "0x%pK-0x%pK %7ld",
-               v->addr, v->addr + v->size, v->size);
+                       seq_printf(m, "0x%pK-0x%pK %7ld",
+                               v->addr, v->addr + v->size, v->size);
  
-       if (v->caller)
-               seq_printf(m, " %pS", v->caller);
+                       if (v->caller)
+                               seq_printf(m, " %pS", v->caller);
  
-       if (v->nr_pages)
-               seq_printf(m, " pages=%d", v->nr_pages);
+                       if (v->nr_pages)
+                               seq_printf(m, " pages=%d", v->nr_pages);
  
-       if (v->phys_addr)
-               seq_printf(m, " phys=%pa", &v->phys_addr);
+                       if (v->phys_addr)
+                               seq_printf(m, " phys=%pa", &v->phys_addr);
  
-       if (v->flags & VM_IOREMAP)
-               seq_puts(m, " ioremap");
+                       if (v->flags & VM_IOREMAP)
+                               seq_puts(m, " ioremap");
  
-       if (v->flags & VM_SPARSE)
-               seq_puts(m, " sparse");
++                      if (v->flags & VM_SPARSE)
++                              seq_puts(m, " sparse");
 +
-       if (v->flags & VM_ALLOC)
-               seq_puts(m, " vmalloc");
+                       if (v->flags & VM_ALLOC)
+                               seq_puts(m, " vmalloc");
  
-       if (v->flags & VM_MAP)
-               seq_puts(m, " vmap");
+                       if (v->flags & VM_MAP)
+                               seq_puts(m, " vmap");
  
-       if (v->flags & VM_USERMAP)
-               seq_puts(m, " user");
+                       if (v->flags & VM_USERMAP)
+                               seq_puts(m, " user");
  
-       if (v->flags & VM_DMA_COHERENT)
-               seq_puts(m, " dma-coherent");
+                       if (v->flags & VM_DMA_COHERENT)
+                               seq_puts(m, " dma-coherent");
  
-       if (is_vmalloc_addr(v->pages))
-               seq_puts(m, " vpages");
+                       if (is_vmalloc_addr(v->pages))
+                               seq_puts(m, " vpages");
  
-       show_numa_info(m, v);
-       seq_putc(m, '\n');
+                       show_numa_info(m, v);
+                       seq_putc(m, '\n');
+               }
+               spin_unlock(&vn->busy.lock);
+       }
  
        /*
         * As a final step, dump "unpurged" areas.
diff --cc mm/vmscan.c
Simple merge