Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/memory: remove unused vmf_insert_mixed_mkwrite()
@ 2026-09-29 14:37 Sang-Heon Jeon
  2026-09-29 21:53 ` Jose A. Perez de Azpillaga
  2026-10-01  5:19 ` Anshuman Khandual
  0 siblings, 2 replies; 5+ messages in thread
From: Sang-Heon Jeon @ 2026-09-29 14:37 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand
  Cc: Liam R. Howlett, linux-mm, Lorenzo Stoakes, Michal Hocko,
	Mike Rapoport, Suren Baghdasaryan, Vlastimil Babka

Since commit 38607c62b34b ("fs/dax: properly refcount fs dax pages"),
vmf_insert_mixed_mkwrite() has no callers, so the mkwrite argument of
__vm_insert_mixed() and insert_pfn() is always false.

So remove the function, the mkwrite argument and the unreachable
mkwrite branches. Also merge __vm_insert_mixed() into vmf_insert_mixed().

No functional change.

Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
 include/linux/mm.h |  2 --
 mm/memory.c        | 76 ++++++++++++----------------------------------
 2 files changed, 19 insertions(+), 59 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index c038d06825c3..2ac734efd4ec 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -5008,8 +5008,6 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
 			unsigned long pfn, pgprot_t pgprot);
 vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
 			unsigned long pfn);
-vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
-		unsigned long addr, unsigned long pfn);
 int vm_iomap_memory(struct vm_area_struct *vma, phys_addr_t start, unsigned long len);
 
 static inline vm_fault_t vmf_insert_page(struct vm_area_struct *vma,
diff --git a/mm/memory.c b/mm/memory.c
index 330cde31bf8b..1f83a26f8733 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2453,7 +2453,14 @@ static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte,
 		if (!mkwrite)
 			return -EBUSY;
 
-		/* see insert_pfn(). */
+		/*
+		 * For read faults on private mappings the PFN passed in may
+		 * not match the PFN we have mapped if the mapped PFN is a
+		 * writeable COW page.  In the mkwrite case we are creating a
+		 * writable PTE for a shared mapping and we expect the PFNs to
+		 * match. If they don't match, we are likely racing with block
+		 * allocation and mapping invalidation.
+		 */
 		if (pte_pfn(pteval) != page_to_pfn(page)) {
 			WARN_ON_ONCE(!is_zero_pfn(pte_pfn(pteval)));
 			return -EFAULT;
@@ -2858,7 +2865,7 @@ int vm_map_pages_zero(struct vm_area_struct *vma, struct page **pages,
 EXPORT_SYMBOL(vm_map_pages_zero);
 
 static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
-			unsigned long pfn, pgprot_t prot, bool mkwrite)
+			unsigned long pfn, pgprot_t prot)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	pte_t *pte, entry;
@@ -2868,38 +2875,12 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
 	if (!pte)
 		return VM_FAULT_OOM;
 	entry = ptep_get(pte);
-	if (!pte_none(entry)) {
-		if (mkwrite) {
-			/*
-			 * For read faults on private mappings the PFN passed
-			 * in may not match the PFN we have mapped if the
-			 * mapped PFN is a writeable COW page.  In the mkwrite
-			 * case we are creating a writable PTE for a shared
-			 * mapping and we expect the PFNs to match. If they
-			 * don't match, we are likely racing with block
-			 * allocation and mapping invalidation so just skip the
-			 * update.
-			 */
-			if (pte_pfn(entry) != pfn) {
-				WARN_ON_ONCE(!is_zero_pfn(pte_pfn(entry)));
-				goto out_unlock;
-			}
-			entry = pte_mkyoung(entry);
-			entry = maybe_mkwrite(pte_mkdirty(entry), vma);
-			if (ptep_set_access_flags(vma, addr, pte, entry, 1))
-				update_mmu_cache(vma, addr, pte);
-		}
+	if (!pte_none(entry))
 		goto out_unlock;
-	}
 
 	/* Ok, finally just insert the thing.. */
 	entry = pte_mkspecial(pfn_pte(pfn, prot));
 
-	if (mkwrite) {
-		entry = pte_mkyoung(entry);
-		entry = maybe_mkwrite(pte_mkdirty(entry), vma);
-	}
-
 	set_pte_at(mm, addr, pte, entry);
 	update_mmu_cache(vma, addr, pte); /* XXX: why not for insert_page? */
 
@@ -2967,7 +2948,7 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
 
 	pfnmap_setup_cachemode_pfn(pfn, &pgprot);
 
-	return insert_pfn(vma, addr, pfn, pgprot, false);
+	return insert_pfn(vma, addr, pfn, pgprot);
 }
 EXPORT_SYMBOL(vmf_insert_pfn_prot);
 
@@ -2998,11 +2979,9 @@ vm_fault_t vmf_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
 }
 EXPORT_SYMBOL(vmf_insert_pfn);
 
-static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn,
-			bool mkwrite)
+static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn)
 {
-	if (unlikely(is_zero_pfn(pfn)) &&
-	    (mkwrite || !vm_mixed_zeropage_allowed(vma)))
+	if (unlikely(is_zero_pfn(pfn)) && !vm_mixed_zeropage_allowed(vma))
 		return false;
 	/* these checks mirror the abort conditions in vm_normal_page */
 	if (vma->vm_flags & VM_MIXEDMAP)
@@ -3012,13 +2991,13 @@ static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn,
 	return false;
 }
 
