Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Chris Down <chris@chrisdown.name>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Muchun Song <muchun.song@linux.dev>,
	Oscar Salvador <osalvador@suse.de>, Zi Yan <ziy@nvidia.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	"Liam R. Howlett" <liam@infradead.org>,
	Nico Pache <nico.pache@linux.dev>,
	Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
	Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
	Usama Arif <usama.arif@linux.dev>,
	Kiryl Shutsemau <kas@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Vlastimil Babka <vbabka@kernel.org>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Pedro Falcato <pfalcato@suse.de>, Jann Horn <jannh@google.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Tal Zussman <tz2294@columbia.edu>
Subject: Re: [PATCH] mm: use softleaf_migration_mkreadable() in change_protection()
Date: Thu, 3 Dec 2026 09:31:04 +0100	[thread overview]
Message-ID: <cd1dc451-84ad-4abf-89b3-2571470838b0@kernel.org> (raw)
In-Reply-To: <1b920241d08ed3c39c2cd19a5507529bb3af95a2.1796187429.git.chris@chrisdown.name>

On 12/2/26 05:59, Chris Down wrote:
> 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.
> 
> Suggested-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> Signed-off-by: Chris Down <chris@chrisdown.name>
> ---
>  mm/huge_memory.c | 7 +------
>  mm/hugetlb.c     | 8 +-------
>  mm/mprotect.c    | 7 +------
>  3 files changed, 3 insertions(+), 19 deletions(-)
> 
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 4fc888ddfb69..ce028838bdba 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -2704,16 +2704,11 @@ static void change_non_present_huge_pmd(struct mm_struct *mm,
>  
>  	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);

softleaf_migration_mkreadable is not upstream yet, so this change best goes
through Andrew's tree.

-- 
Cheers,

David


      parent reply	other threads:[~2026-12-03  8:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  4:59 [PATCH] mm: use softleaf_migration_mkreadable() in change_protection() Chris Down
2026-12-03  3:14 ` Muchun Song
2026-12-03  7:57 ` David Hildenbrand (Arm)
2026-12-03  8:31 ` David Hildenbrand (Arm) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cd1dc451-84ad-4abf-89b3-2571470838b0@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=chris@chrisdown.name \
    --cc=dev.jain@arm.com \
    --cc=jannh@google.com \
    --cc=kas@kernel.org \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=nico.pache@linux.dev \
    --cc=osalvador@suse.de \
    --cc=pfalcato@suse.de \
    --cc=ryan.roberts@arm.com \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=tz2294@columbia.edu \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox