linux-mainline/mm
Chen Yu db6cc3f4ac Revert "sched/numa: add statistics of numa balance task"
This reverts commit ad6b26b6a0.

This commit introduces per-memcg/task NUMA balance statistics, but
unfortunately it introduced a NULL pointer exception due to the following
race condition: After a swap task candidate was chosen, its mm_struct
pointer was set to NULL due to task exit.  Later, when performing the
actual task swapping, the p->mm caused the problem.

CPU0                                   CPU1
:
...
task_numa_migrate
     task_numa_find_cpu
      task_numa_compare
        # a normal task p is chosen
        env->best_task = p

                                          # p exit:
                                          exit_signals(p);
                                             p->flags |= PF_EXITING
                                          exit_mm
                                             p->mm = NULL;

      migrate_swap_stop
        __migrate_swap_task((arg->src_task, arg->dst_cpu)
         count_memcg_event_mm(p->mm, NUMA_TASK_SWAP)# p->mm is NULL

task_lock() should be held and the PF_EXITING flag needs to be checked to
prevent this from happening.  After discussion, the conclusion was that
adding a lock is not worthwhile for some statistics calculations.  Revert
the change and rely on the tracepoint for this purpose.

Link: https://lkml.kernel.org/r/20250704135620.685752-1-yu.c.chen@intel.com
Link: https://lkml.kernel.org/r/20250708064917.BBD13C4CEED@smtp.kernel.org
Fixes: ad6b26b6a0 ("sched/numa: add statistics of numa balance task")
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Reported-by: Jirka Hladky <jhladky@redhat.com>
Closes: https://lore.kernel.org/all/CAE4VaGBLJxpd=NeRJXpSCuw=REhC5LWJpC29kDy-Zh2ZDyzQZA@mail.gmail.com/
Reported-by: Srikanth Aithal <Srikanth.Aithal@amd.com>
Reported-by: Suneeth D <Suneeth.D@amd.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Hladky <jhladky@redhat.com>
Cc: Libo Chen <libo.chen@oracle.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-07-09 21:07:56 -07:00
..
damon mm/damon: fix divide by zero in damon_get_intervals_score() 2025-07-09 21:07:55 -07:00
kasan kasan: remove kasan_find_vm_area() to prevent possible deadlock 2025-07-09 21:07:54 -07:00
kfence
kmsan kmsan: test: add module description 2025-06-05 22:02:25 -07:00
backing-dev.c
balloon_compaction.c
bootmem_info.c
cma_debug.c
cma_sysfs.c
cma.c - The 11 patch series "Add folio_mk_pte()" from Matthew Wilcox 2025-05-31 15:44:16 -07:00
cma.h
compaction.c
debug_page_alloc.c
debug_page_ref.c
debug_vm_pgtable.c
debug.c
dmapool_test.c
dmapool.c
early_ioremap.c
execmem.c Revert "mm/execmem: Unify early execmem_cache behaviour" 2025-06-11 11:20:52 +02:00
fadvise.c
fail_page_alloc.c
failslab.c
filemap.c - The 2 patch series "zram: support algorithm-specific parameters" from 2025-06-02 16:00:26 -07:00
folio-compat.c
gup_test.c
gup_test.h
gup.c mm/gup: revert "mm: gup: fix infinite loop within __get_longterm_locked" 2025-06-19 20:48:01 -07:00
highmem.c
hmm.c
huge_memory.c
hugetlb_cgroup.c
hugetlb_cma.c
hugetlb_cma.h
hugetlb_vmemmap.c
hugetlb_vmemmap.h
hugetlb.c mm/hugetlb: don't crash when allocating a folio if there are no resv 2025-07-09 21:07:53 -07:00
hwpoison-inject.c
init-mm.c
internal.h
interval_tree.c
io-mapping.c
ioremap.c
Kconfig LoongArch changes for v6.16 2025-06-07 09:56:18 -07:00
Kconfig.debug
khugepaged.c mm/khugepaged: clean up refcount check using folio_expected_ref_count() 2025-05-31 22:46:16 -07:00
kmemleak.c mm/alloc_tag: fix the kmemleak false positive issue in the allocation of the percpu variable tag->counters 2025-06-25 15:55:03 -07:00
ksm.c
list_lru.c
maccess.c
madvise.c mm: close theoretical race where stale TLB entries could linger 2025-06-11 22:42:35 -07:00
Makefile
mapping_dirty_helpers.c
memblock.c
memcontrol-v1.c
memcontrol-v1.h
memcontrol.c Revert "sched/numa: add statistics of numa balance task" 2025-07-09 21:07:56 -07:00
memfd.c
memory_hotplug.c
memory-failure.c
memory-tiers.c
memory.c mm/shmem, swap: fix softlockup with mTHP swapin 2025-06-19 20:48:01 -07:00
mempolicy.c mm/mempolicy: fix incorrect freeing of wi_kobj 2025-06-05 22:02:23 -07:00
mempool.c
memremap.c
memtest.c
migrate_device.c
migrate.c mm/migrate: fix do_pages_stat in compat mode 2025-07-09 21:07:54 -07:00
mincore.c
mlock.c
mm_init.c - The 2 patch series "zram: support algorithm-specific parameters" from 2025-06-02 16:00:26 -07:00
mm_slot.h
mmap_lock.c
mmap.c
mmu_gather.c mmu_gather: move tlb flush for VM_PFNMAP/VM_MIXEDMAP vmas into free_pgtables() 2025-05-31 22:46:12 -07:00
mmu_notifier.c
mmzone.c
mprotect.c
mremap.c mm: expose abnormal new_pte during move_ptes 2025-06-05 21:55:41 -07:00
mseal.c
msync.c
nommu.c - The 11 patch series "Add folio_mk_pte()" from Matthew Wilcox 2025-05-31 15:44:16 -07:00
numa_emulation.c
numa_memblks.c
numa.c
oom_kill.c
page_alloc.c - The 11 patch series "Add folio_mk_pte()" from Matthew Wilcox 2025-05-31 15:44:16 -07:00
page_counter.c
page_ext.c
page_frag_cache.c
page_idle.c
page_io.c
page_isolation.c
page_owner.c
page_poison.c
page_reporting.c
page_reporting.h
page_table_check.c
page_vma_mapped.c
page-writeback.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
pagewalk.c
percpu-internal.h
percpu-km.c
percpu-stats.c
percpu-vm.c
percpu.c
pgalloc-track.h
pgtable-generic.c
process_vm_access.c
pt_reclaim.c
ptdump.c
readahead.c
rmap.c mm/rmap: fix potential out-of-bounds page table access during batched unmap 2025-07-09 21:07:53 -07:00
rodata_test.c
secretmem.c fs: export anon_inode_make_secure_inode() and fix secretmem LSM bypass 2025-06-23 12:41:17 +02:00
shmem_quota.c
shmem.c mm/shmem, swap: fix softlockup with mTHP swapin 2025-06-19 20:48:01 -07:00
show_mem.c - The 11 patch series "Add folio_mk_pte()" from Matthew Wilcox 2025-05-31 15:44:16 -07:00
shrinker_debug.c
shrinker.c
shuffle.c
shuffle.h
slab_common.c
slab.h
slub.c slab updates for 6.16 2025-06-04 08:59:59 -07:00
sparse-vmemmap.c
sparse.c
swap_cgroup.c
swap_state.c - The 11 patch series "Add folio_mk_pte()" from Matthew Wilcox 2025-05-31 15:44:16 -07:00
swap.c
swap.h mm/shmem, swap: fix softlockup with mTHP swapin 2025-06-19 20:48:01 -07:00
swapfile.c - The 11 patch series "Add folio_mk_pte()" from Matthew Wilcox 2025-05-31 15:44:16 -07:00
truncate.c - The 2 patch series "zram: support algorithm-specific parameters" from 2025-06-02 16:00:26 -07:00
usercopy.c
userfaultfd.c mm: userfaultfd: fix race of userfaultfd_move and swap cache 2025-06-19 20:48:01 -07:00
util.c mm: add mmap_prepare() compatibility layer for nested file systems 2025-06-12 21:39:02 -07:00
vma_exec.c
vma_init.c
vma_internal.h
vma.c mm: add mmap_prepare() compatibility layer for nested file systems 2025-06-12 21:39:02 -07:00
vma.h mm: add mmap_prepare() compatibility layer for nested file systems 2025-06-12 21:39:02 -07:00
vmalloc.c mm/vmalloc: leave lazy MMU mode on PTE mapping error 2025-07-09 21:07:52 -07:00
vmpressure.c
vmscan.c fuse update for 6.16 2025-06-02 15:31:05 -07:00
vmstat.c Revert "sched/numa: add statistics of numa balance task" 2025-07-09 21:07:56 -07:00
workingset.c
zpdesc.h mm: rename page->index to page->__folio_index 2025-05-31 22:46:06 -07:00
zpool.c
zsmalloc.c
zswap.c