mm: pmd dirty emulation in page fault handler
Subsystems (5)
PATCH 1/1 mm: pmd dirty emulation in page fault handler
Andreas reported [1] made a test in jemalloc hang in THP mode in arm64.
http://lkml.kernel.org/r/[email protected]
The problem is page fault handler supports only accessed flag emulation for THP page of SW-dirty/accessed architecture.
This patch enables dirty-bit emulation for those architectures. Without it, MADV_FREE makes application hang by repeated fault forever.
[1] mm/huge_memory.c: don't split THP page when MADV_FREE syscall is called
--- mm/huge_memory.c | 6 ++++-- mm/memory.c | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-)
mm/huge_memory.c +4 -2
@@ -883,15 +883,17 @@ void huge_pmd_set_accessed(struct vm_fault *vmf, pmd_t orig_pmd) {pmd_t entry;unsigned long haddr; +bool write = vmf->flags &FAULT_FLAG_WRITE ; vmf->ptl =pmd_lock (vmf->vma->vm_mm, vmf->pmd);if (unlikely (!pmd_same (*vmf->pmd, orig_pmd))) goto unlock; entry =pmd_mkyoung (orig_pmd); +if (write) + entry =pmd_mkdirty (entry); haddr = vmf->address &HPAGE_PMD_MASK ; -if (pmdp_set_access_flags (vmf->vma, haddr, vmf->pmd, entry, - vmf->flags &FAULT_FLAG_WRITE )) +if (pmdp_set_access_flags (vmf->vma, haddr, vmf->pmd, entry, write))update_mmu_cache_pmd (vmf->vma, vmf->address, vmf->pmd); unlock:
mm/memory.c +10 -8
@@ -3637,18 +3637,20 @@ static int __handle_mm_fault(struct vm_area_struct *vma, unsigned long address,if (pmd_protnone (orig_pmd) &&vma_is_accessible (vma))return do_huge_pmd_numa_page (&vmf, orig_pmd); -if ((vmf.flags &FAULT_FLAG_WRITE ) && - !pmd_write (orig_pmd)) { - ret =wp_huge_pmd (&vmf, orig_pmd); -if (!(ret &VM_FAULT_FALLBACK )) +if (vmf.flags &FAULT_FLAG_WRITE ) { +if (!pmd_write (orig_pmd)) { + ret =wp_huge_pmd (&vmf, orig_pmd); +if (ret ==VM_FAULT_FALLBACK ) + goto pte_fault;return ret; - }else { -huge_pmd_set_accessed (&vmf, orig_pmd); -return 0 ; + } } + +huge_pmd_set_accessed (&vmf, orig_pmd); +return 0 ; } } - +pte_fault:return handle_pte_fault (&vmf); }
Signature · 7 lines
2.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 1 line · Minchan Kim
Andreas reported [1] made a test in jemalloc hang in THP mode in arm64.
I guess you wanted put b8d3c4c3009d before [1], right?
Quoted 55 lines
http://lkml.kernel.org/r/[email protected]
The problem is page fault handler supports only accessed flag emulation for THP page of SW-dirty/accessed architecture.
This patch enables dirty-bit emulation for those architectures. Without it,
MADV_FREEmakes application hang by repeated fault forever.[1]
mm/huge_memory.c: don't split THP page whenMADV_FREEsyscall is calledCc Jason Evans <[email protected]>Cc Kirill A. Shutemov <[email protected]>Cc Will Deacon <[email protected]>Cc Catalin Marinas <[email protected]>Cc <[email protected]> [4.5+]Fixes b8d3c4c3009d ("mm/huge_memory.c: don't split THP page when MADV_FREE syscall is called")Reported-by Andreas Schwab <[email protected]>Signed-off-by Minchan Kim <[email protected]>--- mm/huge_memory.c | 6 ++++-- mm/memory.c | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-)mm/huge_memory.c +4
-2@@ -883,15 +883,17 @@ void huge_pmd_set_accessed(struct vm_fault *vmf, pmd_t orig_pmd) {pmd_t entry;unsigned long haddr; +bool write = vmf->flags &FAULT_FLAG_WRITE ; vmf->ptl =pmd_lock (vmf->vma->vm_mm, vmf->pmd);if (unlikely (!pmd_same (*vmf->pmd, orig_pmd))) goto unlock; entry =pmd_mkyoung (orig_pmd); +if (write) + entry =pmd_mkdirty (entry); haddr = vmf->address &HPAGE_PMD_MASK ; -if (pmdp_set_access_flags (vmf->vma, haddr, vmf->pmd, entry, - vmf->flags &FAULT_FLAG_WRITE )) +if (pmdp_set_access_flags (vmf->vma, haddr, vmf->pmd, entry, write))update_mmu_cache_pmd (vmf->vma, vmf->address, vmf->pmd); unlock:mm/memory.c +0
-0@@ -3637,18 +3637,20 @@ static int __handle_mm_fault(struct vm_area_struct *vma, unsigned long address,if (pmd_protnone (orig_pmd) &&vma_is_accessible (vma))
mm/memory.c static int __handle_mm_fault(struct vm_area_struct *vma, unsigned long address, · line 3643
Quoted 10 lines
mm/memory.c +4
-4return do_huge_pmd_numa_page (&vmf, orig_pmd); -if ((vmf.flags &FAULT_FLAG_WRITE ) && - !pmd_write (orig_pmd)) { - ret =wp_huge_pmd (&vmf, orig_pmd); -if (!(ret &VM_FAULT_FALLBACK )) +if (vmf.flags &FAULT_FLAG_WRITE ) { +if (!pmd_write (orig_pmd)) { + ret =wp_huge_pmd (&vmf, orig_pmd); +if (ret ==VM_FAULT_FALLBACK )
In theory, more than one flag can be set and it would lead to false-negative. Bit check was the right thing.
And I don't understand why do you need to change code in __handle_mm_fault() at all.
From what I see change to huge_pmd_set_accessed() should be enough.
Quoted 25 lines
mm/memory.c +6
-4+ goto pte_fault;return ret; - }else { -huge_pmd_set_accessed (&vmf, orig_pmd); -return 0 ; + } } + +huge_pmd_set_accessed (&vmf, orig_pmd); +return 0 ; } } - +pte_fault:return handle_pte_fault (&vmf); }Signature · 7 lines
2.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 7 lines
Kirill A. Shutemov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hello,
On Thu, Dec 22, 2016 at 11:17:13AM +0300, Kirill A. Shutemov wrote:
< snip >
Quoted 20 lines
Quoted 6 lines
mm/memory.c +0
-0@@ -3637,18 +3637,20 @@ static int __handle_mm_fault(struct vm_area_struct *vma, unsigned long address,if (pmd_protnone (orig_pmd) &&vma_is_accessible (vma))mm/memory.c static int __handle_mm_fault(struct vm_area_struct *vma, unsigned long address, · line 3643
Quoted 10 lines
mm/memory.c +4
-4return do_huge_pmd_numa_page (&vmf, orig_pmd); -if ((vmf.flags &FAULT_FLAG_WRITE ) && - !pmd_write (orig_pmd)) { - ret =wp_huge_pmd (&vmf, orig_pmd); -if (!(ret &VM_FAULT_FALLBACK )) +if (vmf.flags &FAULT_FLAG_WRITE ) { +if (!pmd_write (orig_pmd)) { + ret =wp_huge_pmd (&vmf, orig_pmd); +if (ret ==VM_FAULT_FALLBACK )In theory, more than one flag can be set and it would lead to false-negative. Bit check was the right thing.
Quoted 3 lines
And I don't understand why do you need to change code in
__handle_mm_fault()at all.
From what I see change tohuge_pmd_set_accessed()should be enough.
Yeb. Thanks for the review. Here v2 goes.
From b3ec95c0df91ad113525968a4a6b53030fd0b48d Mon Sep 17 00:00:00 2001
From: Minchan Kim <[email protected]>
Date: Thu, 22 Dec 2016 23:43:49 +0900
Subject: [PATCH v2] mm: pmd dirty emulation in page fault handler
Andreas reported [1] made a test in jemalloc hang in THP mode in arm64.
http://lkml.kernel.org/r/[email protected]
The problem is page fault handler supports only accessed flag emulation for THP page of SW-dirty/accessed architecture.
This patch enables dirty-bit emulation for those architectures. Without it, MADV_FREE makes application hang by repeated fault forever.
[1] b8d3c4c3009d, mm/huge_memory.c: don't split THP page when MADV_FREE syscall is called
---
* from v1
* Remove __handle_mm_fault part - Kirill
mm/huge_memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
mm/huge_memory.c +4 -2
@@ -883,15 +883,17 @@ void huge_pmd_set_accessed(struct vm_fault *vmf, pmd_t orig_pmd) {pmd_t entry;unsigned long haddr; +bool write = vmf->flags &FAULT_FLAG_WRITE ; vmf->ptl =pmd_lock (vmf->vma->vm_mm, vmf->pmd);if (unlikely (!pmd_same (*vmf->pmd, orig_pmd))) goto unlock; entry =pmd_mkyoung (orig_pmd); +if (write) + entry =pmd_mkdirty (entry); haddr = vmf->address &HPAGE_PMD_MASK ; -if (pmdp_set_access_flags (vmf->vma, haddr, vmf->pmd, entry, - vmf->flags &FAULT_FLAG_WRITE )) +if (pmdp_set_access_flags (vmf->vma, haddr, vmf->pmd, entry, write))update_mmu_cache_pmd (vmf->vma, vmf->address, vmf->pmd); unlock:
Signature · 1 line
2.7.4
Kirill A. Shutemov
Acked-byQuoted 47 lines · Minchan Kim
Hello,
On Thu, Dec 22, 2016 at 11:17:13AM +0300, Kirill A. Shutemov wrote:
< snip >
Quoted 20 lines
Quoted 6 lines
mm/memory.c +0
-0@@ -3637,18 +3637,20 @@ static int __handle_mm_fault(struct vm_area_struct *vma, unsigned long address,if (pmd_protnone (orig_pmd) &&vma_is_accessible (vma))mm/memory.c static int __handle_mm_fault(struct vm_area_struct *vma, unsigned long address, · line 3643
Quoted 10 lines
mm/memory.c +4
-4return do_huge_pmd_numa_page (&vmf, orig_pmd); -if ((vmf.flags &FAULT_FLAG_WRITE ) && - !pmd_write (orig_pmd)) { - ret =wp_huge_pmd (&vmf, orig_pmd); -if (!(ret &VM_FAULT_FALLBACK )) +if (vmf.flags &FAULT_FLAG_WRITE ) { +if (!pmd_write (orig_pmd)) { + ret =wp_huge_pmd (&vmf, orig_pmd); +if (ret ==VM_FAULT_FALLBACK )In theory, more than one flag can be set and it would lead to false-negative. Bit check was the right thing.
Quoted 3 lines
And I don't understand why do you need to change code in
__handle_mm_fault()at all.
From what I see change tohuge_pmd_set_accessed()should be enough.Yeb. Thanks for the review. Here v2 goes.
From
b3ec95c0df91ad113525968a4a6b53030fd0b48dMon Sep 17 00:00:00 2001
From: Minchan Kim <[email protected]>
Date: Thu, 22 Dec 2016 23:43:49 +0900
Subject: [PATCH v2] mm: pmd dirty emulation in page fault handlerAndreas reported [1] made a test in jemalloc hang in THP mode in arm64.
http://lkml.kernel.org/r/[email protected]The problem is page fault handler supports only accessed flag emulation for THP page of SW-dirty/accessed architecture.
This patch enables dirty-bit emulation for those architectures. Without it,
MADV_FREEmakes application hang by repeated fault forever.[1]
b8d3c4c3009d,mm/huge_memory.c: don't split THP page whenMADV_FREEsyscall is called
Quoted 10 lines
Cc Jason Evans <[email protected]>Cc Kirill A. Shutemov <[email protected]>Cc Will Deacon <[email protected]>Cc Catalin Marinas <[email protected]>Cc <[email protected]> [4.5+]Fixes b8d3c4c3009d ("mm/huge_memory.c: don't split THP page when MADV_FREE syscall is called")Reported-by Andreas Schwab <[email protected]>Signed-off-by Minchan Kim <[email protected]>
Signature · 7 lines
Kirill A. Shutemov -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · Minchan Kim
From
b3ec95c0df91ad113525968a4a6b53030fd0b48dMon Sep 17 00:00:00 2001
From: Minchan Kim <[email protected]>
Date: Thu, 22 Dec 2016 23:43:49 +0900
Subject: [PATCH v2] mm: pmd dirty emulation in page fault handlerAndreas reported [1] made a test in jemalloc hang in THP mode in arm64.
http://lkml.kernel.org/r/[email protected]
Quoted 7 lines
The problem is page fault handler supports only accessed flag emulation for THP page of SW-dirty/accessed architecture.
This patch enables dirty-bit emulation for those architectures. Without it,
MADV_FREEmakes application hang by repeated fault forever.[1]
b8d3c4c3009d,mm/huge_memory.c: don't split THP page whenMADV_FREEsyscall is called
Successfully tested a backport to 4.9.
Andreas.
Signature · 9 lines
Andreas Schwab, SUSE Labs, [email protected] GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different." -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
On Thu 22-12-16 23:52:03, Minchan Kim wrote:
[...]
Quoted 5 lines
Quoted 1 line
From
b3ec95c0df91ad113525968a4a6b53030fd0b48dMon Sep 17 00:00:00 2001From: Minchan Kim <[email protected]>
Date: Thu, 22 Dec 2016 23:43:49 +0900
Subject: [PATCH v2] mm: pmd dirty emulation in page fault handler
Quoted 8 lines
Andreas reported [1] made a test in jemalloc hang in THP mode in arm64.
http://lkml.kernel.org/r/mvmmvfy37g1.fsf at hawking.suse.deThe problem is page fault handler supports only accessed flag emulation for THP page of SW-dirty/accessed architecture.
This patch enables dirty-bit emulation for those architectures. Without it,
MADV_FREEmakes application hang by repeated fault forever.
The changelog is rather terse and considering the issue is rather subtle and it aims the stable tree I think it could see more information. How do we end up looping in the page fault and why the dirty pmd stops it. Could you update the changelog to be more verbose, please? I am still digesting this patch but I believe it is correct fwiw...
Thanks!
Quoted 51 lines
[1]
b8d3c4c3009d,mm/huge_memory.c: don't split THP page whenMADV_FREEsyscall is calledCc Jason Evans <[email protected]>Cc Kirill A. Shutemov <[email protected]>Cc Will Deacon <[email protected]>Cc Catalin Marinas <[email protected]>Cc linux-arch at vger.kernel.orgCc linux-arm-kernel at lists.infradead.orgCc <[email protected]> [4.5+]Fixes b8d3c4c3009d ("mm/huge_memory.c: don't split THP page when MADV_FREE syscall is called")Reported-by Andreas Schwab <[email protected]>Signed-off-by Minchan Kim <[email protected]>---
* from v1
* Remove__handle_mm_faultpart - Kirillmm/huge_memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)mm/huge_memory.c +4
-2@@ -883,15 +883,17 @@ void huge_pmd_set_accessed(struct vm_fault *vmf, pmd_t orig_pmd) {pmd_t entry;unsigned long haddr; +bool write = vmf->flags &FAULT_FLAG_WRITE ; vmf->ptl =pmd_lock (vmf->vma->vm_mm, vmf->pmd);if (unlikely (!pmd_same (*vmf->pmd, orig_pmd))) goto unlock; entry =pmd_mkyoung (orig_pmd); +if (write) + entry =pmd_mkdirty (entry); haddr = vmf->address &HPAGE_PMD_MASK ; -if (pmdp_set_access_flags (vmf->vma, haddr, vmf->pmd, entry, - vmf->flags &FAULT_FLAG_WRITE )) +if (pmdp_set_access_flags (vmf->vma, haddr, vmf->pmd, entry, write))update_mmu_cache_pmd (vmf->vma, vmf->address, vmf->pmd); unlock:Signature · 7 lines
2.7.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo at kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> email at kvack.org </a>
Signature · 2 lines
Michal Hocko SUSE Labs
Hi,
Quoted 13 lines · Michal Hocko
On Thu 22-12-16 23:52:03, Minchan Kim wrote:
[...]Quoted 11 lines
Quoted 1 line
From
b3ec95c0df91ad113525968a4a6b53030fd0b48dMon Sep 17 00:00:00 2001From: Minchan Kim <[email protected]>
Date: Thu, 22 Dec 2016 23:43:49 +0900
Subject: [PATCH v2] mm: pmd dirty emulation in page fault handlerAndreas reported [1] made a test in jemalloc hang in THP mode in arm64.
http://lkml.kernel.org/r/[email protected]The problem is page fault handler supports only accessed flag emulation for THP page of SW-dirty/accessed architecture.
Quoted 9 lines
Quoted 2 lines
This patch enables dirty-bit emulation for those architectures. Without it,
MADV_FREEmakes application hang by repeated fault forever.The changelog is rather terse and considering the issue is rather subtle and it aims the stable tree I think it could see more information. How do we end up looping in the page fault and why the dirty pmd stops it. Could you update the changelog to be more verbose, please? I am still digesting this patch but I believe it is correct fwiw...
How about this? Feel free to suggest better wording.
Andreas reported [1] made a test in jemalloc hang in THP mode in arm64.
http://lkml.kernel.org/r/[email protected]
The problem is currently page fault handler doesn't supports dirty bit emulation of pte for non-HW dirty-bit architecture so that application stucks until VM marked the pmd dirty.
How the emulation work depends on the architecture. In case of arm64, when it set up pte firstly, it sets pte PTE_RDONLY to get a chance to mark the pte dirty via triggering page fault when store access happens. Once the page fault occurs, VM marks the pte dirty and arch code for setting pte will clear PTE_RDONLY for application to proceed.
IOW, if VM doesn't mark the pte dirty, application hangs forever by repeated fault(i.e., store op but the pte is PTE_RDONLY).
This patch enables dirty-bit emulation for those architectures.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 26 lines · Minchan Kim
Hi,
Quoted 13 lines · Michal Hocko
On Thu 22-12-16 23:52:03, Minchan Kim wrote:
[...]Quoted 11 lines
Quoted 1 line
From
b3ec95c0df91ad113525968a4a6b53030fd0b48dMon Sep 17 00:00:00 2001From: Minchan Kim <[email protected]>
Date: Thu, 22 Dec 2016 23:43:49 +0900
Subject: [PATCH v2] mm: pmd dirty emulation in page fault handlerAndreas reported [1] made a test in jemalloc hang in THP mode in arm64.
http://lkml.kernel.org/r/[email protected]The problem is page fault handler supports only accessed flag emulation for THP page of SW-dirty/accessed architecture.
Quoted 9 lines
Quoted 2 lines
This patch enables dirty-bit emulation for those architectures. Without it,
MADV_FREEmakes application hang by repeated fault forever.The changelog is rather terse and considering the issue is rather subtle and it aims the stable tree I think it could see more information. How do we end up looping in the page fault and why the dirty pmd stops it. Could you update the changelog to be more verbose, please? I am still digesting this patch but I believe it is correct fwiw...
Quoted 7 lines
How about this? Feel free to suggest better wording.
Andreas reported [1] made a test in jemalloc hang in THP mode in arm64.
http://lkml.kernel.org/r/[email protected]The problem is currently page fault handler doesn't supports dirty bit emulation of pte for non-HW dirty-bit architecture so that application
s@pte@pmd@ ?
Quoted 8 lines
stucks until VM marked the pmd dirty.
How the emulation work depends on the architecture. In case of arm64, when it set up pte firstly, it sets pte
PTE_RDONLYto get a chance to mark the pte dirty via triggering page fault when store access happens. Once the page fault occurs, VM marks the pte dirty and arch code for setting pte will clearPTE_RDONLYfor application to proceed.
Quoted 4 lines
IOW, if VM doesn't mark the pte dirty, application hangs forever by repeated
fault(i.e., store op but the pte is PTE_RDONLY).This patch enables dirty-bit emulation for those architectures.
Yes this is helpful and much more clear, thank you. One thing that is still not clear to me is why cannot we handle that in the arch specific code. I mean what is the side effect of doing pmd_mkdirty for architectures which do not need it?
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 29 lines · Michal Hocko
Quoted 28 lines · Minchan Kim
Hi,
Quoted 13 lines · Michal Hocko
On Thu 22-12-16 23:52:03, Minchan Kim wrote:
[...]Quoted 11 lines
Quoted 1 line
From
b3ec95c0df91ad113525968a4a6b53030fd0b48dMon Sep 17 00:00:00 2001From: Minchan Kim <[email protected]>
Date: Thu, 22 Dec 2016 23:43:49 +0900
Subject: [PATCH v2] mm: pmd dirty emulation in page fault handlerAndreas reported [1] made a test in jemalloc hang in THP mode in arm64.
http://lkml.kernel.org/r/[email protected]The problem is page fault handler supports only accessed flag emulation for THP page of SW-dirty/accessed architecture.
Quoted 9 lines
Quoted 2 lines
This patch enables dirty-bit emulation for those architectures. Without it,
MADV_FREEmakes application hang by repeated fault forever.The changelog is rather terse and considering the issue is rather subtle and it aims the stable tree I think it could see more information. How do we end up looping in the page fault and why the dirty pmd stops it. Could you update the changelog to be more verbose, please? I am still digesting this patch but I believe it is correct fwiw...
How about this? Feel free to suggest better wording.
Quoted 7 lines
Quoted 5 lines
Andreas reported [1] made a test in jemalloc hang in THP mode in arm64.
http://lkml.kernel.org/r/[email protected]The problem is currently page fault handler doesn't supports dirty bit emulation of pte for non-HW dirty-bit architecture so that application
s@pte@pmd@ ?
It would be more clear. Will update with it.
Quoted 12 lines
Quoted 12 lines
stucks until VM marked the pmd dirty.
How the emulation work depends on the architecture. In case of arm64, when it set up pte firstly, it sets pte
PTE_RDONLYto get a chance to mark the pte dirty via triggering page fault when store access happens. Once the page fault occurs, VM marks the pte dirty and arch code for setting pte will clearPTE_RDONLYfor application to proceed.IOW, if VM doesn't mark the pte dirty, application hangs forever by repeated
fault(i.e., store op but the pte is PTE_RDONLY).
Quoted 6 lines
Quoted 1 line
This patch enables dirty-bit emulation for those architectures.
Yes this is helpful and much more clear, thank you. One thing that is still not clear to me is why cannot we handle that in the arch specific code. I mean what is the side effect of doing
pmd_mkdirtyfor architectures which do not need it?
For architecture which supports H/W access/dirty bit, it couldn't be reached there code path so there is no side effect, I think. A thing I can think of is just increasing code size little bit. Maybe, we could optimize away some ifdef magic but not sure worth it. We have been same way pte(not pmd) emulation handling for several decacdes. Anyway, it should be off-topic, I think.
Thanks.
Quoted 4 lines
Signature · 3 lines
-- Michal Hocko SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 2 lines · Minchan Kim
Quoted 1 line · Michal Hocko
On Fri 23-12-16 18:53:36, Minchan Kim wrote:
[...]
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
stucks until VM marked the pmd dirty.
How the emulation work depends on the architecture. In case of arm64, when it set up pte firstly, it sets pte
PTE_RDONLYto get a chance to mark the pte dirty via triggering page fault when store access happens. Once the page fault occurs, VM marks the pte dirty and arch code for setting pte will clearPTE_RDONLYfor application to proceed.IOW, if VM doesn't mark the pte dirty, application hangs forever by repeated
fault(i.e., store op but the pte is PTE_RDONLY).This patch enables dirty-bit emulation for those architectures.
Quoted 7 lines
Quoted 4 lines
Yes this is helpful and much more clear, thank you. One thing that is still not clear to me is why cannot we handle that in the arch specific code. I mean what is the side effect of doing
pmd_mkdirtyfor architectures which do not need it?For architecture which supports H/W access/dirty bit, it couldn't be reached there code path so there is no side effect, I think.
ahh, I knew I was missing something. It definitely wasn't obvious to me and my x86 config it simply generates code to call huge_pmd_set_accessed.
Quoted 3 lines
A thing
I can think of is just increasing code size little bit. Maybe, we could optimize away some ifdef magic but not sure worth it.
it is not
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>