[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <c83a4e698999902057cdf8e3a662ec6837f6f466.1607332046.git.yuleixzhang@tencent.com>
Date: Mon, 7 Dec 2020 19:31:14 +0800
From: yulei.kernel@...il.com
To: linux-mm@...ck.org, akpm@...ux-foundation.org,
linux-fsdevel@...r.kernel.org, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, naoya.horiguchi@....com,
viro@...iv.linux.org.uk, pbonzini@...hat.com
Cc: joao.m.martins@...cle.com, rdunlap@...radead.org,
sean.j.christopherson@...el.com, xiaoguangrong.eric@...il.com,
kernellwp@...il.com, lihaiwei.kernel@...il.com,
Yulei Zhang <yuleixzhang@...cent.com>,
Chen Zhuo <sagazchen@...cent.com>
Subject: [RFC V2 21/37] mm: support dmem huge pmd for follow_pfn()
From: Yulei Zhang <yuleixzhang@...cent.com>
follow_pfn() will get pfn of pmd if huge pmd is encountered.
Signed-off-by: Chen Zhuo <sagazchen@...cent.com>
Signed-off-by: Yulei Zhang <yuleixzhang@...cent.com>
---
mm/memory.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/mm/memory.c b/mm/memory.c
index 6b60981..abb9148 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4807,15 +4807,23 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
int ret = -EINVAL;
spinlock_t *ptl;
pte_t *ptep;
+ pmd_t *pmdp = NULL;
if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
return ret;
- ret = follow_pte(vma->vm_mm, address, &ptep, &ptl);
+ ret = follow_pte_pmd(vma->vm_mm, address, NULL, &ptep, &pmdp, &ptl);
if (ret)
return ret;
- *pfn = pte_pfn(*ptep);
- pte_unmap_unlock(ptep, ptl);
+
+ if (pmdp) {
+ *pfn = pmd_pfn(*pmdp) + ((address & ~PMD_MASK) >> PAGE_SHIFT);
+ spin_unlock(ptl);
+ } else {
+ *pfn = pte_pfn(*ptep);
+ pte_unmap_unlock(ptep, ptl);
+ }
+
return 0;
}
EXPORT_SYMBOL(follow_pfn);
--
1.8.3.1
Powered by blists - more mailing lists