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=1796328746; b=lob8lGgo7m0rtZAcRmdEIR+QT9TwgSh4r4ObXmSP0bl5KDQnF/+SIS+3O0mOKiK9264q SfrU7PCuSEpEsqfgc9swlPnXoBo8z3dmaE/uUCW9EKYNRtCl9uMz7Wio22SKdw1kGXdj4 +4MH6XAHbzSZ2rO20+cE67klgWoA5lT36coNkq0tZkw4w+fmIDseXu786mTAhRMc9FuoH HwLOZEvr3ebZcy+vHxksY5MMtkYiJ4JTqy6xISiml/7ZEnfaRVYkgWFQVtcFgd8kVbNg2 A9dyBALhL10fOAP/ggAyRZUGq7RoVP5n5O2q/0ttyKGmYOIz/NOEM9rEr5Pdf1ZDvUw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796328746; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=2sL0Nu6mi53E5Ud0rYqCc4lfKQMQL+tA9AUwa5RE9QU=; b=Pi4g6wXkMcBULy+yJyVws4bVv+oYB5MGGdcVsHuOU6KWmZJva7+DDJ/JcxtJcC1kiibb P5k3B3S09oZ9JeNRM3ofkMZLW6aink8xQm8sIFIPTiiUX4CkLWuMXE98gFrM7RoVtFtKs 9Ubx8cIRwDtEFJmYZYXODcrmAKWp0ScmVekATu19cMtCoMO4tbr8/LEB0xxag7WgRmAP/ jQmAAv4EE1GxqGxBioOeHt6N5Q2Qv5nMjFCuxAS1nql7lH1pRX438CpKmo7H9e78Mo43b +vPXJVKbM8WOZURF7p2xfxnIlqoyRoyyBeBKM3Ijzug/CMI0Q1eiODQY3zYXi9LVc9g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=p1YchDOe; 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 D3520606A322 for ; Thu, 3 Dec 2026 20:12:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=p1YchDOe Received: by smtp.kernel.org (Postfix) with ESMTPSA id 771881F000C2; Thu, 3 Dec 2026 20:12:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796328746; bh=2sL0Nu6mi53E5Ud0rYqCc4lfKQMQL+tA9AUwa5RE9QU=; h=Date:To:From:In-Reply-To:References:Subject; b=p1YchDOe3fJOMhrCRwHslwdaUOcPUUR4Evy6d0QpZEgjkE0AKblu3IbCLYDMR0BmR OSFjjIzPZb8IGR68V8vAkAgJw40ROFp3nH4644vbM3YTq0FfYkqgtdAoX0irDAqs8I lKo2FcF4v/SPNzG5m+ohi/4lQgACwyB6M5pty6BA= Date: Thu, 03 Dec 2026 12:12:26 -0800 To: mm-commits@vger.kernel.org,ziy@nvidia.com,vbabka@kernel.org, usama.arif@linux.dev,tz2294@columbia.edu,surenb@google.com, shakeel.butt@linux.dev,ryan.roberts@arm.com,pfalcato@suse.de, osalvador@suse.de,nico.pache@linux.dev,muchun.song@linux.dev,ljs@kernel.org, liam@infradead.org,lance.yang@linux.dev,kas@kernel.org,jannh@google.com, dev.jain@arm.com,david@kernel.org,baolin.wang@linux.alibaba.com, baohua@kernel.org,chris@chrisdown.name,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <1b920241d08ed3c39c2cd19a5507529bb3af95a2.1796187429.git.chris@chrisdown.name> References: <1b920241d08ed3c39c2cd19a5507529bb3af95a2.1796187429.git.chris@chrisdown.name> Subject: + mm-use-softleaf_migration_mkreadable-in-change_protection.patch added to mm-new branch Message-Id: <20261203201226.771881F000C2@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: mm: use softleaf_migration_mkreadable() in change_protection() has been added to the -mm mm-new branch. Its filename is mm-use-softleaf_migration_mkreadable-in-change_protection.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-use-softleaf_migration_mkreadable-in-change_protection.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Chris Down Subject: mm: use softleaf_migration_mkreadable() in change_protection() Date: Tue, 01 Dec 2026 20:59:09 -0800 change_protection() downgrades a writable migration entry to a readable one in change_softleaf_pte(), change_non_present_huge_pmd() and hugetlb_change_protection(). Each of them open codes the same choice: the new entry is readable exclusive if the folio is anonymous, since a writable anon migration entry implies AnonExclusive, and plain readable otherwise. PAGEMAP_SCAN's write-protect path needed the same downgrade, so softleaf_migration_mkreadable() was added to leafops.h for it. Let's use it in change_protection() too. Each site still handles the soft-dirty and uffd bits itself as before. hugetlb_change_protection() only looked up the folio for this choice, so its local goes away. The other places that choose between readable exclusive and readable migration entries, such as try_to_migrate_one() and __split_huge_pmd_locked(), carry over the exclusive state of the page or of the old entry rather than downgrade a writable one, so they are left alone. No functional change intended. Link: https://patch.msgid.link/1b920241d08ed3c39c2cd19a5507529bb3af95a2.1796187429.git.chris@chrisdown.name Signed-off-by: Chris Down Signed-off-by: Andrew Morton Suggested-by: Lorenzo Stoakes (ARM) Acked-by: Muchun Song (ByteDance) Acked-by: David Hildenbrand (Arm) Cc: Oscar Salvador Cc: Zi Yan Cc: Baolin Wang Cc: Liam R. Howlett Cc: Nico Pache Cc: Ryan Roberts Cc: Dev Jain Cc: Barry Song Cc: Lance Yang Cc: Usama Arif Cc: Kiryl Shutsemau Cc: Suren Baghdasaryan Cc: Vlastimil Babka Cc: Shakeel Butt Cc: Pedro Falcato Cc: Jann Horn Cc: Tal Zussman mm/huge_memory.c | 7 +------ mm/hugetlb.c | 8 +------- mm/mprotect.c | 7 +------ 3 files changed, 3 insertions(+), 19 deletions(-) --- a/mm/huge_memory.c~mm-use-softleaf_migration_mkreadable-in-change_protection +++ a/mm/huge_memory.c @@ -2703,16 +2703,11 @@ static void change_non_present_huge_pmd( VM_WARN_ON(!pmd_is_valid_softleaf(*pmd)); if (softleaf_is_migration_write(entry)) { - const struct folio *folio = softleaf_to_folio(entry); - /* * A protection check is difficult so * just be safe and disable write */ - if (folio_test_anon(folio)) - entry = make_readable_exclusive_migration_entry(swp_offset(entry)); - else - entry = make_readable_migration_entry(swp_offset(entry)); + entry = softleaf_migration_mkreadable(entry); newpmd = softleaf_to_pmd(entry); if (pmd_swp_soft_dirty(*pmd)) newpmd = pmd_swp_mksoft_dirty(newpmd); --- a/mm/hugetlb.c~mm-use-softleaf_migration_mkreadable-in-change_protection +++ a/mm/hugetlb.c @@ -6919,16 +6919,10 @@ long hugetlb_change_protection(struct vm if (unlikely(softleaf_is_hwpoison(entry))) { /* Nothing to do. */ } else if (unlikely(softleaf_is_migration(entry))) { - struct folio *folio = softleaf_to_folio(entry); pte_t newpte = pte; if (softleaf_is_migration_write(entry)) { - if (folio_test_anon(folio)) - entry = make_readable_exclusive_migration_entry( - swp_offset(entry)); - else - entry = make_readable_migration_entry( - swp_offset(entry)); + entry = softleaf_migration_mkreadable(entry); newpte = swp_entry_to_pte(entry); pages++; } --- a/mm/mprotect.c~mm-use-softleaf_migration_mkreadable-in-change_protection +++ a/mm/mprotect.c @@ -221,16 +221,11 @@ static long change_softleaf_pte(struct v pte_t newpte; if (softleaf_is_migration_write(entry)) { - const struct folio *folio = softleaf_to_folio(entry); - /* * A protection check is difficult so * just be safe and disable write */ - if (folio_test_anon(folio)) - entry = make_readable_exclusive_migration_entry(swp_offset(entry)); - else - entry = make_readable_migration_entry(swp_offset(entry)); + entry = softleaf_migration_mkreadable(entry); newpte = swp_entry_to_pte(entry); if (pte_swp_soft_dirty(oldpte)) newpte = pte_swp_mksoft_dirty(newpte); _ Patches currently in -mm which might be from chris@chrisdown.name are selftests-mm-add-uffdio_move-huge-zeropage-pmd-regression-test.patch mm-use-softleaf_migration_mkreadable-in-change_protection.patch