-static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
-		unsigned long addr, unsigned long pfn, bool mkwrite)
+vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
+		unsigned long pfn)
 {
 	pgprot_t pgprot = vma->vm_page_prot;
 	int err;
 
-	if (!vm_mixed_ok(vma, pfn, mkwrite))
+	if (!vm_mixed_ok(vma, pfn))
 		return VM_FAULT_SIGBUS;
 
 	if (addr < vma->vm_start || addr >= vma->vm_end)
@@ -3045,9 +3024,9 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
 		 * result in pfn_t_has_page() == false.
 		 */
 		page = pfn_to_page(pfn);
-		err = insert_page(vma, addr, page, pgprot, mkwrite);
+		err = insert_page(vma, addr, page, pgprot, false);
 	} else {
-		return insert_pfn(vma, addr, pfn, pgprot, mkwrite);
+		return insert_pfn(vma, addr, pfn, pgprot);
 	}
 
 	if (err == -ENOMEM)
@@ -3057,6 +3036,7 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
 
 	return VM_FAULT_NOPAGE;
 }
+EXPORT_SYMBOL(vmf_insert_mixed);
 
 vm_fault_t vmf_insert_page_mkwrite(struct vm_fault *vmf, struct page *page,
 			bool write)
@@ -3078,24 +3058,6 @@ vm_fault_t vmf_insert_page_mkwrite(struct vm_fault *vmf, struct page *page,
 }
 EXPORT_SYMBOL_GPL(vmf_insert_page_mkwrite);
 
-vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
-		unsigned long pfn)
-{
-	return __vm_insert_mixed(vma, addr, pfn, false);
-}
-EXPORT_SYMBOL(vmf_insert_mixed);
-
-/*
- *  If the insertion of PTE failed because someone else already added a
- *  different entry in the mean time, we treat that as success as we assume
- *  the same entry was actually inserted.
- */
-vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
-		unsigned long addr, unsigned long pfn)
-{
-	return __vm_insert_mixed(vma, addr, pfn, true);
-}
-
 /*
  * maps a range of physical memory into the requested pages. the old
  * mappings are removed. any references to nonexistent pages results

base-commit: 1c2b8d2725f84b43fabe3b3e9628c91db8ca6c65
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/memory: remove unused vmf_insert_mixed_mkwrite()
  2026-09-29 14:37 [PATCH] mm/memory: remove unused vmf_insert_mixed_mkwrite() Sang-Heon Jeon
@ 2026-09-29 21:53 ` Jose A. Perez de Azpillaga
  2026-09-30  2:07   ` Sang-Heon Jeon
  2026-10-01  5:19 ` Anshuman Khandual
  1 sibling, 1 reply; 5+ messages in thread
From: Jose A. Perez de Azpillaga @ 2026-09-29 21:53 UTC (permalink / raw)
  To: Sang-Heon Jeon
  Cc: Andrew Morton, David Hildenbrand, Liam R. Howlett, linux-mm,
	Lorenzo Stoakes, Michal Hocko, Mike Rapoport, Suren Baghdasaryan,
	Vlastimil Babka

On Tue, Sep 29, 2026 at 11:37:06PM +0900, Sang-Heon Jeon wrote:
> Since commit 38607c62b34b ("fs/dax: properly refcount fs dax pages"),
> vmf_insert_mixed_mkwrite() has no callers, so the mkwrite argument of
> __vm_insert_mixed() and insert_pfn() is always false.
>
> So remove the function, the mkwrite argument and the unreachable
> mkwrite branches. Also merge __vm_insert_mixed() into vmf_insert_mixed().
>
> No functional change.
>
> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> ---
>  include/linux/mm.h |  2 --
>  mm/memory.c        | 76 ++++++++++++----------------------------------
>  2 files changed, 19 insertions(+), 59 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index c038d06825c3..2ac734efd4ec 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -5008,8 +5008,6 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
>  			unsigned long pfn, pgprot_t pgprot);
>  vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
>  			unsigned long pfn);
> -vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
> -		unsigned long addr, unsigned long pfn);
>  int vm_iomap_memory(struct vm_area_struct *vma, phys_addr_t start, unsigned long len);
>
>  static inline vm_fault_t vmf_insert_page(struct vm_area_struct *vma,
> diff --git a/mm/memory.c b/mm/memory.c
> index 330cde31bf8b..1f83a26f8733 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -2453,7 +2453,14 @@ static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte,
>  		if (!mkwrite)
>  			return -EBUSY;
>
> -		/* see insert_pfn(). */
> +		/*
> +		 * For read faults on private mappings the PFN passed in may
> +		 * not match the PFN we have mapped if the mapped PFN is a
> +		 * writeable COW page.  In the mkwrite case we are creating a
> +		 * writable PTE for a shared mapping and we expect the PFNs to
> +		 * match. If they don't match, we are likely racing with block
> +		 * allocation and mapping invalidation.
> +		 */
>  		if (pte_pfn(pteval) != page_to_pfn(page)) {
>  			WARN_ON_ONCE(!is_zero_pfn(pte_pfn(pteval)));
>  			return -EFAULT;
> @@ -2858,7 +2865,7 @@ int vm_map_pages_zero(struct vm_area_struct *vma, struct page **pages,
>  EXPORT_SYMBOL(vm_map_pages_zero);
>
>  static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> -			unsigned long pfn, pgprot_t prot, bool mkwrite)
> +			unsigned long pfn, pgprot_t prot)
>  {
>  	struct mm_struct *mm = vma->vm_mm;
>  	pte_t *pte, entry;
> @@ -2868,38 +2875,12 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
>  	if (!pte)
>  		return VM_FAULT_OOM;
>  	entry = ptep_get(pte);
> -	if (!pte_none(entry)) {
> -		if (mkwrite) {
> -			/*
> -			 * For read faults on private mappings the PFN passed
> -			 * in may not match the PFN we have mapped if the
> -			 * mapped PFN is a writeable COW page.  In the mkwrite
> -			 * case we are creating a writable PTE for a shared
> -			 * mapping and we expect the PFNs to match. If they
> -			 * don't match, we are likely racing with block
> -			 * allocation and mapping invalidation so just skip the
> -			 * update.
> -			 */
> -			if (pte_pfn(entry) != pfn) {
> -				WARN_ON_ONCE(!is_zero_pfn(pte_pfn(entry)));
> -				goto out_unlock;
> -			}
> -			entry = pte_mkyoung(entry);
> -			entry = maybe_mkwrite(pte_mkdirty(entry), vma);
> -			if (ptep_set_access_flags(vma, addr, pte, entry, 1))
> -				update_mmu_cache(vma, addr, pte);
> -		}
> +	if (!pte_none(entry))
>  		goto out_unlock;
> -	}
>
>  	/* Ok, finally just insert the thing.. */
>  	entry = pte_mkspecial(pfn_pte(pfn, prot));
>
> -	if (mkwrite) {
> -		entry = pte_mkyoung(entry);
> -		entry = maybe_mkwrite(pte_mkdirty(entry), vma);
> -	}
> -
>  	set_pte_at(mm, addr, pte, entry);
>  	update_mmu_cache(vma, addr, pte); /* XXX: why not for insert_page? */
>
> @@ -2967,7 +2948,7 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
>
>  	pfnmap_setup_cachemode_pfn(pfn, &pgprot);
>
> -	return insert_pfn(vma, addr, pfn, pgprot, false);
> +	return insert_pfn(vma, addr, pfn, pgprot);
>  }
>  EXPORT_SYMBOL(vmf_insert_pfn_prot);
>
> @@ -2998,11 +2979,9 @@ vm_fault_t vmf_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
>  }
>  EXPORT_SYMBOL(vmf_insert_pfn);
>
> -static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn,
> -			bool mkwrite)
> +static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn)
>  {
> -	if (unlikely(is_zero_pfn(pfn)) &&
> -	    (mkwrite || !vm_mixed_zeropage_allowed(vma)))
> +	if (unlikely(is_zero_pfn(pfn)) && !vm_mixed_zeropage_allowed(vma))
>  		return false;
>  	/* these checks mirror the abort conditions in vm_normal_page */
>  	if (vma->vm_flags & VM_MIXEDMAP)
> @@ -3012,13 +2991,13 @@ static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn,
>  	return false;
>  }
>
> -static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
> -		unsigned long addr, unsigned long pfn, bool mkwrite)
> +vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
> +		unsigned long pfn)
>  {
>  	pgprot_t pgprot = vma->vm_page_prot;
>  	int err;
>
> -	if (!vm_mixed_ok(vma, pfn, mkwrite))
> +	if (!vm_mixed_ok(vma, pfn))
>  		return VM_FAULT_SIGBUS;
>
>  	if (addr < vma->vm_start || addr >= vma->vm_end)
> @@ -3045,9 +3024,9 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
>  		 * result in pfn_t_has_page() == false.
>  		 */
>  		page = pfn_to_page(pfn);
> -		err = insert_page(vma, addr, page, pgprot, mkwrite);
> +		err = insert_page(vma, addr, page, pgprot, false);
>  	} else {
> -		return insert_pfn(vma, addr, pfn, pgprot, mkwrite);
> +		return insert_pfn(vma, addr, pfn, pgprot);
>  	}
>
>  	if (err == -ENOMEM)
> @@ -3057,6 +3036,7 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
>
>  	return VM_FAULT_NOPAGE;
>  }
> +EXPORT_SYMBOL(vmf_insert_mixed);
>
>  vm_fault_t vmf_insert_page_mkwrite(struct vm_fault *vmf, struct page *page,
>  			bool write)
> @@ -3078,24 +3058,6 @@ vm_fault_t vmf_insert_page_mkwrite(struct vm_fault *vmf, struct page *page,
>  }
>  EXPORT_SYMBOL_GPL(vmf_insert_page_mkwrite);
>
> -vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
> -		unsigned long pfn)
> -{
> -	return __vm_insert_mixed(vma, addr, pfn, false);
> -}
> -EXPORT_SYMBOL(vmf_insert_mixed);
> -
> -/*
> - *  If the insertion of PTE failed because someone else already added a
> - *  different entry in the mean time, we treat that as success as we assume
> - *  the same entry was actually inserted.
> - */

