mm: split 'tlb_flush_mmu()' into tlb flushing and memory freeing parts
Subsystems (8)
PATCH 1/1 mm: split 'tlb_flush_mmu()' into tlb flushing and memory freeing parts
From: Linus Torvalds <[email protected]>
Date: Fri, 25 Apr 2014 16:05:40 -0700
Subject: [PATCH] mm: split 'tlb_flush_mmu()' into tlb flushing and memory freeing parts
The mmu-gather operation 'tlb_flush_mmu()' has done two things: the actual tlb flush operation, and the batched freeing of the pages that the TLB entries pointed at.
This splits the operation into separate phases, so that the forced batched flushing done by zap_pte_range() can now do the actual TLB flush while still holding the page table lock, but delay the batched freeing of all the pages to after the lock has been dropped.
This in turn allows us to avoid a race condition between set_page_dirty() (as called by zap_pte_range() when it finds a dirty shared memory pte) and page_mkclean(): because we now flush all the dirty page data from the TLB's while holding the pte lock, page_mkclean() will be held up walking the (recently cleaned) page tables until after the TLB entries have been flushed from all CPU's.
---
Ok, this is now tentatively committed to my tree. I decided to just go ahead and do the ARM/ia64/sh parts blindly, since the splitup was fairly trivial (ia64 being slightly more complicated). I tested the UM one, at least as far as compiling. The others are totally untested, it would be good to make sure I didn't screw anything up.
The x86 and generic parts are the same that DaveH already tested and that got sent out a few days ago.
arch/arm/include/asm/tlb.h | 12 +++++++++- arch/ia64/include/asm/tlb.h | 42 ++++++++++++++++++++++++++--------- arch/s390/include/asm/tlb.h | 13 ++++++++++- arch/sh/include/asm/tlb.h | 8 +++++++ arch/um/include/asm/tlb.h | 16 ++++++++++++-- mm/memory.c | 53 +++++++++++++++++++++++++++++---------------- 6 files changed, 111 insertions(+), 33 deletions(-)
arch/arm/include/asm/tlb.h +11 -1
@@ -98,15 +98,25 @@ static inline void __tlb_alloc_page(struct mmu_gather *tlb) } } -static inline void tlb_flush_mmu (struct mmu_gather *tlb) +static inline void tlb_flush_mmu_tlbonly (struct mmu_gather *tlb) {tlb_flush (tlb); +} + +static inline void tlb_flush_mmu_free (struct mmu_gather *tlb) +{free_pages_and_swap_cache (tlb->pages, tlb->nr); tlb->nr =0 ;if (tlb->pages == tlb->local)__tlb_alloc_page (tlb); } +static inline void tlb_flush_mmu (struct mmu_gather *tlb) +{ +tlb_flush_mmu_tlbonly (tlb); +tlb_flush_mmu_free (tlb); +} +static inline void tlb_gather_mmu (struct mmu_gather *tlb,struct mm_struct *mm,unsigned long start,unsigned long end) {
arch/ia64/include/asm/tlb.h +32 -10
68 lines not on this page · raw message
arch/s390/include/asm/tlb.h +12 -1
@@ -59,12 +59,23 @@ static inline void tlb_gather_mmu(struct mmu_gather *tlb, tlb->batch =NULL ; } -static inline void tlb_flush_mmu (struct mmu_gather *tlb) +static inline void tlb_flush_mmu_tlbonly (struct mmu_gather *tlb) {__tlb_flush_mm_lazy (tlb->mm); +} + +static inline void tlb_flush_mmu_free (struct mmu_gather *tlb) +{tlb_table_flush (tlb); } + +static inline void tlb_flush_mmu (struct mmu_gather *tlb) +{ +tlb_flush_mmu_tlbonly (tlb); +tlb_flush_mmu_free (tlb); +} +static inline void tlb_finish_mmu (struct mmu_gather *tlb,unsigned long start,unsigned long end) {
arch/sh/include/asm/tlb.h +8 -0
@@ -86,6 +86,14 @@ tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma) } } +static inline void tlb_flush_mmu_tlbonly (struct mmu_gather *tlb) +{ +} + +static inline void tlb_flush_mmu_free (struct mmu_gather *tlb) +{ +} +static inline void tlb_flush_mmu (struct mmu_gather *tlb) { }
arch/um/include/asm/tlb.h +14 -2
@@ -59,13 +59,25 @@ extern void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, unsigned long end);static inline void +tlb_flush_mmu_tlbonly (struct mmu_gather *tlb) +{ +flush_tlb_mm_range (tlb->mm, tlb->start, tlb->end); +} + +static inline void +tlb_flush_mmu_free (struct mmu_gather *tlb) +{ +init_tlb_gather (tlb); +} + +static inline void tlb_flush_mmu (struct mmu_gather *tlb) {if (!tlb->need_flush)return ; -flush_tlb_mm_range (tlb->mm, tlb->start, tlb->end); -init_tlb_gather (tlb); +tlb_flush_mmu_tlbonly (tlb); +tlb_flush_mmu_free (tlb); }/* tlb_finish_mmu
mm/memory.c +34 -19
103 lines not on this page · raw message
Signature · 8 lines
2.0.0.rc1 -- 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>