Subject: linux-next: manual merge of the arm64 tree with the mm-unstable tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 20 Nov 2025 10:25:32 +1100

Hi all,

Today's linux-next merge of the arm64 tree got a conflict in:

  mm/memory.c

between commit:

  b08b123ead1a ("mm: avoid unnecessary use of is_swap_pmd()")

from the mm-unstable tree and commit:

  79301c7d605a ("mm: add spurious fault fixing support for huge pmd")

from the arm64 tree.

I fixed it up (I think - see below) and can carry the fix as
necessary. This is now fixed as far as linux-next is concerned, but any
non trivial conflicts should be mentioned to your upstream maintainer
when your tree is submitted for merging.  You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc mm/memory.c
index 50b93b45b174,6e5a08c4fd2e..000000000000
--- a/mm/memory.c
+++ b/mm/memory.c
@@@ -6342,40 -6314,37 +6369,43 @@@ retry_pud
  	if (pmd_none(*vmf.pmd) &&
  	    thp_vma_allowable_order(vma, vm_flags, TVA_PAGEFAULT, PMD_ORDER)) {
  		ret = create_huge_pmd(&vmf);
 -		if (!(ret & VM_FAULT_FALLBACK))
 +		if (ret & VM_FAULT_FALLBACK)
 +			goto fallback;
 +		else
  			return ret;
 -	} else {
 -		vmf.orig_pmd = pmdp_get_lockless(vmf.pmd);
 +	}
  
 -		if (unlikely(is_swap_pmd(vmf.orig_pmd))) {
 -			VM_BUG_ON(thp_migration_supported() &&
 -					  !is_pmd_migration_entry(vmf.orig_pmd));
 -			if (is_pmd_migration_entry(vmf.orig_pmd))
 -				pmd_migration_entry_wait(mm, vmf.pmd);
 +	vmf.orig_pmd = pmdp_get_lockless(vmf.pmd);
 +	if (pmd_none(vmf.orig_pmd))
 +		goto fallback;
 +
 +	if (unlikely(!pmd_present(vmf.orig_pmd))) {
 +		if (pmd_is_device_private_entry(vmf.orig_pmd))
 +			return do_huge_pmd_device_private(&vmf);
 +
 +		if (pmd_is_migration_entry(vmf.orig_pmd))
 +			pmd_migration_entry_wait(mm, vmf.pmd);
 +		return 0;
 +	}
 +	if (pmd_trans_huge(vmf.orig_pmd)) {
 +		if (pmd_protnone(vmf.orig_pmd) && vma_is_accessible(vma))
 +			return do_huge_pmd_numa_page(&vmf);
 +
 +		if ((flags & (FAULT_FLAG_WRITE|FAULT_FLAG_UNSHARE)) &&
 +		    !pmd_write(vmf.orig_pmd)) {
 +			ret = wp_huge_pmd(&vmf);
 +			if (!(ret & VM_FAULT_FALLBACK))
 +				return ret;
 +		} else {
- 			huge_pmd_set_accessed(&vmf);
++			vmf.ptl = pmd_lock(mm, vmf.pmd);
++			if (!huge_pmd_set_accessed(&vmf))
++				fix_spurious_fault(&vmf, PGTABLE_LEVEL_PMD);
++			spin_unlock(vmf.ptl);
  			return 0;
  		}
 -		if (pmd_trans_huge(vmf.orig_pmd)) {
 -			if (pmd_protnone(vmf.orig_pmd) && vma_is_accessible(vma))
 -				return do_huge_pmd_numa_page(&vmf);
 -
 -			if ((flags & (FAULT_FLAG_WRITE|FAULT_FLAG_UNSHARE)) &&
 -			    !pmd_write(vmf.orig_pmd)) {
 -				ret = wp_huge_pmd(&vmf);
 -				if (!(ret & VM_FAULT_FALLBACK))
 -					return ret;
 -			} else {
 -				vmf.ptl = pmd_lock(mm, vmf.pmd);
 -				if (!huge_pmd_set_accessed(&vmf))
 -					fix_spurious_fault(&vmf, PGTABLE_LEVEL_PMD);
 -				spin_unlock(vmf.ptl);
 -				return 0;
 -			}
 -		}
  	}
  
 +fallback:
  	return handle_pte_fault(&vmf);
  }