it reads to me like it describes the -EBUSY handling rather than
vmf_insert_mixed_mkwrite() itself, and that handling is still there in
__vm_insert_mixed(), which this patch renames to vmf_insert_mixed(). so
I would have expected it to move above the "if (err < 0 && err != -EBUSY)"
there rather than go away with the wrapper.

am I missing a reason to drop it? because, if not, moving it would keep
one explanation we have for why -EBUSY is not treated as an error there.

> -vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
> -		unsigned long addr, unsigned long pfn)
> -{
> -	return __vm_insert_mixed(vma, addr, pfn, true);
> -}
> -
>  /*
>   * maps a range of physical memory into the requested pages. the old
>   * mappings are removed. any references to nonexistent pages results
>
> base-commit: 1c2b8d2725f84b43fabe3b3e9628c91db8ca6c65
> --
> 2.43.0
>
>

overall, looks good to me. but I want to know about the comment.

--
cheers,
jose a. p-a


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/memory: remove unused vmf_insert_mixed_mkwrite()
  2026-09-29 21:53 ` Jose A. Perez de Azpillaga
@ 2026-09-30  2:07   ` Sang-Heon Jeon
  0 siblings, 0 replies; 5+ messages in thread
From: Sang-Heon Jeon @ 2026-09-30  2:07 UTC (permalink / raw)
  To: Jose A. Perez de Azpillaga
  Cc: Andrew Morton, David Hildenbrand, Liam R. Howlett, linux-mm,
	Lorenzo Stoakes, Michal Hocko, Mike Rapoport, Suren Baghdasaryan,
	Vlastimil Babka

Hi, Jose

2026년 9월 30일 (수) 오전 6:53, Jose A. Perez de Azpillaga <azpijr@gmail.com>님이 작성:
>
> On Tue, Sep 29, 2026 at 11:37:06PM +0900, Sang-Heon Jeon wrote:
> > Since commit 38607c62b34b ("fs/dax: properly refcount fs dax pages"),
> > vmf_insert_mixed_mkwrite() has no callers, so the mkwrite argument of
> > __vm_insert_mixed() and insert_pfn() is always false.
> >
> > So remove the function, the mkwrite argument and the unreachable
> > mkwrite branches. Also merge __vm_insert_mixed() into vmf_insert_mixed().
> >
> > No functional change.
> >
> > Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> > ---
> >  include/linux/mm.h |  2 --
> >  mm/memory.c        | 76 ++++++++++++----------------------------------
> >  2 files changed, 19 insertions(+), 59 deletions(-)
> >
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index c038d06825c3..2ac734efd4ec 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -5008,8 +5008,6 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
> >                       unsigned long pfn, pgprot_t pgprot);
> >  vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
> >                       unsigned long pfn);
> > -vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
> > -             unsigned long addr, unsigned long pfn);
> >  int vm_iomap_memory(struct vm_area_struct *vma, phys_addr_t start, unsigned long len);
> >
> >  static inline vm_fault_t vmf_insert_page(struct vm_area_struct *vma,
> > diff --git a/mm/memory.c b/mm/memory.c
> > index 330cde31bf8b..1f83a26f8733 100644
> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -2453,7 +2453,14 @@ static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte,
> >               if (!mkwrite)
> >                       return -EBUSY;
> >
> > -             /* see insert_pfn(). */
> > +             /*
> > +              * For read faults on private mappings the PFN passed in may
> > +              * not match the PFN we have mapped if the mapped PFN is a
> > +              * writeable COW page.  In the mkwrite case we are creating a
> > +              * writable PTE for a shared mapping and we expect the PFNs to
> > +              * match. If they don't match, we are likely racing with block
> > +              * allocation and mapping invalidation.
> > +              */
> >               if (pte_pfn(pteval) != page_to_pfn(page)) {
> >                       WARN_ON_ONCE(!is_zero_pfn(pte_pfn(pteval)));
> >                       return -EFAULT;
> > @@ -2858,7 +2865,7 @@ int vm_map_pages_zero(struct vm_area_struct *vma, struct page **pages,
> >  EXPORT_SYMBOL(vm_map_pages_zero);
> >
> >  static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> > -                     unsigned long pfn, pgprot_t prot, bool mkwrite)
> > +                     unsigned long pfn, pgprot_t prot)
> >  {
> >       struct mm_struct *mm = vma->vm_mm;
> >       pte_t *pte, entry;
> > @@ -2868,38 +2875,12 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> >       if (!pte)
> >               return VM_FAULT_OOM;
> >       entry = ptep_get(pte);
> > -     if (!pte_none(entry)) {
> > -             if (mkwrite) {
> > -                     /*
> > -                      * For read faults on private mappings the PFN passed
> > -                      * in may not match the PFN we have mapped if the
> > -                      * mapped PFN is a writeable COW page.  In the mkwrite
> > -                      * case we are creating a writable PTE for a shared
> > -                      * mapping and we expect the PFNs to match. If they
> > -                      * don't match, we are likely racing with block
> > -                      * allocation and mapping invalidation so just skip the
> > -                      * update.
> > -                      */
> > -                     if (pte_pfn(entry) != pfn) {
> > -                             WARN_ON_ONCE(!is_zero_pfn(pte_pfn(entry)));
> > -                             goto out_unlock;
> > -                     }
> > -                     entry = pte_mkyoung(entry);
> > -                     entry = maybe_mkwrite(pte_mkdirty(entry), vma);
> > -                     if (ptep_set_access_flags(vma, addr, pte, entry, 1))
> > -                             update_mmu_cache(vma, addr, pte);
> > -             }
> > +     if (!pte_none(entry))
> >               goto out_unlock;
> > -     }
> >
> >       /* Ok, finally just insert the thing.. */
> >       entry = pte_mkspecial(pfn_pte(pfn, prot));
> >
> > -     if (mkwrite) {
> > -             entry = pte_mkyoung(entry);
> > -             entry = maybe_mkwrite(pte_mkdirty(entry), vma);
> > -     }
> > -
> >       set_pte_at(mm, addr, pte, entry);
> >       update_mmu_cache(vma, addr, pte); /* XXX: why not for insert_page? */
> >
> > @@ -2967,7 +2948,7 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
> >
> >       pfnmap_setup_cachemode_pfn(pfn, &pgprot);
> >
> > -     return insert_pfn(vma, addr, pfn, pgprot, false);
> > +     return insert_pfn(vma, addr, pfn, pgprot);
> >  }
> >  EXPORT_SYMBOL(vmf_insert_pfn_prot);
> >
> > @@ -2998,11 +2979,9 @@ vm_fault_t vmf_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> >  }
> >  EXPORT_SYMBOL(vmf_insert_pfn);
> >
> > -static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn,
> > -                     bool mkwrite)
> > +static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn)
> >  {
> > -     if (unlikely(is_zero_pfn(pfn)) &&
> > -         (mkwrite || !vm_mixed_zeropage_allowed(vma)))
> > +     if (unlikely(is_zero_pfn(pfn)) && !vm_mixed_zeropage_allowed(vma))
> >               return false;
> >       /* these checks mirror the abort conditions in vm_normal_page */
> >       if (vma->vm_flags & VM_MIXEDMAP)
> > @@ -3012,13 +2991,13 @@ static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn,
> >       return false;
> >  }
> >
> > -static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
> > -             unsigned long addr, unsigned long pfn, bool mkwrite)
> > +vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
> > +             unsigned long pfn)
> >  {
> >       pgprot_t pgprot = vma->vm_page_prot;
> >       int err;
> >
> > -     if (!vm_mixed_ok(vma, pfn, mkwrite))
> > +     if (!vm_mixed_ok(vma, pfn))
> >               return VM_FAULT_SIGBUS;
> >
> >       if (addr < vma->vm_start || addr >= vma->vm_end)
> > @@ -3045,9 +3024,9 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
> >                * result in pfn_t_has_page() == false.
> >                */
> >               page = pfn_to_page(pfn);
> > -             err = insert_page(vma, addr, page, pgprot, mkwrite);
> > +             err = insert_page(vma, addr, page, pgprot, false);
> >       } else {
> > -             return insert_pfn(vma, addr, pfn, pgprot, mkwrite);
> > +             return insert_pfn(vma, addr, pfn, pgprot);
> >       }
> >
> >       if (err == -ENOMEM)
> > @@ -3057,6 +3036,7 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
> >
> >       return VM_FAULT_NOPAGE;
> >  }
> > +EXPORT_SYMBOL(vmf_insert_mixed);
> >
> >  vm_fault_t vmf_insert_page_mkwrite(struct vm_fault *vmf, struct page *page,
> >                       bool write)
> > @@ -3078,24 +3058,6 @@ vm_fault_t vmf_insert_page_mkwrite(struct vm_fault *vmf, struct page *page,
> >  }
> >  EXPORT_SYMBOL_GPL(vmf_insert_page_mkwrite);
> >
> > -vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
> > -             unsigned long pfn)
> > -{
> > -     return __vm_insert_mixed(vma, addr, pfn, false);
> > -}
> > -EXPORT_SYMBOL(vmf_insert_mixed);
> > -
> > -/*
> > - *  If the insertion of PTE failed because someone else already added a
> > - *  different entry in the mean time, we treat that as success as we assume
> > - *  the same entry was actually inserted.
> > - */
>
> it reads to me like it describes the -EBUSY handling rather than
> vmf_insert_mixed_mkwrite() itself, and that handling is still there in
> __vm_insert_mixed(), which this patch renames to vmf_insert_mixed(). so
> I would have expected it to move above the "if (err < 0 && err != -EBUSY)"
> there rather than go away with the wrapper.
>
> am I missing a reason to drop it? because, if not, moving it would keep
> one explanation we have for why -EBUSY is not treated as an error there.

