linux/mm
Mikhail Gavrilov 2fb552b0be mm: don't schedule deferred kernel page table freeing while booting
Booting with a boot-time function tracer and a filter, for example

  ftrace=function ftrace_filter=pud_free_pmd_page

panics on 7.3-rc4 as soon as the tracer starts:

  [   23.531178] Starting tracer 'function'
  [   23.675800] Oops: general protection fault, probably for non-canonical address 0xdffffc0000000038: 0000 [#1] SMP KASAN NOPTI
  [   23.819917] KASAN: null-ptr-deref in range [0x00000000000001c0-0x00000000000001c7]
  [   23.964025] CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 7.3.0-rc4-fe2ec83746e5-with-fixes-v2+ #195 PREEMPT(undef)
  [   24.252248] RIP: 0010:__queue_work+0xab/0xf00
  [   25.981629] Call Trace:
  [   26.125727]  <TASK>
  [   26.413912]  ? pagetable_free_kernel+0x20/0x120
  [   26.990283]  queue_work_on+0x97/0xf0
  [   27.134382]  __cpa_collapse_large_pages+0x501/0x6f0
  [   27.566662]  cpa_flush+0x394/0x620
  [   27.998953]  change_page_attr_set_clr+0x321/0x4a0
  [   29.151729]  set_memory_rox+0xa2/0xf0
  [   29.584018]  create_trampoline+0x431/0x6f0
  ...
  [   44.343347] Kernel panic - not syncing: Attempted to kill the idle task!

The boot-time tracer is started from early_trace_init(), which runs
before workqueue_init_early().  Making its trampoline read-only splits a
large page, and CPA collapses it again right away.  The split table has
been a kernel page table since commit 9e4a3ec341
("x86/mm/pat: Allocate split page tables as kernel page tables"), so the
collapse frees it through pagetable_free_kernel(), which queues work on
system_percpu_wq - still NULL at that point.  That commit is correct in
itself; it only lets CPA reach pagetable_free_kernel() before the
workqueue that function relies on exists.

Keep putting the table on the list, but don't schedule the work while
the system is still booting.  A core_initcall schedules it once to free
whatever was queued by then.

Link: https://lore.kernel.org/20260925050647.86913-1-mikhail.v.gavrilov@gmail.com
Link: https://lore.kernel.org/20260924064321.23787-1-mikhail.v.gavrilov@gmail.com
Fixes: 9e4a3ec341 ("x86/mm/pat: Allocate split page tables as kernel page tables")
Signed-off-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: David Hildenbrand (Arm) <david@kernel.org>
Suggested-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Tested-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: <stable@vger.kernel.org>
2026-10-06 16:44:18 -07:00
..
damon mm/damon/core: don't skip damos_adjust_quota() while esz is not zero 2026-09-26 13:55:10 -07:00
kasan kasan: unpoison task stack below watermark only in generic mode 2026-09-26 13:55:10 -07:00
kfence mm/slab, kfence, memcg: completely remove obj_ext for kfence objects 2026-08-04 12:30:45 +02:00
kmsan mm: split out vmalloc declarations from internal.h 2026-08-04 19:18:46 -07:00
tests
alloc_tag.c alloc_tag: add accuracy based filtering to ioctl 2026-08-24 18:43:13 -07:00
arch_numa.c mm.git review status for linus..mm-stable 2026-08-27 09:17:06 -07:00
backing-dev.c writeback: report a Tasks-RCU quiescent state per cgwb drain pass 2026-09-18 08:20:15 -07:00
balloon.c
bpf_memcontrol.c
cma_debug.c mm/cma_debug: fix invalid accesses for inactive CMA areas 2026-05-28 20:50:33 -07:00
cma_sysfs.c mm/cma_sysfs: skip inactive CMA areas in sysfs 2026-06-03 16:25:49 -07:00
cma.c mm/cma: remove stray newline from auto-generated CMA area name 2026-08-24 18:43:16 -07:00
cma.h mm: add some missing includes to mm-local headers 2026-08-24 18:43:03 -07:00
compaction.c mm: page_alloc: fix non-movable reclaim storm in defrag_mode 2026-08-06 18:57:24 -07:00
debug_page_alloc.c mm: debug_page_alloc: fix NULL buf in debug_guardpage_minorder_setup 2026-08-24 18:43:08 -07:00
debug_page_ref.c
debug_vm_pgtable.c mm: decouple protnone helpers from CONFIG_NUMA_BALANCING 2026-08-04 19:18:36 -07:00
debug.c mm: prefer mm->def_vma_flags in mm logic 2026-08-06 18:57:02 -07:00
dmapool_test.c
dmapool.c
early_ioremap.c mm/early_ioremap: clarify early_ioremap_reset() semantics 2026-08-06 18:57:21 -07:00
execmem.c mm: split out vmalloc declarations from internal.h 2026-08-04 19:18:46 -07:00
fadvise.c
fail_page_alloc.c
failslab.c
filemap.c mm: filemap: retain mapped dropbehind folios 2026-09-05 11:47:48 -07:00
folio-compat.c mm/page-writeback: document folio_mark_dirty() locking more explicitly 2026-08-24 18:43:19 -07:00
folio.c mm/folio: EXPORT_SYMBOL_FOR_KVM(lru_cache_drain_for_folio) 2026-09-08 23:28:06 -07:00
gup_test.c mm/gup_test: keep longterm pin state per file 2026-08-24 18:43:17 -07:00
gup_test.h
gup.c mm/gup: factor out LRU cache draining for folio into lru_cache_drain_for_folio() 2026-08-24 18:43:00 -07:00
highmem.c
hmm.c mm/hmm.c:hmm_do_fault(): suppress sparse warning 2026-08-24 18:43:24 -07:00
huge_memory.c mm/huge_memory: bypass THP tuneables for huge pfnmap mappings 2026-09-05 11:47:47 -07:00
hugetlb_cgroup.c mm/hugetlb_cgroup: call page_counter_set_max() outside VM_BUG_ON() 2026-09-01 20:26:20 -07:00
hugetlb_cma.c mm/hugetlb_cma: fix null nodemask dereference in hugetlb_cma_alloc_frozen_folio 2026-09-01 20:26:19 -07:00
hugetlb_cma.h mm: add some missing includes to mm-local headers 2026-08-24 18:43:03 -07:00
hugetlb_internal.h
hugetlb_sysctl.c
hugetlb_sysfs.c
hugetlb_vmemmap.c mm/hugetlb_vmemmap: remove bootmem_info leftovers 2026-08-04 19:18:42 -07:00
hugetlb_vmemmap.h mm/sparse-vmemmap: remove sparse_vmemmap_init_nid_late() 2026-07-28 21:12:00 -07:00
hugetlb.c mm/hugetlb: preserve mremap address delta when skipping page tables 2026-09-18 08:20:14 -07:00
hwpoison-inject.c
init-mm.c exec_state: relocate dumpable information 2026-05-26 11:02:01 +02:00
internal.h mm/gup: factor out LRU cache draining for folio into lru_cache_drain_for_folio() 2026-08-24 18:43:00 -07:00
interval_tree.c mm/rmap: use anon pgoff to track MAP_PRIVATE file-backed anon folios 2026-08-24 18:42:53 -07:00
ioremap.c
Kconfig mm/Kconfig: make MEMORY_FAILURE select MIGRATION 2026-08-24 18:43:24 -07:00
Kconfig.debug percpu: drop CONFIG_DEBUG_FORCE_WEAK_PER_CPU 2026-08-24 18:43:24 -07:00
khugepaged.c mm: fix incorrect vm_flags usage when checking allowable orders for tmpfs 2026-09-01 20:26:21 -07:00
kmemleak.c mm: kmemleak: default min_unref_scans to 2 for verbose auto-scan 2026-08-24 18:43:18 -07:00
ksm.c ksm: update comments and docs to reference folio->mapping 2026-08-24 18:43:02 -07:00
list_lru.c mm.git review status for mm-hotfixes-stable..mm-stable 2026-06-19 10:14:34 -07:00
maccess.c
madvise.c mm: fix incorrect vm_flags usage when checking allowable orders for tmpfs 2026-09-01 20:26:21 -07:00
Makefile drivers/base, mm: move arch_numa.c to mm/ 2026-08-24 18:43:10 -07:00
mapping_dirty_helpers.c mm/vma: use vma_start_pgoff(), linear_page_index() in mm code 2026-08-04 19:19:00 -07:00
memblock.c mm: memblock: add missing HugeTLB flag name 2026-09-15 15:54:35 +03:00
memcontrol-v1.c memcg: make the v1 soft limit knob inert 2026-09-01 20:26:20 -07:00
memcontrol-v1.h mm: add some missing includes to mm-local headers 2026-08-24 18:43:03 -07:00
memcontrol.c memcg: avoid charging the root memcg from obj_cgroup_charge_pages() 2026-09-05 11:47:48 -07:00
memfd_luo.c mm/memfd_luo: document preservation of file seals 2026-05-04 14:03:16 +00:00
memfd.c mm/vma: update do_mmap() to use vma_flags_t 2026-08-06 18:57:01 -07:00
memory_hotplug.c mm/memory_hotplug: add offline_and_remove_memory_ranges() 2026-08-06 18:56:59 -07:00
memory-failure.c mm: introduce and use vma_filebacked_address() 2026-08-24 18:42:51 -07:00
memory-tiers.c
memory.c mm.git review status for linus..mm-stable 2026-08-27 09:17:06 -07:00
mempolicy.c mm/mempolicy: fix sleeping allocation in alloc_pages_bulk_weighted_interleave() 2026-09-01 20:26:22 -07:00
mempool.c mm/mempool: Untangle CONFIG_SLUB_DEBUG_ON abuse and switch to static key 2026-07-08 18:31:27 +02:00
memremap.c mm: decrement MTHP_STAT_NR_ANON in free_zone_device_folio() 2026-07-28 17:37:31 -07:00
memtest.c
migrate_device.c mm/migrate_device: avoid out-of-bounds writes for compound folios 2026-09-01 20:26:20 -07:00
migrate.c mm/migrate: calculate large folio page index using PFN 2026-08-24 18:42:53 -07:00
mincore.c mm: mincore: refactor mincore_page() 2026-08-06 18:57:15 -07:00
mlock.c mm/mlock: use the IRQ-safe accessor for NR_MLOCK in __munlock_folio() 2026-09-05 11:47:49 -07:00
mm_init.c mm.git review status for linus..mm-stable 2026-08-27 09:17:06 -07:00
mm_init.h mm: split out mm_init and memblock declarations from internal.h 2026-08-04 19:18:45 -07:00
mm_slot.h mm/mm_slot.h: add comments for mm_slot_lookup/insert 2026-08-06 18:57:04 -07:00
mmap_lock.c
mmap.c mm/vma: convert miscellaneous uses of VMA flags in core mm 2026-08-06 18:57:03 -07:00
mmu_gather.c
mmu_notifier.c mm/vma: correct incorrect vma.h inclusion 2026-08-04 19:19:04 -07:00
mmzone.c mm/vmscan: reduce lru_lock contention via vmstat-derived scan-balance cost 2026-08-24 18:42:56 -07:00
mprotect.c mm/mprotect: convert mprotect code to use vma_flags_t 2026-08-06 18:57:04 -07:00
mremap.c mm/mremap: fix locked_vm leak by splitting VMA for MREMAP_DONTUNMAP 2026-10-06 16:44:17 -07:00
mseal.c mm/mseal: remove further superfluous comments, do_mseal() 2026-08-06 18:57:12 -07:00
msync.c mm/vma: use vma_start_pgoff(), linear_page_index() in mm code 2026-08-04 19:19:00 -07:00
nommu.c mm: nommu: point to the write iterator upon split_vma 2026-08-24 18:42:48 -07:00
numa_emulation.c mm/fake-numa: fix under-allocation detection in uniform split 2026-06-02 08:34:03 +03:00
numa_memblks.c mm: numa_memblks: use numa_add_reserved_memblk() in numa_cleanup_meminfo() 2026-07-03 11:16:27 +03:00
numa.c
oom_kill.c
page_alloc.c mm/page_alloc: only update lowmem_reserve_ratio on sysctl write 2026-08-24 18:43:01 -07:00
page_alloc.h mm: replace __GFP_NO_CODETAG with ALLOC_NO_CODETAG 2026-07-30 19:40:44 -07:00
page_counter.c
page_ext.c mm/page_ext: remove pgdat_page_ext_init() 2026-08-24 18:43:03 -07:00
page_frag_cache.c mm: replace __GFP_NO_CODETAG with ALLOC_NO_CODETAG 2026-07-30 19:40:44 -07:00
page_idle.c
page_io.c mm/swap: move swap_ops into file systems for file system-based swap 2026-08-24 18:43:20 -07:00
page_isolation.c mm: split out internal page_alloc.h 2026-07-30 19:40:41 -07:00
page_owner.c mm: split out internal page_alloc.h 2026-07-30 19:40:41 -07:00
page_poison.c
page_reporting.c mm/page_reporting: add page_reporting_delay_ms module parameter 2026-08-24 18:42:58 -07:00
page_reporting.h
page_table_check.c Merge branch 'mm-hotfixes-stable' into mm-stable to pick up 2026-08-24 18:40:27 -07:00
page_vma_mapped.c mm/rmap: use anon pgoff to track MAP_PRIVATE file-backed anon folios 2026-08-24 18:42:53 -07:00
page-writeback.c mm.git review status for linus..mm-stable 2026-08-27 09:17:06 -07:00
pagewalk.c Merge branch 'mm-hotfixes-stable' into mm-stable to pick up 2026-08-24 18:40:27 -07:00
percpu-internal.h mm/percpu-internal.h: optimise pcpu_chunk struct to save memory 2026-06-02 15:22:13 -07:00
percpu-km.c mm/percpu-km: clear page->private before free them 2026-08-04 19:18:32 -07:00
percpu-stats.c
percpu-vm.c mm: split out vmalloc declarations from internal.h 2026-08-04 19:18:46 -07:00
percpu.c mm/percpu: avoid IO/FS reclaim in backing allocations 2026-07-28 21:11:47 -07:00
pgalloc-track.h mm: add some missing includes to mm-local headers 2026-08-24 18:43:03 -07:00
pgtable-generic.c mm: don't schedule deferred kernel page table freeing while booting 2026-10-06 16:44:18 -07:00
process_vm_access.c
ptdump.c mm/ptdump: always stabilise against page table freeing using init_mm 2026-08-04 20:02:00 -07:00
readahead.c block: split out a new blk_plug.h header 2026-08-04 06:57:05 -06:00
rmap.c mm/rmap: fix missing barrier between anon_vma init and vma->anon_vma publish 2026-09-18 08:20:14 -07:00
rodata_test.c
secretmem.c mm/secretmem: properly account locked pages 2026-09-03 10:56:10 -07:00
shmem_quota.c
shmem.c mm: shmem: ignore sysfs configs for shmem forced collapse 2026-09-26 13:55:09 -07:00
show_mem.c mm/show_mem: fix format string inconsistencies and type mismatches 2026-08-24 18:43:06 -07:00
shrinker_debug.c mm: shrinker: fix NULL pointer dereference in debugfs 2026-07-01 19:02:52 -07:00
shrinker.c mm/shrinker: fix bogus set_shrinker_bit() with cgroup.memory=nokmem 2026-09-08 23:28:06 -07:00
shuffle.c mm: split out internal page_alloc.h 2026-07-30 19:40:41 -07:00
shuffle.h mm: add some missing includes to mm-local headers 2026-08-24 18:43:03 -07:00
slab_common.c mm/slab: disallow kfree_rcu_sheaf() on PREEMPT_RT again 2026-09-04 12:15:41 +02:00
slab.h slab changes for 7.3 2026-08-24 10:58:57 -07:00
slub.c mm/slab: do not wake up kswapd in __kfree_rcu_sheaf() 2026-09-24 10:14:02 +02:00
sparse-vmemmap.c mm: split out sparse declarations from internal.h 2026-08-04 19:18:46 -07:00
sparse.c mm/sparse: keep mem_section_usage_size() internal 2026-08-24 18:43:06 -07:00
sparse.h mm/sparse: keep mem_section_usage_size() internal 2026-08-24 18:43:06 -07:00
swap_state.c mm.git review status for linus..mm-stable 2026-08-27 09:17:06 -07:00
swap_table.h mm, swap: merge zeromap into swap table 2026-06-02 15:22:23 -07:00
swap.h mm/swap: add a new swap_ops.h header to allow for pluggable swap ops 2026-08-24 18:43:20 -07:00
swapfile.c mm, swap: fix SWAP_USAGE_OFFLIST_BIT collision with real usage count 2026-09-05 11:47:48 -07:00
truncate.c mm/truncate: use folio_split() in truncate_inode_partial_folio() 2026-06-21 11:37:16 -07:00
usercopy.c
userfaultfd.c userfaultfd: reset err to be 0 when move_pages_ptes succeeded 2026-09-01 20:26:21 -07:00
util.c mm/vma: update do_mmap() to use vma_flags_t 2026-08-06 18:57:01 -07:00
vma_exec.c mm: propagate VMA anonymous page offset on map, remap, split + merge 2026-08-24 18:42:52 -07:00
vma_init.c mm/vma: introduce VMA anon page offset field and add helpers 2026-08-24 18:42:49 -07:00
vma_internal.h mm/vma: correct incorrect vma.h inclusion 2026-08-04 19:19:04 -07:00
vma.c mm/mremap: fix locked_vm leak by splitting VMA for MREMAP_DONTUNMAP 2026-10-06 16:44:17 -07:00
vma.h mm/mremap: fix locked_vm leak by splitting VMA for MREMAP_DONTUNMAP 2026-10-06 16:44:17 -07:00
vmalloc.c mm/vmalloc: do not warn on -ENOMEM from va_alloc() 2026-08-24 18:43:02 -07:00
vmalloc.h mm: add some missing includes to mm-local headers 2026-08-24 18:43:03 -07:00
vmpressure.c mm/vmpressure: move v1 userspace eventfd code into memcontrol-v1.c 2026-07-30 19:40:28 -07:00
vmscan.c mm.git review status for linus..mm-stable 2026-08-27 09:17:06 -07:00
vmstat.c mm/vmstat: add NRSWP{IN,OUT} counters 2026-08-24 18:43:15 -07:00
workingset.c mm/vmscan: reduce lru_lock contention via vmstat-derived scan-balance cost 2026-08-24 18:42:56 -07:00
zpdesc.h
zsmalloc.c zsmalloc: account for handle size in class lookup 2026-08-24 18:43:19 -07:00
zswap.c mm/swap: add a new swap_ops.h header to allow for pluggable swap ops 2026-08-24 18:43:20 -07:00