Merge tag 'mm-stable-2022-12-13' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 14 Dec 2022 03:29:45 +0000 (19:29 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 14 Dec 2022 03:29:45 +0000 (19:29 -0800)
Pull MM updates from Andrew Morton:

 - More userfaultfs work from Peter Xu

 - Several convert-to-folios series from Sidhartha Kumar and Huang Ying

 - Some filemap cleanups from Vishal Moola

 - David Hildenbrand added the ability to selftest anon memory COW
   handling

 - Some cpuset simplifications from Liu Shixin

 - Addition of vmalloc tracing support by Uladzislau Rezki

 - Some pagecache folioifications and simplifications from Matthew
   Wilcox

 - A pagemap cleanup from Kefeng Wang: we have VM_ACCESS_FLAGS, so use
   it

 - Miguel Ojeda contributed some cleanups for our use of the
   __no_sanitize_thread__ gcc keyword.

   This series should have been in the non-MM tree, my bad

 - Naoya Horiguchi improved the interaction between memory poisoning and
   memory section removal for huge pages

 - DAMON cleanups and tuneups from SeongJae Park

 - Tony Luck fixed the handling of COW faults against poisoned pages

 - Peter Xu utilized the PTE marker code for handling swapin errors

 - Hugh Dickins reworked compound page mapcount handling, simplifying it
   and making it more efficient

 - Removal of the autonuma savedwrite infrastructure from Nadav Amit and
   David Hildenbrand

 - zram support for multiple compression streams from Sergey Senozhatsky

 - David Hildenbrand reworked the GUP code's R/O long-term pinning so
   that drivers no longer need to use the FOLL_FORCE workaround which
   didn't work very well anyway

 - Mel Gorman altered the page allocator so that local IRQs can remnain
   enabled during per-cpu page allocations

 - Vishal Moola removed the try_to_release_page() wrapper

 - Stefan Roesch added some per-BDI sysfs tunables which are used to
   prevent network block devices from dirtying excessive amounts of
   pagecache

 - David Hildenbrand did some cleanup and repair work on KSM COW
   breaking

 - Nhat Pham and Johannes Weiner have implemented writeback in zswap's
   zsmalloc backend

 - Brian Foster has fixed a longstanding corner-case oddity in
   file[map]_write_and_wait_range()

 - sparse-vmemmap changes for MIPS, LoongArch and NIOS2 from Feiyang
   Chen

 - Shiyang Ruan has done some work on fsdax, to make its reflink mode
   work better under xfstests. Better, but still not perfect

 - Christoph Hellwig has removed the .writepage() method from several
   filesystems. They only need .writepages()

 - Yosry Ahmed wrote a series which fixes the memcg reclaim target
   beancounting

 - David Hildenbrand has fixed some of our MM selftests for 32-bit
   machines

 - Many singleton patches, as usual

* tag 'mm-stable-2022-12-13' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (313 commits)
  mm/hugetlb: set head flag before setting compound_order in __prep_compound_gigantic_folio
  mm: mmu_gather: allow more than one batch of delayed rmaps
  mm: fix typo in struct pglist_data code comment
  kmsan: fix memcpy tests
  mm: add cond_resched() in swapin_walk_pmd_entry()
  mm: do not show fs mm pc for VM_LOCKONFAULT pages
  selftests/vm: ksm_functional_tests: fixes for 32bit
  selftests/vm: cow: fix compile warning on 32bit
  selftests/vm: madv_populate: fix missing MADV_POPULATE_(READ|WRITE) definitions
  mm/gup_test: fix PIN_LONGTERM_TEST_READ with highmem
  mm,thp,rmap: fix races between updates of subpages_mapcount
  mm: memcg: fix swapcached stat accounting
  mm: add nodes= arg to memory.reclaim
  mm: disable top-tier fallback to reclaim on proactive reclaim
  selftests: cgroup: make sure reclaim target memcg is unprotected
  selftests: cgroup: refactor proactive reclaim code to reclaim_until()
  mm: memcg: fix stale protection of reclaim target memcg
  mm/mmap: properly unaccount memory on mas_preallocate() failure
  omfs: remove ->writepage
  jfs: remove ->writepage
  ...

40 files changed:
1  2 
Documentation/filesystems/proc.rst
MAINTAINERS
arch/arm/include/asm/pgtable-nommu.h
arch/arm/include/asm/pgtable.h
arch/arm64/include/asm/pgtable.h
arch/arm64/mm/mmu.c
arch/arm64/mm/pageattr.c
arch/loongarch/Kconfig
arch/loongarch/include/asm/pgtable.h
arch/x86/kernel/cpu/sgx/encl.c
drivers/acpi/numa/hmat.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
drivers/gpu/drm/etnaviv/etnaviv_gem.c
drivers/media/common/videobuf2/frame_vector.c
fs/fuse/dev.c
fs/hfs/inode.c
fs/hfsplus/inode.c
fs/xfs/xfs_iops.c
include/linux/damon.h
include/linux/mm.h
include/linux/mmzone.h
include/linux/sched.h
kernel/cgroup/cpuset.c
kernel/fork.c
kernel/sysctl.c
lib/Kconfig.debug
lib/Kconfig.kasan
mm/Kconfig
mm/gup.c
mm/huge_memory.c
mm/hugetlb.c
mm/kasan/kasan_test.c
mm/kfence/core.c
mm/madvise.c
mm/migrate.c
mm/mmap.c
mm/shmem.c
mm/slub.c
mm/swapfile.c
tools/testing/selftests/vm/.gitignore

Simple merge
diff --cc MAINTAINERS
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -1187,50 -1153,12 +1153,12 @@@ int __meminit vmemmap_check_pmd(pmd_t *
  int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
                struct vmem_altmap *altmap)
  {
-       unsigned long addr = start;
-       unsigned long next;
-       pgd_t *pgdp;
-       p4d_t *p4dp;
-       pud_t *pudp;
-       pmd_t *pmdp;
        WARN_ON((start < VMEMMAP_START) || (end > VMEMMAP_END));
  
 -      if (!ARM64_KERNEL_USES_PMD_MAPS)
 +      if (!IS_ENABLED(CONFIG_ARM64_4K_PAGES))
                return vmemmap_populate_basepages(start, end, node, altmap);
-       do {
-               next = pmd_addr_end(addr, end);
-               pgdp = vmemmap_pgd_populate(addr, node);
-               if (!pgdp)
-                       return -ENOMEM;
-               p4dp = vmemmap_p4d_populate(pgdp, addr, node);
-               if (!p4dp)
-                       return -ENOMEM;
-               pudp = vmemmap_pud_populate(p4dp, addr, node);
-               if (!pudp)
-                       return -ENOMEM;
-               pmdp = pmd_offset(pudp, addr);
-               if (pmd_none(READ_ONCE(*pmdp))) {
-                       void *p = NULL;
-                       p = vmemmap_alloc_block_buf(PMD_SIZE, node, altmap);
-                       if (!p) {
-                               if (vmemmap_populate_basepages(addr, next, node, altmap))
-                                       return -ENOMEM;
-                               continue;
-                       }
-                       pmd_set_huge(pmdp, __pa(p), __pgprot(PROT_SECT_NORMAL));
-               } else
-                       vmemmap_verify((pte_t *)pmdp, node, addr, next);
-       } while (addr = next, addr != end);
-       return 0;
+       else
+               return vmemmap_populate_hugepages(start, end, node, altmap);
  }
  
  #ifdef CONFIG_MEMORY_HOTPLUG
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
   *
   * This function takes care of grabbing mmap_lock as necessary.
   */
 -int get_vaddr_frames(unsigned long start, unsigned int nr_frames,
 +int get_vaddr_frames(unsigned long start, unsigned int nr_frames, bool write,
                     struct frame_vector *vec)
  {
 -      struct mm_struct *mm = current->mm;
 -      struct vm_area_struct *vma;
 -      int ret_pin_user_pages_fast = 0;
 -      int ret = 0;
 -      int err;
 +      int ret;
-       unsigned int gup_flags = FOLL_FORCE | FOLL_LONGTERM;
++      unsigned int gup_flags = FOLL_LONGTERM;
  
        if (nr_frames == 0)
                return 0;
diff --cc fs/fuse/dev.c
Simple merge
diff --cc fs/hfs/inode.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc kernel/fork.c
Simple merge
diff --cc kernel/sysctl.c
Simple merge
Simple merge
Simple merge
diff --cc mm/Kconfig
Simple merge
diff --cc mm/gup.c
Simple merge
Simple merge
diff --cc mm/hugetlb.c
@@@ -6220,6 -6215,62 +6215,62 @@@ static inline bool __follow_hugetlb_mus
        return false;
  }
  
 -               * try_grab_page() should always succeed here, because we hold
 -               * the ptl lock and have verified pte_present().
+ struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma,
+                               unsigned long address, unsigned int flags)
+ {
+       struct hstate *h = hstate_vma(vma);
+       struct mm_struct *mm = vma->vm_mm;
+       unsigned long haddr = address & huge_page_mask(h);
+       struct page *page = NULL;
+       spinlock_t *ptl;
+       pte_t *pte, entry;
+       /*
+        * FOLL_PIN is not supported for follow_page(). Ordinary GUP goes via
+        * follow_hugetlb_page().
+        */
+       if (WARN_ON_ONCE(flags & FOLL_PIN))
+               return NULL;
+ retry:
+       pte = huge_pte_offset(mm, haddr, huge_page_size(h));
+       if (!pte)
+               return NULL;
+       ptl = huge_pte_lock(h, mm, pte);
+       entry = huge_ptep_get(pte);
+       if (pte_present(entry)) {
+               page = pte_page(entry) +
+                               ((address & ~huge_page_mask(h)) >> PAGE_SHIFT);
+               /*
+                * Note that page may be a sub-page, and with vmemmap
+                * optimizations the page struct may be read only.
+                * try_grab_page() will increase the ref count on the
+                * head page, so this will be OK.
+                *
 -              if (WARN_ON_ONCE(!try_grab_page(page, flags))) {
++               * try_grab_page() should always be able to get the page here,
++               * because we hold the ptl lock and have verified pte_present().
+                */
++              if (try_grab_page(page, flags)) {
+                       page = NULL;
+                       goto out;
+               }
+       } else {
+               if (is_hugetlb_entry_migration(entry)) {
+                       spin_unlock(ptl);
+                       __migration_entry_wait_huge(pte, ptl);
+                       goto retry;
+               }
+               /*
+                * hwpoisoned entry is treated as no_page_table in
+                * follow_page_mask().
+                */
+       }
+ out:
+       spin_unlock(ptl);
+       return page;
+ }
  long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
                         struct page **pages, struct vm_area_struct **vmas,
                         unsigned long *position, unsigned long *nr_pages,
Simple merge
Simple merge
diff --cc mm/madvise.c
Simple merge
diff --cc mm/migrate.c
Simple merge
diff --cc mm/mmap.c
Simple merge
diff --cc mm/shmem.c
Simple merge
diff --cc mm/slub.c
Simple merge
diff --cc mm/swapfile.c
Simple merge
Simple merge