Skip to content

Rebase edera/mainline onto master @ c339f4010dea - #66

Closed
edera-rebase-app[bot] wants to merge 10000 commits into
edera/mainlinefrom
rebase/edera-mainline/20261029-cde3385b5531-c339f4010dea
Closed

edera-rebase-app[bot] wants to merge 10000 commits into
edera/mainlinefrom
rebase/edera-mainline/20261029-cde3385b5531-c339f4010dea

Conversation

@edera-rebase-app

Copy link
Copy Markdown

Nightly rebase of edera/mainline (cde3385b5531) onto master (c339f4010dea), driven by Claude. Not pushed automatically because the checker found drift. Run log.

Important

Do not use the merge button: this branch replaces edera/mainline rather than merging into it. Approve the pull request to land it; the land workflow force-pushes edera/mainline to the approved head, pinned to cde3385b5531, and keeps a backup.

Independent checks

Builds: success (x86_64 vmlinux on the Edera host config and arm64 vmlinux, both with the Edera features built in; per-build results in the run).

Old tip cde3385b5531
New tip 45350a8c9e14
Old upstream base 864c07de0c7d
New upstream base c339f4010dea
  • New branch is based on the upstream tip.
  • Downstream series is linear.
  • All 97 downstream commits replayed; 3 changed only in hunk context (listed below).
  • Downstream drift: the tree changed by more than the upstream delta.
Commits whose hunk context moved (own +/- lines identical)
  • ea62ac9f1b0f iommu/xen: Add Xen PV-IOMMU driver → 82dd0fcb90ca
  • bd1c0dba57c3 sysctl: wire up PaX softmode setting → 8f357abc46c5
  • 849ed61740ea use maximum supported mmap rnd entropy by default → 4ba9dfaca474
Drift (changed lines: upstream delta vs. actual change)
--- upstream-lines
+++ actual-lines
@@ -796406,6 +796406,18 @@
 +	return ret;
 +}
 +