No, I just missed it. Moving the comment above the -EBUSY check looks
good to me as well. I'll address it in v2.

> > -vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
> > -             unsigned long addr, unsigned long pfn)
> > -{
> > -     return __vm_insert_mixed(vma, addr, pfn, true);
> > -}
> > -
> >  /*
> >   * maps a range of physical memory into the requested pages. the old
> >   * mappings are removed. any references to nonexistent pages results
> >
> > base-commit: 1c2b8d2725f84b43fabe3b3e9628c91db8ca6c65
> > --
> > 2.43.0
> >
> >
>
> overall, looks good to me. but I want to know about the comment.

Thanks for the review :)

> --
> cheers,
> jose a. p-a

Best regards,
Sang-Heon Jeon


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/memory: remove unused vmf_insert_mixed_mkwrite()
  2026-09-29 14:37 [PATCH] mm/memory: remove unused vmf_insert_mixed_mkwrite() Sang-Heon Jeon
  2026-09-29 21:53 ` Jose A. Perez de Azpillaga
@ 2026-10-01  5:19 ` Anshuman Khandual
  2026-10-02 13:58   ` Sang-Heon Jeon
  1 sibling, 1 reply; 5+ messages in thread
From: Anshuman Khandual @ 2026-10-01  5:19 UTC (permalink / raw)
  To: Sang-Heon Jeon
  Cc: Andrew Morton, David Hildenbrand, Liam R. Howlett, linux-mm,
	Lorenzo Stoakes, Michal Hocko, Mike Rapoport, Suren Baghdasaryan,
	Vlastimil Babka

On Tue, Sep 29, 2026 at 11:37:06PM +0900, Sang-Heon Jeon wrote:
> Since commit 38607c62b34b ("fs/dax: properly refcount fs dax pages"),
> vmf_insert_mixed_mkwrite() has no callers, so the mkwrite argument of
> __vm_insert_mixed() and insert_pfn() is always false.
> 
> So remove the function, the mkwrite argument and the unreachable
> mkwrite branches. Also merge __vm_insert_mixed() into vmf_insert_mixed().
> 
> No functional change.
> 
> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>

This patch is doing multiple independent changes and should be split IMHO

1. mm: Drop vmf_insert_mixed_mkwrite()
	- No users after 38607c62b34b ("fs/dax: properly refcount fs dax pages")
	- Unreachable function and should be dropped

3. mm: Drop mkwrite argument from __vm_insert_mixed()
	- With vmf_insert_mixed_mkwrite() dropped
		- mkwrite is always false in __vm_insert_mixed()
			- mkwrite is always false in insert_pfn()
			+ mkwrite is always false in vm_mixed_ok()
	- Drop mkwrite from __vm_insert_mixed(), insert_pfn() and vm_mixed_ok()
	- Drop mkwrite based conditional handling
	- Rename __vm_insert_mixed() as vm_insert_mixed()

The above improves the clarity/readability making it easier to review.

> ---
>  include/linux/mm.h |  2 --
>  mm/memory.c        | 76 ++++++++++++----------------------------------
>  2 files changed, 19 insertions(+), 59 deletions(-)
> 
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index c038d06825c3..2ac734efd4ec 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -5008,8 +5008,6 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
>  			unsigned long pfn, pgprot_t pgprot);
>  vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
>  			unsigned long pfn);
> -vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
> -		unsigned long addr, unsigned long pfn);
>  int vm_iomap_memory(struct vm_area_struct *vma, phys_addr_t start, unsigned long len);
>  
>  static inline vm_fault_t vmf_insert_page(struct vm_area_struct *vma,
> diff --git a/mm/memory.c b/mm/memory.c
> index 330cde31bf8b..1f83a26f8733 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -2453,7 +2453,14 @@ static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte,
>  		if (!mkwrite)
>  			return -EBUSY;
>  
> -		/* see insert_pfn(). */
> +		/*
> +		 * For read faults on private mappings the PFN passed in may
> +		 * not match the PFN we have mapped if the mapped PFN is a
> +		 * writeable COW page.  In the mkwrite case we are creating a
> +		 * writable PTE for a shared mapping and we expect the PFNs to
> +		 * match. If they don't match, we are likely racing with block
> +		 * allocation and mapping invalidation.
> +		 */
>  		if (pte_pfn(pteval) != page_to_pfn(page)) {
>  			WARN_ON_ONCE(!is_zero_pfn(pte_pfn(pteval)));
>  			return -EFAULT;
> @@ -2858,7 +2865,7 @@ int vm_map_pages_zero(struct vm_area_struct *vma, struct page **pages,
>  EXPORT_SYMBOL(vm_map_pages_zero);
>  
>  static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> -			unsigned long pfn, pgprot_t prot, bool mkwrite)
> +			unsigned long pfn, pgprot_t prot)
>  {
>  	struct mm_struct *mm = vma->vm_mm;
>  	pte_t *pte, entry;
> @@ -2868,38 +2875,12 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
>  	if (!pte)
>  		return VM_FAULT_OOM;
>  	entry = ptep_get(pte);
> -	if (!pte_none(entry)) {
> -		if (mkwrite) {
> -			/*
> -			 * For read faults on private mappings the PFN passed
> -			 * in may not match the PFN we have mapped if the
> -			 * mapped PFN is a writeable COW page.  In the mkwrite
> -			 * case we are creating a writable PTE for a shared
> -			 * mapping and we expect the PFNs to match. If they
> -			 * don't match, we are likely racing with block
> -			 * allocation and mapping invalidation so just skip the
> -			 * update.
> -			 */
> -			if (pte_pfn(entry) != pfn) {
> -				WARN_ON_ONCE(!is_zero_pfn(pte_pfn(entry)));
> -				goto out_unlock;
> -			}
> -			entry = pte_mkyoung(entry);
> -			entry = maybe_mkwrite(pte_mkdirty(entry), vma);
> -			if (ptep_set_access_flags(vma, addr, pte, entry, 1))
> -				update_mmu_cache(vma, addr, pte);
> -		}
> +	if (!pte_none(entry))
>  		goto out_unlock;
> -	}
>  
>  	/* Ok, finally just insert the thing.. */
>  	entry = pte_mkspecial(pfn_pte(pfn, prot));
>  
> -	if (mkwrite) {
> -		entry = pte_mkyoung(entry);
> -		entry = maybe_mkwrite(pte_mkdirty(entry), vma);
> -	}
> -
>  	set_pte_at(mm, addr, pte, entry);
>  	update_mmu_cache(vma, addr, pte); /* XXX: why not for insert_page? */
>  
> @@ -2967,7 +2948,7 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
>  
>  	pfnmap_setup_cachemode_pfn(pfn, &pgprot);
>  
> -	return insert_pfn(vma, addr, pfn, pgprot, false);
> +	return insert_pfn(vma, addr, pfn, pgprot);
>  }
>  EXPORT_SYMBOL(vmf_insert_pfn_prot);
>  
> @@ -2998,11 +2979,9 @@ vm_fault_t vmf_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
>  }
>  EXPORT_SYMBOL(vmf_insert_pfn);
>  
> -static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn,
> -			bool mkwrite)
> +static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn)
>  {
> -	if (unlikely(is_zero_pfn(pfn)) &&
> -	    (mkwrite || !vm_mixed_zeropage_allowed(vma)))
> +	if (unlikely(is_zero_pfn(pfn)) && !vm_mixed_zeropage_allowed(vma))
>  		return false;
>  	/* these checks mirror the abort conditions in vm_normal_page */
>  	if (vma->vm_flags & VM_MIXEDMAP)
> @@ -3012,13 +2991,13 @@ static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn,
>  	return false;
>  }
>  
> -static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
> -		unsigned long addr, unsigned long pfn, bool mkwrite)
> +vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
> +		unsigned long pfn)
>  {
>  	pgprot_t pgprot = vma->vm_page_prot;
>  	int err;
>  
> -	if (!vm_mixed_ok(vma, pfn, mkwrite))
> +	if (!vm_mixed_ok(vma, pfn))
>  		return VM_FAULT_SIGBUS;
>  
>  	if (addr < vma->vm_start || addr >= vma->vm_end)
> @@ -3045,9 +3024,9 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
>  		 * result in pfn_t_has_page() == false.
>  		 */
>  		page = pfn_to_page(pfn);
> -		err = insert_page(vma, addr, page, pgprot, mkwrite);
> +		err = insert_page(vma, addr, page, pgprot, false);
>  	} else {
> -		return insert_pfn(vma, addr, pfn, pgprot, mkwrite);
> +		return insert_pfn(vma, addr, pfn, pgprot);
>  	}
>  
>  	if (err == -ENOMEM)
> @@ -3057,6 +3036,7 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
>  
>  	return VM_FAULT_NOPAGE;
>  }
> +EXPORT_SYMBOL(vmf_insert_mixed);
>  
>  vm_fault_t vmf_insert_page_mkwrite(struct vm_fault *vmf, struct page *page,
>  			bool write)
> @@ -3078,24 +3058,6 @@ vm_fault_t vmf_insert_page_mkwrite(struct vm_fault *vmf, struct page *page,
>  }
>  EXPORT_SYMBOL_GPL(vmf_insert_page_mkwrite);
>  
> -vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
> -		unsigned long pfn)
> -{
> -	return __vm_insert_mixed(vma, addr, pfn, false);
> -}
> -EXPORT_SYMBOL(vmf_insert_mixed);
> -
> -/*
> - *  If the insertion of PTE failed because someone else already added a
> - *  different entry in the mean time, we treat that as success as we assume
> - *  the same entry was actually inserted.
> - */
> -vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
> -		unsigned long addr, unsigned long pfn)
> -{
> -	return __vm_insert_mixed(vma, addr, pfn, true);
> -}
> -
>  /*
>   * maps a range of physical memory into the requested pages. the old
>   * mappings are removed. any references to nonexistent pages results
> 
> base-commit: 1c2b8d2725f84b43fabe3b3e9628c91db8ca6c65
> -- 
> 2.43.0
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/memory: remove unused vmf_insert_mixed_mkwrite()
  2026-10-01  5:19 ` Anshuman Khandual
@ 2026-10-02 13:58   ` Sang-Heon Jeon
  0 siblings, 0 replies; 5+ messages in thread
From: Sang-Heon Jeon @ 2026-10-02 13:58 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Andrew Morton, David Hildenbrand, Liam R. Howlett, linux-mm,
	Lorenzo Stoakes, Michal Hocko, Mike Rapoport, Suren Baghdasaryan,
	Vlastimil Babka

Hi, Anshuman

2026년 10월 1일 (목) 오후 2:19, Anshuman Khandual <anshuman.khandual@arm.com>님이 작성:
>
> On Tue, Sep 29, 2026 at 11:37:06PM +0900, Sang-Heon Jeon wrote:
> > Since commit 38607c62b34b ("fs/dax: properly refcount fs dax pages"),
> > vmf_insert_mixed_mkwrite() has no callers, so the mkwrite argument of
> > __vm_insert_mixed() and insert_pfn() is always false.
> >
> > So remove the function, the mkwrite argument and the unreachable
> > mkwrite branches. Also merge __vm_insert_mixed() into vmf_insert_mixed().
> >
> > No functional change.
> >
> > Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
>
> This patch is doing multiple independent changes and should be split IMHO

Sure, I'll address it in v2 as well.

> 1. mm: Drop vmf_insert_mixed_mkwrite()
>         - No users after 38607c62b34b ("fs/dax: properly refcount fs dax pages")
>         - Unreachable function and should be dropped
>
> 3. mm: Drop mkwrite argument from __vm_insert_mixed()
>         - With vmf_insert_mixed_mkwrite() dropped
>                 - mkwrite is always false in __vm_insert_mixed()
>                         - mkwrite is always false in insert_pfn()
>                         + mkwrite is always false in vm_mixed_ok()
>         - Drop mkwrite from __vm_insert_mixed(), insert_pfn() and vm_mixed_ok()
>         - Drop mkwrite based conditional handling
>         - Rename __vm_insert_mixed() as vm_insert_mixed()
>
> The above improves the clarity/readability making it easier to review.
>
> > ---
> >  include/linux/mm.h |  2 --
> >  mm/memory.c        | 76 ++++++++++++----------------------------------
> >  2 files changed, 19 insertions(+), 59 deletions(-)
> >
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index c038d06825c3..2ac734efd4ec 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -5008,8 +5008,6 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
> >                       unsigned long pfn, pgprot_t pgprot);
> >  vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
> >                       unsigned long pfn);
> > -vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
> > -             unsigned long addr, unsigned long pfn);
> >  int vm_iomap_memory(struct vm_area_struct *vma, phys_addr_t start, unsigned long len);
> >
> >  static inline vm_fault_t vmf_insert_page(struct vm_area_struct *vma,
> > diff --git a/mm/memory.c b/mm/memory.c
> > index 330cde31bf8b..1f83a26f8733 100644
> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -2453,7 +2453,14 @@ static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte,
> >               if (!mkwrite)
> >                       return -EBUSY;
> >
> > -             /* see insert_pfn(). */
> > +             /*
> > +              * For read faults on private mappings the PFN passed in may
> > +              * not match the PFN we have mapped if the mapped PFN is a
> > +              * writeable COW page.  In the mkwrite case we are creating a
> > +              * writable PTE for a shared mapping and we expect the PFNs to
> > +              * match. If they don't match, we are likely racing with block
> > +              * allocation and mapping invalidation.
> > +              */
> >               if (pte_pfn(pteval) != page_to_pfn(page)) {
> >                       WARN_ON_ONCE(!is_zero_pfn(pte_pfn(pteval)));
> >                       return -EFAULT;
> > @@ -2858,7 +2865,7 @@ int vm_map_pages_zero(struct vm_area_struct *vma, struct page **pages,
> >  EXPORT_SYMBOL(vm_map_pages_zero);
> >
> >  static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> > -                     unsigned long pfn, pgprot_t prot, bool mkwrite)
> > +                     unsigned long pfn, pgprot_t prot)
> >  {
> >       struct mm_struct *mm = vma->vm_mm;
> >       pte_t *pte, entry;
> > @@ -2868,38 +2875,12 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> >       if (!pte)
> >               return VM_FAULT_OOM;
> >       entry = ptep_get(pte);
> > -     if (!pte_none(entry)) {
> > -             if (mkwrite) {
> > -                     /*
> > -                      * For read faults on private mappings the PFN passed
> > -                      * in may not match the PFN we have mapped if the
> > -                      * mapped PFN is a writeable COW page.  In the mkwrite
> > -                      * case we are creating a writable PTE for a shared
> > -                      * mapping and we expect the PFNs to match. If they
> > -                      * don't match, we are likely racing with block
> > -                      * allocation and mapping invalidation so just skip the
> > -                      * update.
> > -                      */
> > -                     if (pte_pfn(entry) != pfn) {
> > -                             WARN_ON_ONCE(!is_zero_pfn(pte_pfn(entry)));
> > -                             goto out_unlock;
> > -                     }
> > -                     entry = pte_mkyoung(entry);
> > -                     entry = maybe_mkwrite(pte_mkdirty(entry), vma);
> > -                     if (ptep_set_access_flags(vma, addr, pte, entry, 1))
> > -                             update_mmu_cache(vma, addr, pte);
> > -             }
> > +     if (!pte_none(entry))
> >               goto out_unlock;
> > -     }
> >
> >       /* Ok, finally just insert the thing.. */
> >       entry = pte_mkspecial(pfn_pte(pfn, prot));
> >
> > -     if (mkwrite) {
> > -             entry = pte_mkyoung(entry);
> > -             entry = maybe_mkwrite(pte_mkdirty(entry), vma);
> > -     }
> > -
> >       set_pte_at(mm, addr, pte, entry);
> >       update_mmu_cache(vma, addr, pte); /* XXX: why not for insert_page? */
> >
> > @@ -2967,7 +2948,7 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr,
> >
> >       pfnmap_setup_cachemode_pfn(pfn, &pgprot);
> >
> > -     return insert_pfn(vma, addr, pfn, pgprot, false);
> > +     return insert_pfn(vma, addr, pfn, pgprot);
> >  }
> >  EXPORT_SYMBOL(vmf_insert_pfn_prot);
> >
> > @@ -2998,11 +2979,9 @@ vm_fault_t vmf_insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> >  }
> >  EXPORT_SYMBOL(vmf_insert_pfn);
> >
> > -static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn,
> > -                     bool mkwrite)
> > +static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn)
> >  {
> > -     if (unlikely(is_zero_pfn(pfn)) &&
> > -         (mkwrite || !vm_mixed_zeropage_allowed(vma)))
> > +     if (unlikely(is_zero_pfn(pfn)) && !vm_mixed_zeropage_allowed(vma))
> >               return false;
> >       /* these checks mirror the abort conditions in vm_normal_page */
> >       if (vma->vm_flags & VM_MIXEDMAP)
> > @@ -3012,13 +2991,13 @@ static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn,
> >       return false;
> >  }
> >
> > -static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
> > -             unsigned long addr, unsigned long pfn, bool mkwrite)
> > +vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
> > +             unsigned long pfn)
> >  {
> >       pgprot_t pgprot = vma->vm_page_prot;
> >       int err;
> >
> > -     if (!vm_mixed_ok(vma, pfn, mkwrite))
> > +     if (!vm_mixed_ok(vma, pfn))
> >               return VM_FAULT_SIGBUS;
> >
> >       if (addr < vma->vm_start || addr >= vma->vm_end)
> > @@ -3045,9 +3024,9 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
> >                * result in pfn_t_has_page() == false.
> >                */
> >               page = pfn_to_page(pfn);
> > -             err = insert_page(vma, addr, page, pgprot, mkwrite);
> > +             err = insert_page(vma, addr, page, pgprot, false);
> >       } else {
> > -             return insert_pfn(vma, addr, pfn, pgprot, mkwrite);
> > +             return insert_pfn(vma, addr, pfn, pgprot);
> >       }
> >
> >       if (err == -ENOMEM)
> > @@ -3057,6 +3036,7 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,
> >
> >       return VM_FAULT_NOPAGE;
> >  }
> > +EXPORT_SYMBOL(vmf_insert_mixed);
> >
> >  vm_fault_t vmf_insert_page_mkwrite(struct vm_fault *vmf, struct page *page,
> >                       bool write)
> > @@ -3078,24 +3058,6 @@ vm_fault_t vmf_insert_page_mkwrite(struct vm_fault *vmf, struct page *page,
> >  }
> >  EXPORT_SYMBOL_GPL(vmf_insert_page_mkwrite);
> >
> > -vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
> > -             unsigned long pfn)
> > -{
> > -     return __vm_insert_mixed(vma, addr, pfn, false);
> > -}
> > -EXPORT_SYMBOL(vmf_insert_mixed);
> > -
> > -/*
> > - *  If the insertion of PTE failed because someone else already added a
> > - *  different entry in the mean time, we treat that as success as we assume
> > - *  the same entry was actually inserted.
> > - */
> > -vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
> > -             unsigned long addr, unsigned long pfn)
> > -{
> > -     return __vm_insert_mixed(vma, addr, pfn, true);
> > -}
> > -
> >  /*
> >   * maps a range of physical memory into the requested pages. the old
> >   * mappings are removed. any references to nonexistent pages results
> >
> > base-commit: 1c2b8d2725f84b43fabe3b3e9628c91db8ca6c65
> > --
> > 2.43.0
> >
> >

Best regards,
Sang-Heon Jeon


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-02 13:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-29 14:37 [PATCH] mm/memory: remove unused vmf_insert_mixed_mkwrite() Sang-Heon Jeon
2026-09-29 21:53 ` Jose A. Perez de Azpillaga
2026-09-30  2:07   ` Sang-Heon Jeon
2026-10-01  5:19 ` Anshuman Khandual
2026-10-02 13:58   ` Sang-Heon Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox