Various mm improvements.
Subsystems (5)
cover Various mm improvements.
While working on 1K/2K page tables for s390 I noticed room for improvement in regard to some common mm code:
- unnecessary tlb flushing in unmap_vmas
- ptep_establish has fallen into disuse
- ptep_test_and_clear_dirty / ptep_clear_flush_dirty are not used either
- the definitions of mm_struct and vm_area_struct should be moved to mm_types.h
- page_mkclean_one is giving false positives
Signature · 10 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin. -- 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>
PATCH 1/5 avoid tlb gather restarts.
If need_resched() is false it is unnecessary to call tlb_finish_mmu() and tlb_gather_mmu() for each vma in unmap_vmas(). Moving the tlb gather restart under the if that contains the cond_resched() will avoid unnecessary tlb flush operations that are triggered by tlb_finish_mmu() and tlb_gather_mmu().
---
mm/memory.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
mm/memory.c +3 -4
@@ -851,19 +851,18 @@ unsigned long unmap_vmas(struct mmu_gathbreak ; } -tlb_finish_mmu (*tlbp, tlb_start, start); -if (need_resched () || (i_mmap_lock &&need_lockbreak (i_mmap_lock))) { +tlb_finish_mmu (*tlbp, tlb_start, start);if (i_mmap_lock) { *tlbp =NULL ; goto out; }cond_resched (); + *tlbp =tlb_gather_mmu (vma->vm_mm, fullmm); + tlb_start_valid =0 ; } - *tlbp =tlb_gather_mmu (vma->vm_mm, fullmm); - tlb_start_valid =0 ; zap_work =ZAP_BLOCK_SIZE ; } }
Signature · 10 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin. -- 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>
Re: [patch 1/5] avoid tlb gather restarts.
I don't dare comment on your page_mkclean_one patch (5/5), that dirty page business has grown too subtle for me.
Your cleanups 2-4 look good, especially the mm_types.h one (how confident are you that everything builds?), and I'm glad we can now lay ptep_establish to rest. Though I think you may have missed removing a __HAVE_ARCH_PTEP... from frv at least?
But this one...
Quoted 7 lines · Martin Schwidefsky
If
need_resched()is false it is unnecessary to calltlb_finish_mmu()andtlb_gather_mmu()for each vma inunmap_vmas(). Moving the tlb gather restart under the if that contains thecond_resched()will avoid unnecessary tlb flush operations that are triggered bytlb_finish_mmu()andtlb_gather_mmu().Signed-off-by Martin Schwidefsky <[email protected]>
Sorry, no. It looks reasonable, but unmap_vmas is treading a delicate and uncomfortable line between hi-performance and lo-latency: you've chosen to improve performance at the expense of latency.
You think you're just moving the finish/gather to where they're actually necessary; but the thing is, that per-cpu struct mmu_gather is liable to accumulate a lot of unpreemptible work for the future tlb_finish_mmu, particularly when anon pages are associated with swap.
So although there may be no need to resched right now, if we keep on gathering more and more without flushing, we'll be very unresponsive when a resched is needed later on. Hence Ingo's ZAP_BLOCK_SIZE to split it up, small when CONFIG_PREEMPT, more reasonable but still limited when not.
I expect there is some tinkering which could be done to improve it a little; but my ambition has always been to eliminate ZAP_BLOCK_SIZE, get away from the per-cpu'ness of the mmu_gather, and make unmap_vmas preemptible. But the i_mmap_lock case, and the per-arch variations in TLB flushing, have forever stalled me.
Hugh
Quoted 21 lines
---
mm/memory.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)diff -urpN
linux-2.6/mm/memory.clinux-2.6-patched/mm/memory.cmm/memory.c +1
-2@@ -851,19 +851,18 @@ unsigned long unmap_vmas(struct mmu_gathbreak ; } -tlb_finish_mmu (*tlbp, tlb_start, start); -if (need_resched () || (i_mmap_lock &&need_lockbreak (i_mmap_lock))) { +tlb_finish_mmu (*tlbp, tlb_start, start);if (i_mmap_lock) { *tlbp =NULL ; goto out; }
mm/memory.c unsigned long unmap_vmas(struct mmu_gath · line 868
Quoted 10 lines
mm/memory.c +2
-2cond_resched (); + *tlbp =tlb_gather_mmu (vma->vm_mm, fullmm); + tlb_start_valid =0 ; } - *tlbp =tlb_gather_mmu (vma->vm_mm, fullmm); - tlb_start_valid =0 ; zap_work =ZAP_BLOCK_SIZE ; } }
--
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>
Re: [patch 1/5] avoid tlb gather restarts.
Quoted 2 lines · Hugh Dickins
I don't dare comment on your
page_mkclean_onepatch (5/5), that dirty page business has grown too subtle for me.
Oh yes, the dirty handling is tricky. I had to fix a really nasty bug with it lately. As for page_mkclean_one the difference is that it doesn't claim a page is dirty if only the write protect bit has not been set. If we manage to lose dirty bits from ptes and have to rely on the write protect bit to take over the job, then we have a different problem altogether, no ?
Quoted 4 lines
Your cleanups 2-4 look good, especially the
mm_types.hone (how confident are you that everything builds?), and I'm glad we can now layptep_establishto rest. Though I think you may have missed removing a__HAVE_ARCH_PTEP... from frv at least?
Ok, thanks for the review. I take a look at frv to see if I missed something.
Quoted 10 lines
But this one...
Quoted 6 lines · Martin Schwidefsky
If
need_resched()is false it is unnecessary to calltlb_finish_mmu()andtlb_gather_mmu()for each vma inunmap_vmas(). Moving the tlb gather restart under the if that contains thecond_resched()will avoid unnecessary tlb flush operations that are triggered bytlb_finish_mmu()andtlb_gather_mmu().
Quoted 5 lines
Quoted 1 line
Signed-off-by Martin Schwidefsky <[email protected]>Sorry, no. It looks reasonable, but
unmap_vmasis treading a delicate and uncomfortable line between hi-performance and lo-latency: you've chosen to improve performance at the expense of latency.
That it true, my only concern had been performance. You likely have a point here.
Quoted 4 lines
You think you're just moving the finish/gather to where they're actually necessary; but the thing is, that per-cpu struct
mmu_gatheris liable to accumulate a lot of unpreemptible work for the futuretlb_finish_mmu, particularly when anon pages are associated with swap.
Hmm, ok, so you are saying that we should do a flush at the end of each vma.
Quoted 5 lines
So although there may be no need to resched right now, if we keep on gathering more and more without flushing, we'll be very unresponsive when a resched is needed later on. Hence Ingo's
ZAP_BLOCK_SIZEto split it up, small whenCONFIG_PREEMPT, more reasonable but still limited when not.
Would it be acceptable to call tlb_flush_mmu instead of the tlb_finish_mmu / tlb_gather_mmu pair if the condition around cond_resched evaluates to false?
The background for this change is that I'm working on another patch that will change the tlb flushing for s390 quite a bit. We won't have anything to flush with tlb_finish_mmu because we will either flush all tlbs with tlb_gather_mmu or each pte seperatly. The pages will always be freed immediatly. If we are forced to restart the tlb gather then we'll do multiple flush_tlb_mm because the information that we already flushed everything is lost with tlb_finish_mmu.
Signature · 11 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin. -- 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>
Re: [patch 1/5] avoid tlb gather restarts.
Quoted 5 lines · Martin Schwidefsky
Quoted 2 lines · Hugh Dickins
I don't dare comment on your
page_mkclean_onepatch (5/5), that dirty page business has grown too subtle for me.Oh yes, the dirty handling is tricky....
I'll move that discussion over to 5/5 and Cc Peter (sorry I was too lazy to do so in the first place).
Quoted 8 lines
Quoted 5 lines · Martin Schwidefsky
You think you're just moving the finish/gather to where they're actually necessary; but the thing is, that per-cpu struct
mmu_gatheris liable to accumulate a lot of unpreemptible work for the futuretlb_finish_mmu, particularly when anon pages are associated with swap.Hmm, ok, so you are saying that we should do a flush at the end of each vma.
I think of it as doing a flush every ZAP_BLOCK_SIZE, with the imperfect structure of the loop forcing perhaps an early flush at the end of each
vma: I seem to assume large vmas, and you to assume small ones.
IIRC, the common case for doing multiple vmas here is exit, when it ends up that the TLB flush can often be skipped because already done by the switch from exiting task; so the premature flush per vma doesn't matter much. But treat that claim with maximum scepticism: I've not rechecked it, several aspects may be wrong. What I do remember is that (at least on i386) there's a lot less actual TLB flushing done here than it appears from the outside.
Quoted 9 lines
Quoted 5 lines
So although there may be no need to resched right now, if we keep on gathering more and more without flushing, we'll be very unresponsive when a resched is needed later on. Hence Ingo's
ZAP_BLOCK_SIZEto split it up, small whenCONFIG_PREEMPT, more reasonable but still limited when not.Would it be acceptable to call
tlb_flush_mmuinstead of thetlb_finish_mmu/tlb_gather_mmupair if the condition aroundcond_reschedevaluates to false?
That sounds a good idea, yes, that should be fine. But beware, tlb_flush_mmu is an internal detail of the asm-generic/tlb.h method and perhaps some others, it currently doesn't exist on some arches.
I think you just need to add a simple one to arm & arm26, and take the "ia64_" off the ia64 one. powerpc and sparc64 go about it all a bit differently, but it should be easy to give them one too. There may be some others missing.
Quoted 7 lines
The background for this change is that I'm working on another patch that will change the tlb flushing for s390 quite a bit. We won't have anything to flush with
tlb_finish_mmubecause we will either flush all tlbs withtlb_gather_mmuor each pte seperatly. The pages will always be freed immediatly. If we are forced to restart the tlb gather then we'll do multipleflush_tlb_mmbecause the information that we already flushed everything is lost withtlb_finish_mmu.
Thanks for the info. Sounds like we may have trouble ahead when rearranging this stuff, easy to forget s390 from our assumptions:
keep watch!
Hugh
--
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>
PATCH 2/5 remove ptep_establish.
In reply to Martin SchwidefskyThe last user of ptep_establish in mm/ is long gone. Remove the architecture primitive as well.
---
include/asm-generic/pgtable.h | 19 ------------------- include/asm-i386/pgtable.h | 11 ----------- include/asm-ia64/pgtable.h | 6 ++++-- 3 files changed, 4 insertions(+), 32 deletions(-)
include/asm-generic/pgtable.h +0 -19
@@ -3,25 +3,6 @@#ifndef __ASSEMBLY__ -#ifndef __HAVE_ARCH_PTEP_ESTABLISH -/* -* Establish a new mapping: -* - flush the old one -* - update the page tables -* - inform the TLB about the new one -* -* We hold the mm semaphore for reading, and the pte lock. -* -* Note: the old pte is known to not be writable, so we don't need to -* worry about dirty bits etc getting lost. -*/ -#define ptep_establish (__vma, __address, __ptep, __entry) \ -do { \ - set_pte_at((__vma)->vm_mm, (__address), __ptep, __entry); \ - flush_tlb_page(__vma, __address); \ -} while (0) -#endif -#ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS/* * Largely same as above, but only sets the access flags (dirty,
include/asm-i386/pgtable.h +0 -11
@@ -317,17 +317,6 @@ static inline pte_t native_local_ptep_ge __ret; \ }) -/* -* Rules for using ptep_establish: the pte MUST be a user pte, and -* must be a present->present transition. -*/ -#define __HAVE_ARCH_PTEP_ESTABLISH -#define ptep_establish (vma, address, ptep, pteval) \ -do { \ - set_pte_present((vma)->vm_mm, address, ptep, pteval); \ - flush_tlb_page(vma, address); \ -} while (0) -#define __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH#define ptep_clear_flush_dirty (vma, address, ptep) \ ({ \
include/asm-ia64/pgtable.h +4 -2
@@ -546,8 +546,10 @@ extern void lazy_mmu_prot_update (pte_t# define ptep_set_access_flags (__vma, __addr, __ptep, __entry, __safely_writable) \ ({ \ int __changed = !pte_same(*(__ptep), __entry); \ - if (__changed) \ - ptep_establish(__vma, __addr, __ptep, __entry); \ + if (__changed) { \ + set_pte_at((__vma)->vm_mm, (__addr), __ptep, __entry); \ + flush_tlb_page(__vma, __addr); \ + } \ __changed; \ })#endif
Signature · 10 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin. -- 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>
PATCH 3/5 remove ptep_test_and_clear_dirty and ptep_clear_flush_dirty.
In reply to Martin SchwidefskyNobody is using ptep_test_and_clear_dirty and ptep_clear_flush_dirty. Remove the functions from all architectures.
---
include/asm-frv/pgtable.h | 7 ------- include/asm-generic/pgtable.h | 25 ------------------------- include/asm-i386/pgtable.h | 21 --------------------- include/asm-ia64/pgtable.h | 17 ----------------- include/asm-m32r/pgtable.h | 6 ------ include/asm-parisc/pgtable.h | 16 ---------------- include/asm-powerpc/pgtable-ppc32.h | 7 ------- include/asm-powerpc/pgtable-ppc64.h | 31 ------------------------------- include/asm-ppc/pgtable.h | 7 ------- include/asm-s390/pgtable.h | 15 --------------- include/asm-x86_64/pgtable.h | 8 -------- include/asm-xtensa/pgtable.h | 12 ------------ 12 files changed, 172 deletions(-)
include/asm-frv/pgtable.h +0 -7
@@ -394,13 +394,6 @@ static inline pte_t pte_mkdirty(pte_t ptstatic inline pte_t pte_mkyoung (pte_t pte) { (pte).pte |= _PAGE_ACCESSED;return pte; }static inline pte_t pte_mkwrite (pte_t pte) { (pte).pte &= ~_PAGE_WP;return pte; } -static inline int ptep_test_and_clear_dirty (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) -{ -int i =test_and_clear_bit (_PAGE_BIT_DIRTY, ptep); - asmvolatile ("dcf %M0" ::"U" (*ptep)); -return i; -} -static inline int ptep_test_and_clear_young (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) {int i =test_and_clear_bit (_PAGE_BIT_ACCESSED, ptep);
include/asm-generic/pgtable.h +0 -25
@@ -49,31 +49,6 @@ })#endif -#ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY -#define ptep_test_and_clear_dirty (__vma, __address, __ptep) \ -({ \ - pte_t __pte = *__ptep; \ - int r = 1; \ - if (!pte_dirty(__pte)) \ - r = 0; \ - else \ - set_pte_at((__vma)->vm_mm, (__address), (__ptep), \ - pte_mkclean(__pte)); \ - r; \ -}) -#endif - -#ifndef __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH -#define ptep_clear_flush_dirty (__vma, __address, __ptep) \ -({ \ - int __dirty; \ - __dirty = ptep_test_and_clear_dirty(__vma, __address, __ptep); \ - if (__dirty) \ - flush_tlb_page(__vma, __address); \ - __dirty; \ -}) -#endif -#ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR#define ptep_get_and_clear (__mm, __address, __ptep) \ ({ \
include/asm-i386/pgtable.h +0 -21
@@ -295,17 +295,6 @@ static inline pte_t native_local_ptep_ge __changed; \ }) -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY -#define ptep_test_and_clear_dirty (vma, addr, ptep) ({ \ - int __ret = 0; \ - if (pte_dirty(*(ptep))) \ - __ret = test_and_clear_bit(_PAGE_BIT_DIRTY, \ - &(ptep)->pte_low); \ - if (__ret) \ - pte_update((vma)->vm_mm, addr, ptep); \ - __ret; \ -}) -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG#define ptep_test_and_clear_young (vma, addr, ptep) ({ \ int __ret = 0; \
@@ -317,16 +306,6 @@ static inline pte_t native_local_ptep_ge __ret; \ }) -#define __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH -#define ptep_clear_flush_dirty (vma, address, ptep) \ -({ \ - int __dirty; \ - __dirty = ptep_test_and_clear_dirty((vma), (address), (ptep)); \ - if (__dirty) \ - flush_tlb_page(vma, address); \ - __dirty; \ -}) -#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH#define ptep_clear_flush_young (vma, address, ptep) \ ({ \
include/asm-ia64/pgtable.h +0 -17
@@ -398,22 +398,6 @@ ptep_test_and_clear_young (struct vm_are#endif } -static inline int -ptep_test_and_clear_dirty (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) -{ -#ifdef CONFIG_SMP -if (!pte_dirty (*ptep)) -return 0 ; -return test_and_clear_bit (_PAGE_D_BIT, ptep); -#else -pte_t pte = *ptep; -if (!pte_dirty (pte)) -return 0 ; -set_pte_at (vma->vm_mm, addr, ptep,pte_mkclean (pte)); -return 1 ; -#endif -} -static inline pte_t ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep) {
@@ -593,7 +577,6 @@ extern void lazy_mmu_prot_update (pte_t#endif #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY#define __HAVE_ARCH_PTEP_GET_AND_CLEAR#define __HAVE_ARCH_PTEP_SET_WRPROTECT#define __HAVE_ARCH_PTE_SAME
include/asm-m32r/pgtable.h +0 -6
@@ -284,11 +284,6 @@ static inline pte_t pte_mkwrite(pte_t ptreturn pte; } -static inline int ptep_test_and_clear_dirty (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) -{ -return test_and_clear_bit (_PAGE_BIT_DIRTY, ptep); -} -static inline int ptep_test_and_clear_young (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) {return test_and_clear_bit (_PAGE_BIT_ACCESSED, ptep);
@@ -382,7 +377,6 @@ static inline void pmd_set(pmd_t * pmdp, remap_pfn_range(vma, vaddr, pfn, size, prot)#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY#define __HAVE_ARCH_PTEP_GET_AND_CLEAR#define __HAVE_ARCH_PTEP_SET_WRPROTECT#define __HAVE_ARCH_PTE_SAME
include/asm-parisc/pgtable.h +0 -16
@@ -451,21 +451,6 @@ static inline int ptep_test_and_clear_yo#endif } -static inline int ptep_test_and_clear_dirty (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) -{ -#ifdef CONFIG_SMP -if (!pte_dirty (*ptep)) -return 0 ; -return test_and_clear_bit (xlate_pabit (_PAGE_DIRTY_BIT), &pte_val (*ptep)); -#else -pte_t pte = *ptep; -if (!pte_dirty (pte)) -return 0 ; -set_pte_at (vma->vm_mm, addr, ptep,pte_mkclean (pte)); -return 1 ; -#endif -} -extern spinlock_t pa_dbit_lock;struct mm_struct ;
@@ -533,7 +518,6 @@ static inline void ptep_set_wrprotect(st#define HAVE_ARCH_UNMAPPED_AREA #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY#define __HAVE_ARCH_PTEP_GET_AND_CLEAR#define __HAVE_ARCH_PTEP_SET_WRPROTECT#define __HAVE_ARCH_PTE_SAME
include/asm-powerpc/pgtable-ppc32.h +0 -7
@@ -643,13 +643,6 @@ static inline int __ptep_test_and_clear_#define ptep_test_and_clear_young (__vma, __addr, __ptep) \ __ptep_test_and_clear_young((__vma)->vm_mm->context.id, __addr, __ptep) -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY -static inline int ptep_test_and_clear_dirty (struct vm_area_struct *vma, -unsigned long addr,pte_t *ptep) -{ -return (pte_update (ptep, (_PAGE_DIRTY | _PAGE_HWWRITE),0 ) & _PAGE_DIRTY) !=0 ; -} -#define __HAVE_ARCH_PTEP_GET_AND_CLEARstatic inline pte_t ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep)
include/asm-powerpc/pgtable-ppc64.h +0 -31
@@ -307,29 +307,6 @@ static inline int __ptep_test_and_clear_ __r; \ }) -/* -* On RW/DIRTY bit transitions we can avoid flushing the hpte. For the -* moment we always flush but we need to fix hpte_update and test if the -* optimisation is worth it. -*/ -static inline int __ptep_test_and_clear_dirty (struct mm_struct *mm, -unsigned long addr,pte_t *ptep) -{ -unsigned long old; - -if ((pte_val (*ptep) & _PAGE_DIRTY) ==0 ) -return 0 ; - old =pte_update (mm, addr, ptep, _PAGE_DIRTY,0 ); -return (old & _PAGE_DIRTY) !=0 ; -} -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY -#define ptep_test_and_clear_dirty (__vma, __addr, __ptep) \ -({ \ - int __r; \ - __r = __ptep_test_and_clear_dirty((__vma)->vm_mm, __addr, __ptep); \ - __r; \ -}) -#define __HAVE_ARCH_PTEP_SET_WRPROTECTstatic inline void ptep_set_wrprotect (struct mm_struct *mm,unsigned long addr,pte_t *ptep)
@@ -357,14 +334,6 @@ static inline void ptep_set_wrprotect(st __young; \ }) -#define __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH -#define ptep_clear_flush_dirty (__vma, __address, __ptep) \ -({ \ - int __dirty = __ptep_test_and_clear_dirty((__vma)->vm_mm, __address, \ - __ptep); \ - __dirty; \ -}) -#define __HAVE_ARCH_PTEP_GET_AND_CLEARstatic inline pte_t ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep)
include/asm-ppc/pgtable.h +0 -7
@@ -664,13 +664,6 @@ static inline int __ptep_test_and_clear_#define ptep_test_and_clear_young (__vma, __addr, __ptep) \ __ptep_test_and_clear_young((__vma)->vm_mm->context.id, __addr, __ptep) -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY -static inline int ptep_test_and_clear_dirty (struct vm_area_struct *vma, -unsigned long addr,pte_t *ptep) -{ -return (pte_update (ptep, (_PAGE_DIRTY | _PAGE_HWWRITE),0 ) & _PAGE_DIRTY) !=0 ; -} -#define __HAVE_ARCH_PTEP_GET_AND_CLEARstatic inline pte_t ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep)
include/asm-s390/pgtable.h +0 -15
@@ -677,19 +677,6 @@ ptep_clear_flush_young(struct vm_area_streturn ptep_test_and_clear_young (vma, address, ptep); } -static inline int ptep_test_and_clear_dirty (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) -{ -return 0 ; -} - -static inline int -ptep_clear_flush_dirty (struct vm_area_struct *vma, -unsigned long address,pte_t *ptep) -{ -/* No need to flush TLB; bits are in storage key */ -return ptep_test_and_clear_dirty (vma, address, ptep); -} -static inline pte_t ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep) {pte_t pte = *ptep;
@@ -952,8 +939,6 @@ extern void memmap_init(unsigned long, i#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY -#define __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH#define __HAVE_ARCH_PTEP_GET_AND_CLEAR#define __HAVE_ARCH_PTEP_CLEAR_FLUSH#define __HAVE_ARCH_PTEP_SET_WRPROTECT
include/asm-x86_64/pgtable.h +0 -8
@@ -290,13 +290,6 @@ static inline pte_t pte_clrhuge(pte_t ptstruct vm_area_struct ; -static inline int ptep_test_and_clear_dirty (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) -{ -if (!pte_dirty (*ptep)) -return 0 ; -return test_and_clear_bit (_PAGE_BIT_DIRTY, &ptep->pte); -} -static inline int ptep_test_and_clear_young (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) {if (!pte_young (*ptep))
@@ -433,7 +426,6 @@ extern int kern_addr_valid(unsigned long (((o) & (1UL << (__VIRTUAL_MASK_SHIFT-1))) ? ((o) | (~__VIRTUAL_MASK)) : (o))#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY#define __HAVE_ARCH_PTEP_GET_AND_CLEAR#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL#define __HAVE_ARCH_PTEP_SET_WRPROTECT
include/asm-xtensa/pgtable.h +0 -12
@@ -270,17 +270,6 @@ ptep_test_and_clear_young(struct vm_areareturn 1 ; } -static inline int -ptep_test_and_clear_dirty (struct vm_area_struct *vma,unsigned long addr, -pte_t *ptep) -{ -pte_t pte = *ptep; -if (!pte_dirty (pte)) -return 0 ; -update_pte (ptep,pte_mkclean (pte)); -return 1 ; -} -static inline pte_t ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep) {
@@ -421,7 +410,6 @@ typedef pte_t *pte_addr_t;#endif /* !defined (__ASSEMBLY__) */ #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY#define __HAVE_ARCH_PTEP_GET_AND_CLEAR#define __HAVE_ARCH_PTEP_SET_WRPROTECT#define __HAVE_ARCH_PTEP_MKDIRTY
Signature · 10 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin. -- 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>
Re: [patch 3/5] remove ptep_test_and_clear_dirty and ptep_clear_flush_dirty.
Quoted 11 lines · Martin Schwidefsky
From: Martin Schwidefsky <[email protected]>
Nobody is using
ptep_test_and_clear_dirtyandptep_clear_flush_dirty. Remove the functions from all architectures.include/asm-ia64/pgtable.h +0
-5-static inline int -ptep_test_and_clear_dirty (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) -{ -#ifdef CONFIG_SMP -if (!pte_dirty (*ptep))
include/asm-ia64/pgtable.h ptep_test_and_clear_young (struct vm_are · line 415
Quoted 10 lines
include/asm-ia64/pgtable.h +0
-10-return 0 ; -return test_and_clear_bit (_PAGE_D_BIT, ptep); -#else -pte_t pte = *ptep; -if (!pte_dirty (pte)) -return 0 ; -set_pte_at (vma->vm_mm, addr, ptep,pte_mkclean (pte)); -return 1 ; -#endif -}
I've not followed all the changes lately - what is the current protocol for clearing dirty bit? Is it simply pte_clear followed by set or is it not done at all? At least for i386 and virtualization, we had several optimizations to the test_and_clear path that are not possible with a pte_clear / set_pte approach.
Zach
--
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>
Re: [patch 3/5] remove ptep_test_and_clear_dirty and ptep_clear_flush_dirty.
Quoted 13 lines · Zachary Amsden
Quoted 13 lines
include/asm-ia64/pgtable.h +0
-13-static inline int -ptep_test_and_clear_dirty (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) -{ -#ifdef CONFIG_SMP -if (!pte_dirty (*ptep)) -return 0 ; -return test_and_clear_bit (_PAGE_D_BIT, ptep); -#else -pte_t pte = *ptep; -if (!pte_dirty (pte)) -return 0 ; -set_pte_at (vma->vm_mm, addr, ptep,pte_mkclean (pte)); -return 1 ;
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +0
-2-#endif -}I've not followed all the changes lately - what is the current protocol for clearing dirty bit? Is it simply
pte_clearfollowed by set or is it not done at all? At least for i386 and virtualization, we had several optimizations to thetest_and_clearpath that are not possible with apte_clear/set_pteapproach.
Imho with a sequence of ptep_get_and_clear, pte_wrprotect, set_pte_at. One of the reasons why ptep_test_and_clear_dirty doesn't make sense anymore is the shared dirty page tracking. You never just test and clear the dirty bit, the latest code always sets the write protect bit as well.
Signature · 11 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin. -- 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>
PATCH 4/5 move mm_struct and vm_area_struct.
In reply to Martin SchwidefskyMove the definitions of struct mm_struct and struct vma_area_struct to include/mm_types.h. This allows to define more function in asm/pgtable.h and friends with inline assemblies instead of macros.
---
include/linux/mm.h | 63 -------------------- include/linux/mm_types.h | 143 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/sched.h | 74 ------------------------ 3 files changed, 144 insertions(+), 136 deletions(-)
include/linux/mm.h +0 -63
@@ -51,69 +51,6 @@ extern int sysctl_legacy_va_layout;* mmap() functions). */ -/* -* This struct defines a memory VMM memory area. There is one of these -* per VM-area/task. A VM area is any part of the process virtual memory -* space that has a special rule for the page-fault handlers (ie a shared -* library, the executable area etc). -*/ -struct vm_area_struct { -struct mm_struct * vm_mm;/* The address space we belong to. */ -unsigned long vm_start;/* Our start address within vm_mm. */ -unsigned long vm_end;/* The first byte after our end address -within vm_mm. */ - -/* linked list of VM areas per task, sorted by address */ -struct vm_area_struct *vm_next; - -pgprot_t vm_page_prot;/* Access permissions of this VMA. */ -unsigned long vm_flags;/* Flags, listed below. */ - -struct rb_node vm_rb; - -/* -* For areas with an address space and backing store, -* linkage into the address_space->i_mmap prio tree, or -* linkage to the list of like vmas hanging off its node, or -* linkage of vma in the address_space->i_mmap_nonlinear list. -*/ -union { -struct { -struct list_head list; -void *parent;/* aligns with prio_tree_node parent */ -struct vm_area_struct *head; - } vm_set; - -struct raw_prio_tree_node prio_tree_node; - } shared; - -/* -* A file's MAP_PRIVATE vma can be in both i_mmap tree and anon_vma -* list, after a COW of one of the file pages. A MAP_SHARED vma -* can only be in the i_mmap tree. An anonymous MAP_PRIVATE, stack -* or brk vma (with NULL file) can only be in an anon_vma list. -*/ -struct list_head anon_vma_node;/* Serialized by anon_vma->lock */ -struct anon_vma *anon_vma;/* Serialized by page_table_lock */ - -/* Function pointers to deal with this struct. */ -struct vm_operations_struct * vm_ops; - -/* Information about our backing store: */ -unsigned long vm_pgoff;/* Offset (within vm_file) in PAGE_SIZE -units, *not* PAGE_CACHE_SIZE */ -struct file * vm_file;/* File we map to (can be NULL). */ -void * vm_private_data;/* was vm_pte (shared mem) */ -unsigned long vm_truncate_count;/* truncate_count or restart_addr */ - -#ifndef CONFIG_MMU -atomic_t vm_usage;/* refcount (VMAs shared if !MMU) */ -#endif -#ifdef CONFIG_NUMA -struct mempolicy *vm_policy;/* NUMA policy for the VMA */ -#endif -}; -extern struct kmem_cache *vm_area_cachep;/*
include/linux/mm_types.h +143 -0
160 lines not on this page · raw message
include/linux/sched.h +1 -73
109 lines not on this page · raw message
Signature · 10 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin. -- 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>
PATCH 5/5 Optimize page_mkclean_one
In reply to Martin Schwidefskypage_mkclean_one is used to clear the dirty bit and to set the write protect bit of a pte. In additions it returns true if the pte either has been dirty or if it has been writable. As far as I can see the function should return true only if the pte has been dirty, or page writeback will needlessly write a clean page.
---
mm/rmap.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-)
mm/rmap.c +2 -1
@@ -433,11 +433,12 @@ static int page_mkclean_one(struct pageflush_cache_page (vma, address,pte_pfn (*pte)); entry =ptep_clear_flush (vma, address, pte); +if (pte_dirty (entry)) + ret =1 ; entry =pte_wrprotect (entry); entry =pte_mkclean (entry);set_pte_at (mm, address, pte, entry);lazy_mmu_prot_update (entry); - ret =1 ; }pte_unmap_unlock (pte, ptl);
Signature · 10 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin. -- 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>
Re: [patch 5/5] Optimize page_mkclean_one
Quoted 10 lines · Martin Schwidefsky
Quoted 2 lines · Hugh Dickins
I don't dare comment on your
page_mkclean_onepatch (5/5), that dirty page business has grown too subtle for me.Oh yes, the dirty handling is tricky. I had to fix a really nasty bug with it lately. As for
page_mkclean_onethe difference is that it doesn't claim a page is dirty if only the write protect bit has not been set. If we manage to lose dirty bits from ptes and have to rely on the write protect bit to take over the job, then we have a different problem altogether, no ?
[Moving that over from 1/5 discussion].
Expect you're right, but I _really_ don't want to comment, when I don't understand that "|| pte_write" in the first place, and don't know the consequence of pte_dirty && !pte_write or !pte_dirty && pte_write there. Peter?
My suspicion is that the "|| pte_write" is precisely to cover your s390 case where pte is never dirty (it may even have been me who got Peter to put it in for that reason). In which case your patch would be fine - though I think it'd be improved a lot by a comment or rearrangement or new macro in place of the pte_dirty || pte_write line (perhaps adjust my pte_maybe_dirty in asm-generic/pgtable.h, and use that - its former use in msync has gone away now).
Hugh
Quoted 19 lines · Martin Schwidefsky
page_mkclean_oneis used to clear the dirty bit and to set the write protect bit of a pte. In additions it returns true if the pte either has been dirty or if it has been writable. As far as I can see the function should return true only if the pte has been dirty, or page writeback will needlessly write a clean page.Signed-off-by Martin Schwidefsky <[email protected]>---
mm/rmap.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-)diff -urpN
linux-2.6/mm/rmap.clinux-2.6-patched/mm/rmap.cmm/rmap.c +0
-0@@ -433,11 +433,12 @@ static int page_mkclean_one(struct pageflush_cache_page (vma, address,pte_pfn (*pte)); entry =ptep_clear_flush (vma, address, pte);
mm/rmap.c static int page_mkclean_one(struct page · line 444
Quoted 10 lines
mm/rmap.c +2
-1+if (pte_dirty (entry)) + ret =1 ; entry =pte_wrprotect (entry); entry =pte_mkclean (entry);set_pte_at (mm, address, pte, entry);lazy_mmu_prot_update (entry); - ret =1 ; }pte_unmap_unlock (pte, ptl);
--
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>
Re: [patch 5/5] Optimize page_mkclean_one
Quoted 7 lines · Hugh Dickins
Quoted 6 lines
Oh yes, the dirty handling is tricky. I had to fix a really nasty bug with it lately. As for
page_mkclean_onethe difference is that it doesn't claim a page is dirty if only the write protect bit has not been set. If we manage to lose dirty bits from ptes and have to rely on the write protect bit to take over the job, then we have a different problem altogether, no ?
Quoted 5 lines
[Moving that over from 1/5 discussion].
Expect you're right, but I _really_ don't want to comment, when I don't understand that "||
pte_write" in the first place, and don't know the consequence ofpte_dirty&& !pte_write or !pte_dirty &&pte_writethere.
The pte_write() part is for the shared dirty page tracking. If you want to make sure that a max of x% of your pages are dirty then you cannot allow to have more than x% to be writable. Thats why page_mkclean_one clears the dirty bit and makes the page read-only.
Quoted 7 lines
My suspicion is that the "||
pte_write" is precisely to cover your s390 case where pte is never dirty (it may even have been me who got Peter to put it in for that reason). In which case your patch would be fine - though I think it'd be improved a lot by a comment or rearrangement or new macro in place of thepte_dirty||pte_writeline (perhaps adjust mypte_maybe_dirtyinasm-generic/pgtable.h, and use that - its former use in msync has gone away now).
No, s390 is covered by the page_test_dirty / page_clear_dirty pair in page_mkclean.
Signature · 11 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin. -- 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>
Re: [patch 5/5] Optimize page_mkclean_one
Quoted 9 lines · Martin Schwidefsky
Quoted 4 lines
Expect you're right, but I _really_ don't want to comment, when I don't understand that "||
pte_write" in the first place, and don't know the consequence ofpte_dirty&& !pte_write or !pte_dirty &&pte_writethere.The
pte_write()part is for the shared dirty page tracking. If you want to make sure that a max of x% of your pages are dirty then you cannot allow to have more than x% to be writable. Thats whypage_mkclean_oneclears the dirty bit and makes the page read-only.
The whole of page_mkclean_one is for the dirty page tracking: so it's obvious why it tests pte_dirty, but not obvious why it tests pte_write.
Quoted 11 lines
Quoted 8 lines
My suspicion is that the "||
pte_write" is precisely to cover your s390 case where pte is never dirty (it may even have been me who got Peter to put it in for that reason). In which case your patch would be fine - though I think it'd be improved a lot by a comment or rearrangement or new macro in place of thepte_dirty||pte_writeline (perhaps adjust mypte_maybe_dirtyinasm-generic/pgtable.h, and use that - its former use in msync has gone away now).No, s390 is covered by the
page_test_dirty/page_clear_dirtypair inpage_mkclean.
That's where its dirty page count comes from, yes: but since the s390 pte_dirty just says no, if page_mkclean_one tested only pte_dirty, then it wouldn't do anything on s390, and in particular wouldn't write protect the ptes to re-enforce dirty counting from then on.
So in answering your denials, I grow more confident that the pte_write test is precisely for the s390 case. Though it might also be to cover some defect in the write-protection scheme on other arches.
Come to think of it, would your patch really make any difference? Although page_mkclean's "count" of dirty ptes on s390 will be nonsense, that count would anyway be unknown, and it's only used as a boolean; and now I don't think your patch changes the boolean value - if any pte is found writable (and if the scheme is working) that implies that the page was written to, and so should give the same answer as the page_test_dirty.
But I could easily be overlooking something: Peter will recall.
Hugh
--
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>
Peter Zijlstra
maintainerRe: [patch 5/5] Optimize page_mkclean_one
Quoted 1 line · Hugh Dickins
But I could easily be overlooking something: Peter will recall.
/me tries to get his brain up to speed after the OLS closing party :-)
I did both pte_dirty and pte_write because I was extra careful. One _should_ imply the other, but since we'll be clearing both, I thought it prudent to also check both.
I will have to think on this a little more, but I'm currently of the opinion that the optimisation is not correct. But I'll have a thorough look at s390 again when I get home.
--
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>
Re: [patch 5/5] Optimize page_mkclean_one
Quoted 3 lines · Peter Zijlstra
Quoted 1 line
But I could easily be overlooking something: Peter will recall.
/me tries to get his brain up to speed after the OLS closing party :-)
Oh-oh, the Black Thorn party :-)
Quoted 3 lines
I did both
pte_dirtyandpte_writebecause I was extra careful. One _should_ imply the other, but since we'll be clearing both, I thought it prudent to also check both.
Just ran a little experiment: I've added a simple WARN_ON(ret == 0) to page_mkclean after the page_test_dirty() check to see if there are cases where the page is dirty and all ptes are read-only. A little stress run including massive swap did not print a single warning.
Quoted 3 lines
I will have to think on this a little more, but I'm currently of the opinion that the optimisation is not correct. But I'll have a thorough look at s390 again when I get home.
I think the patch is correct, although I beginning to doubt that is has any effect.
Signature · 11 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin. -- 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>
Re: [patch 5/5] Optimize page_mkclean_one
In reply to Hugh DickinsQuoted 6 lines · Hugh Dickins
Quoted 5 lines · Martin Schwidefsky
Quoted 4 lines
Expect you're right, but I _really_ don't want to comment, when I don't understand that "||
pte_write" in the first place, and don't know the consequence ofpte_dirty&& !pte_write or !pte_dirty &&pte_writethere.
Quoted 7 lines
Quoted 4 lines
The
pte_write()part is for the shared dirty page tracking. If you want to make sure that a max of x% of your pages are dirty then you cannot allow to have more than x% to be writable. Thats whypage_mkclean_oneclears the dirty bit and makes the page read-only.The whole of
page_mkclean_oneis for the dirty page tracking: so it's obvious why it testspte_dirty, but not obvious why it testspte_write.
Yes, the pte_write call is needed for shared dirty page tracking. In particular its needed for s390 but for corner cases where a page is writable but not dirty it might be needed for other architectures as well.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
My suspicion is that the "||
pte_write" is precisely to cover your s390 case where pte is never dirty (it may even have been me who got Peter to put it in for that reason). In which case your patch would be fine - though I think it'd be improved a lot by a comment or rearrangement or new macro in place of thepte_dirty||pte_writeline (perhaps adjust mypte_maybe_dirtyinasm-generic/pgtable.h, and use that - its former use in msync has gone away now).
Quoted 7 lines
Quoted 2 lines
No, s390 is covered by the
page_test_dirty/page_clear_dirtypair inpage_mkclean.That's where its dirty page count comes from, yes: but since the s390
pte_dirtyjust says no, ifpage_mkclean_onetested onlypte_dirty, then it wouldn't do anything on s390, and in particular wouldn't write protect the ptes to re-enforce dirty counting from then on.
Yes, I definitly agree that the pte_write is required for s390.
Quoted 3 lines
So in answering your denials, I grow more confident that the
pte_writetest is precisely for the s390 case. Though it might also be to cover some defect in the write-protection scheme on other arches.
Well, here I'm not so sure. You need the implication
pte_write() == true -> pte_dirty() == true
to be able to skip the pte_write check for architectures that keep their dirty bits in the pte. Is this really true for all corner-cases?
Quoted 7 lines
Come to think of it, would your patch really make any difference? Although page_mkclean's "count" of dirty ptes on s390 will be nonsense, that count would anyway be unknown, and it's only used as a boolean; and now I don't think your patch changes the boolean value - if any pte is found writable (and if the scheme is working) that implies that the page was written to, and so should give the same answer as the
page_test_dirty.
It depends on code outside of pte_mkclean_one if the patch makes a difference or not. The additional check for pte_dirty will make the function less suble as it will not depends on code outside of it. With the additional check for pte_dirty the function does the following:
1) make the pte clean, 2) make the pte read-only, 3) return true if the pte has been marked dirty.
Without the check the function does 1), 2) as above and 3) return true if the pte has been marked dirty or has been writable.
I find it easier to understand the semantics of the function with the additional check. But that is only me ..
Signature · 11 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin. -- 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>
Re: [patch 5/5] Optimize page_mkclean_one
In reply to Martin SchwidefskyQuoted 5 lines
page_mkclean_oneis used to clear the dirty bit and to set the write protect bit of a pte. In additions it returns true if the pte either has been dirty or if it has been writable. As far as I can see the function should return true only if the pte has been dirty, or page writeback will needlessly write a clean page.
There are some weird cases, like for example get_user_pages(), when the pte takes a write fault and the page is modified, but the pte doesn't become dirty, because the page is written through the kernel mapping.
In the get_user_pages() case the page itself is dirtied, so your patch probably doesn't break that. But I'm not sure if there aren't similar cases like that that the pte_write() check is taking care of.
And anyway if the dirty page tracking works correctly, your patch won't optimize anything, since the pte will _only_ become writable if the page was dirtied.
So in fact normally pte_dirty() and pte_write() should be equivalent, except for some weird cases.
Miklos
--
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>