++#ifdef CONFIG_OPENPAX_SOFTMODE
++static const struct ctl_table pax_table[] = {
++	{
++		.procname       = "softmode",
++		.data           = &pax_softmode,
++		.maxlen         = sizeof(int),
++		.mode           = 0600,
++		.proc_handler   = proc_dointvec,
++	},
++};
++#endif
++
 +static const struct ctl_table sysctl_subsys_table[] = {
 +	{
 +		.procname	= "sysctl_writes_strict",
@@ -796453,6 +796465,9 @@
 +int __init sysctl_init_bases(void)
 +{
 +	register_sysctl_init("kernel", sysctl_subsys_table);
++#ifdef CONFIG_OPENPAX_SOFTMODE
++	register_sysctl_init("kernel/pax", pax_table);
++#endif
 +
 +	return 0;
 +}
@@ -796486,6 +796501,18 @@
 -	mutex_unlock(&static_key_mutex);
 -	return ret;
 +	return -ENOSYS;
+-#ifdef CONFIG_OPENPAX_SOFTMODE
+-static const struct ctl_table pax_table[] = {
+-	{
+-		.procname       = "softmode",
+-		.data           = &pax_softmode,
+-		.maxlen         = sizeof(int),
+-		.mode           = 0600,
+-		.proc_handler   = proc_dointvec,
+-	},
+-};
+-#endif
+-
 -static const struct ctl_table sysctl_subsys_table[] = {
 -#ifdef CONFIG_SYSCTL
 -	{
@@ -796535,6 +796562,9 @@
 -int __init sysctl_init_bases(void)
 -{
 -	register_sysctl_init("kernel", sysctl_subsys_table);
+-#ifdef CONFIG_OPENPAX_SOFTMODE
+-	register_sysctl_init("kernel/pax", pax_table);
+-#endif
 -
 -	return 0;
 -}

Claude's report

Summary

Rebased edera/mainline (cde3385b5531) onto torvalds master c339f4010dea (v7.2-rc5-39336-gc339f4010dea), from merge base 864c07de0c7d (v7.2-rc5-26646-g864c07de0c7d). That is 12032 non-merge upstream commits (merge window). All 97 downstream commits were replayed onto rebase-result (45350a8c9e14). Two conflicts were resolved (kernel/sysctl.c, arch/Kconfig), no commits were dropped, and no build fixes were needed. The checker passes base, linearity and commit count. It reports downstream drift, all of it in kernel/sysctl.c: the PaX softmode sysctl moved together with the table upstream relocated (see below). The arch/Kconfig resolution produces no drift. The checker also lists 3 commits whose hunk context moved: the two conflicted ones and iommu/xen: Add Xen PV-IOMMU driver, whose Kconfig/Makefile neighbours changed when upstream added the BCM2712 and Hyper-V IOMMU drivers. Their own +/- lines are identical. Both x86_64 and arm64 builds pass.

Needs a decision

None.

Conflicts resolved

  • sysctl: wire up PaX softmode setting (bd1c0dba57c3 → 8f357abc46c5), kernel/sysctl.c.
    • Collided with Oleg Nesterov's acd19f2c56f2 ("sysctl: collapse redundant CONFIG_SYSCTL nesting") and 443bea2f71c5 ("sysctl: consolidate CONFIG_SYSCTL into a single block"). Those moved sysctl_subsys_table and sysctl_init_bases() into the single #ifdef CONFIG_SYSCTL block, after the real proc_do_static_key(). The old position was after the #else stubs.
    • I put the downstream pax_table (under CONFIG_OPENPAX_SOFTMODE) directly above sysctl_subsys_table at its new location, and its register_sysctl_init("kernel/pax", pax_table) call into the relocated sysctl_init_bases(). I kept the upstream layout as it is.
    • The commit's own diff is line-for-line the same as before; only its position in the file changed. That relocation is the whole of the checker's drift.
  • use maximum supported mmap rnd entropy by default (849ed61740ea → 4ba9dfaca474), arch/Kconfig.
    • Collided with 8cdae75cebe0 ("arch/Kconfig: fix dead conditions by removing dead options"). That commit removed ARCH_MMAP_RND_BITS_DEFAULT and ARCH_MMAP_RND_COMPAT_BITS_DEFAULT and their default ... if ... lines, which were dead because an int symbol used as a condition is always false.
    • I kept the upstream removal and applied the downstream change (default *_MIN → default *_MAX) to the remaining default line in both ARCH_MMAP_RND_BITS and ARCH_MMAP_RND_COMPAT_BITS.
    • Effective behaviour is unchanged, because the removed line never fired. Nothing in the tree references the removed symbols, and the checker shows no drift from this resolution.

Dropped downstream commits

None.

Build fixes

None.

Upstream commits that meet the series

These upstream commits touch files the series also touches. For each fix (Fixes:/stable), I read the final tree.

  • 68cb098eadda mm/vma: avoid broken uffd merge on mremap: fix (stable). The series doesn't touch mm/vma.c; intact.
  • 7135a05838e8 mm/vma: avoid spurious write locks when mm->mm_lock_seq overflows: fix (stable). The downstream pax_flags field in mm_types.h is unrelated to mm_lock_seq; intact.
  • dc0b17144d62 mm/vma: don't remove VMA from rmap if pgoff unchanged: OK.
  • 14a5c975b138 mm: update comments to refer to anon rmap rather than anon_vma: OK.
  • 38564710f443 mm: implement and use vma_has_anon_rmap(), silence KCSAN: OK.
  • 6a9ef02c60bf mm/vma: const-ify vma_assert_stabilised() and associated functions: OK.
  • 72a993449cb0 mm: eliminate VM_SPECIAL, VMA_SPECIAL_FLAGS: no VM_SPECIAL left anywhere in the result, OpenPaX included.
  • 44debd840ec9 mm/vma: introduce vma[_flags]_is_mm_backed(): OK.
  • c911e7ebebf5 mm: rename is_vm_hugetlb_page() to vma_is_hugetlb(): no stale callers downstream.
  • 94c86564538e mm: remove hugetlb_inline.h: no downstream includers.
  • 88d77002e1a1 mm: remove VMA_IO_BIT check in vma[_flags]_is_mm_managed(): OK.
  • 9201d0f5b9d5 mm/vma: add and use vma_[flags]_is_fixed_mapping: OK.
  • 7fdbc26b69c0 mm/vma: add vma[_flags]_is_mm_managed() predicates: OK.
  • b7b4d8f37a4f mm: add mmap action for discontiguous kernel page mapping: OK. The downstream mm/util.c change is in arch_randomize_brk(), a different function.
  • 4852f3421456 mm/vma: tidy up map kernel pages enum values: OK.
  • 9cae38dc11da mm: consistently validate VMA state after mmap[_prepare] hooks: OK.
  • 86a779c53204 mm/vma: introduce and use vma_[flags_]can_merge(): OK.
  • f85eb0656c40 mm/vma: fix mmap_prepare file handling, remove file_doesnt_need_get: no downstream users of the removed field.
  • 2e83e2ce34ff arch, mm: promote DEBUG_WX to CHECK_WX: no DEBUG_WX references in the series or in the build script.
  • c2d4ccfbba3f mm: fix typos in various comments: OK.
  • 28d5df7b7274 KVM: split CONFIG_KVM_PRIVATE_MEMATTR_VM out of KVM_VM_MEMORY_ATTRIBUTES: overlaps only in kernel-parameters.txt.
  • 084100a1b579 tracing: Parse filter from boot event string: overlaps only in docs.
  • aabe6e1b36ce init/main.c: remove unreachable check in obsolete_checksetup(): OK. pax_softmode= has a setup function.
  • 677f83795fdf bootconfig: Move BOOTCONFIG_FOOTER_SIZE to include/linux/bootconfig.h: OK.
  • 958c01049e0a bootconfig: Skip printing early params to cmdline from bootconfig: OK. pax_softmode= is a __setup, not an early_param, so it still passes through.
  • 10823ced2f18 kho: rename kho_scratch= commandline parameter to kho_bootmem=: overlaps only in docs.
  • 8ebd2eb87f50 kho: rename KHO scratch to KHO bootmem: overlaps only in docs.
  • fdd81f15fc43 iommu/dma: Clean up redundant MSI cookie check: OK. The downstream dma-iommu.c hunk is in iova_reserve_iommu_regions() only.
  • 1c8f6308e557 iommu/dma: Catch scatterlist length overflows: fix (stable). The only downstream commit on dma-iommu.c (0788b07b17d0) doesn't touch the scatterlist path, and the overflow checks are present in the final tree; intact.
  • 2690d4156b51 iommu/hyperv: Add para-virtualized IOMMU support for Hyper-V guest: no collision with Hyper-V-nested-on-Xen.
    • hv_iommu_init is installed only from hyperv_init(), which returns early unless x86_hyper_type == X86_HYPER_MS_HYPERV.
    • The downstream nested-on-Xen init path never installs it, and xen_iommu_init bails unless xen_domain(). So the two drivers can't both be active.
    • Their Kconfig and Makefile entries sit side by side without conflict.
  • 118bdac10546 Drivers: hv: Add logical device ID registry for vPCI devices: the registry is set up in hv_common_init(), which the nested-on-Xen path also calls, so hv_pci_register_dev_id() in pci-hyperv.c works when nested. The downstream pci-hyperv hunks don't overlap.
  • 1ae140d0f272 iommu: Make iommu-dma helpers private: xen-iommu.c doesn't use the helpers that became private.
    • Upstream now includes iommu-priv.h in dma-iommu.c, and so does downstream 0788b07b17d0, so the header is included twice (lines 33 and 42).
    • This is harmless because of the include guard, and the downstream commit is unchanged. It was left alone to keep the replay exact; dropping the downstream include is an optional follow-up.
  • bbe5d3b3d402 treewide: remove PagePrivate() and PG_private from comments and docs: OK.
  • 6eecb67b69af xen/grant-table: stop setting PG_private on pages for grant mapping: the downstream gnttab_alloc_pages_node() goes through the fixed gnttab_pages_set_private(). No SetPagePrivate or PagePrivate is left in drivers/xen or include/xen.
  • e59c9a971a9f mm/vma: make MAP_PRIVATE-mapped /dev/zero mappings truly anonymous: OK, not relied on by OpenPaX.
  • 4b019e056f6c mm: implement file_is_dev_zero() to uniquely identify /dev/zero: no clash with the downstream tools/testing/vma stubs.
  • 35e340a47888 mm: userland pgtable freeing is RCU-safe now, remove leftover bits: no downstream users of the removed symbols, arch/x86/xen/mmu_pv.c included.
  • 8cdae75cebe0 arch/Kconfig: fix dead conditions by removing dead options: conflict, resolved as above. Zero references to the removed symbols remain.
  • 51e766bcd35e init/main: fix false-positive kernel panic on environment variable overwrite: fix. Intact in init/main.c; the downstream pax_softmode= code is separate.
  • b82ed0e3a1da init/main: fix off-by-one in argv_init cleanup: fix; intact.
  • 47e725702b0b mm: make per-VMA locks available universally: OK. The downstream EMUTRAMP hook in do_user_addr_fault() runs before both the VMA-lock and mmap-lock paths and doesn't depend on CONFIG_PER_VMA_LOCK.
  • 681f3b68f435 KVM: guest_memfd: Fix the in-place conversion documentation: fix, docs only.
  • 0bf031ba8c49 iommu: Add Broadcom BCM2712 IOMMU driver: neighbour in Kconfig/Makefile; XEN_IOMMU entries intact.
  • 42eed9bb9ca4 iommu: apple-dart: Support specifying the DMA aperture in the DT: same as the previous item.
  • 537ec2b15fdd KVM: Let userspace disable per-VM mem attributes, enable per-gmem attributes: overlaps only in docs.
  • 69d38c792c53 mm: Add copy_remote_mm_str(): a different function in mm/util.c.
  • 5728d3523f12 memblock: reject non-page-aligned reserve_mem regions: fix. Overlaps only in docs; intact.
  • 443bea2f71c5 sysctl: consolidate CONFIG_SYSCTL into a single block in kernel/sysctl.c: conflict, resolved as above.
  • acd19f2c56f2 sysctl: collapse redundant CONFIG_SYSCTL nesting in kernel/sysctl.c: conflict, resolved as above.
  • 242bac52294e sysctl: Disallow partial updates for erroneous sysctl vectors: proc_dointvec on a single int (pax_softmode) keeps the same semantics.
  • d08ab285b096 sysctl: Reject uint arrays before calling the general proc_vec: same as the previous item.
  • 2bfbb09b505c sysctl: Split data conversion and file position handling: same as the previous item.
  • 641a9b9cc697 dma-mapping: use exact allocation for DMA pages: no downstream callers.
  • 95d2fec40c48 dma-mapping: rename dma_opt_mapping_size(): no downstream callers of the old name.
  • d0ec95a8a4e7 hv_netvsc: Advertise the SR-IOV capability for CoCo VMs: touches different functions from the downstream netvsc_dma_map/unmap change, which is intact. The nested-on-Xen case is not an isolated VM, so its behaviour is unchanged.
  • abaa0835b4f3 bpf: Refuse caller-supplied keyrings when the bpf one is active: overlaps only in docs.
  • 264d8fd2794f bpf, keys: Add a bpf keyring for program signature validation: overlaps only in docs.

Builds

Unrelated to this rebase, and the same on the old tip cde3385b5531: drivers/hv/vmbus_drv.c calls hyperv_remove_xen_vmbus_irq(), but only arch/x86/include/asm/mshyperv.h declares it. include/asm-generic/mshyperv.h has no declaration or stub. An arm64 build with CONFIG_HYPERV enabled would therefore fail on an implicit declaration. The arm64 defconfig build doesn't enable Hyper-V, so it isn't hit here.

Enze Li and others added 30 commits October 24, 2026 01:56
The HUGETLB SUBSYSTEM F: entries list include/linux/hugetlb.h explicitly,
but other hugetlb headers are not covered, so get_maintainer.pl does not
attribute them to the hugetlb maintainers.

Enumerating headers by hand is also fragile: any header not listed (such
as hugetlb_cgroup.h) falls outside the subsystem.  Joe Perches suggested
using a glob F: entry, which covers all current and future hugetlb headers
in one line and avoids the gap.

Link: https://lore.kernel.org/20261003060029.2152489-1-lienze@kylinos.cn
Signed-off-by: Enze Li <lienze@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Joe Perches <joe@perches.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: SJ Park <sj@kernel.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
The final #endif that closes the _LINUX_HUGETLB_CGROUP_H include guard
is left without a comment.  Add the macro name to the comment for
consistency and easier navigation.

Link: https://lore.kernel.org/20261003060029.2152489-2-lienze@kylinos.cn
Signed-off-by: Enze Li <lienze@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
Reviewed-by: SJ Park <sj@kernel.org>
Cc: Oscar Salvador <osalvador@suse.de>
mrelease_test doubles the child allocation when process_mrelease() returns
ESRCH.

When size is already MAX_SIZE_MB, the current <= check still allows
another retry, causing the allocation to grow from 1024 MB to 2048 MB.

Use < instead of <= so the largest allocation attempted remains
MAX_SIZE_MB.

LLM used in discovering bug. Changes were made and reviewed manually.

Link: https://lore.kernel.org/CANOyQmFzsssM_BXHUDrV+UuVD5SZMBmSkg3UQnmw9Ns1PV7GCQ@mail.gmail.com
Fixes: 3377614 ("selftests: vm: add process_mrelease tests")
Signed-off-by: Aveline Noir <jm5905938@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: SJ Park <sj@kernel.org>
Assisted-by: LLM
Cc: Shuah Khan <shuah@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
kmsan_vmalloc_to_page_or_null() rejects addresses outside the regular
vmalloc and module ranges, including the shadow and origin addresses
passed by its callers.  As a result, iounmap does not free the metadata
backing pages.  Also, the first iteration of the teardown loop unmaps the
entire metadata range, preventing subsequent iterations from finding their
pages even if the address lookup is fixed.

Factor the page-table walk out of vmalloc_to_page() into
__vmalloc_to_page(), keeping the address check in the public wrapper.  Use
the unchecked helper in kmsan_vmalloc_to_page_or_null() and check for NULL
before converting the returned page to a PFN.  Mark __vmalloc_to_page() as
__always_inline to avoid an additional function call in vmalloc_to_page().

Move metadata teardown into kmsan_iounmap_pages().  Free the backing
blocks while their mappings are still available, then unmap each metadata
range once and flush its TLB entries.

Link: https://lore.kernel.org/20261002200508.546-1-dmytrokoziuk68@gmail.com
Fixes: b073d7f ("mm: kmsan: maintain KMSAN metadata for page operations")
Signed-off-by: Dima Koziuk <dmytrokoziuk68@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Alexander Potapenko <glider@google.com>
Link: https://lkml.iu.edu/2609.3/12748.html
Cc: Marco Elver <elver@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Uladzislau Rezki (Sony) <urezki@gmail.com>
Looking further at kmsan_ioremap_page_range(), I found three cases where
error cleanup leaks metadata blocks.

1. If the first iteration fails, clean is zero and cleanup is skipped,
   leaking any allocations that succeeded in that iteration.

2. If shadow mapping succeeds but origin mapping fails, the shadow
   pointer has already been cleared. Removing its mapping loses the
   backing block.

3. On failures after completed iterations, cleanup removes the earlier
   metadata mappings without freeing their backing blocks.

The cleanup needed here is the same as for iounmap, so it makes sense to
reuse kmsan_iounmap_pages().  Track the end of installed mappings with
mapped_end and advance it after each successful shadow mapping.  This
includes the current shadow block if origin mapping subsequently fails,
while the helper skips the missing origin mapping.

Run cleanup whenever err is non-zero.  Free allocations that have not been
mapped directly, and use the shared helper to unmap and free the installed
metadata, including blocks from completed iterations.

Link: https://lore.kernel.org/20261002200508.546-2-dmytrokoziuk68@gmail.com
Fixes: fdea03e ("mm: kmsan: handle alloc failures in kmsan_ioremap_page_range()")
Signed-off-by: Dima Koziuk <dmytrokoziuk68@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Alexander Potapenko <glider@google.com>
Cc: Marco Elver <elver@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Uladzislau Rezki (Sony) <urezki@gmail.com>
…e_noflush()

__vmap_pages_range_noflush() currently only warns when page_shift is
smaller than PAGE_SHIFT, then continues with the invalid shift.  Return
-EINVAL instead so the bogus argument is caught immediately.

Link: https://lore.kernel.org/20261004071639.119857-1-jiangwenxiaomi@gmail.com
Signed-off-by: Wen Jiang <jiangwen6@xiaomi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Barry Song <baohua@kernel.org>
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Vishal Moola (Fractile) <vishal.moola@gmail.com>
Cc: Dev Jain <dev.jain@arm.com>
The per-node hugepages section writes the free_hugepages and
surplus_hugepages file names with stray trailing quotes.  Quote the real
names as inline literals instead.

Link: https://lore.kernel.org/20261003161125.40485-1-lienze@kylinos.cn
Signed-off-by: Enze Li <lienze@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: David Hildenbrand <david@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Every test is expected to reserve the HugeTLB pages it needs. 
hugetlb-read-hwpoison was not converted, so on a system without
pre-reserved huge pages the MAP_POPULATE mmap() fails with ENOMEM and
every test case is skipped.

Reserve the pages with hugetlb_setup_default().  Each chunk size runs two
HWPOISON tests and a poisoned huge page can't be reused, so reserve two
pages per chunk size.  The pool size is restored on exit.  The poisoned
pages remain allocated until reboot.

With the patch, all 12 cases pass on a system with no huge pages
reserved (tested on Fedora, x86_64, CONFIG_MEMORY_FAILURE=y).

Link: https://lore.kernel.org/20261004205458.119608-1-jaeyeon.lee.dev@gmail.com
Signed-off-by: Jaeyeon Lee <jaeyeon.lee.dev@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Tested-by: Sarthak Sharma <sarthak.sharma@arm.com>
Reviewed-by: Sarthak Sharma <sarthak.sharma@arm.com>
Assisted-by: LLM
Cc: David Hildenbrand <david@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
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>
On systems/VMs with a large number of CPUs (e.g.  4096), hugetlb_init()
computes num_fault_mutexes = roundup_pow_of_two(8 * num_possible_cpus()) =
32768.  The subsequent kmalloc for the mutex table can exceed
MAX_PAGE_ORDER when struct mutex is enlarged by debug options like
CONFIG_DEBUG_MUTEXES and CONFIG_DEBUG_LOCK_ALLOC, resulting in:

  WARNING: at __alloc_frozen_pages_noprof (order > MAX_PAGE_ORDER)
  kernel BUG at mm/hugetlb.c (BUG_ON(!hugetlb_fault_mutex_table))
  Kernel panic - not syncing: Fatal exception

Switch to kvmalloc_objs() so the allocation falls back to vmalloc when the
contiguous physical allocation is too large.  The table is only accessed
by index, so virtual contiguity is sufficient.

Link: https://lore.kernel.org/20261006160128.31447-1-dheerajkumar.srivastava@amd.com
Fixes: 8382d91 ("mm, hugetlb: improve page-fault scalability")
Signed-off-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: David Hildenbrand <david@kernel.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Vasant Hegde <vasant.hegde@amd.com>
Cc: Bharata B Rao <bharata@amd.com>
Patch series "support kselftest on nommu platform", v5.

This patchset adds an ability to execute kselftest on nommu platforms.

Currently there are several issues if we wish to run kselftests on nommu
targets:

- it cannot compile/build test binaries because the current files mainly
  assume to build with glibc,
- some of the tests are not able to run on nommu targets as there are no
  fork(2) syscall.

The first issue can be avoided if we can build static PIE binaries (if
targets support it), but in our case (build on ubuntu/glibc and run on
alpine/musl-libc), it fails to invoke due to lack of the GNU ifunc
mechanism.  Thus, we need to cross-compile with musl toolchain, which
needs to be solved the first issue.

The second issue is the lack of fork(2) syscall on those platforms.
Especially the test harness helper (kselftest_harness.h) uses the
syscall, which cannot be simply with vfork(2).  `timeout` command used
in `runner.sh` never works for nommu platform as it uses fork(2).

nommu component in the mm subsystem has several known issues and having
test cases should help this situation, thus this patchset is very first
step toward enriching test environment which has not been well tested
for a while.  The test cases is implemented based on the document
(Documentation/admin-guide/mm/nommu-mmap.rst).

Initial shape for this patches is implemented as an opt-in TARGET, not
built/invoked automatically if users don't specify this nommu target.


This patch (of 2):

Architectures lacking MMU don't support fork(2) syscall and only vfork(2)
is available with limitations.  Thus, we cannot run kselftest on nommu
architecture as is.

This commit addresses this issue with the following changes:

- Detect NOMMU at runtime from the MmapCopy field in /proc/meminfo
  and avoid timeout, which requires fork(2).
- Document how to build and run the NOMMU tests, including the procfs
  prerequisite for runtime detection.

Build and run the tests with:

 $ make ARCH=um O=build kselftest-all TARGETS=nommu
 $ make ARCH=um O=build kselftest-install TARGETS=nommu
 $ ./build/kselftest/kselftest_install/run_kselftest.sh -p -c nommu

Link: https://lore.kernel.org/20261006085642.3852152-1-thehajime@gmail.com
Link: https://lore.kernel.org/20261006085642.3852152-2-thehajime@gmail.com
Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Closes: https://sashiko.dev/#/patchset/20260813063401.1786548-1-thehajime%40gmail.com
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kees Cook <kees@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Will Drewry <wad@chromium.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Brendan Jackman <brendan.jackman@linux.dev>
Cc: Hangbin Liu <liuhangbin@gmail.com>
Cc: "Ricardo B. Marliere" <rbm@suse.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Daniel Palmer <daniel@thingy.jp>
Introduce a kselftest utility to validate memory mapping capabilities
under nommu kernels, aligned with
Documentation/admin-guide/mm/nommu-mmap.rst.

The test implements basic checks into a generic architecture-agnostic
test matrix applicable across nommu targets. It evaluates:

1. MAP_FIXED allocation rejections.
2. Standard MAP_PRIVATE and MAP_ANONYMOUS allocation resilience.
3. Regular file mappings via standard filesystem storage.
4. Block device subsystem mappings (gracefully skipping if node is
   missing).
5. Shared vs Private backing discrepancies under nommu conditions.
6. mremap limits, ensuring non-expandable restrictions behave properly.

Link: https://lore.kernel.org/20261006085642.3852152-3-thehajime@gmail.com
Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260825015945.141739-1-thehajime@gmail.com
Assisted-by: Gemini:Pro [AI_Reviewer] [Sashiko_Linter]
Assisted-by: cubic.dev:unspecified
Cc: David Hildenbrand <david@kernel.org>
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: Shuah Khan <shuah@kernel.org>
Cc: Ricardo B . Marlière <rbm@suse.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Brendan Jackman <brendan.jackman@linux.dev>
Cc: Hangbin Liu <liuhangbin@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kees Cook <kees@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Will Drewry <wad@chromium.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Daniel Palmer <daniel@thingy.jp>
Patch series "mm/damon: fix a minor bug, clean code, and add a test".

Patch 1 from Jaeyeon Lee fixes a minor overflow issue in DAMOS.  Patch 2
from Gregory Price (Meta) cleans up the code for handling of hugetlb
pages.  Patch 3 from Liew Rui Yan adds a kunit test for a recently fixed
bug.


This patch (of 3):

damon_hot_score() calculates the age of a region by multiplying r->age and
the aggregation interval.  On 32-bit architectures, unsigned long is 32
bits, so the multiplication overflows once the age exceeds about 4295
seconds.  Then old regions are scored as if they were young.

Fix it by doing the calculation in 64-bit arithmetic using div_u64(). 
Also make age_in_sec u64, so the result is not truncated back to 32 bits.

The issue was discovered [1] by Sashiko.

Link: https://lore.kernel.org/20261006065209.41507-1-sj@kernel.org
Link: https://lore.kernel.org/20261006065209.41507-2-sj@kernel.org
Link: https://lore.kernel.org/20260623011652.1354-1-sj@kernel.org [1]
Fixes: 198f0f4 ("mm/damon/vaddr,paddr: support pageout prioritization")
Signed-off-by: Jaeyeon Lee <jaeyeon.lee.dev@gmail.com>
Signed-off-by: SJ Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SJ Park <sj@kernel.org>
Assisted-by: LLM
Hugetlb folio acquisition is open-coded in three places:
  - damon_hugetlb_mkold()
  - damon_young_hugetlb_entry()
  - damon_va_probe_hugetlb_entry()

DAMON already has damon_get_monitor_folio(), which paddr uses to get
monitored LRU and hugetlb folios and to filter them through
damon_folio_acceptable().  These paths bypass that check.

Use that helper in these paths too, so that DAMON acquires hugetlb folios
and applies its acceptance policy in one place.

No functional change intended.  All callers reach these paths with a
present hugetlb PTE under the page table lock, so the folio is always a
mapped hugetlb folio and the helper always returns it.

Link: https://lore.kernel.org/20261006065209.41507-3-sj@kernel.org
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Signed-off-by: SJ Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SJ Park <sj@kernel.org>
…last region

Commit b3723b5 ("mm/damon/core: fix unconditionally skip last
region") fixed a minor bug.

Add a KUnit test case to cover this behavior and prevent regressions in
the future.

Link: https://lore.kernel.org/20261006065209.41507-4-sj@kernel.org
Signed-off-by: Liew Rui Yan <aethernet65535@gmail.com>
Signed-off-by: SJ Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SJ Park <sj@kernel.org>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@davidgow.net>
If hugetlb_add_to_page_cache() in memfd_alloc_folio() fails with -EEXIST,
a concurrent fault has already instantiated the folio in the page cache,
and the reservation now belongs to that folio.  Calling
hugetlb_unreserve_pages() in that case incorrectly removes the region
backing the cached folio and releases one reservation more than it should,
leaving that folio in the page cache with no region recording it.

That leaves resv_huge_pages one page short until that folio is removed
from the page cache, so available_huge_pages() reports a page that is not
actually free and the pool can grant one reservation more than it can
back.  Applications using hugetlb memfds can then fail to allocate or
fault in a page they already reserved.  They see -ENOMEM or -ENOSPC from
the allocation or fault path even though the reservation and
HugePages_Free still look healthy.

So hold the hugetlb fault mutex from hugetlb_reserve_pages() until the
error-path unreserve completes to make the reserve, allocate and
instantiate steps atomic against concurrent faults.  With the mutex held
from the start, a concurrent fault can no longer consume the reservation
between reserve and allocate/instantiate.  If a fault completed before the
mutex was taken, it has already added the region for that index, so
hugetlb_reserve_pages() returns 0 and the error path leaves the region in
place.

Link: https://lore.kernel.org/20260927094757.31665-1-hongfu.li@linux.dev
Link: https://lore.kernel.org/20260903030134.7407-1-hongfu.li@linux.dev
Fixes: 717cf93 ("mm/memfd: reserve hugetlb folios before allocation")
Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
Cc: <stable@vger.kernel.org>
snapshot_set_swap_area() unpins the previously selected swap device and
pins the new one in two separate swap_lock critical sections.  In the gap
between them, swapoff() observes SWP_HIBERNATION cleared, bypasses the
guard, and tears down the device, reopening the race the SWP_HIBERNATION
pin was meant to close.  The window is reachable on any
SNAPSHOT_SET_SWAP_AREA call after the snapshot device is opened for
hibernation, and on any retry after the resume path's first selection.

Add repin_hibernation_swap_type(), which looks up the new device, clears
the old SWP_HIBERNATION flag and sets the new one under a single swap_lock
acquisition.  The same-device case is short- circuited so userspace can
re-select the same swap area without tripping WARN_ON_ONCE and -EBUSY. 
Switch snapshot_set_swap_area() to the new helper.

A failed lookup now preserves the previous pin instead of dropping it, so
a bad SNAPSHOT_SET_SWAP_AREA leaves the prior selection intact.  The open
and release paths keep using pin_hibernation_swap_type() and
unpin_hibernation_swap_type().

The race was identified during AI-assisted review of the SWP_HIBERNATION
pinning series.

[akpm@linux-foundation.org: coding-style cleanups]
Link: https://lore.kernel.org/20260430195651.287659-1-devnexen@gmail.com
Fixes: 8e6e0d845823 ("mm/swap, PM: hibernate: fix swapoff race in uswsusp by pinning swap device")
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Assisted-by: Codex (gpt-5-codex)
Cc: Baoquan He <bhe@redhat.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Chris Li <chrisl@kernel.org>
Cc: Kairui Song <kasong@tencent.com>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: Len Brown <lenb@kernel.org>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: DaeMyung Kang <charsyam@gmail.com>
Cc: Youngjun Park <youngjun.park@lge.com>
Pretty much every pr_* message in this file starts with "HugeTLB: ", typed
out by hand, and one of them even drifted to lowercase ("hugetlb:"). 
hugetlb_vmemmap.c already handles this with pr_fmt, so let's do the same
here instead of repeating the prefix over and over.

The output stays the same for almost everything; the only tweaks are that
the lowercase message now matches the others, and the ratelimited "killed
due to inadequate hugepage pool" warning picks up the prefix like
everything else.

Link: https://lore.kernel.org/20261010092333.137126-1-lienze@kylinos.cn
Signed-off-by: Enze Li <lienze@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: David Hildenbrand <david@kernel.org>
Cc: Enze Li <enze.li@gmx.com>
…ut_pte_range()

During stress testing with stress-ng on a 256-CPU system, a softlockup was
observed when madvise(MADV_COLD) was called on a 31GB memory region backed
by transparent hugepages.  The region contains 15935 THP PMD entries, and
the softlockup was triggered after 14485 of them had been processed.

The THP branch of madvise_cold_or_pageout_pte_range() has no scheduling
point.  walk_pmd_range() invokes it once per 2MB PMD entry with no
cond_resched() anywhere in the loop.  Each iteration calls
pmdp_invalidate() which issues a synchronous TLB shootdown (dsb ish)
waiting for all CPUs to acknowledge.  This operation can be time-consuming
under heavy system load, causing the accumulated time across all PMD
entries to exceed the softlockup threshold (20s) and panic when
softlockup_panic=1.  On a CONFIG_PREEMPT_NONE=y kernel, there is no other
opportunity to reschedule during this entire traversal.

The regular PTE path already has an unconditional cond_resched() at the
function tail (introduced by commit 9c276cc ("mm: introduce
MADV_COLD") and commit 1a4e58c ("mm: introduce MADV_PAGEOUT") when
MADV_COLD and MADV_PAGEOUT were first introduced) and a conditional one
inside the loop (commit b2f557a ("mm/madvise: add cond_resched() in
madvise_cold_or_pageout_pte_range()")).  The THP branch never received
equivalent treatment.

Fix by adding cond_resched() at the huge_unlock exit path after
spin_unlock(ptl) and reclaim_pages(), which is the single exit point for
all goto paths in the THP branch.

Crash log:
  watchdog: BUG: soft lockup - CPU#63 stuck for 23s! [stress-ng-vm:1665914]
  ...
  Call trace:
  pmdp_invalidate+0x48/0x68
  madvise_cold_or_pageout_pte_range+0x84c/0xb00
  walk_pmd_range.isra.0+0x1ac/0x3b0
  walk_pud_range+0x120/0x190
  walk_pgd_range+0x170/0x1b8
  __walk_page_range+0x184/0x198
  walk_page_range_vma+0x94/0x128
  madvise_cold+0xd8/0x198
  madvise_vma_behavior+0x234/0x638
  madvise_walk_vmas.constprop.0+0xdc/0x210
  madvise_do_behavior+0xa8/0x328
  do_madvise+0xd8/0x140
  __arm64_sys_madvise+0x2c/0xe0

Link: https://lore.kernel.org/20261010024042.4070048-1-albin_yang@163.com
Signed-off-by: Wei Yang <albinwyang@tencent.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Gregory Price (Meta) <gourry@gourry.net>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Jann Horn <jannh@google.com>
Cc: <stable@vger.kernel.org>
__discard_anon_folio_pmd_locked() clears a lazyfree THP's PMD before it
determines whether the folio can be discarded, and restores it if the
folio is dirty or has extra references.  It is done under only the PMD
lock and the anon_vma read lock inside try_to_unmap_one() and no mmap lock
is held.  The temporarily none PMD causes UAF.

A parallel munmap() or mremap() is supposed to serialize with it on the
PMD lock, but zap_pmd_range() (called by munmap()) and move_page_tables()
(called by mremap()) do not take the lock when they see the temporarily
none PMD and skip the PMD.  There is no more page table walk after the
none PMD is restored:

- munmap(): free_pgtables() waits in unlink_anon_vmas() for the anon_vma
  lock, then free_pmd_range() drops the restored PMD as bad without
  removing the rmap, so the folio keeps a stale mapcount.

- whole-VMA MREMAP_DONTUNMAP: dontunmap_complete() unlinks the source VMA
  from its anon_vma while the restored PMD still maps the folio.

- plain mremap(): the THP is not moved but unmapped, so the THP's data is
  lost.

In the first two cases, the folio stays mapped, but no VMA that maps it is
linked to its anon_vma.  When the anon_vma is freed, it is still reachable
when one rmap walks the folio.  Racing lazyfree reclaim against
MREMAP_DONTUNMAP as an unprivileged user reproduces a KASAN use-after-free
in folio_lock_anon_vma_read() as reported in the Closes link.

One solution is to use an invalidated PMD instead of a cleared one until
the discard is committed, but it needs arch fixes first.
1. GUP-fast still follows an invalidated PMD on riscv, LoongArch and s390.
2. sparc64 miscounts thp_pte_count when an invalidated PMD is set again or
   cleared.

To keep the fix simple for backport, stop discarding lazyfree THPs at PMD
level instead. try_to_unmap_one() splits the PMD and discards the folio at
PTE level.

unmap_huge_pmd_locked() and __discard_anon_folio_pmd_locked() are left in
place, unused, to minimize this fix for backport and the invalidated PMD
approach is planned as a follow-up series to use them again.

Link: https://lore.kernel.org/20261012-lazyfree-stable-fix-v2-1-6387d6e30063@nvidia.com
Fixes: 735ecdf ("mm/vmscan: avoid split lazyfree THP during shrink_folio_list()")
Signed-off-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Kyle Zeng <kylebot@openai.com>
Closes: https://lore.kernel.org/r/20261009165214.40212-2-kylebot@openai.com
Reviewed-by: Kyle Zeng <kylebot@openai.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Tested-by: JongHyuk Kim(MalHyuk) <malhyuk97@gmail.com>
  Link: https://lore.kernel.org/CADQRuqvXQ=YE=7T3oR66vTxE33pi=ygEeZKPTOU=cALZL0Figw@mail.gmail.com
Assisted-by: LLM
Cc: Rik van Riel <riel@surriel.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Harry Yoo <harry@kernel.org>
Cc: Jann Horn <jannh@google.com>
Cc: <stable@vger.kernel.org>
MREMAP_DONTUNMAP keeps the source VMA in place, but clears its mlock flags
while setting them on the destination VMA.  The "mm/mremap: fix two issues
with MREMAP_DONTUNMAP" series fixed two cases where this leaked
mm->locked_vm:

 - an unfaulted mlock-on-fault VMA moved behind itself self-merges, so the
   single resulting VMA loses the flags without the accounting being
   dropped;

 - a partial mremap() moves only part of the range, leaving the pages which
   are not moved accounted as locked in a VMA whose flags were cleared.

Add a test which mlock2()s a source mapping, moves all or part of it with
MREMAP_DONTUNMAP, unmaps everything and checks that VmLck is back to its
value from before, and run it for the self-merge case and for a partial
move with and without MLOCK_ONFAULT.

Verified on x86_64: the three cases fail on mm-unstable with the two fixes
reverted and pass with them applied.

Link: https://lore.kernel.org/20261006064120.6796-1-azpijr@gmail.com
Signed-off-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
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>
…nodes()

hugetlb_sysfs_init() guards the "hugetlb_sysfs_initialized = true"
assignment with an #ifdef CONFIG_NUMA block, while the following
hugetlb_register_all_nodes() call is left unguarded and relies on the
empty !CONFIG_NUMA stub.

Move the assignment into the NUMA version of hugetlb_register_all_nodes(),
before it registers the online nodes, so the #ifdef in
hugetlb_sysfs_init() can go away.  Keep the !CONFIG_NUMA stub, so the call
site is unconditional in both configurations.

No functional change; this is an #ifdef cleanup.

Link: https://lore.kernel.org/20261009142010.552614-1-lienze@kylinos.cn
Signed-off-by: Enze Li <lienze@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Muchun Song <muchun.song@linux.dev>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Enze Li <enze.li@gmx.com>
uffd_move_pmd_test()/uffd_move_test_common() splits the test area into
chunks of chunk_size and moves them one by one.  On arm64 with 64K base
pages the chunk_size (read_pmd_pagesize()) is 512MB, which is larger than
the whole 32MB (UFFD_TEST_MEM_SIZE) test area:

  step_count = nr_pages / (chunk_size / page_size) == 0

Because chunk_size > page_size, the test then aligns both areas up to
512MB, which points far outside of the 32MB mappings, and decrements
step_count, which underflows to ULONG_MAX.  The verification loop then
runs away and the first dereference of area_src faults with a SIGSEGV.

Skip the test when a single chunk cannot fit into the test area.

Link: https://lore.kernel.org/20261011163527.95988-1-zenghui.yu@linux.dev
Fixes: a2bf6a9 ("selftests/mm: add UFFDIO_MOVE ioctl test")
Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Tested-by: Sarthak Sharma <sarthak.sharma@arm.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Since commit 7e8756d ("mm: page_alloc: fix non-movable reclaim storm
in defrag_mode"), direct reclaim and compaction for non-movable requests
under defrag_mode run at pageblock_order, to produce the whole blocks that
ALLOC_NOFRAGMENT needs.  The retry decisions that follow still use the
request order.  An order-0 request can therefore retry indefinitely
without ever reaching the ALLOC_NOFRAGMENT fallback:

- Reclaim at pageblock_order gives up after one pass as soon as a zone
  looks compaction_ready(), and do_try_to_free_pages() then returns 1
  even though nothing was reclaimed. It returns before the retry that
  would reclaim memory.low-protected cgroups, so when most memory is
  protected, the pass that did run finds next to nothing.

- Compaction at pageblock_order fails or is deferred.

- should_reclaim_retry() takes the reported progress as progress for
  the order-0 request and resets no_progress_loops. The request
  retries.

Order 1-3 requests loop the same way, and should_compact_retry() also
checks their pageblock_order compaction result against the request order.

On a production host (64G, defrag_mode, memory.low covering most of the
workload), 95% of direct reclaim runs were order-9 runs that returned 1
with nothing reclaimed, at up to 60k runs per second.  Across ~200M
should_reclaim_retry() calls in a day, no_progress_loops never left 0. 
The spinning allocations were SLUB slab refills for inode and dentry
caches.  The time spent registers as memory pressure, and pressure-based
OOM killing takes down both workloads and system services.

For promoted requests:

- Reclaim progress does not reset no_progress_loops, as for costly
  orders.

- should_compact_retry() checks the compaction result at the promoted
  order and does not retry COMPACT_SKIPPED, since the request can fall
  back. The compaction priority floor and the COMPACT_SUCCESS retry
  limit stay those of the request order, so a non-costly request still
  gets its COMPACT_PRIO_SYNC_FULL pass before it falls back.

When a promoted request takes the fallback, reset the retry counters, so
that the fallback attempt gets a full retry budget before the OOM killer
is considered.  A request whose reclaim was not promoted spent its budget
on the request itself and keeps its counters, as Usama Arif pointed out.

__alloc_pages_slowpath() computes the promoted order once per iteration
and keeps it in alloc_context for direct reclaim, direct compaction and
the two retry helpers, so no callee has to recompute it.  Harry Yoo asked
for the promoted order to be explicit rather than derived in each callee,
and Vlastimil Babka suggested alloc_context over new function parameters.

In a VM reproducer (32G, defrag_mode, inode churn under memory.low):

                                        before    after
    should_reclaim_retry() calls           63M     293k
    peak memory pressure (PSI some avg10)  99%      12%

File creation runs 5.7x faster.

[kas@kernel.org: s/order_nofrag_promoted/order_defrag_promoted/, per hannes]
  Link: https://lore.kernel.org/atDL-nSFP2KVU7cI@thinkstation
Link: https://lore.kernel.org/as5q14OsbK2CmOrh@thinkstation
Fixes: 7e8756d ("mm: page_alloc: fix non-movable reclaim storm in defrag_mode")
Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Assisted-by: LLM
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Harry Yoo <harry@kernel.org>
Cc: Usama Arif <usama.arif@linux.dev>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Brendan Jackman <brendan.jackman@linux.dev>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: <stable@vger.kernel.org>
Replace the hardcoded 32 with sizeof(buf) at the remaining four call
sites, for consistency with the rest of the file.

Link: https://lore.kernel.org/20261014031147.444733-1-lienze@kylinos.cn
Signed-off-by: Enze Li <lienze@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: David Hildenbrand <david@kernel.org>
find_vma_and_prepare_anon() can end up allocating an anon_vma in VMAs that
are not CoW mappings, which is wrong.

If we have a MAP_SHARED R/O file mapped, we lack VM_SHARED (but do have
VM_MAYSHARE) and lack VM_MAYWRITE.

While uffd later rejects such mappings (uffd registration requires
VM_MAYWRITE, see comment in validate_dst_vma) find_vma_and_prepare_anon()
still wrongly allocates an anon vma before it validates the vma.

This in turn later confuses copy_page_range()->vma_needs_copy() such
that we end up calling copy_hugetlb_page_range() with ranges that
actually do not contain *any* per-pagetable information that would
require copying, which is the basis for PMD-table sharing in the first
place.

copy_hugetlb_page_range() should not have to worry about shared
PMD tables at all: it doesn't make any sense to copy page tables that are
shared, as they can be fully recreated later. Ending up in the function
with shareable page tables is the real issue.

If a destination PMD table is shared in copy_hugetlb_page_range(), it
might get concurrently unshared as we are not holding relevant
locks, resulting in us using a page table that is no longer mapped and
possibly freed after calling:

	dst_pte = huge_pte_alloc(dst, dst_vma, addr, sz);

To fix it, do not allocate an anon_vma in non-CoW mappings and add a
safety guard to copy_hugetlb_page_range(), making sure that we never
end up messing with shared PMD tables in there.

Before commit 867a43a ("userfaultfd: use per-vma locks in userfaultfd
operations") we would always validate the VMA before allocating an
anon_vma, and consequently never wrongly allocate an anon_vma.

As uffd_lock_vma() is part of the same lookup machinery and
also contains a misleading VM_SHARED check, change that one as well
directly for consistency.

A follow-up cleanup will stop taking the hugetlb_vma_lock_read(src_vma)
lock in copy_hugetlb_page_range() entirely. Further, the usage of
VM_SHARED in userfaultfd code should be cleaned up later to focus on
CoW vs. non-CoW mappings.

Link: https://lore.kernel.org/20261014-copy_hugetlb_page_range-v1-1-5b68e03fe7fe@kernel.org
Fixes: 867a43a ("userfaultfd: use per-vma locks in userfaultfd operations")
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Kyle Zeng <kylebot@openai.com>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: Kyle Zeng <kylebot@openai.com>
Tested-by: Kyle Zeng <kylebot@openai.com>
Acked-by: Muchun Song <muchun.song@linux.dev>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Tested-by: Lance Yang <lance.yang@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Lokesh Gidra <lokeshgidra@google.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: <stable@vger.kernel.org>
Patch series "mm/collapse: separate a collapse from its callers", v5.

There is no line between the collapse engine and the callers that ask for
a collapse.  khugepaged.c holds both, and they reach into each other.

 - Sixteen tests through the collapse path read cc->is_khugepaged to work
   out what they are allowed to do, when every one of those decisions was
   made by the caller before it asked.

 - collapse_single_pmd() does both halves of a collapse behind one call.
   Where it gives up mmap_lock between them is buried in the anonymous
   scan on one side and ahead of the file scan on the other.

Start drawing the line.  The caller states what it allows in a policy,
and the collapse code reads the policy instead of asking who called.  The
scan of a PTE table and the collapse that follows get a function each,
with the mmap_lock drop between them in one place.


This patch (of 9):

madvise_collapse() holds an mmgrab() reference across its work. It is
redundant. Every caller already holds mm_users:

 - madvise(2) works on current->mm, which lives as long as the task is in
   the syscall;
 - process_madvise(2) reaches a remote mm through mm_access(), which takes
   an mm_users reference and holds it until the syscall returns;
 - io_uring passes current->mm;
 - DAMON takes one with get_task_mm() and drops it after the call.

Drop the mmgrab()/mmdrop() pair.

Link: https://lore.kernel.org/20261014171145.3292736-1-kas@kernel.org
Link: https://lore.kernel.org/20261014171145.3292736-2-kas@kernel.org
Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Assisted-by: LLM
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Nico Pache <nico.pache@linux.dev>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Usama Arif <usama.arif@linux.dev>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Jann Horn <jannh@google.com>
collapse_single_pmd() bumps khugepaged_pages_collapsed for its caller, and
tests cc->is_khugepaged to know whether it should: the counter belongs to
the daemon, and MADV_COLLAPSE must not touch it.

The daemon sees every result of every collapse it asks for, so it can keep
its own counter without the shared path testing who called.

Link: https://lore.kernel.org/20261014171145.3292736-3-kas@kernel.org
Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Assisted-by: LLM
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Nico Pache <nico.pache@linux.dev>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Usama Arif <usama.arif@linux.dev>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Jann Horn <jannh@google.com>
The name says less than the bit means.  A set bit means not only that the
PTE is present, but also that it passed the other checks: uffd,
lazyfree, anonymity, sharing.  The PTE can be considered a collapse
source.

mthp_collapse() then reads the bitmap starting at the PMD order, so the
bitmap is not specific to mTHP either.

Name it for what a set bit means, and update the comments that named it.

No functional change.

Link: https://lore.kernel.org/20261014171145.3292736-4-kas@kernel.org
Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Assisted-by: LLM
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Nico Pache <nico.pache@linux.dev>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Usama Arif <usama.arif@linux.dev>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Jann Horn <jannh@google.com>
khugepaged.c holds both the users of collapse and the machinery that
performs it.  The daemon's scan loop, the sysfs tunables, MADV_COLLAPSE's
entry point and the collapse itself all sit in one file and reach into
each other freely.  Nothing marks where a user ends and the engine
begins.

Start drawing that line.

Add mm/collapse.h for what the two sides have to agree on:

  - enum scan_result - what the engine hands back;
  - struct collapse_control - the state a request carries.

And two constants move with them:

  - KHUGEPAGED_MAX_PTES_LIMIT -> COLLAPSE_MAX_PTES_LIMIT;
  - KHUGEPAGED_MIN_MTHP_ORDER -> COLLAPSE_MIN_MTHP_ORDER.

Neither is a fact about the daemon, so both lose the KHUGEPAGED_ prefix.

No functional change.

Link: https://lore.kernel.org/20261014171145.3292736-5-kas@kernel.org
Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Assisted-by: LLM
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Nico Pache <nico.pache@linux.dev>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Usama Arif <usama.arif@linux.dev>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Jann Horn <jannh@google.com>
Tests scattered through the collapse path decide what a collapse is
allowed to do by asking whether khugepaged started it.  Between them they
settle:

 - which VMAs are eligible, and how hard to try for a folio;
 - how many empty, swapped-out or shared PTEs a window may contain, and
   whether a sub-PMD window is held to a stricter rule than a PMD;
 - whether a range has to look used, and whether a MADV_FREE'd page is
   left alone;
 - whether the PMD is mapped as part of the request, and whether dirty
   pages are worth writing back and retrying.

None of those is a fact about khugepaged.  Each is something the caller
decided before asking, and the collapse code should not have to look up
who called to find out.

Add struct collapse_policy for the caller to fill: khugepaged from its
own settings, MADV_COLLAPSE from the fact that a user asked explicitly.
Every test becomes a read of a field, and cc->is_khugepaged goes, having
no reader left.

The PTE limits come as two sets, one for a PMD-sized window and one for
anything smaller, so that the helpers pick a set for the order and read
it.  khugepaged takes no swapped-out or shared PTE into a sub-PMD window,
and empty PTEs only when the knob says all or nothing; the warning for a
knob value in between moves to where khugepaged fills its policy.  The
fields only one side reads say which: anon_ or file_.  David Hildenbrand
asked for both.

khugepaged fills the policy once per scan pass, MADV_COLLAPSE once per
call.  That is the one change in behaviour.  The max_ptes_* limits and the
defrag setting behind the allocation mask are sampled once per pass rather
than on every table.  A table scanned early in a pass and one scanned late
are then treated alike.

collapse_file() also drops a NULL check on the collapse_control.  It has
one call site, reached only from collapse_single_pmd(), which dereferences
cc unconditionally, so the check was already dead.

Link: https://lore.kernel.org/20261014171145.3292736-6-kas@kernel.org
Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Tested-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Assisted-by: LLM
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Nico Pache <nico.pache@linux.dev>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Usama Arif <usama.arif@linux.dev>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Jann Horn <jannh@google.com>
Alexander M. Merritt and others added 26 commits October 29, 2026 03:42
Deflate still breaks a parked block into pages and asks Xen to populate
each with its own order-0 extent, which lets Xen back the block with any
512 frames it has.

Populate a parked block as a single order-9 extent instead, so that Xen
allocates one machine-contiguous 2 MiB run for it:

  - On PVH Xen maps that run with a single 2 MiB EPT entry rather than
    512 4 KiB ones.

  - On PV there is no EPT, and the guest cannot use 2 MiB mappings. The
    guest maps the run in itself, with the batched contiguous-run
    helper, from the base machine frame Xen reports.

The p2m leaves of each block are preallocated while walking the block
list, before the populate hypercall: mapping the block afterwards cannot
allocate, and once Xen has populated an extent there is no way to hand
it back. Failing there only shortens the batch.

A block is only an option here too. balloon_deflate() falls back to the
page at a time path when a block makes no progress: Xen refuses an
order-9 extent when the host has no free 2 MiB run, or when the domain
is less than 2 MiB below its max_pages ceiling, and neither should stop
the guest growing by what it can still get. Credits smaller than a block
take the page at a time path as well.

Blocks are populated at most BALLOON_BLOCK_BATCH at a time, which bounds
the work done under balloon_mutex; the OOM notifier can only trylock it.

Backends: PV, PVH
Direction: deflate (frames move from Xen to the guest)
Signed-off-by: Alexander M. Merritt <alexander@edera.dev>
The OOM notifier deflates through increase_reservation(), which works a
page at a time and reaches parked blocks only by breaking them up.

Deflate through balloon_deflate() instead, so that an OOM deflate
populates a whole block as a single order-9 extent where Xen can supply
one, and still falls back to single pages where it cannot, including the
last 2 MiB below the domain's max_pages ceiling.

Backends: PV, PVH
Direction: deflate (frames move from Xen to the guest)
Signed-off-by: Alexander M. Merritt <alexander@edera.dev>
xen_init_time_common() points x86_platform.calibrate_tsc at
xen_tsc_khz() but leaves calibrate_cpu native, so tsc_early_init() ->
determine_cpu_tsc_frequencies() still calls
native_calibrate_cpu_early() for cpu_khz. That tries CPUID 0x16, then
MSR_PLATFORM_INFO, and then falls through to quick_pit_calibrate() --
which on a PVH guest waits out its full 50ms timeout on a PIT that is
not there, prints "Fast TSC calibration failed", and arrives at a
value the hypervisor had already been asked for a moment later.

It is 48ms of every boot, and it is the largest single item in one: a
512 MiB PVH guest reached "Run /init as init process" at 0.330s, and
0.118s once this and the xenbus boot wait were out of the way.

There is nothing for the calibration to find out here. Xen reports the
TSC frequency, tsc_khz already comes from it, and cpu_khz differing
from tsc_khz under a hypervisor is not information --
determine_cpu_tsc_frequencies() would overwrite cpu_khz with tsc_khz
anyway once they disagree by more than 10%. Note that tsc_early_khz=
does not help: it only short-circuits calibrate_tsc, and the 50ms is
spent in calibrate_cpu.

Set in xen_init_time_common() so PV and PVH/HVM guests both get it,
which is where calibrate_tsc is already set for the same reason.

Signed-off-by: Alex Zenla <alex@edera.dev>
boot_wait_for_devices() sleeps HZ/10 between checks, so on a
CONFIG_HZ=100 kernel it waits a tenth of a second to notice something
that has already happened. What it is waiting for is not slow: a
toolstack has every backend sitting in XenbusStateInitWait before it
unpauses the guest, so the wait covers the frontend half of the
handshake, which finishes a few milliseconds after the late_initcall
starts looking. Measured on a PVH guest, the last frontend connected
at 0.232s and init started at 0.311s -- 79ms of sleeping past the
event.

Frontends move to XenbusStateConnected (and blkfront sets is_ready)
from their otherend_changed callback, which runs from the frontend
bus's backend_changed() watch. Bump a sequence count and wake a wait
queue there, and have wait_for_devices() sleep on it instead of for a
fixed interval. The sequence is sampled before each check, so a change
that lands between the check and the sleep still wakes the waiter.

The HZ/10 interruptible sleep stays as the timeout, so state changes
that do not come through the watch are noticed no later than before,
and the 30/270-second budgets and their reporting are unchanged.

Signed-off-by: Alex Zenla <alex@edera.dev>
Port the nightly upstream rebase from the Xen tree to the kernel. Every
night at 03:23 UTC, Claude rebases edera/mainline onto torvalds master,
following .automation/skills/upstream-rebase/SKILL.md: it replays the
series, resolves conflicts, fixes what the replay broke, builds, audits
upstream fixes that meet the series, and writes a report.

The model's own account of its result decides nothing. It runs with a
read-only token; its branch leaves the job as a git bundle and is judged
by scripts taken from the commit the run started from:

- verify-upstream-rebase.sh (unchanged from Xen) proves the series sits
  on the upstream tip, is linear, kept every commit, and moved the tree
  by exactly the upstream delta;
- kernel-build.sh builds x86_64 and arm64 vmlinux with the Hyper-V, Xen
  dom0/backend, PV-IOMMU, NUMA affinity and OpenPaX options built in,
  and fails if olddefconfig drops any of them.

If both pass and the report asks for no decision, edera/mainline is
force-pushed with a lease pinned to the tip the rebase started from, and
the old tip is kept as a backup branch. Otherwise the result goes up as
a pull request carrying the report, and approving it lands it
(rebase-land.yml). A night with no result opens an issue.

Every job clones blobless: the jobs need the kernel's commit graph but
only the contents of the files the series and upstream touch.
The rebase runs from a scheduled or dispatched event and needs its own
federation rule rather than the organization-wide one, so read it from
vars.REBASE_FEDERATION_RULE_ID.
edera/6.18-lts carries its own rebase automation, but scheduled
workflows run only from the default branch. Add a workflow here whose
only job is to dispatch edera/6.18-lts's kernel-nightly.yml each night.
OPENPAX currently defaults to y, which means OpenPaX gets enabled
for any configuration that picks up the new symbol, including ones
that never asked for it. Default it to n so it has to be selected
explicitly.

While at it, make OPENPAX_SOFTMODE depend on OPENPAX. Soft mode does
nothing without OpenPaX enabled, so there is no reason for it to be
selectable (and default y) on its own.

Signed-off-by: Alex Zenla <alex@edera.dev>
(cherry picked from commit 514cd60)
edera/6.18-lts proposes a backport of each pull request merged into
edera/mainline, driven by its own workflows. Add a workflow here whose
only job is to dispatch that, skipping pull requests labelled
no-backport and the nightly's rebase pull requests.
xen-pciback seizes a hidden device in an fs_initcall, but the Xen IOMMU
registered from a device_initcall. Registering probes every PCI device
that already exists, so a hidden device was found with a driver bound and
the IOMMU core warned about a late probe at driver bind.

Register from subsys_initcall_sync instead, so the IOMMU is in place
before pciback binds anything.

Signed-off-by: Alex Zenla <alex@edera.dev>
Signed-off-by: Alexander M. Merritt <alexander@edera.dev>
Signed-off-by: Alexander M. Merritt <alexander@edera.dev>
All of the extra memory Linux reserves at boot goes to the mapping
pool, so dom0's balloon starts empty. Growing dom0 at runtime then
means memory hotplug, which places the new range at the first free
physical address: on PVH that is the host's own map, where nothing
guarantees the range is not a device's MMIO window.

Keep the part of the extra memory dom0 may grow into on the balloon
instead. Xen's ceiling for dom0 (dom0_mem=...,max:) sizes that part,
so a host booted without a max: keeps today's behaviour. Every
region gives up the same fraction, which spreads the growth over the
NUMA nodes on PVH and leaves each node's mapping pool its share, and
the last memory section stays with the pool so that early grant
mappings never fall back to holes in the physical map.

Signed-off-by: Alexander M. Merritt <alexander@edera.dev>
A request that does not fit in its ring sleeps in
io_wait_event_killable() until the backend frees space, but the event
handler wakes the ring with wake_up_interruptible(), which only wakes
TASK_INTERRUPTIBLE sleepers. A TASK_KILLABLE waiter therefore sleeps
until it is killed, which hangs a guest that has enough large requests
in flight to fill a ring.

Wake the ring with wake_up() so killable waiters see the freed space.

Fixes: 9523fea ("net/9p: Switch to wait_event_killable()")
Signed-off-by: Alex Zenla <alex@edera.dev>
The frontend's resume handler only warned that suspend and resume are
unsupported. After a restore its rings, grant references and event
channels are gone, yet the mounted client kept writing requests into
them, so every request on the mount hung. The next InitWait from the
backend then allocated a second frontend instance for the same device,
which no client used.

On resume, collect any replies the backend left in the rings, free the
rings, fail the requests that are still unanswered with -EIO, and
publish Initialising so that a backend which still serves the old rings
starts over. When the backend reaches InitWait, allocate and publish new
rings for the existing frontend, keeping its clients. Requests that
arrive while the frontend is not connected wait until it is, and a
rw_semaphore keeps them off the rings while a resume replaces them.

Signed-off-by: Alex Zenla <alex@edera.dev>
A forked, restored or imported domain resumes against a new backend
whose fid table is empty, while the guest's 9P clients still hold the
fids of the session they were suspended with. With the transport
reconnected every request on those fids still fails, so even an idle
mount comes back unusable.

When the backend advertises feature-session-transfer, wait at suspend
for the requests in flight to be answered, then ask the backend for its
fid table with Tsession_save and keep the pages in guest memory, where
they survive into whatever domain the guest resumes in. Once a restored
frontend's new backend connects, replay the pages with Tsession_restore
before any request can use the rings. The pages are opaque to the
frontend; the backend validates every entry as it would a walk or open.

Signed-off-by: Alex Zenla <alex@edera.dev>
The toolstack has to know whether a guest can carry its 9P session into a
new backend before it exports the domain, because a guest that cannot
comes back with every open file on its mounts unusable. Until now only the
backend advertised the feature, and the frontend's support was invisible
from dom0.

Publish feature-session-transfer = 1 in the frontend's own xenstore
directory, next to version and num-rings.

Signed-off-by: Alex Zenla <alex@edera.dev>
arch/x86/xen/enlighten.c includes xen/interface/memory.h for
XENMEM_maximum_reservation, but memory.h uses xen_ulong_t, domid_t and
GUEST_HANDLE without including where they are defined,
xen/interface/xen.h. Other configurations reach those through an earlier
include. The zone-tiny configuration does not, and fails to build with
CONFIG_WERROR=y:

  include/xen/interface/physdev.h:41:5: error: unknown type name 'xen_ulong_t'

Include xen/interface/xen.h first, as arch/arm/xen/enlighten.c does.

Signed-off-by: Alex Zenla <alex@edera.dev>
A node whose pool is short called fill_list() even when other nodes
still held free pages. fill_list() takes new address space from
iomem_resource, which on a PVH dom0 can overlap MMIO that Xen has
identity mapped. A later grant map onto such a gfn makes Xen refuse the
p2m change and crash dom0.

Carve a new region only when every node's pool is short, and otherwise
take pages from the preferred node first, then the others. Return pages
to the pool of their own node when the PV p2m allocation fails.
…ode variant

Borrowing across nodes made xen_alloc_unpopulated_pages_node() best
effort, so a caller that asked for a node could get pages of another.

The node variant now takes pages only from the requested node's pool and
fails with -ENOMEM when it is short. It no longer carves a region.
xen_alloc_unpopulated_pages() has no node requirement: it prefers the
local pool, borrows from other nodes, and carves a region only when
every pool is short. xenbus falls back to it when the node's pool is
short, and gnttab_alloc_pages_node() uses it for NUMA_NO_NODE.
GitHub starts no workflow for a review of a pull request it cannot
compute a merge ref for, and a rebase often conflicts with the tree it
replaces: approving #48 started nothing, and it had to be landed by
hand.

The land workflow can now also be run with a pull request number. It
then reads the head, branch and base from the pull request, requires
the same rebase/edera-mainline/... branch into edera/mainline, and
lands on the most recent approval of the current head from a reviewer
whose latest review is still an approval. Everything after that, the
write-access check, the tip check, the backup and the leased push, is
unchanged.
When a backport pull request merges into edera/6.18-lts, delete its
branch and retry the mainline pull requests waiting for it.

A backport/edera-6.18-lts/pr-<N> branch is the automation's own and is
of no use once its pull request has merged, but delete_branch_on_merge
stays off so feature branches survive, and the merged ones pile up. It
is deleted only if it still points at the commit that merged.

The retry was meant to happen already, from lts-backport-merged.yml on
edera/6.18-lts, but that has never run: pull_request_target always takes
the workflow from the default branch. This copy of that path lives on
edera/mainline and runs edera/6.18-lts's retry-backports.sh.
edera/6.18-lts audits itself for Edera commits from edera/mainline that
it lacks (kernel-nightly.yml with audit=true), but scheduled workflows
run only from the default branch. Add a workflow here whose only job is
to dispatch that audit every Monday.
The acceptance build judged x86_64 against defconfig with the Edera
options forced on, which is not the kernel we ship. Merge the latest
configs/x86_64/host.config from edera-dev/linux-kernel-oci over
defconfig first, the way linux-kernel-oci itself applies it (the file
is a fragment against x86_64_defconfig and omits SMP, NET and the rest
of what matches it), and log the commit it came from.

The Edera options are still forced on as built-ins afterwards: the host
config builds OpenPaX out and 9P/Xen, virtio-gpu and the Hyper-V
network drivers as modules, which a vmlinux build would never compile.
AGP joins that list on x86_64 because host.config has it as a module,
which caps DRM at m.

arm64 is unchanged.
A rebase whose independent build failed went straight to a pull request,
and in practice that was a run Claude never finished: the Bash tool's
two-minute default timeout cannot hold a kernel build, so the build went
to the background and the session ended "waiting for the x86 build"
(#47, and #35 before it). Nobody saw the error until a reviewer did.

Give the rebase step a 90-minute Bash timeout, and tell the skill to run
builds in the foreground and to keep fixing and rebuilding until both
pass rather than treat a failing build as an outcome to report.

If the independent build still fails, a new read-only fix job hands
Claude its branch and the build logs for one repair round, following a
new "Repairing a failed build" section of the skill. A repaired branch
is verified and built again from scratch before publish judges it; the
checker now runs on whichever branch is final. Publish takes the
repaired branch and report when there is one, says so in the pull
request, and keeps the repair round's report when it repaired nothing.

The build job moves to a reusable rebase-build.yml so the first build
and the rebuild are the same job, and it now keeps each build's log as
an artifact for the repair round to read.

A repair changes downstream commits, so a repaired branch still shows
drift and still goes to review rather than being pushed: what changes is
that the reviewer gets a branch that builds.
The previous commit moved the build job into rebase-build.yml and calls
it twice, but the file itself never made it into the commit: the
kernel's .gitignore ignores dot-directories, so it has to be added with
-f. Without it, upstream-rebase.yml calls a workflow that does not exist.
@edera-rebase-app

ghost commented Oct 30, 2026

Copy link
Copy Markdown
Author

Superseded by #68.

@edera-rebase-app edera-rebase-app Bot closed this Oct 30, 2026
@edera-rebase-app
edera-rebase-app Bot deleted the rebase/edera-mainline/20261029-cde3385b5531-c339f4010dea branch October 30, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.