summaryrefslogtreecommitdiff
path: root/scripts/patch-kernel
diff options
context:
space:
mode:
authorGregory Price <gourry@gourry.net>2026-09-12 07:08:32 -0400
committerAndrew Morton <akpm@linux-foundation.org>2026-09-29 23:13:27 -0700
commit1e0bf803be75d4ade312638bab490eb1f8918c29 (patch)
tree3027620c4cfa4b050d856a95eff6b36ebbee6546 /scripts/patch-kernel
parent78e68bfc54b69f935e1b9d66a13e7bbd3ed0e1aa (diff)
downloadlinux-next-1e0bf803be75d4ade312638bab490eb1f8918c29.tar.gz
linux-next-1e0bf803be75d4ade312638bab490eb1f8918c29.zip
mm/madvise: reclaim isolated folios if PTE restart fails
MADV_PAGEOUT collects isolated folios on a local list before reclaiming them after the PTE walk. The reschedule path drops the PTE lock and then restarts the mapping with pte_offset_map_lock(). A concurrent operation can remove or replace the PTE table while the lock is dropped, causing pte_offset_map_lock() to return NULL. Returning directly in that case bypasses reclaim_pages(), leaving the collected folios off the LRU with elevated references. This results in a permanent memory leak. nr_isolated_anon increases reliably and does not decrease when the process dies. Route the failure through the existing cleanup path so any isolated folios are reclaimed or put back. Simplest userland pseudo-code reproducer: p = mmap(PMD_SIZE, ANONYMOUS); touch_every_page(p, PMD_SIZE); parallel { while (1) madvise(p, PMD_SIZE, MADV_PAGEOUT); while (1) { madvise(p, PMD_SIZE, MADV_DONTNEED); touch_every_page(p, PMD_SIZE); } } Reproduced in qemu trivially with some explicit widening of the race window. Link: https://lore.kernel.org/20260912110832.3203902-1-gourry@gourry.net Fixes: b2f557a21bc8 ("mm/madvise: add cond_resched() in madvise_cold_or_pageout_pte_range()") Signed-off-by: Gregory Price (Meta) <gourry@gourry.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reported-by: sashiko-bot <sashiko-bot@kernel.org> Closes: https://sashiko.dev/#/patchset/20260821150912.183976-1-gourry@gourry.net Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org> Assisted-by: LLM Cc: David Hildenbrand <david@kernel.org> Cc: Jann Horn <jannh@google.com> Cc: Jiexun Wang <wangjiexun@tinylab.org> Cc: Liam R. Howlett <liam@infradead.org> Cc: Vlastimil Babka <vbabka@kernel.org> Cc: <stable@vger.kernel.org>
Diffstat (limited to 'scripts/patch-kernel')
0 files changed, 0 insertions, 0 deletions