From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795946819; b=b97MYlJJuZWUsfdAhCnbaAbWgWaRRRRg7OGXv/dM5FAQ5imGEJCEWCSGgk03Cjsoew5t NHvUvwDLm5r2JPyFlol5F54ieBorPb8lLjYf94kH4k2xkZpbyEDXDUEqtk+ZXa7eNwrk+ DPaGINsiqqIu7VP415OYfbgcSJB7nTjApSMdhsGp95zvUgsSmNFa+3yxywxje2gceMOfs 3z2xJouC4Ek0zX06zVwR5j3UMd9Eo0oOIfojxkejxFmNU0ViuUEJS6wkzcMi+JOERQR8z hrfLnIx40J139KD85c2YKZssxeDh9jl0xqcpBK9ywCZTQKnR2TT6anFmjWkGmMnFvWQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795946819; h=Received:DKIM-Signature:From:Subject:Date:Message-Id:MIME-Version: Content-Type:Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To: Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; bh=tWc/ojtw/lqba+p1HFkB5nw0PVFE3YMbyhy8tBarzpc=; b=BLDeFoZwJE+1Coc+6MMh1Sn121Glmb6mjQi6ziU9lPV9dnJLR1CvrbVW+sNxv8Nwq6i8 3sZ3QWOL5JGozrG3uhnD/oJqDjqcknlIXb0pURmGHhQkz/xXQj+YqMhv9SVK1CA9DidCl lXobMs/SwN1g3PO7DP/XBXF1u0mGe92Cv3U19s13QTcODDAHspQIL0PufaUE9IaEvO6/9 NMpGl01gakA1W64Lkjg+ZJ8NuAuHiMd8TPQzy/cI/oOb6BhgPL5TbUMx5amNPL8w/1+G8 AfwZZNEibTNXajo/ts0K1FlENMctIO26FDpacXfhPdI5bMlmi+7s1lLjWk+vQVOv7Gw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=J+ia5mW5; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AF6E606A31C; Sun, 29 Nov 2026 10:06:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=J+ia5mW5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 690F11F00899; Sun, 29 Nov 2026 10:06:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795946818; bh=tWc/ojtw/lqba+p1HFkB5nw0PVFE3YMbyhy8tBarzpc=; h=From:Subject:Date:To:Cc; b=J+ia5mW5otAU7MyPzod8/bA5dsLr5kr8wByQpFjIfLb2268Yo+FhqRv5a3RlkMukL zC38WNh+daOhPhTmBotadGioCH2Chry0ySzZknhVZSSdZHNkHqp0htTHLxr6pLiuz1 zo7DwyQ9Zb96DFyGyHH/5A8fWSWyUdXDzfDE3mqcYQl0ckXYriyPhwvvzSCySSAeFx GX3w/ae3qqcE2YC7SSGSz3VP21v3jQsA2Ar8FIcn9ATI8yzKPy8nHi5YZ50t+XHWqa uFUVOlQc5m9t+hUnzBhXtPAS+eih0G2zlhVHuG3vqAsJUjgQc+IOjXpk2KjNSRUOPd VQL3Fa6fSqA6g== From: "David Hildenbrand (Arm)" Subject: [PATCH 00/32] mm: various (urgent?) fixes, part 3 Date: Sun, 29 Nov 2026 11:06:31 +0100 Message-Id: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAA/yXMQQqDMBBG4asM/9pAJqUKuYqIpMm0nS5UMioF8 e6l7fLxwTtgUlUMkQ5U2dV0nhCJG0J+pukhTgsiIfjQMrN3d32LjXmuMl5c5znlcC1t6QIawlL l54jUD/+27faSvH4fOM8PETI3DnAAAAA= X-Change-ID: 20261110-fixes_core_3-701ac25d6d72 To: Hugh Dickins , Baolin Wang , Andrew Morton , Mike Rapoport , Peter Xu , Michal Hocko , Kiryl Shutsemau , Manfred Spraul , Davidlohr Bueso , Cyrill Gorcunov , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Yang Shi , Zach O'Keefe , Song Liu , David Stevens , Kefeng Wang , Alex Williamson , Suren Baghdasaryan , Dave Jiang , Matthew Wilcox , Miaohe Lin , David Rientjes , Shakeel Butt , Jan Kara , Mel Gorman , Jason Gunthorpe , John Hubbard , Gerd Hoffmann , Vivek Kasireddy , Dave Airlie , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hagen Paul Pfeifer , James Bottomley , Felix Kuehling , Alex Sierra , Balbir Singh , Kairui Song , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Oscar Salvador , Muchun Song , Dan Williams , Rakie Kim , Hao Li , Christoph Lameter , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Alexei Starovoitov , Xu Xin , Chengming Zhou , Shivank Garg Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-rt-devel@lists.linux.dev, SJ Park , "David Hildenbrand (Arm)" , Chris Mason , stable@vger.kernel.org, Oleg Nesterov X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5601; i=david@kernel.org; h=from:subject:message-id; bh=RkWNuf9kjvb3RhG8rxHT33CNZ/Egi2UyQmrt5tqJe70=; b=owGbwMvMwCF2/OVpCdfQ3ZWMp9WSGLK5f2rPSJocO+dmy22Vq5GFH5nfZh/LjnziMym4TaGpU 3olV6dFRwkLgxgHg6yYIktQ8H2Dly/X1Va78THDzGFlAhnCwMUpABP5HMzI0DdJTyJr2wGW6CN1 X39cMhc1SHvz/t7S0kOVL1REs1uF1jJ8j58Ze/vg4t8TpNY2n9sxVfsR54YTmpa6a1m1HISVNk1 kAQA= X-Developer-Key: i=david@kernel.org; a=openpgp; fpr=1BD9CAAD735C4C3A460DFCCA4DDE10F700FF835A Hi, this is actually part 3. I didn't indicate part 2 properly, and it caused confusion for people monitoring these fixes :) So, here is another set of fixes for core MM that I will pick up once reviewed. This time it's mostly shmem, khugepaged and some nasty, nasty KSM things. Mostly AI-reported fixes, with some fixes found while redoing some of them properly. 1 fix has high urgency, 12 have medium urgency and 19 have low urgency. The last patch is not a fix; for a while I thought it would be one. It's all confusing. But it's a reasonable locking consistency change in migration code. The really critical ones IMHO are: - "mm/khugepaged: check the VMA before walking page tables when collapsing" (high) - "mm/ksm: copy KSM folios at swap-in without VM_MERGEABLE" (medium) - "mm/ksm: don't convert a shared anon folio into a KSM folio" (medium) - "mm/memory: don't clear a PUD leaf as bad in a zap" (medium) - "mm/migrate_device: don't collect KSM folios" (medium) I might pick these early to send them to Linus before the merge window. OTOH, the merge window is just around the corner ... and the KSM things require systems with KSM enabled. Most fixes are fairly simple, but I consider the following more involved and would appreciate some extra careful eyes: - "mm/ksm: don't convert a shared anon folio into a KSM folio" - "mm: taint device sections before setting subsections valid" - "mm/khugepaged: check for uffd outside the i_pages lock" And I am not 100% sure about the following uffd one. It closes a hole where UFFDIO_COPY, UFFDIO_ZEROPAGE and UFFDIO_CONTINUE behave differently than page faults while a hole is punched. But I don't see a more elegant solution than just letting these ioctls fail with -EAGAIN, and I am not sure about the real impact of the bug and the change: - "mm/shmem: reject userfaultfd fills during hole punch" This is based on mm-core/for-next. I did a bunch of testing (selftests, some targeted reproducers/tests), but more testing will be highly appreciated. Again, thanks to everyone helping out with moving the flood of fixes forward :) Signed-off-by: David Hildenbrand (Arm) --- Chris Mason (10): mm/khugepaged: flush file after unlocking folios in collapse_file() mm/khugepaged: store new folio before adding it to LRU mm/khugepaged: check PMD support with the folios locked mm/memory: drop the swap device ref before do_wp_page() mm/migrate_device: don't collect secretmem pages mm/mempolicy: check access under exec_update_lock mm/mempolicy: reject an empty set of allowed nodes mm/ksm: look up the folio again in cmp_and_merge_page() mm/ksm: copy KSM folios at swap-in without VM_MERGEABLE mm/migrate_device: don't collect KSM folios David Hildenbrand (Arm) (22): mm/shmem: count only the swapped pages in the requested range mm/shmem: don't skip parts of a split swap entry when punching holes mm/shmem: reject userfaultfd fills during hole punch mm/shmem: fix commit limit bypass with very large shmem sizes mm/shmem: don't pin inodes with eviction held off in the huge shrinker mm/shmem: seal the size of SysV and shared anon files mm/khugepaged: check the VMA before walking page tables when collapsing mm/khugepaged: check for uffd outside the i_pages lock mm/khugepaged: don't wait for userfaultfd mm/khugepaged: stop MADV_COLLAPSE on a fatal signal mm/huge_memory: split huge zero PMDs on unshare faults mm/huge_memory: don't map huge PFN entries if the arch restricts PFNs mm/memory: don't clear a PUD leaf as bad in a zap mm: consistently check MMF_UNSTABLE when populating in CoW mappings mm/gup: check for fatal signals in memfd_pin_folios() mm/migrate_device: mark folios leaving device memory dirty mm: taint device sections before setting subsections valid mm/mempolicy: don't wait for mems_allowed_seq in kmalloc_nolock() mm/ksm: don't convert a shared anon folio into a KSM folio mm/ksm: use a migration counter to detect KSM folio migration mm/migrate: fix KSM oddity by checking expected refcount without mappings mm/migrate: use consistent folio locking logic include/linux/mempolicy.h | 2 +- include/linux/mm.h | 62 ++++++++++++-------- include/linux/mmzone.h | 9 +++ include/linux/oom.h | 48 ++++++++++++---- include/linux/shmem_fs.h | 11 ++++ ipc/shm.c | 2 + mm/filemap.c | 9 +++ mm/gup.c | 5 ++ mm/huge_memory.c | 34 ++++++++++- mm/khugepaged.c | 124 ++++++++++++++++++++++++++-------------- mm/ksm.c | 143 ++++++++++++++++++++++++++++++++++++---------- mm/memory.c | 46 ++++++++++----- mm/memory_hotplug.c | 34 +++-------- mm/mempolicy.c | 38 ++++++++---- mm/migrate.c | 73 ++++++++++++----------- mm/migrate_device.c | 34 ++++++++++- mm/rmap.c | 6 +- mm/shmem.c | 97 ++++++++++++++++++++++++++----- mm/slub.c | 15 +++-- mm/sparse-vmemmap.c | 39 +++++++++---- mm/userfaultfd.c | 37 ++++++++++++ 21 files changed, 635 insertions(+), 233 deletions(-) --- base-commit: c6f53520f32302ea64cbcfd7cc25a31081e34548 change-id: 20261110-fixes_core_3-701ac25d6d72 Best regards, -- David Hildenbrand (Arm)