mm: replace is_zero_pfn with is_huge_zero_pmd for thp
Subsystems (2)
PATCH 1/1 mm: replace is_zero_pfn with is_huge_zero_pmd for thp
For hugely mapped thp, we use is_huge_zero_pmd() to check if it's zero page or not.
We do fill ptes with my_zero_pfn() when we split zero thp pmd, but
this is not what we have in vm_normal_page_pmd().pmd_trans_huge_lock() makes sure of it.
This is a trivial fix for /proc/pid/numa_maps, and AFAIK nobody complains about it.
--- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +1 -1
@@ -654,7 +654,7 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,if (pmd_devmap (pmd))return NULL ; -if (is_zero_pfn (pfn)) +if (is_huge_zero_pmd (pmd))return NULL ;if (unlikely (pfn > highest_memmap_pfn))return NULL ;
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
Why did you not cc Gerald who wrote the patch? You can't just run get_maintainers.pl and call it good.
Quoted 31 lines · Yu Zhao
For hugely mapped thp, we use
is_huge_zero_pmd()to check if it's zero page or not.We do fill ptes with
my_zero_pfn()when we split zero thp pmd, but
this is not what we have invm_normal_page_pmd().pmd_trans_huge_lock()makes sure of it.This is a trivial fix for
/proc/pid/numa_maps, and AFAIK nobody complains about it.Signed-off-by Yu Zhao <[email protected]>--- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/memory.c +1
-1@@ -654,7 +654,7 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,if (pmd_devmap (pmd))return NULL ; -if (is_zero_pfn (pfn)) +if (is_huge_zero_pmd (pmd))return NULL ;if (unlikely (pfn > highest_memmap_pfn))return NULL ;Signature · 1 line
2.23.0.187.g17f5b7556c-goog
Quoted 25 lines · On Mon, 26 Aug 2019 06:18:58 -0700 Matthew Wilcox <[email protected]> wrote:
Why did you not cc Gerald who wrote the patch? You can't just run get_maintainers.pl and call it good.
Quoted 21 lines · Yu Zhao
For hugely mapped thp, we use
is_huge_zero_pmd()to check if it's zero page or not.We do fill ptes with
my_zero_pfn()when we split zero thp pmd, but
this is not what we have invm_normal_page_pmd().pmd_trans_huge_lock()makes sure of it.This is a trivial fix for
/proc/pid/numa_maps, and AFAIK nobody complains about it.Signed-off-by Yu Zhao <[email protected]>--- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/memory.c +0
-0@@ -654,7 +654,7 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,
Quoted 10 lines
Quoted 10 lines
mm/memory.c +1
-1if (pmd_devmap (pmd))return NULL ; -if (is_zero_pfn (pfn)) +if (is_huge_zero_pmd (pmd))return NULL ;if (unlikely (pfn > highest_memmap_pfn))return NULL ;Signature · 1 line
2.23.0.187.g17f5b7556c-goog
Looks good to me. The "_pmd" versions for can_gather_numa_stats() and vm_normal_page() were introduced to avoid using pte_present/dirty() on pmds, which is not affected by this patch.
In fact, for vm_normal_page_pmd() I basically copied most of the code from vm_normal_page(), including the is_zero_pfn(pfn) check, which does look wrong to me now. Using is_huge_zero_pmd() should be correct.
Maybe the description could also mention the symptom of this bug? I would assume that it affects anon/dirty accounting in gather_pte_stats(), for huge mappings, if zero page mappings are not correctly recognized.
Regards,
Gerald
Quoted 43 lines · Gerald Schaefer
Quoted 25 lines · On Mon, 26 Aug 2019 06:18:58 -0700 Matthew Wilcox <[email protected]> wrote:
Why did you not cc Gerald who wrote the patch? You can't just run get_maintainers.pl and call it good.
Quoted 21 lines · Yu Zhao
For hugely mapped thp, we use
is_huge_zero_pmd()to check if it's zero page or not.We do fill ptes with
my_zero_pfn()when we split zero thp pmd, but
this is not what we have invm_normal_page_pmd().pmd_trans_huge_lock()makes sure of it.This is a trivial fix for
/proc/pid/numa_maps, and AFAIK nobody complains about it.Signed-off-by Yu Zhao <[email protected]>--- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/memory.c +0
-0@@ -654,7 +654,7 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,Quoted 10 lines
Quoted 10 lines
mm/memory.c +1
-1if (pmd_devmap (pmd))return NULL ; -if (is_zero_pfn (pfn)) +if (is_huge_zero_pmd (pmd))return NULL ;if (unlikely (pfn > highest_memmap_pfn))return NULL ;Signature · 1 line
2.23.0.187.g17f5b7556c-googLooks good to me. The "
_pmd" versions forcan_gather_numa_stats()andvm_normal_page()were introduced to avoid using pte_present/dirty() on pmds, which is not affected by this patch.
Quoted 7 lines
In fact, for
vm_normal_page_pmd()I basically copied most of the code fromvm_normal_page(), including theis_zero_pfn(pfn)check, which does look wrong to me now. Usingis_huge_zero_pmd()should be correct.Maybe the description could also mention the symptom of this bug? I would assume that it affects anon/dirty accounting in
gather_pte_stats(), for huge mappings, if zero page mappings are not correctly recognized.
Hi, sorry for not copying you on the original email. I came across this while I was looking at the code. I'm not aware of any symptom. Thank you.
PATCH v2 1/1 mm: replace is_zero_pfn with is_huge_zero_pmd for thp
In reply to Yu ZhaoFor hugely mapped thp, we use is_huge_zero_pmd() to check if it's zero page or not.
We do fill ptes with my_zero_pfn() when we split zero thp pmd, but this is not what we have in vm_normal_page_pmd() -- pmd_trans_huge_lock() makes sure of it.
This is a trivial fix for /proc/pid/numa_maps, and AFAIK nobody complains about it.
Gerald Schaefer asked:
Quoted 3 lines
Maybe the description could also mention the symptom of this bug? I would assume that it affects anon/dirty accounting in
gather_pte_stats(), for huge mappings, if zero page mappings are not correctly recognized.
I came across this while I was looking at the code, so I'm not aware of any symptom.
--- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +1 -1
@@ -654,7 +654,7 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,if (pmd_devmap (pmd))return NULL ; -if (is_zero_pfn (pfn)) +if (is_huge_zero_pmd (pmd))return NULL ;if (unlikely (pfn > highest_memmap_pfn))return NULL ;
Signature · 1 line
2.24.0.rc1.363.gb1bccd3e3d-goog