Another go at speculative page faults
Subsystems (7)
Peter Zijlstra
maintainercover Another go at speculative page faults
Hi,
I figured I'd give my 2010 speculative fault series another spin:
https://lkml.org/lkml/2010/1/4/257
Since then I think many of the outstanding issues have changed sufficiently to warrant another go. In particular Al Viro's delayed fput seems to have made it entirely 'normal' to delay fput(). Lai Jiangshan's SRCU rewrite provided us with call_srcu() and my preemptible mmu_gather removed the TLB flushes from under the PTL.
The code needs way more attention but builds a kernel and runs the micro-benchmark so I figured I'd post it before sinking more time into it.
I realize the micro-bench is about as good as it gets for this series and not very realistic otherwise, but I think it does show the potential benefit the approach has.
(patches go against .18-rc1+)
---
Using Kamezawa's multi-fault micro-bench from: https://lkml.org/lkml/2010/1/6/28
My Ivy Bridge EP (2*10*2) has a ~58% improvement in pagefault throughput:
PRE:
root@ivb-ep:~# perf stat -e page-faults,cache-misses --repeat 5 ./multi-fault 20
Performance counter stats for './multi-fault 20' (5 runs):
149,441,555 page-faults ( +- 1.25% )
2,153,651,828 cache-misses ( +- 1.09% )60.003082014 seconds time elapsed ( +- 0.00% )
POST:
root@ivb-ep:~# perf stat -e page-faults,cache-misses --repeat 5 ./multi-fault 20
Performance counter stats for './multi-fault 20' (5 runs):
236,442,626 page-faults ( +- 0.08% )
2,796,353,939 cache-misses ( +- 1.01% )60.002792431 seconds time elapsed ( +- 0.00% )
My Ivy Bridge EX (4*15*2) has a ~78% improvement in pagefault throughput:
PRE:
root@ivb-ex:~# perf stat -e page-faults,cache-misses --repeat 5 ./multi-fault 60
Performance counter stats for './multi-fault 60' (5 runs):
105,789,078 page-faults ( +- 2.24% )
1,314,072,090 cache-misses ( +- 1.17% )60.009243533 seconds time elapsed ( +- 0.00% )
POST:
root@ivb-ex:~# perf stat -e page-faults,cache-misses --repeat 5 ./multi-fault 60
Performance counter stats for './multi-fault 60' (5 runs):
187,751,767 page-faults ( +- 2.24% )
1,792,758,664 cache-misses ( +- 2.30% )60.011611579 seconds time elapsed ( +- 0.00% )
(I've not yet looked at why the EX sucks chunks compared to the EP box, I
suspect we contend on other locks, but it could be anything.)
---
arch/x86/mm/fault.c | 35 ++- include/linux/mm.h | 19 +- include/linux/mm_types.h | 5 + kernel/fork.c | 1 + mm/init-mm.c | 1 + mm/internal.h | 18 ++ mm/memory.c | 672 ++++++++++++++++++++++++++++------------------- mm/mmap.c | 101 +++++-- 8 files changed, 544 insertions(+), 308 deletions(-)
--
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
maintainerRFC PATCH 1/6 mm: Dont assume page-table invariance during faults
One of the side effects of speculating on faults (without holding mmap_sem) is that we can race with free_pgtables() and therefore we cannot assume the page-tables will stick around.
Remove the relyance on the pte pointer.
--- mm/memory.c | 76 ++++++++++++++++-------------------------------------------- 1 file changed, 21 insertions(+), 55 deletions(-)
mm/memory.c +21 -55
@@ -1933,31 +1933,6 @@ int apply_to_page_range(struct mm_struct }EXPORT_SYMBOL_GPL (apply_to_page_range); -/* -* handle_pte_fault chooses page fault handler according to an entry -* which was read non-atomically. Before making any commitment, on -* those architectures or configurations (e.g. i386 with PAE) which -* might give a mix of unmatched parts, do_swap_page and do_nonlinear_fault -* must check under lock before unmapping the pte and proceeding -* (but do_wp_page is only called after already making such a check; -* and do_anonymous_page can safely check later on). -*/ -static inline int pte_unmap_same (struct mm_struct *mm,pmd_t *pmd, -pte_t *page_table,pte_t orig_pte) -{ -int same =1 ; -#if defined(CONFIG_SMP ) || defined(CONFIG_PREEMPT ) -if (sizeof (pte_t) >sizeof (unsigned long )) { -spinlock_t *ptl =pte_lockptr (mm, pmd); -spin_lock (ptl); - same =pte_same (*page_table, orig_pte); -spin_unlock (ptl); - } -#endif -pte_unmap (page_table); -return same; -} -static inline void cow_user_page (struct page *dst,struct page *src,unsigned long va,struct vm_area_struct *vma) {debug_dma_assert_idle (src);
@@ -2407,21 +2382,18 @@ EXPORT_SYMBOL(unmap_mapping_range);* as does filemap_fault(). */ static int do_swap_page (struct mm_struct *mm,struct vm_area_struct *vma, -unsigned long address,pte_t *page_table,pmd_t *pmd, +unsigned long address,pmd_t *pmd,unsigned int flags,pte_t orig_pte) {spinlock_t *ptl;struct page *page, *swapcache;struct mem_cgroup *memcg;swp_entry_t entry; -pte_t pte; +pte_t *page_table, pte;int locked;int exclusive =0 ;int ret =0 ; -if (!pte_unmap_same (mm, pmd, page_table, orig_pte)) - goto out; - entry =pte_to_swp_entry (orig_pte);if (unlikely (non_swap_entry (entry))) {if (is_migration_entry (entry)) {
@@ -2624,15 +2596,13 @@ static inline int check_stack_guard_page* We return with mmap_sem still held, but pte unmapped and unlocked. */ static int do_anonymous_page (struct mm_struct *mm,struct vm_area_struct *vma, -unsigned long address,pte_t *page_table,pmd_t *pmd, +unsigned long address,pmd_t *pmd,unsigned int flags) {struct mem_cgroup *memcg;struct page *page;spinlock_t *ptl; -pte_t entry; - -pte_unmap (page_table); +pte_t entry, *page_table;/* Check if we need to add a guard page to the stack */ if (check_stack_guard_page (vma, address) <0 )
@@ -3031,13 +3001,12 @@ static int do_shared_fault(struct mm_str* return value. See filemap_fault() and __lock_page_or_retry(). */ static int do_linear_fault (struct mm_struct *mm,struct vm_area_struct *vma, -unsigned long address,pte_t *page_table,pmd_t *pmd, +unsigned long address,pmd_t *pmd,unsigned int flags,pte_t orig_pte) {pgoff_t pgoff = (((address &PAGE_MASK ) - vma->vm_start) >>PAGE_SHIFT ) + vma->vm_pgoff; -pte_unmap (page_table);if (!(flags &FAULT_FLAG_WRITE ))return do_read_fault (mm, vma, address, pmd, pgoff, flags, orig_pte);
@@ -3059,16 +3028,13 @@ static int do_linear_fault(struct mm_str* return value. See filemap_fault() and __lock_page_or_retry(). */ static int do_nonlinear_fault (struct mm_struct *mm,struct vm_area_struct *vma, -unsigned long address,pte_t *page_table,pmd_t *pmd, +unsigned long address,pmd_t *pmd,unsigned int flags,pte_t orig_pte) {pgoff_t pgoff; flags |=FAULT_FLAG_NONLINEAR ; -if (!pte_unmap_same (mm, pmd, page_table, orig_pte)) -return 0 ; -if (unlikely (!(vma->vm_flags &VM_NONLINEAR ))) {/* * Page table corrupted: show pte and kill process.
@@ -3103,7 +3069,7 @@ static int numa_migrate_prep(struct page }static int do_numa_page (struct mm_struct *mm,struct vm_area_struct *vma, -unsigned long addr,pte_t pte,pte_t *ptep,pmd_t *pmd) +unsigned long addr,pte_t pte,pmd_t *pmd) {struct page *page =NULL ;spinlock_t *ptl;
@@ -3112,6 +3078,7 @@ static int do_numa_page(struct mm_structint target_nid;bool migrated = false;int flags =0 ; +pte_t *ptep;/* * The "pte" at this point cannot be used safely without
@@ -3122,8 +3089,7 @@ static int do_numa_page(struct mm_struct* the _PAGE_NUMA bit and it is not really expected that there * would be concurrent hardware modifications to the PTE. */ - ptl =pte_lockptr (mm, pmd); -spin_lock (ptl); + ptep =pte_offset_map_lock (mm, pmd, addr, &ptl);if (unlikely (!pte_same (*ptep, pte))) {pte_unmap_unlock (ptep, ptl); goto out;
@@ -3195,34 +3161,32 @@ static int do_numa_page(struct mm_struct*/ static int handle_pte_fault (struct mm_struct *mm,struct vm_area_struct *vma,unsigned long address, -pte_t *pte,pmd_t *pmd,unsigned int flags) +pte_t entry,pmd_t *pmd,unsigned int flags) { -pte_t entry;spinlock_t *ptl; +pte_t *pte; - entry =ACCESS_ONCE (*pte);if (!pte_present (entry)) {if (pte_none (entry)) {if (vma->vm_ops) {if (likely (vma->vm_ops->fault))return do_linear_fault (mm, vma, address, - pte, pmd, flags, entry); + pmd, flags, entry); }return do_anonymous_page (mm, vma, address, - pte, pmd, flags); + pmd, flags); }if (pte_file (entry))return do_nonlinear_fault (mm, vma, address, - pte, pmd, flags, entry); + pmd, flags, entry);return do_swap_page (mm, vma, address, - pte, pmd, flags, entry); + pmd, flags, entry); }if (pte_numa (entry)) -return do_numa_page (mm, vma, address, entry, pte, pmd); +return do_numa_page (mm, vma, address, entry, pmd); - ptl =pte_lockptr (mm, pmd); -spin_lock (ptl); + pte =pte_offset_map_lock (mm, pmd, address, &ptl);if (unlikely (!pte_same (*pte, entry))) goto unlock;if (flags &FAULT_FLAG_WRITE ) {
@@ -3261,7 +3225,7 @@ static int __handle_mm_fault(struct mm_spgd_t *pgd;pud_t *pud;pmd_t *pmd; -pte_t *pte; +pte_t *pte, entry;if (unlikely (is_vm_hugetlb_page (vma)))return hugetlb_fault (mm, vma, address, flags);
@@ -3331,8 +3295,10 @@ static int __handle_mm_fault(struct mm_s* safe to run pte_offset_map(). */ pte =pte_offset_map (pmd, address); + entry =ACCESS_ONCE (*pte); +pte_unmap (pte); -return handle_pte_fault (mm, vma, address, pte, pmd, flags); +return handle_pte_fault (mm, vma, address, entry, pmd, flags); }/*
--
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
maintainerRFC PATCH 2/6 mm: Prepare for FAULT_FLAG_SPECULATIVE
In reply to Peter ZijlstraWhen speculating faults (without holding mmap_sem) we need to validate that the vma against which we loaded pages is still valid when we're ready to install the new PTE.
Therefore, replace the pte_offset_map_lock() calls that (re)take the PTL with pte_map_lock() which can fail in case we find the VMA changed since we started the fault.
Instead of passing around the endless list of function arguments, replace the lot with a single structure so we can change context without endless function signature changes.
XXX: split this patch into two parts, the first which introduces fault_env and the second doing the pte_map_lock bit.
--- include/linux/mm.h | 17 - mm/memory.c | 522 +++++++++++++++++++++++++++++------------------------ 2 files changed, 297 insertions(+), 242 deletions(-)
include/linux/mm.h +9 -8
@@ -187,14 +187,15 @@ extern unsigned int kobjsize(const void*/ extern pgprot_t protection_map[16 ]; -#define FAULT_FLAG_WRITE 0x01/* Fault was a write access */ -#define FAULT_FLAG_NONLINEAR 0x02/* Fault was via a nonlinear mapping */ -#define FAULT_FLAG_MKWRITE 0x04/* Fault was mkwrite of existing pte */ -#define FAULT_FLAG_ALLOW_RETRY 0x08/* Retry fault if blocking */ -#define FAULT_FLAG_RETRY_NOWAIT 0x10/* Don't drop mmap_sem and wait when retrying */ -#define FAULT_FLAG_KILLABLE 0x20/* The fault task is in SIGKILL killable region */ -#define FAULT_FLAG_TRIED 0x40/* second try */ -#define FAULT_FLAG_USER 0x80/* The fault originated in userspace */ +#define FAULT_FLAG_WRITE 0x001/* Fault was a write access */ +#define FAULT_FLAG_NONLINEAR 0x002/* Fault was via a nonlinear mapping */ +#define FAULT_FLAG_MKWRITE 0x004/* Fault was mkwrite of existing pte */ +#define FAULT_FLAG_ALLOW_RETRY 0x008/* Retry fault if blocking */ +#define FAULT_FLAG_RETRY_NOWAIT 0x010/* Don't drop mmap_sem and wait when retrying */ +#define FAULT_FLAG_KILLABLE 0x020/* The fault task is in SIGKILL killable region */ +#define FAULT_FLAG_TRIED 0x040/* second try */ +#define FAULT_FLAG_USER 0x080/* The fault originated in userspace */ +#define FAULT_FLAG_SPECULATIVE 0x100/* Speculative fault, not holding mmap_sem */ /* * vm_fault is filled by the the pagefault handler and passed to the vma's
mm/memory.c +288 -234
1,000 lines not on this page · raw message
--
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
maintainerRFC PATCH 3/6 mm: VMA sequence count
In reply to Peter ZijlstraWrap the VMA modifications (vma_adjust/unmap_page_range) with sequence counts such that we can easily test if a VMA is changed.
The unmap_page_range() one allows us to make assumptions about page-tables; when we find the seqcount hasn't changed we can assume page-tables are still valid.
The flip side is that we cannot distinguish between a vma_adjust() and the unmap_page_range() -- where with the former we could have re-checked the vma bounds against the address.
--- include/linux/mm_types.h | 2 ++ mm/memory.c | 2 ++ mm/mmap.c | 13 +++++++++++++ 3 files changed, 17 insertions(+)
include/linux/mm_types.h +2 -0
@@ -13,6 +13,7 @@#include <linux/page-debug-flags.h> #include <linux/uprobes.h> #include <linux/page-flags-layout.h> +#include <linux/seqlock.h> #include <asm/page.h> #include <asm/mmu.h>
@@ -308,6 +309,7 @@ struct vm_area_struct {#ifdef CONFIG_NUMA struct mempolicy *vm_policy;/* NUMA policy for the VMA */ #endif +seqcount_t vm_sequence; };struct core_thread {
mm/memory.c +2 -0
@@ -1293,6 +1293,7 @@ static void unmap_page_range(struct mmu_ details =NULL ;BUG_ON (addr >= end); +write_seqcount_begin (&vma->vm_sequence);tlb_start_vma (tlb, vma); pgd =pgd_offset (vma->vm_mm, addr); do {
@@ -1302,6 +1303,7 @@ static void unmap_page_range(struct mmu_ next =zap_pud_range (tlb, vma, pgd, addr, next, details); }while (pgd++, addr = next, addr != end);tlb_end_vma (tlb, vma); +write_seqcount_end (&vma->vm_sequence); }
mm/mmap.c +13 -0
@@ -596,6 +596,8 @@ void __vma_link_rb(struct mm_struct *mm,else mm->highest_vm_end = vma->vm_end; +seqcount_init (&vma->vm_sequence); +/* * vma->vm_prev wasn't known when we followed the rbtree to find the * correct insertion point for that vma. As a result, we could not
@@ -715,6 +717,10 @@ int vma_adjust(struct vm_area_struct *vmlong adjust_next =0 ;int remove_next =0 ; +write_seqcount_begin (&vma->vm_sequence); +if (next) +write_seqcount_begin_nested (&next->vm_sequence,SINGLE_DEPTH_NESTING ); +if (next && !insert) {struct vm_area_struct *exporter =NULL ;
@@ -880,7 +886,10 @@ again: remove_next = 1 + (end > next->* we must remove another next too. It would clutter * up the code too much to do both in one go. */ +write_seqcount_end (&next->vm_sequence); next = vma->vm_next; +write_seqcount_begin_nested (&next->vm_sequence,SINGLE_DEPTH_NESTING ); +if (remove_next ==2 ) goto again;else if (next)
@@ -891,6 +900,10 @@ again: remove_next = 1 + (end > next->if (insert && file)uprobe_mmap (insert); +if (next) +write_seqcount_end (&next->vm_sequence); +write_seqcount_end (&vma->vm_sequence); +validate_mm (mm);return 0 ;
--
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: [RFC][PATCH 3/6] mm: VMA sequence count
Quoted 10 lines · Peter Zijlstra
Wrap the VMA modifications (vma_adjust/unmap_page_range) with sequence counts such that we can easily test if a VMA is changed.
The
unmap_page_range()one allows us to make assumptions about page-tables; when we find the seqcount hasn't changed we can assume page-tables are still valid.The flip side is that we cannot distinguish between a
vma_adjust()and theunmap_page_range()-- where with the former we could have re-checked the vma bounds against the address.
You only took care about changing size of VMA or unmap. What about other aspects of VMA. How would you care about race with mprotect(2)?
CPU0 CPU1
mprotect()
mprotect_fixup()
vma_merge()
[ maybe update vm_sequence ]
[ page fault kicks in ]
do_anonymous_page()
entry = mk_pte(page, fe->vma->vm_page_prot);
vma_set_page_prot(vma)
[ update vma->vm_page_prot ]
change_protection()
pte_map_lock()
[ vm_sequence is ok ]
set_pte_at(entry) // With old vm_page_prot!!!
This can end up a security issue.
This particular case can be fixed pretty easily: we should move vm_page_prot reference under the ptl and make sure that we walk over virtual addresses in same (direct) order everywhere (this is seems true).
But who knows what else we're missing?
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>
Peter Zijlstra
maintainerRe: [RFC][PATCH 3/6] mm: VMA sequence count
Quoted 16 lines · Kirill A. Shutemov
Quoted 10 lines · Peter Zijlstra
Wrap the VMA modifications (vma_adjust/unmap_page_range) with sequence counts such that we can easily test if a VMA is changed.
The
unmap_page_range()one allows us to make assumptions about page-tables; when we find the seqcount hasn't changed we can assume page-tables are still valid.The flip side is that we cannot distinguish between a
vma_adjust()and theunmap_page_range()-- where with the former we could have re-checked the vma bounds against the address.You only took care about changing size of VMA or unmap. What about other aspects of VMA. How would you care about race with mprotect(2)?
CPU0 CPU1
Quoted 14 lines
mprotect()
mprotect_fixup()
vma_merge()
[ maybe updatevm_sequence]
[ page fault kicks in ]
do_anonymous_page()
entry =mk_pte(page, fe->vma->vm_page_prot);
vma_set_page_prot(vma)
[ updatevma->vm_page_prot]
change_protection()
pte_map_lock()
[vm_sequenceis ok ]
set_pte_at(entry)// With oldvm_page_prot!!!
This won't happen, this is be serialized by the PTL and the fault validates that the PTE is the 'same' it started out with after acquiring the PTL.
Re: [RFC][PATCH 3/6] mm: VMA sequence count
Quoted 32 lines · Peter Zijlstra
Quoted 16 lines · Kirill A. Shutemov
Quoted 10 lines · Peter Zijlstra
Wrap the VMA modifications (vma_adjust/unmap_page_range) with sequence counts such that we can easily test if a VMA is changed.
The
unmap_page_range()one allows us to make assumptions about page-tables; when we find the seqcount hasn't changed we can assume page-tables are still valid.The flip side is that we cannot distinguish between a
vma_adjust()and theunmap_page_range()-- where with the former we could have re-checked the vma bounds against the address.You only took care about changing size of VMA or unmap. What about other aspects of VMA. How would you care about race with mprotect(2)?
CPU0 CPU1Quoted 14 lines
mprotect()
mprotect_fixup()
vma_merge()
[ maybe updatevm_sequence]
[ page fault kicks in ]
do_anonymous_page()
entry =mk_pte(page, fe->vma->vm_page_prot);
vma_set_page_prot(vma)
[ updatevma->vm_page_prot]
change_protection()
pte_map_lock()
[vm_sequenceis ok ]
set_pte_at(entry)// With oldvm_page_prot!!!
Quoted 3 lines
This won't happen, this is be serialized by the PTL and the fault validates that the PTE is the 'same' it started out with after acquiring the PTL.
Em, no. In this case change_protection() will not touch the pte, since it's pte_none() and the pte_same() check will pass just fine.
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>
Peter Zijlstra
maintainerRe: [RFC][PATCH 3/6] mm: VMA sequence count
Quoted 2 lines · Kirill A. Shutemov
Em, no. In this case
change_protection()will not touch the pte, since it'spte_none()and thepte_same()check will pass just fine.
Oh, that's what you meant. Yes that's a problem, yes vm_page_prot needs wrapping too.
--
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: [RFC][PATCH 3/6] mm: VMA sequence count
Quoted 6 lines · Peter Zijlstra
Quoted 2 lines · Kirill A. Shutemov
Em, no. In this case
change_protection()will not touch the pte, since it'spte_none()and thepte_same()check will pass just fine.Oh, that's what you meant. Yes that's a problem, yes
vm_page_protneeds wrapping too.
Maybe also vm_policy, is there anything else that can change while a vma lives?
--
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: [RFC][PATCH 3/6] mm: VMA sequence count
Quoted 10 lines · Peter Zijlstra
Quoted 6 lines · Peter Zijlstra
Quoted 2 lines · Kirill A. Shutemov
Em, no. In this case
change_protection()will not touch the pte, since it'spte_none()and thepte_same()check will pass just fine.Oh, that's what you meant. Yes that's a problem, yes
vm_page_protneeds wrapping too.Maybe also
vm_policy, is there anything else that can change while a vma lives?
- vm_flags, obviously;
- shared, anon_vma and anon_vma_chain (at least on the first write fault to private mapping);
- vm_pgoff (mremap(2) ?);
- vm_private_data -- it's all over drivers. Potential nightmare, but seems not in use for anon mappings.
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>
Peter Zijlstra
maintainerRe: [RFC][PATCH 3/6] mm: VMA sequence count
Quoted 6 lines · Kirill A. Shutemov
Quoted 5 lines · Peter Zijlstra
Quoted 4 lines · Peter Zijlstra
Quoted 2 lines · Kirill A. Shutemov
Em, no. In this case
change_protection()will not touch the pte, since it'spte_none()and thepte_same()check will pass just fine.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Oh, that's what you meant. Yes that's a problem, yes
vm_page_protneeds wrapping too.Maybe also
vm_policy, is there anything else that can change while a vma lives?-
vm_flags, obviously;
Do those ever change? The only thing that jumps out is the VM_LOCKED thing and that should not really matter one way or the other, but sure can do.
Quoted 3 lines
- shared,
anon_vmaandanon_vma_chain(at least on the first write fault to private mapping);
-vm_pgoff(mremap(2) ?);
Right you are. Never thought about that one.
Quoted 2 lines
-
vm_private_data-- it's all over drivers. Potential nightmare, but seems not in use for anon mappings.
Yeah, we need to either audit drivers or otherwise exclude stuff from speculative faults, Andy already noted that drivers might not expect .fault after .close or whatnot.
In any case, yes I'll go include them.
--
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: [RFC][PATCH 3/6] mm: VMA sequence count
Quoted 10 lines · Peter Zijlstra
Quoted 9 lines · Kirill A. Shutemov
Quoted 8 lines · Peter Zijlstra
Quoted 6 lines · Peter Zijlstra
Quoted 2 lines · Kirill A. Shutemov
Em, no. In this case
change_protection()will not touch the pte, since it'spte_none()and thepte_same()check will pass just fine.Oh, that's what you meant. Yes that's a problem, yes
vm_page_protneeds wrapping too.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Maybe also
vm_policy, is there anything else that can change while a vma lives?-
vm_flags, obviously;Do those ever change?
The flags which can change (probably incomplete):
- prot-related: VM_READ, VM_WRITE, VM_EXEC -- mprotect();
- VM_LOCKED - mlock();
- VM_SEQ_READ, VM_RAND_READ, VM_DONTCOPY, VM_DONTDUMP, VM_HUGEPAGE, VM_NOHUGEPAGE, VM_MERGEABLE -- madvise();
- VM_SOFTDIRTY -- through procfs;
Quoted 2 lines
The only thing that jumps out is the
VM_LOCKEDthing and that should not really matter one way or the other, but sure can do.
I would not be that sure about VM_LOCKED. Consider munlock() vs. write fault race.
static int do_wp_page(struct fault_env *fe)
__releases(ptl)
{
...
err:
if (old_page) {
/*
* Don't let another task, with possibly unlocked vma,
* keep the mlocked page.
*/
if ((ret & VM_FAULT_WRITE) && (fe->vma->vm_flags & VM_LOCKED)) {
lock_page(old_page); /* LRU manipulation */
munlock_vma_page(old_page);
unlock_page(old_page);
}
page_cache_release(old_page);
}
return ret;...
}
The page can leak out mlocked, iiuc.
Some other flags can be problematic too.
Quoted 1 line
In any case, yes I'll go include them.
I hope it will not hurt single-threaded workloads even more. :-/
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>
Peter Zijlstra
maintainerRFC PATCH 4/6 SRCU free VMAs
In reply to Peter ZijlstraManage the VMAs with SRCU such that we can do a lockless VMA lookup.
We put the fput(vma->vm_file) in the SRCU callback, this keeps files valid during speculative faults, this is possible due to the delayed fput work by Al Viro -- do we need srcu_barrier() in unmount someplace?
We guard the mm_rb tree with a seqlock (XXX could be a seqcount but we'd have to disable preemption around the write side in order to make the retry loop in __read_seqcount_begin() work) such that we can know if the rb tree walk was correct. We cannot trust the restult of a lockless tree walk in the face of concurrent tree rotations; although we can trust on the termination of such walks -- tree rotations guarantee the end result is a tree again after all.
Furthermore, we rely on the WMB implied by the write_seqlock/count_begin() to separate the VMA initialization and the publishing stores, analogous to the RELEASE in rcu_assign_pointer(). We also rely on the RMB from read_seqretry() to separate the vma load from further loads like the smp_read_barrier_depends() in regular RCU.
We must not touch the vmacache while doing SRCU lookups as that is not properly serialized against changes. We update gap information after publishing the VMA, but A) we don't use that and B) the seqlock read side would fix that anyhow.
We clear vma->vm_rb for nodes removed from the vma tree such that we can easily detect such 'dead' nodes, we rely on the WMB from write_sequnlock() to separate the tree removal and clearing the node.
Provide find_vma_srcu() which wraps the required magic.
XXX: mmap()/munmap() heavy workloads might suffer from the global lock in call_srcu() -- this is fixable with a 'better' SRCU implementation.
--- include/linux/mm_types.h | 3 + kernel/fork.c | 1 mm/init-mm.c | 1 mm/internal.h | 18 +++++++++ mm/mmap.c | 88 ++++++++++++++++++++++++++++++++++++----------- 5 files changed, 91 insertions(+), 20 deletions(-)
include/linux/mm_types.h +3 -0
@@ -14,6 +14,7 @@#include <linux/uprobes.h> #include <linux/page-flags-layout.h> #include <linux/seqlock.h> +#include <linux/srcu.h> #include <asm/page.h> #include <asm/mmu.h>
@@ -310,6 +311,7 @@ struct vm_area_struct {struct mempolicy *vm_policy;/* NUMA policy for the VMA */ #endif seqcount_t vm_sequence; +struct rcu_head vm_rcu_head; };struct core_thread {
@@ -347,6 +349,7 @@ struct kioctx_table;struct mm_struct {struct vm_area_struct *mmap;/* list of VMAs */ struct rb_root mm_rb; +seqlock_t mm_seq;u32 vmacache_seqnum;/* per-thread vmacache */ #ifdef CONFIG_MMU unsigned long (*get_unmapped_area) (struct file *filp,
kernel/fork.c +1 -0
@@ -553,6 +553,7 @@ static struct mm_struct *mm_init(struct mm->mmap =NULL ; mm->mm_rb =RB_ROOT ; mm->vmacache_seqnum =0 ; +seqlock_init (&mm->mm_seq);atomic_set (&mm->mm_users,1 );atomic_set (&mm->mm_count,1 );init_rwsem (&mm->mmap_sem);
mm/init-mm.c +1 -0
@@ -15,6 +15,7 @@struct mm_struct init_mm = { .mm_rb =RB_ROOT , + .mm_seq =__SEQLOCK_UNLOCKED (init_mm.mm_seq), .pgd = swapper_pg_dir, .mm_users =ATOMIC_INIT (2 ), .mm_count =ATOMIC_INIT (1 ),
mm/internal.h +18 -0
@@ -14,6 +14,24 @@#include <linux/fs.h> #include <linux/mm.h> +extern struct srcu_struct vma_srcu; + +extern struct vm_area_struct *find_vma_srcu (struct mm_struct *mm,unsigned long addr); + +static inline bool vma_is_dead (struct vm_area_struct *vma,unsigned int sequence) +{ +int ret =RB_EMPTY_NODE (&vma->vm_rb); +unsigned seq =ACCESS_ONCE (vma->vm_sequence.sequence); + +/* +* Matches both the wmb in write_seqlock_{begin,end}() and +* the wmb in vma_rb_erase(). +*/ +smp_rmb (); + +return ret || seq != sequence; +} +void free_pgtables (struct mmu_gather *tlb,struct vm_area_struct *start_vma,unsigned long floor,unsigned long ceiling);
mm/mmap.c +68 -20
176 lines not on this page · raw message
Re: [RFC][PATCH 4/6] SRCU free VMAs
Quoted 1 line · Peter Zijlstra
Manage the VMAs with SRCU such that we can do a lockless VMA lookup.
Can you explain why srcu, and not plain regular rcu?
Especially as you then *note* some of the problems srcu can have. Making it regular rcu would also seem to make it possible to make the seqlock be just a seqcount, no?
Linus
--
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: [RFC][PATCH 4/6] SRCU free VMAs
Quoted 8 lines · Linus Torvalds
Quoted 1 line · Peter Zijlstra
Manage the VMAs with SRCU such that we can do a lockless VMA lookup.
Can you explain why srcu, and not plain regular rcu?
Especially as you then *note* some of the problems srcu can have. Making it regular rcu would also seem to make it possible to make the seqlock be just a seqcount, no?
Because we need to hold onto the RCU read side lock across the entire fault, which can involve IO and all kinds of other blocking ops.
--
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: [RFC][PATCH 4/6] SRCU free VMAs
Quoted 4 lines · Peter Zijlstra
Quoted 3 lines · Linus Torvalds
Quoted 1 line · Peter Zijlstra
Manage the VMAs with SRCU such that we can do a lockless VMA lookup.
Quoted 8 lines
Quoted 5 lines
Can you explain why srcu, and not plain regular rcu?
Especially as you then *note* some of the problems srcu can have. Making it regular rcu would also seem to make it possible to make the seqlock be just a seqcount, no?
Because we need to hold onto the RCU read side lock across the entire fault, which can involve IO and all kinds of other blocking ops.
Hmmm... One optimization to do before we get into these changes is to work on allowing the dropping of mmap_sem before we get to sleeping and I/O and then reevaluate when I/O etc is complete? This is probably the longest hold on mmap_sem that is also frequent. Then it may be easier to use standard RCU later.
--
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: [RFC][PATCH 4/6] SRCU free VMAs
Quoted 5 lines · Christoph Lameter
Hmmm... One optimization to do before we get into these changes is to work on allowing the dropping of
mmap_sembefore we get to sleeping and I/O and then reevaluate when I/O etc is complete? This is probably the longest hold onmmap_semthat is also frequent. Then it may be easier to use standard RCU later.
The hold time isn't relevant, in fact breaking up the mmap_sem such that we require multiple acquisitions will just increase the cacheline bouncing.
Also I think it makes more sense to continue an entire fault operation, including blocking, if at all possible. Every retry will just waste more time.
Also, there is a lot of possible blocking, there's lock_page, page_mkwrite() -- which ends up calling into the dirty throttle etc. We could not possibly retry on all that, the error paths involved would be horrible for one.
That said, there's a fair bit of code that does allow the retry, and I think most fault paths actually do the retry on IO.
--
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: [RFC][PATCH 4/6] SRCU free VMAs
Quoted 3 lines · Peter Zijlstra
The hold time isn't relevant, in fact breaking up the
mmap_semsuch that we require multiple acquisitions will just increase the cacheline bouncing.
Well this wont be happening anymore once you RCUify the stuff. If you go to sleep then its best to release mmap_sem and then the bouncing wont matter.
Dropping mmap_sem there will also expose you to races you will see later too when you RCUify the code paths. That way those can be deal with beforehand.
Quoted 3 lines
Also I think it makes more sense to continue an entire fault operation, including blocking, if at all possible. Every retry will just waste more time.
Ok then dont retry. Just drop mmap_sem before going to sleep. When you come back evaluate the situation and if we can proceed do so otherwise retry.
--
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: [RFC][PATCH 4/6] SRCU free VMAs
In reply to Linus TorvaldsQuoted 8 lines · Linus Torvalds
Quoted 1 line · Peter Zijlstra
Manage the VMAs with SRCU such that we can do a lockless VMA lookup.
Can you explain why srcu, and not plain regular rcu?
Especially as you then *note* some of the problems srcu can have. Making it regular rcu would also seem to make it possible to make the seqlock be just a seqcount, no?
Ah, the reason I did the seqlock is because the read side will spin-wait for &1 to go away. If the write side is preemptible that's horrid. I used seqlock because that takes a lock (and thus disables preemption) on the write side, but I could equally have done:
preempt_disable(); write_seqcount_begin(); ... write_seqcount_end(); preempt_disable();
Since the lock is indeed superfluous, we're already fully serialized by mmap_sem in this path.
Using regular RCU isn't sufficient, because of PREEMPT_RCU.
--
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: [RFC][PATCH 4/6] SRCU free VMAs
In reply to Peter Zijlstramm/mmap.c struct vm_area_struct *find_vma(struct m · line 2106
Quoted 12 lines
mm/mmap.c +10
-0+struct vm_area_struct *find_vma_srcu (struct mm_struct *mm,unsigned long addr) +{ +struct vm_area_struct *vma; +unsigned int seq; + +WARN_ON_ONCE (!srcu_read_lock_held (&vma_srcu)); + + do { + seq = read_seqbegin(&mm->mm_seq); + vma = __find_vma(mm, addr);
will the __find_vma() loops for ever due to the rotations in the RBtree?
mm/mmap.c struct vm_area_struct *find_vma(struct m · line 2110
Quoted 4 lines
mm/mmap.c +4
-0+ }while (read_seqretry (&mm->mm_seq, seq)); + +return vma; +}
--
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: [RFC][PATCH 4/6] SRCU free VMAs
Quoted 14 lines · Lai Jiangshan
mm/mmap.c struct vm_area_struct *find_vma(struct m · line 2106
Quoted 12 lines
mm/mmap.c +10
-0+struct vm_area_struct *find_vma_srcu (struct mm_struct *mm,unsigned long addr) +{ +struct vm_area_struct *vma; +unsigned int seq; + +WARN_ON_ONCE (!srcu_read_lock_held (&vma_srcu)); + + do { + seq = read_seqbegin(&mm->mm_seq); + vma = __find_vma(mm, addr);will the
__find_vma()loops for ever due to the rotations in the RBtree?
No, a rotation takes a tree and generates a tree, furthermore the rotation has a fairly strict fwd progress guarantee seeing how its now done with preemption disabled.
Therefore, even if we're in a node that's being rotated up, we can only 'loop' for as long as it takes for the new pointer stores to become visible on our CPU.
Thus we have a tree descent termination guarantee.
--
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: [RFC][PATCH 4/6] SRCU free VMAs
Quoted 16 lines · Peter Zijlstra
Quoted 14 lines · Lai Jiangshan
mm/mmap.c struct vm_area_struct *find_vma(struct m · line 2106
Quoted 12 lines
mm/mmap.c +10
-0+struct vm_area_struct *find_vma_srcu (struct mm_struct *mm,unsigned long addr) +{ +struct vm_area_struct *vma; +unsigned int seq; + +WARN_ON_ONCE (!srcu_read_lock_held (&vma_srcu)); + + do { + seq = read_seqbegin(&mm->mm_seq); + vma = __find_vma(mm, addr);will the
__find_vma()loops for ever due to the rotations in the RBtree?
Quoted 3 lines
No, a rotation takes a tree and generates a tree, furthermore the rotation has a fairly strict fwd progress guarantee seeing how its now done with preemption disabled.
I can't get the magic.
__find_vma is visiting vma_a,vma_a is rotated to near the top due to multiple updates to the mm. __find_vma is visiting down to near the bottom, vma_b. now vma_b is rotated up to near the top again. __find_vma is visiting down to near the bottom, vma_c. now vma_c is rotated up to near the top again.
...
Quoted 8 lines
Therefore, even if we're in a node that's being rotated up, we can only 'loop' for as long as it takes for the new pointer stores to become visible on our CPU.
Thus we have a tree descent termination guarantee. .
--
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: [RFC][PATCH 4/6] SRCU free VMAs
Quoted 23 lines · Lai Jiangshan
Quoted 16 lines · Peter Zijlstra
Quoted 14 lines · Lai Jiangshan
mm/mmap.c struct vm_area_struct *find_vma(struct m · line 2106
Quoted 12 lines
mm/mmap.c +10
-0+struct vm_area_struct *find_vma_srcu (struct mm_struct *mm,unsigned long addr) +{ +struct vm_area_struct *vma; +unsigned int seq; + +WARN_ON_ONCE (!srcu_read_lock_held (&vma_srcu)); + + do { + seq = read_seqbegin(&mm->mm_seq); + vma = __find_vma(mm, addr);will the
__find_vma()loops for ever due to the rotations in the RBtree?Quoted 3 lines
No, a rotation takes a tree and generates a tree, furthermore the rotation has a fairly strict fwd progress guarantee seeing how its now done with preemption disabled.
I can't get the magic.
Quoted 8 lines
__find_vmais visitingvma_a,vma_ais rotated to near the top due to multiple updates to the mm.__find_vmais visiting down to near the bottom,vma_b. nowvma_bis rotated up to near the top again.__find_vmais visiting down to near the bottom,vma_c. nowvma_cis rotated up to near the top again....
Why would there be that much rotations? Is this a scenario where someone is endlessly changing the tree?
If you stop updating the tree, the traversal will finish.
This is no different to the reader starvation already present with seqlocks.
--
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
maintainerRFC PATCH 5/6 mm: Provide speculative fault infrastructure
In reply to Peter ZijlstraProvide infrastructure to do a speculative fault (not holding mmap_sem).
The not holding of mmap_sem means we can race against VMA change/removal and page-table destruction. We use the SRCU VMA freeing to keep the VMA around. We use the VMA seqcount to detect change (including umapping / page-table deletion) and we use gup_fast() style page-table walking to deal with page-table races.
Once we've obtained the page and are ready to update the PTE, we validate if the state we started the fault with is still valid, if not, we'll fail the fault with VM_FAULT_RETRY, otherwise we update the PTE and we're done.
--- include/linux/mm.h | 2 mm/memory.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 119 insertions(+), 1 deletion(-)
include/linux/mm.h +2 -0
@@ -1162,6 +1162,8 @@ int generic_error_remove_page(struct addint invalidate_inode_page (struct page *page);#ifdef CONFIG_MMU +extern int handle_speculative_fault (struct mm_struct *mm, +unsigned long address,unsigned int flags);extern int handle_mm_fault (struct mm_struct *mm,struct vm_area_struct *vma,unsigned long address,unsigned int flags); extern int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm,
mm/memory.c +117 -1
141 lines not on this page · raw message
--
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: [RFC][PATCH 5/6] mm: Provide speculative fault infrastructure
Quoted 125 lines · Peter Zijlstra
Provide infrastructure to do a speculative fault (not holding
mmap_sem).The not holding of
mmap_semmeans we can race against VMA change/removal and page-table destruction. We use the SRCU VMA freeing to keep the VMA around. We use the VMA seqcount to detect change (including umapping / page-table deletion) and we usegup_fast()style page-table walking to deal with page-table races.Once we've obtained the page and are ready to update the PTE, we validate if the state we started the fault with is still valid, if not, we'll fail the fault with
VM_FAULT_RETRY, otherwise we update the PTE and we're done.Signed-off-by Peter Zijlstra (Intel) <[email protected]>--- include/linux/mm.h | 2 mm/memory.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 119 insertions(+), 1 deletion(-)include/linux/mm.h +2
-0@@ -1162,6 +1162,8 @@ int generic_error_remove_page(struct addint invalidate_inode_page (struct page *page);#ifdef CONFIG_MMU +extern int handle_speculative_fault (struct mm_struct *mm, +unsigned long address,unsigned int flags);extern int handle_mm_fault (struct mm_struct *mm,struct vm_area_struct *vma,unsigned long address,unsigned int flags); extern int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm,mm/memory.c +68
-1@@ -2004,12 +2004,40 @@ struct fault_env {pte_t entry;spinlock_t *ptl;unsigned int flags; +unsigned int sequence; };static bool pte_map_lock (struct fault_env *fe) { +bool ret = false; + +if (!(fe->flags &FAULT_FLAG_SPECULATIVE )) { + fe->pte =pte_offset_map_lock (fe->mm, fe->pmd, fe->address, &fe->ptl); +return true; + } + +/* +* The first vma_is_dead() guarantees the page-tables are still valid, +* having IRQs disabled ensures they stay around, hence the second +* vma_is_dead() to make sure they are still valid once we've got the +* lock. After that a concurrent zap_pte_range() will block on the PTL +* and thus we're safe. +*/ +local_irq_disable (); +if (vma_is_dead (fe->vma, fe->sequence)) + goto out; + fe->pte =pte_offset_map_lock (fe->mm, fe->pmd, fe->address, &fe->ptl); -return true; + +if (vma_is_dead (fe->vma, fe->sequence)) { +pte_unmap_unlock (fe->pte, fe->ptl); + goto out; + } + + ret = true; +out: +local_irq_enable (); +return ret; }/* @@ -2432,6 +2460,7 @@ static int do_swap_page(struct fault_env entry =pte_to_swp_entry (fe->entry);if (unlikely (non_swap_entry (entry))) {if (is_migration_entry (entry)) { +/* XXX fe->pmd might be dead */ migration_entry_wait (fe->mm, fe->pmd, fe->address); }else if (is_hwpoison_entry (entry)) { ret =VM_FAULT_HWPOISON ;@@ -3357,6 +3386,93 @@ static int __handle_mm_fault(struct mm_sreturn handle_pte_fault (&fe); } +int handle_speculative_fault (struct mm_struct *mm,unsigned long address,unsigned int flags) +{ +struct fault_env fe = { + .mm = mm, + .address = address, + .flags = flags |FAULT_FLAG_SPECULATIVE , + }; +pgd_t *pgd; +pud_t *pud; +pmd_t *pmd; +pte_t *pte; +int dead, seq, idx, ret =VM_FAULT_RETRY ; +struct vm_area_struct *vma; + + idx =srcu_read_lock (&vma_srcu); + vma =find_vma_srcu (mm, address); +if (!vma) + goto unlock; + +/* +* Validate the VMA found by the lockless lookup. +*/ + dead =RB_EMPTY_NODE (&vma->vm_rb); + seq =raw_read_seqcount (&vma->vm_sequence);/* rmb <-> seqlock,vma_rb_erase() */ +if ((seq &1 ) || dead)/* XXX wait for !&1 instead? */ + goto unlock; + +if (address < vma->vm_start || vma->vm_end <= address) + goto unlock; + +/* +* We need to re-validate the VMA after checking the bounds, otherwise +* we might have a false positive on the bounds. +*/ +if (read_seqcount_retry (&vma->vm_sequence, seq)) + goto unlock; + +/*
mm/memory.c static int __handle_mm_fault(struct mm_s · line 3436
Quoted 10 lines
mm/memory.c +10
-0+* Do a speculative lookup of the PTE entry. +*/ +local_irq_disable (); + pgd =pgd_offset (mm, address); +if (pgd_none (*pgd) ||unlikely (pgd_bad (*pgd))) + goto out_walk; + + pud =pud_offset (pgd, address); +if (pud_none (*pud) ||unlikely (pud_bad (*pud))) + goto out_walk;
pud_huge() too. Or filter out VM_HUGETLB altogether.
BTW, what keeps mm_struct around? It seems we don't take reference during page fault.
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>
Peter Zijlstra
maintainerRe: [RFC][PATCH 5/6] mm: Provide speculative fault infrastructure
Quoted 1 line · Kirill A. Shutemov
pud_huge()too. Or filter outVM_HUGETLBaltogether.
Oh right, giga pages, all this new fangled stuff ;-) But yes, I suppose we can exclude hugetlbfs, we should arguably make the thp muck work though.
Quoted 2 lines
BTW, what keeps
mm_structaround? It seems we don't take reference during page fault.
Last I checked tasks have a ref on their own mm, and seeing this all runs in task context, the mm should be pretty safe.
--
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: [RFC][PATCH 5/6] mm: Provide speculative fault infrastructure
In reply to Peter ZijlstraQuoted 11 lines · Peter Zijlstra
static bool
pte_map_lock(struct fault_env *fe)
{mm/memory.c +9
-0+bool ret = false; + +if (!(fe->flags &FAULT_FLAG_SPECULATIVE )) { + fe->pte =pte_offset_map_lock (fe->mm, fe->pmd, fe->address, &fe->ptl); +return true; + } + +/* +* The first vma_is_dead() guarantees the page-tables are still valid,
mm/memory.c struct fault_env { · line 2030
Quoted 10 lines
mm/memory.c +9
-0+* having IRQs disabled ensures they stay around, hence the second +* vma_is_dead() to make sure they are still valid once we've got the +* lock. After that a concurrent zap_pte_range() will block on the PTL +* and thus we're safe. +*/ +local_irq_disable (); +if (vma_is_dead (fe->vma, fe->sequence)) + goto out; + fe->pte =pte_offset_map_lock (fe->mm, fe->pmd, fe->address, &fe->ptl);
Yeah, so this deadlocks just fine, I found we still do TLB flushes while holding the PTL. Bugger that, the alternative is either force everybody to do RCU freed page-tables or put back the ugly code :/
A well..
mm/memory.c struct fault_env { · line 2041
Quoted 11 lines
mm/memory.c +10
-0+ +if (vma_is_dead (fe->vma, fe->sequence)) { +pte_unmap_unlock (fe->pte, fe->ptl); + goto out; + } + + ret = true; +out: +local_irq_enable (); +return ret; }
--
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
maintainerRFC PATCH 6/6 mm,x86: Add speculative pagefault handling
In reply to Peter ZijlstraTry a speculative fault before acquiring mmap_sem, if it returns with VM_FAULT_RETRY continue with the mmap_sem acquisition and do the traditional fault.
--- arch/x86/mm/fault.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-)
arch/x86/mm/fault.c +22 -13
@@ -844,11 +844,8 @@ do_sigbus(struct pt_regs *regs, unsigned unsigned int fault) {struct task_struct *tsk = current; -struct mm_struct *mm = tsk->mm;int code =BUS_ADRERR ; -up_read (&mm->mmap_sem); -/* Kernel mode? Handle exceptions or die: */ if (!(error_code &PF_USER )) {no_context (regs, error_code, address,SIGBUS ,BUS_ADRERR );
@@ -879,7 +876,6 @@ mm_fault_error(struct pt_regs *regs, uns unsigned long address, unsigned int fault) { if (fatal_signal_pending(current) && !(error_code & PF_USER)) { - up_read(¤t->mm->mmap_sem); no_context(regs, error_code, address, 0, 0);return ; }
@@ -887,14 +883,11 @@ mm_fault_error(struct pt_regs *regs, unsif (fault &VM_FAULT_OOM ) {/* Kernel mode? Handle exceptions or die: */ if (!(error_code &PF_USER )) { -up_read (¤t->mm->mmap_sem);no_context (regs, error_code, address,SIGSEGV ,SEGV_MAPERR );return ; } -up_read (¤t->mm->mmap_sem); -/* * We ran out of memory, call the OOM killer, and return the * userspace (which will retry the fault, or kill us if we got
@@ -1141,6 +1134,16 @@ __do_page_fault(struct pt_regs *regs, unif (error_code &PF_WRITE ) flags |=FAULT_FLAG_WRITE ; +if (error_code &PF_USER ) { + fault =handle_speculative_fault (mm, address, + flags & ~FAULT_FLAG_ALLOW_RETRY ); + +if (fault &VM_FAULT_RETRY ) + goto retry; + + goto done; + } +/* * When running in the kernel we expect faults to occur only to * addresses in user space. All other faults represent errors in
@@ -1225,9 +1228,15 @@ __do_page_fault(struct pt_regs *regs, un* signal first. We do not need to release the mmap_sem because it * would already be released in __lock_page_or_retry in mm/filemap.c. */ -if (unlikely ((fault &VM_FAULT_RETRY ) &&fatal_signal_pending (current))) -return ; +if (unlikely (fault &VM_FAULT_RETRY )) { +if (fatal_signal_pending (current)) +return ; + + goto done; + } +up_read (&mm->mmap_sem); +done:if (unlikely (fault &VM_FAULT_ERROR )) {mm_fault_error (regs, error_code, address, fault);return ;
@@ -1249,8 +1258,10 @@ __do_page_fault(struct pt_regs *regs, un regs, address); }if (fault &VM_FAULT_RETRY ) { -/* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk -* of starvation. */ +/* +* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk of +* starvation. +*/ flags &= ~FAULT_FLAG_ALLOW_RETRY ; flags |=FAULT_FLAG_TRIED ; goto retry;
@@ -1258,8 +1269,6 @@ __do_page_fault(struct pt_regs *regs, un }check_v8086_mode (regs, address, tsk); - -up_read (&mm->mmap_sem); }NOKPROBE_SYMBOL (__do_page_fault);
--
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 12 lines · Peter Zijlstra
Hi,
I figured I'd give my 2010 speculative fault series another spin:
https://lkml.org/lkml/2010/1/4/257
Since then I think many of the outstanding issues have changed sufficiently to warrant another go. In particular Al Viro's delayed fput seems to have made it entirely 'normal' to delay
fput(). Lai Jiangshan's SRCU rewrite provided us withcall_srcu()and my preemptiblemmu_gatherremoved the TLB flushes from under the PTL.
Quoted 6 lines
The code needs way more attention but builds a kernel and runs the micro-benchmark so I figured I'd post it before sinking more time into it.
I realize the micro-bench is about as good as it gets for this series and not very realistic otherwise, but I think it does show the potential benefit the approach has.
Does this mean that an entire fault can complete without ever taking mmap_sem at all? If so, that's a *huge* win.
I'm a bit concerned about drivers that assume that the vma is unchanged during .fault processing. In particular, is there a race between .close and .fault? Would it make sense to add a per-vma rw lock and hold it during vma modification and .fault calls?
--Andy
Quoted 71 lines
(patches go against .18-rc1+)
---
Using Kamezawa's multi-fault micro-bench from: https://lkml.org/lkml/2010/1/6/28
My Ivy Bridge EP (2*10*2) has a ~58% improvement in pagefault throughput:
PRE:
root@ivb-ep:~# perf stat -e page-faults,cache-misses --repeat 5 ./multi-fault 20Performance counter stats for './multi-fault 20' (5 runs):
149,441,555 page-faults ( +- 1.25% ) 2,153,651,828 cache-misses ( +- 1.09% )60.003082014 seconds time elapsed ( +- 0.00% )POST:
root@ivb-ep:~# perf stat -e page-faults,cache-misses --repeat 5 ./multi-fault 20Performance counter stats for './multi-fault 20' (5 runs):
236,442,626 page-faults ( +- 0.08% ) 2,796,353,939 cache-misses ( +- 1.01% )60.002792431 seconds time elapsed ( +- 0.00% )My Ivy Bridge EX (4*15*2) has a ~78% improvement in pagefault throughput:
PRE:
root@ivb-ex:~# perf stat -e page-faults,cache-misses --repeat 5 ./multi-fault 60Performance counter stats for './multi-fault 60' (5 runs):
105,789,078 page-faults ( +- 2.24% ) 1,314,072,090 cache-misses ( +- 1.17% )60.009243533 seconds time elapsed ( +- 0.00% )POST:
root@ivb-ex:~# perf stat -e page-faults,cache-misses --repeat 5 ./multi-fault 60Performance counter stats for './multi-fault 60' (5 runs):
187,751,767 page-faults ( +- 2.24% ) 1,792,758,664 cache-misses ( +- 2.30% )60.011611579 seconds time elapsed ( +- 0.00% )(I've not yet looked at why the EX sucks chunks compared to the EP box, I
suspect we contend on other locks, but it could be anything.)---
arch/x86/mm/fault.c | 35 ++- include/linux/mm.h | 19 +- include/linux/mm_types.h | 5 + kernel/fork.c | 1 + mm/init-mm.c | 1 + mm/internal.h | 18 ++ mm/memory.c | 672 ++++++++++++++++++++++++++++------------------- mm/mmap.c | 101 +++++-- 8 files changed, 544 insertions(+), 308 deletions(-)
Quoted 6 lines
--
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>
--
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
maintainerQuoted 16 lines · Andy Lutomirski
Quoted 15 lines · Peter Zijlstra
Hi,
I figured I'd give my 2010 speculative fault series another spin:
https://lkml.org/lkml/2010/1/4/257
Since then I think many of the outstanding issues have changed sufficiently to warrant another go. In particular Al Viro's delayed fput seems to have made it entirely 'normal' to delay
fput(). Lai Jiangshan's SRCU rewrite provided us withcall_srcu()and my preemptiblemmu_gatherremoved the TLB flushes from under the PTL.The code needs way more attention but builds a kernel and runs the micro-benchmark so I figured I'd post it before sinking more time into it.
Quoted 6 lines
Quoted 3 lines
I realize the micro-bench is about as good as it gets for this series and not very realistic otherwise, but I think it does show the potential benefit the approach has.
Does this mean that an entire fault can complete without ever taking
mmap_semat all? If so, that's a *huge* win.
Yep.
Quoted 4 lines
I'm a bit concerned about drivers that assume that the vma is unchanged during .fault processing. In particular, is there a race between .close and .fault? Would it make sense to add a per-vma rw lock and hold it during vma modification and .fault calls?
VMA granularity contention would be about as bad as mmap_sem for many workloads. But yes, that is one of the things we need to look at, I was _hoping_ that holding the file open would sort most these problems, but I'm sure there plenty 'interesting' cruft left.
--
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 · Peter Zijlstra
My Ivy Bridge EP (2*10*2) has a ~58% improvement in pagefault throughput:
PRE:
149,441,555 page-faults ( +- 1.25% )POST:
236,442,626 page-faults ( +- 0.08% )
Quoted 7 lines
My Ivy Bridge EX (4*15*2) has a ~78% improvement in pagefault throughput:
PRE:
105,789,078 page-faults ( +- 2.24% )POST:
187,751,767 page-faults ( +- 2.24% )
I guess the 'PRE' and 'POST' numbers should be flipped around?
Thanks,
Ingo
--
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 13 lines · Ingo Molnar
Quoted 10 lines · Peter Zijlstra
My Ivy Bridge EP (2*10*2) has a ~58% improvement in pagefault throughput:
PRE:
149,441,555 page-faults ( +- 1.25% )POST:
236,442,626 page-faults ( +- 0.08% )My Ivy Bridge EX (4*15*2) has a ~78% improvement in pagefault throughput:
Quoted 7 lines
Quoted 5 lines
PRE:
105,789,078 page-faults ( +- 2.24% )POST:
187,751,767 page-faults ( +- 2.24% )I guess the 'PRE' and 'POST' numbers should be flipped around?
I think it's faults per second.
It would be interesting to see if the patchset affects non-condended case. Like a one-threaded workload.
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>
Peter Zijlstra
maintainerQuoted 2 lines · Kirill A. Shutemov
It would be interesting to see if the patchset affects non-condended case. Like a one-threaded workload.
It does, and not in a good way, I'll have to look at that... :/
Performance counter stats for './multi-fault 1' (5 runs):
73,860,251 page-faults ( +- 0.28% )
40,914 cache-misses ( +- 41.26% )60.001484913 seconds time elapsed ( +- 0.00% )
Performance counter stats for './multi-fault 1' (5 runs):
70,700,838 page-faults ( +- 0.03% )
31,466 cache-misses ( +- 8.62% )60.001753906 seconds time elapsed ( +- 0.00% )
--
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 5 lines · Peter Zijlstra
Quoted 2 lines · Kirill A. Shutemov
It would be interesting to see if the patchset affects non-condended case. Like a one-threaded workload.
It does, and not in a good way, I'll have to look at that... :/
Maybe it is blamed to find_vma_srcu() that it doesn't take the advantage of the vmacache_find() and cause more cache-misses.
Is it hard to use the vmacache in the find_vma_srcu()?
Quoted 9 lines
Performance counter stats for './multi-fault 1' (5 runs):
73,860,251 page-faults ( +- 0.28% ) 40,914 cache-misses ( +- 41.26% )60.001484913 seconds time elapsed ( +- 0.00% )
Quoted 8 lines
Performance counter stats for './multi-fault 1' (5 runs):
70,700,838 page-faults ( +- 0.03% ) 31,466 cache-misses ( +- 8.62% )60.001753906 seconds time elapsed ( +- 0.00% )
.
--
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
maintainerQuoted 9 lines · Lai Jiangshan
Quoted 5 lines · Peter Zijlstra
Quoted 2 lines · Kirill A. Shutemov
It would be interesting to see if the patchset affects non-condended case. Like a one-threaded workload.
It does, and not in a good way, I'll have to look at that... :/
Maybe it is blamed to
find_vma_srcu()that it doesn't take the advantage of thevmacache_find()and cause more cache-misses.
Its what I thought initially, I tried doing perf record with and without, but then I ran into perf diff not quite working for me and I've yet to find time to kick that thing into shape.
Quoted 1 line
Is it hard to use the vmacache in the
find_vma_srcu()?
I've not had time to look at it.
--
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 6 lines · Peter Zijlstra
Quoted 5 lines · Lai Jiangshan
Quoted 4 lines · Peter Zijlstra
Quoted 2 lines · Kirill A. Shutemov
It would be interesting to see if the patchset affects non-condended case. Like a one-threaded workload.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
It does, and not in a good way, I'll have to look at that... :/
Maybe it is blamed to
find_vma_srcu()that it doesn't take the advantage of thevmacache_find()and cause more cache-misses.Its what I thought initially, I tried doing perf record with and without, but then I ran into perf diff not quite working for me and I've yet to find time to kick that thing into shape.
Might be the 'perf diff' regression fixed by this:
9ab1f50876db perf diff: Add missing hists__init() call at tool start
I just pushed it out into tip:master.
Thanks,
Ingo
--
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
maintainerQuoted 18 lines · Ingo Molnar
Quoted 6 lines · Peter Zijlstra
Quoted 5 lines · Lai Jiangshan
Quoted 4 lines · Peter Zijlstra
Quoted 2 lines · Kirill A. Shutemov
It would be interesting to see if the patchset affects non-condended case. Like a one-threaded workload.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
It does, and not in a good way, I'll have to look at that... :/
Maybe it is blamed to
find_vma_srcu()that it doesn't take the advantage of thevmacache_find()and cause more cache-misses.Its what I thought initially, I tried doing perf record with and without, but then I ran into perf diff not quite working for me and I've yet to find time to kick that thing into shape.
Quoted 5 lines
Might be the 'perf diff' regression fixed by this:
9ab1f50876dbperf diff: Add missinghists__init()call at tool startI just pushed it out into tip:master.
I was on tip/master, so unlikely to be that as I was likely already having it.
perf-report was affected too, for some reason my CONFIG_DEBUG_INFO=y vmlinux wasn't showing symbols (and I double checked that KASLR crap was disabled, so that wasn't confusing stuff either).
When I forced perf-report to use kallsyms it works, however perf-diff doesn't have that option.
So there's two issues there, 1) perf-report failing to generate useful output and 2) per-diff lacking options to force it to behave.
--
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>
Hi Peter,
Quoted 20 lines · Peter Zijlstra
Quoted 11 lines · Ingo Molnar
Quoted 3 lines · Peter Zijlstra
Its what I thought initially, I tried doing perf record with and without, but then I ran into perf diff not quite working for me and I've yet to find time to kick that thing into shape.
Might be the 'perf diff' regression fixed by this:
9ab1f50876dbperf diff: Add missinghists__init()call at tool startI just pushed it out into tip:master.
I was on tip/master, so unlikely to be that as I was likely already having it.
perf-report was affected too, for some reason my
CONFIG_DEBUG_INFO=yvmlinux wasn't showing symbols (and I double checked that KASLR crap was disabled, so that wasn't confusing stuff either).
Quoted 5 lines
When I forced perf-report to use kallsyms it works, however perf-diff doesn't have that option.
So there's two issues there, 1) perf-report failing to generate useful output and 2) per-diff lacking options to force it to behave.
Did the perf-report fail to show any (kernel) symbols or are they wrong symbols? Maybe it's related to this:
https://lkml.org/lkml/2014/9/22/78
Thanks,
Namhyung
--
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
maintainerQuoted 13 lines · Ingo Molnar
Quoted 10 lines · Peter Zijlstra
My Ivy Bridge EP (2*10*2) has a ~58% improvement in pagefault throughput:
PRE:
149,441,555 page-faults ( +- 1.25% )POST:
236,442,626 page-faults ( +- 0.08% )My Ivy Bridge EX (4*15*2) has a ~78% improvement in pagefault throughput:
Quoted 7 lines
Quoted 5 lines
PRE:
105,789,078 page-faults ( +- 2.24% )POST:
187,751,767 page-faults ( +- 2.24% )I guess the 'PRE' and 'POST' numbers should be flipped around?
Nope, its the number of page-faults serviced in a fixed amount of time (60 seconds), therefore higher is better.
Quoted 17 lines · Peter Zijlstra
Quoted 16 lines · Ingo Molnar
Quoted 13 lines · Peter Zijlstra
My Ivy Bridge EP (2*10*2) has a ~58% improvement in pagefault throughput:
PRE:
149,441,555 page-faults ( +- 1.25% )POST:
236,442,626 page-faults ( +- 0.08% )My Ivy Bridge EX (4*15*2) has a ~78% improvement in pagefault throughput:
PRE:
105,789,078 page-faults ( +- 2.24% )
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
POST:
187,751,767 page-faults ( +- 2.24% )I guess the 'PRE' and 'POST' numbers should be flipped around?
Nope, its the number of page-faults serviced in a fixed amount of time (60 seconds), therefore higher is better.
Ah, okay!
Thanks,
Ingo
--
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 12 lines · Peter Zijlstra
Hi,
I figured I'd give my 2010 speculative fault series another spin:
https://lkml.org/lkml/2010/1/4/257
Since then I think many of the outstanding issues have changed sufficiently to warrant another go. In particular Al Viro's delayed fput seems to have made it entirely 'normal' to delay
fput(). Lai Jiangshan's SRCU rewrite provided us withcall_srcu()and my preemptiblemmu_gatherremoved the TLB flushes from under the PTL.
Quoted 8 lines
The code needs way more attention but builds a kernel and runs the micro-benchmark so I figured I'd post it before sinking more time into it.
I realize the micro-bench is about as good as it gets for this series and not very realistic otherwise, but I think it does show the potential benefit the approach has.
(patches go against .18-rc1+)
I think patch 2/6 is borken:
error: patch failed: mm/memory.c:2025
error: mm/memory.c: patch does not apply
and related, as you mention, I would very much welcome having the introduction of 'struct faut_env' as a separate cleanup patch. May I suggest renaming it to fault_cxt?
Thanks,
Davidlohr
--
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 22 lines · Davidlohr Bueso
Quoted 12 lines · Peter Zijlstra
Hi,
I figured I'd give my 2010 speculative fault series another spin:
https://lkml.org/lkml/2010/1/4/257
Since then I think many of the outstanding issues have changed sufficiently to warrant another go. In particular Al Viro's delayed fput seems to have made it entirely 'normal' to delay
fput(). Lai Jiangshan's SRCU rewrite provided us withcall_srcu()and my preemptiblemmu_gatherremoved the TLB flushes from under the PTL.Quoted 8 lines
The code needs way more attention but builds a kernel and runs the micro-benchmark so I figured I'd post it before sinking more time into it.
I realize the micro-bench is about as good as it gets for this series and not very realistic otherwise, but I think it does show the potential benefit the approach has.
(patches go against .18-rc1+)
Quoted 8 lines
I think patch 2/6 is borken:
error: patch failed:
mm/memory.c:2025
error:mm/memory.c: patch does not applyand related, as you mention, I would very much welcome having the introduction of 'struct
faut_env' as a separate cleanup patch. May I suggest renaming it tofault_cxt?
What about extend start using 'struct vm_fault' earlier by stack?
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>
Peter Zijlstra
maintainerQuoted 25 lines · Kirill A. Shutemov
Quoted 24 lines · Davidlohr Bueso
Quoted 12 lines · Peter Zijlstra
Hi,
I figured I'd give my 2010 speculative fault series another spin:
https://lkml.org/lkml/2010/1/4/257
Since then I think many of the outstanding issues have changed sufficiently to warrant another go. In particular Al Viro's delayed fput seems to have made it entirely 'normal' to delay
fput(). Lai Jiangshan's SRCU rewrite provided us withcall_srcu()and my preemptiblemmu_gatherremoved the TLB flushes from under the PTL.Quoted 8 lines
The code needs way more attention but builds a kernel and runs the micro-benchmark so I figured I'd post it before sinking more time into it.
I realize the micro-bench is about as good as it gets for this series and not very realistic otherwise, but I think it does show the potential benefit the approach has.
(patches go against .18-rc1+)
I think patch 2/6 is borken:
Quoted 8 lines
Quoted 6 lines
error: patch failed:
mm/memory.c:2025
error:mm/memory.c: patch does not applyand related, as you mention, I would very much welcome having the introduction of 'struct
faut_env' as a separate cleanup patch. May I suggest renaming it tofault_cxt?What about extend start using 'struct
vm_fault' earlier by stack?
I'm not sure we should mix the environment for vm_ops::fault, which acquires the page, and the fault path, which deals with changing the PTE. Ideally we should not expose the page-table information to file ops, its a layering violating if nothing else, drivers should not have access to the page tables.
--
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 33 lines · Peter Zijlstra
Quoted 32 lines · Kirill A. Shutemov
Quoted 30 lines · Davidlohr Bueso
Quoted 12 lines · Peter Zijlstra
Hi,
I figured I'd give my 2010 speculative fault series another spin:
https://lkml.org/lkml/2010/1/4/257
Since then I think many of the outstanding issues have changed sufficiently to warrant another go. In particular Al Viro's delayed fput seems to have made it entirely 'normal' to delay
fput(). Lai Jiangshan's SRCU rewrite provided us withcall_srcu()and my preemptiblemmu_gatherremoved the TLB flushes from under the PTL.Quoted 8 lines
The code needs way more attention but builds a kernel and runs the micro-benchmark so I figured I'd post it before sinking more time into it.
I realize the micro-bench is about as good as it gets for this series and not very realistic otherwise, but I think it does show the potential benefit the approach has.
(patches go against .18-rc1+)
I think patch 2/6 is borken:
error: patch failed:
mm/memory.c:2025
error:mm/memory.c: patch does not applyand related, as you mention, I would very much welcome having the introduction of 'struct
faut_env' as a separate cleanup patch. May I suggest renaming it tofault_cxt?
Quoted 7 lines
Quoted 1 line
What about extend start using 'struct
vm_fault' earlier by stack?I'm not sure we should mix the environment for
vm_ops::fault, which acquires the page, and the fault path, which deals with changing the PTE. Ideally we should not expose the page-table information to file ops, its a layering violating if nothing else, drivers should not have access to the page tables.
We already have this for ->map_pages() :-P
I have asked if it's considered layering violation and seems nobody cares...
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>