mm/memory: remove unused vmf_insert_mixed_mkwrite()
Subsystems (2)
v2 cover mm/memory: remove unused vmf_insert_mixed_mkwrite()
Hello,
Since commit 38607c62b34b ("fs/dax: properly refcount fs dax pages"), vmf_insert_mixed_mkwrite() has no callers. This series removes it and the mkwrite handling that only it used.
Patch 1 removes the function.
Patch 2 removes the mkwrite argument, which is then always false. It also removes the unreachable code in insert_pfn().
Patch 3 merges __vm_insert_mixed() into vmf_insert_mixed().
No functional change.
---
Changes from v1 [1]
- Split into three patches for easier review
- Move the comment about -EBUSY handling above the check in __vm_insert_mixed()
[1] https://lore.kernel.org/all/[email protected]/
---
Sang-Heon Jeon (3):
mm/memory: remove unused vmf_insert_mixed_mkwrite() mm/memory: remove the mkwrite argument from __vm_insert_mixed() mm/memory: merge __vm_insert_mixed() into vmf_insert_mixed()
include/linux/mm.h | 2 -- mm/memory.c | 81 ++++++++++++++-------------------------------- 2 files changed, 24 insertions(+), 59 deletions(-)
base-commit: 1c2b8d2725f84b43fabe3b3e9628c91db8ca6c65
Signature · 1 line
2.43.0
PATCH v2 1/3 mm/memory: remove unused vmf_insert_mixed_mkwrite()
Since commit 38607c62b34b ("fs/dax: properly refcount fs dax pages"), vmf_insert_mixed_mkwrite() has no callers.
So remove the function and its declaration.
The comment above the function describes the -EBUSY handling in __vm_insert_mixed(). Move it above that check.
No functional change.
--- include/linux/mm.h | 2 -- mm/memory.c | 16 +++++----------- 2 files changed, 5 insertions(+), 13 deletions(-)
include/linux/mm.h +0 -2
@@ -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,
mm/memory.c +5 -11
@@ -3052,6 +3052,11 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,if (err == -ENOMEM )return VM_FAULT_OOM ; +/* +* 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. +*/ if (err <0 && err != -EBUSY )return VM_FAULT_SIGBUS ;
@@ -3085,17 +3090,6 @@ vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr, }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
Signature · 1 line
2.43.0
Quoted 9 lines · On Sat, 3 Oct 2026 01:05:32 +0900 Sang-Heon Jeon <[email protected]> wrote:
Since commit
38607c62b34b("fs/dax: properly refcount fs dax pages"),vmf_insert_mixed_mkwrite()has no callers.So remove the function and its declaration.
The comment above the function describes the
-EBUSYhandling in__vm_insert_mixed(). Move it above that check.No functional change.
Looks good to me.
Quoted 2 lines
Signed-off-by Sang-Heon Jeon <[email protected]>
Thanks,
SJ
[...]
Quoted 11 lines · Sang-Heon Jeon
Since commit
38607c62b34b("fs/dax: properly refcount fs dax pages"),vmf_insert_mixed_mkwrite()has no callers.So remove the function and its declaration.
The comment above the function describes the
-EBUSYhandling in__vm_insert_mixed(). Move it above that check.No functional change.
Signed-off-by Sang-Heon Jeon <[email protected]>
all three LGMT so I'll RB them :)
Signature · 2 lines
cheers, jose a. p-a
Quoted 11 lines · Sang-Heon Jeon
Since commit
38607c62b34b("fs/dax: properly refcount fs dax pages"),vmf_insert_mixed_mkwrite()has no callers.So remove the function and its declaration.
The comment above the function describes the
-EBUSYhandling in__vm_insert_mixed(). Move it above that check.No functional change.
Signed-off-by Sang-Heon Jeon <[email protected]>
Quoted 55 lines
--- include/linux/mm.h | 2 -- mm/memory.c | 16 +++++----------- 2 files changed, 5 insertions(+), 13 deletions(-)include/linux/mm.h +0
-2@@ -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,mm/memory.c +5
-11@@ -3052,6 +3052,11 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma,if (err == -ENOMEM )return VM_FAULT_OOM ; +/* +* 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. +*/ if (err <0 && err != -EBUSY )return VM_FAULT_SIGBUS ;@@ -3085,17 +3090,6 @@ vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr, }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 Signature · 1 line
2.43.0
PATCH v2 2/3 mm/memory: remove the mkwrite argument from __vm_insert_mixed()
In reply to Sang-Heon Jeon__vm_insert_mixed() is only called from vmf_insert_mixed() with mkwrite == false, so mkwrite is also always false in vm_mixed_ok() and insert_pfn().
So remove the argument and the unreachable code in insert_pfn().
No functional change.
--- mm/memory.c | 57 +++++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 39 deletions(-)
mm/memory.c +18 -39
@@ -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 )
@@ -3013,12 +2992,12 @@ static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn, }static vm_fault_t __vm_insert_mixed (struct vm_area_struct *vma, -unsigned long addr,unsigned long pfn,bool mkwrite) +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 )
@@ -3086,7 +3065,7 @@ 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); +return __vm_insert_mixed (vma, addr, pfn); }EXPORT_SYMBOL (vmf_insert_mixed);
Signature · 1 line
2.43.0
Re: [PATCH v2 2/3] mm/memory: remove the mkwrite argument from __vm_insert_mixed()
Quoted 7 lines · On Sat, 3 Oct 2026 01:05:33 +0900 Sang-Heon Jeon <[email protected]> wrote:
__vm_insert_mixed()is only called fromvmf_insert_mixed()with mkwrite == false, so mkwrite is also always false invm_mixed_ok()andinsert_pfn().So remove the argument and the unreachable code in
insert_pfn().No functional change.
Looks correct to me.
Quoted 2 lines
Signed-off-by Sang-Heon Jeon <[email protected]>
Thanks,
SJ
[...]
Re: [PATCH v2 2/3] mm/memory: remove the mkwrite argument from __vm_insert_mixed()
In reply to Sang-Heon JeonQuoted 9 lines · Sang-Heon Jeon
__vm_insert_mixed()is only called fromvmf_insert_mixed()with mkwrite == false, so mkwrite is also always false invm_mixed_ok()andinsert_pfn().So remove the argument and the unreachable code in
insert_pfn().No functional change.
Signed-off-by Sang-Heon Jeon <[email protected]>
Signature · 2 lines
cheers, jose a. p-a
Re: [PATCH v2 2/3] mm/memory: remove the mkwrite argument from __vm_insert_mixed()
In reply to Sang-Heon JeonQuoted 9 lines · Sang-Heon Jeon
__vm_insert_mixed()is only called fromvmf_insert_mixed()with mkwrite == false, so mkwrite is also always false invm_mixed_ok()andinsert_pfn().So remove the argument and the unreachable code in
insert_pfn().No functional change.
Signed-off-by Sang-Heon Jeon <[email protected]>
Quoted 135 lines
--- mm/memory.c | 57 +++++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 39 deletions(-)mm/memory.c +18
-39@@ -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 )@@ -3013,12 +2992,12 @@ static bool vm_mixed_ok(struct vm_area_struct *vma, unsigned long pfn, }static vm_fault_t __vm_insert_mixed (struct vm_area_struct *vma, -unsigned long addr,unsigned long pfn,bool mkwrite) +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 )@@ -3086,7 +3065,7 @@ 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); +return __vm_insert_mixed (vma, addr, pfn); }EXPORT_SYMBOL (vmf_insert_mixed);Signature · 1 line
2.43.0
PATCH v2 3/3 mm/memory: merge __vm_insert_mixed() into vmf_insert_mixed()
In reply to Sang-Heon Jeonvmf_insert_mixed() just calls __vm_insert_mixed() with the same arguments.
So merge __vm_insert_mixed() into vmf_insert_mixed().
No functional change.
--- mm/memory.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
mm/memory.c +3 -9
@@ -2991,8 +2991,8 @@ 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) +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;
@@ -3041,6 +3041,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)
@@ -3062,13 +3063,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); -} -EXPORT_SYMBOL (vmf_insert_mixed); -/* * maps a range of physical memory into the requested pages. the old * mappings are removed. any references to nonexistent pages results
Signature · 1 line
2.43.0
Re: [PATCH v2 3/3] mm/memory: merge __vm_insert_mixed() into vmf_insert_mixed()
Quoted 6 lines · On Sat, 3 Oct 2026 01:05:34 +0900 Sang-Heon Jeon <[email protected]> wrote:
vmf_insert_mixed()just calls__vm_insert_mixed()with the same arguments.So merge
__vm_insert_mixed()intovmf_insert_mixed().No functional change.
Makes sense to me.
Quoted 2 lines
Signed-off-by Sang-Heon Jeon <[email protected]>
Thanks,
SJ
[...]
Re: [PATCH v2 3/3] mm/memory: merge __vm_insert_mixed() into vmf_insert_mixed()
In reply to Sang-Heon JeonQuoted 8 lines · Sang-Heon Jeon
vmf_insert_mixed()just calls__vm_insert_mixed()with the same arguments.So merge
__vm_insert_mixed()intovmf_insert_mixed().No functional change.
Signed-off-by Sang-Heon Jeon <[email protected]>
Signature · 2 lines
cheers, jose a. p-a
Re: [PATCH v2 3/3] mm/memory: merge __vm_insert_mixed() into vmf_insert_mixed()
In reply to Sang-Heon JeonQuoted 8 lines · Sang-Heon Jeon
vmf_insert_mixed()just calls__vm_insert_mixed()with the same arguments.So merge
__vm_insert_mixed()intovmf_insert_mixed().No functional change.
Signed-off-by Sang-Heon Jeon <[email protected]>
Quoted 44 lines
--- mm/memory.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)mm/memory.c +3
-9@@ -2991,8 +2991,8 @@ 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) +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;@@ -3041,6 +3041,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)@@ -3062,13 +3063,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); -} -EXPORT_SYMBOL (vmf_insert_mixed); -/* * maps a range of physical memory into the requested pages. the old * mappings are removed. any references to nonexistent pages results Signature · 1 line
2.43.0