Re: [RFC PATCH 1/8] mm: mmap: unmap large mapping by section

2018-03-22 Thread Laurent Dufour
On 22/03/2018 17:13, Matthew Wilcox wrote: > On Thu, Mar 22, 2018 at 09:06:14AM -0700, Yang Shi wrote: >> On 3/22/18 2:10 AM, Michal Hocko wrote: >>> On Wed 21-03-18 15:36:12, Yang Shi wrote: On 3/21/18 2:23 PM, Michal Hocko wrote: > On Wed 21-03-18 10:16:41, Yang Shi wrote: >>

Re: [RFC PATCH 1/8] mm: mmap: unmap large mapping by section

2018-03-22 Thread Laurent Dufour
On 22/03/2018 17:05, Matthew Wilcox wrote: > On Thu, Mar 22, 2018 at 04:54:52PM +0100, Laurent Dufour wrote: >> On 22/03/2018 16:40, Matthew Wilcox wrote: >>> On Thu, Mar 22, 2018 at 04:32:00PM +0100, Laurent Dufour wrote: >>>> Regarding the page fault, why

Re: [RFC PATCH 1/8] mm: mmap: unmap large mapping by section

2018-03-22 Thread Laurent Dufour
On 22/03/2018 17:05, Matthew Wilcox wrote: > On Thu, Mar 22, 2018 at 04:54:52PM +0100, Laurent Dufour wrote: >> On 22/03/2018 16:40, Matthew Wilcox wrote: >>> On Thu, Mar 22, 2018 at 04:32:00PM +0100, Laurent Dufour wrote: >>>> Regarding the page fault, why

Re: [RFC PATCH 1/8] mm: mmap: unmap large mapping by section

2018-03-22 Thread Laurent Dufour
On 22/03/2018 16:40, Matthew Wilcox wrote: > On Thu, Mar 22, 2018 at 04:32:00PM +0100, Laurent Dufour wrote: >> On 21/03/2018 23:46, Matthew Wilcox wrote: >>> On Wed, Mar 21, 2018 at 02:45:44PM -0700, Yang Shi wrote: >>>> Marking vma as deleted sounds good. The p

Re: [RFC PATCH 1/8] mm: mmap: unmap large mapping by section

2018-03-22 Thread Laurent Dufour
On 22/03/2018 16:40, Matthew Wilcox wrote: > On Thu, Mar 22, 2018 at 04:32:00PM +0100, Laurent Dufour wrote: >> On 21/03/2018 23:46, Matthew Wilcox wrote: >>> On Wed, Mar 21, 2018 at 02:45:44PM -0700, Yang Shi wrote: >>>> Marking vma as deleted sounds good. The p

Re: [RFC PATCH 1/8] mm: mmap: unmap large mapping by section

2018-03-22 Thread Laurent Dufour
On 21/03/2018 23:46, Matthew Wilcox wrote: > On Wed, Mar 21, 2018 at 02:45:44PM -0700, Yang Shi wrote: >> Marking vma as deleted sounds good. The problem for my current approach is >> the concurrent page fault may succeed if it access the not yet unmapped >> section. Marking deleted vma could

Re: [RFC PATCH 1/8] mm: mmap: unmap large mapping by section

2018-03-22 Thread Laurent Dufour
On 21/03/2018 23:46, Matthew Wilcox wrote: > On Wed, Mar 21, 2018 at 02:45:44PM -0700, Yang Shi wrote: >> Marking vma as deleted sounds good. The problem for my current approach is >> the concurrent page fault may succeed if it access the not yet unmapped >> section. Marking deleted vma could

Re: [mm] b1f0502d04: INFO:trying_to_register_non-static_key

2018-03-21 Thread Laurent Dufour
On 17/03/2018 08:51, kernel test robot wrote: > FYI, we noticed the following commit (built with gcc-7): > > commit: b1f0502d04537ef55b0c296823affe332b100eb5 ("mm: VMA sequence count") > url: > https://github.com/0day-ci/linux/commits/Laurent-Dufour/Speculative-pa

Re: [mm] b1f0502d04: INFO:trying_to_register_non-static_key

2018-03-21 Thread Laurent Dufour
On 17/03/2018 08:51, kernel test robot wrote: > FYI, we noticed the following commit (built with gcc-7): > > commit: b1f0502d04537ef55b0c296823affe332b100eb5 ("mm: VMA sequence count") > url: > https://github.com/0day-ci/linux/commits/Laurent-Dufour/Speculative-pa

Re: [PATCH] mm/hugetlb: prevent hugetlb VMA to be misaligned

2018-03-21 Thread Laurent Dufour
an be split. This was mostly for device-dax and > hugetlbfs mappings which have specific alignment constraints. > > mappings initiated via shmget/shmat have their original vm_ops > overwritten with shm_vm_ops. shm_vm_ops functions will call back > to the original vm_ops if neede

Re: [PATCH] mm/hugetlb: prevent hugetlb VMA to be misaligned

2018-03-21 Thread Laurent Dufour
evice-dax and > hugetlbfs mappings which have specific alignment constraints. > > mappings initiated via shmget/shmat have their original vm_ops > overwritten with shm_vm_ops. shm_vm_ops functions will call back > to the original vm_ops if needed. Add such a split function.

Re: [PATCH] mm/hugetlb: prevent hugetlb VMA to be misaligned

2018-03-21 Thread Laurent Dufour
On 20/03/2018 22:26, Mike Kravetz wrote: > On 03/20/2018 10:25 AM, Laurent Dufour wrote: >> When running the sampler detailed below, the kernel, if built with the VM >> debug option turned on (as many distro do), is panicing with the following >> message : >> kernel

Re: [PATCH] mm/hugetlb: prevent hugetlb VMA to be misaligned

2018-03-21 Thread Laurent Dufour
On 20/03/2018 22:26, Mike Kravetz wrote: > On 03/20/2018 10:25 AM, Laurent Dufour wrote: >> When running the sampler detailed below, the kernel, if built with the VM >> debug option turned on (as many distro do), is panicing with the following >> message : >> kernel

[PATCH] mm/hugetlb: prevent hugetlb VMA to be misaligned

2018-03-20 Thread Laurent Dufour
rror("shmdt"); goto out; } printf("test done.\n"); ret = 0; out: shmctl(shmid, IPC_RMID, NULL); return ret; } --- End of code Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- mm/mmap.c | 11 +++ 1 file changed, 11 ins

[PATCH] mm/hugetlb: prevent hugetlb VMA to be misaligned

2018-03-20 Thread Laurent Dufour
goto out; } printf("test done.\n"); ret = 0; out: shmctl(shmid, IPC_RMID, NULL); return ret; } --- End of code Signed-off-by: Laurent Dufour --- mm/mmap.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/mm/mmap.c b/mm/mmap.c index 188f195883b

Re: [mm] b33ddf50eb: INFO:trying_to_register_non-static_key

2018-03-16 Thread Laurent Dufour
On 16/03/2018 11:23, kernel test robot wrote: > FYI, we noticed the following commit (built with gcc-7): > > commit: b33ddf50ebcc740b990dd2e0e8ff0b92c7acf58e ("mm: Protect mm_rb tree > with a rwlock") > url: > https://github.com/0day-ci/linux/commits/Laurent-Du

Re: [mm] b33ddf50eb: INFO:trying_to_register_non-static_key

2018-03-16 Thread Laurent Dufour
On 16/03/2018 11:23, kernel test robot wrote: > FYI, we noticed the following commit (built with gcc-7): > > commit: b33ddf50ebcc740b990dd2e0e8ff0b92c7acf58e ("mm: Protect mm_rb tree > with a rwlock") > url: > https://github.com/0day-ci/linux/commits/Laurent-Du

Re: [PATCH v9 17/24] mm: Protect mm_rb tree with a rwlock

2018-03-14 Thread Laurent Dufour
On 14/03/2018 09:48, Peter Zijlstra wrote: > On Tue, Mar 13, 2018 at 06:59:47PM +0100, Laurent Dufour wrote: >> This change is inspired by the Peter's proposal patch [1] which was >> protecting the VMA using SRCU. Unfortunately, SRCU is not scaling well in >>

Re: [PATCH v9 17/24] mm: Protect mm_rb tree with a rwlock

2018-03-14 Thread Laurent Dufour
On 14/03/2018 09:48, Peter Zijlstra wrote: > On Tue, Mar 13, 2018 at 06:59:47PM +0100, Laurent Dufour wrote: >> This change is inspired by the Peter's proposal patch [1] which was >> protecting the VMA using SRCU. Unfortunately, SRCU is not scaling well in >>

Re: [PATCH v9 00/24] Speculative page faults

2018-03-14 Thread Laurent Dufour
On 14/03/2018 14:11, Michal Hocko wrote: > On Tue 13-03-18 18:59:30, Laurent Dufour wrote: >> Changes since v8: >> - Don't check PMD when locking the pte when THP is disabled >>Thanks to Daniel Jordan for reporting this. >> - Rebase on 4.16 > > Is this real

Re: [PATCH v9 00/24] Speculative page faults

2018-03-14 Thread Laurent Dufour
On 14/03/2018 14:11, Michal Hocko wrote: > On Tue 13-03-18 18:59:30, Laurent Dufour wrote: >> Changes since v8: >> - Don't check PMD when locking the pte when THP is disabled >>Thanks to Daniel Jordan for reporting this. >> - Rebase on 4.16 > > Is this real

[PATCH v9 01/24] mm: Introduce CONFIG_SPECULATIVE_PAGE_FAULT

2018-03-13 Thread Laurent Dufour
This configuration variable will be used to build the code needed to handle speculative page fault. By default it is turned off, and activated depending on architecture support. Suggested-by: Thomas Gleixner <t...@linutronix.de> Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com

[PATCH v9 01/24] mm: Introduce CONFIG_SPECULATIVE_PAGE_FAULT

2018-03-13 Thread Laurent Dufour
This configuration variable will be used to build the code needed to handle speculative page fault. By default it is turned off, and activated depending on architecture support. Suggested-by: Thomas Gleixner Signed-off-by: Laurent Dufour --- mm/Kconfig | 3 +++ 1 file changed, 3 insertions

[PATCH v9 03/24] powerpc/mm: Define CONFIG_SPECULATIVE_PAGE_FAULT

2018-03-13 Thread Laurent Dufour
for book3e_hugetlb_preload() called by update_mmu_cache() Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- arch/powerpc/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 73ce5dd07642..acf2696a6505 100644 --- a/arch/powerpc/K

[PATCH v9 03/24] powerpc/mm: Define CONFIG_SPECULATIVE_PAGE_FAULT

2018-03-13 Thread Laurent Dufour
for book3e_hugetlb_preload() called by update_mmu_cache() Signed-off-by: Laurent Dufour --- arch/powerpc/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 73ce5dd07642..acf2696a6505 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig

[PATCH v9 12/24] mm/migrate: Pass vm_fault pointer to migrate_misplaced_page()

2018-03-13 Thread Laurent Dufour
migrate_misplaced_page() is only called during the page fault handling so it's better to pass the pointer to the struct vm_fault instead of the vma. This way during the speculative page fault path the saved vma->vm_flags could be used. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.i

[PATCH v9 12/24] mm/migrate: Pass vm_fault pointer to migrate_misplaced_page()

2018-03-13 Thread Laurent Dufour
migrate_misplaced_page() is only called during the page fault handling so it's better to pass the pointer to the struct vm_fault instead of the vma. This way during the speculative page fault path the saved vma->vm_flags could be used. Signed-off-by: Laurent Dufour --- include/linux/migrat

[PATCH v9 08/24] mm: Protect VMA modifications using VMA sequence count

2018-03-13 Thread Laurent Dufour
to prevent write to be split and intermediate values to be pushed to other CPUs. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- fs/proc/task_mmu.c | 5 - fs/userfaultfd.c | 17 + mm/khugepaged.c| 3 +++ mm/madvise.c | 6 +- mm/mempo

[PATCH v9 08/24] mm: Protect VMA modifications using VMA sequence count

2018-03-13 Thread Laurent Dufour
to prevent write to be split and intermediate values to be pushed to other CPUs. Signed-off-by: Laurent Dufour --- fs/proc/task_mmu.c | 5 - fs/userfaultfd.c | 17 + mm/khugepaged.c| 3 +++ mm/madvise.c | 6 +- mm/mempolicy.c | 51

[PATCH v9 06/24] mm: make pte_unmap_same compatible with SPF

2018-03-13 Thread Laurent Dufour
is then trapped in cow_user_page(). If VM_FAULT_RETRY is returned, it is passed up to the callers to retry the page fault while holding the mmap_sem. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/mm.h | 1 + mm/memory.c| 29 +++-- 2 files c

[PATCH v9 06/24] mm: make pte_unmap_same compatible with SPF

2018-03-13 Thread Laurent Dufour
is then trapped in cow_user_page(). If VM_FAULT_RETRY is returned, it is passed up to the callers to retry the page fault while holding the mmap_sem. Signed-off-by: Laurent Dufour --- include/linux/mm.h | 1 + mm/memory.c| 29 +++-- 2 files changed, 20 insertions(+), 10

[PATCH v9 11/24] mm: Cache some VMA fields in the vm_fault structure

2018-03-13 Thread Laurent Dufour
hanges. This patch also set the fields in hugetlb_no_page() and __collapse_huge_page_swapin even if it is not need for the callee. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/mm.h | 6 ++ mm/hugetlb.c | 2 ++ mm/khugepaged.c| 2 ++ mm/memory.c

[PATCH v9 11/24] mm: Cache some VMA fields in the vm_fault structure

2018-03-13 Thread Laurent Dufour
hanges. This patch also set the fields in hugetlb_no_page() and __collapse_huge_page_swapin even if it is not need for the callee. Signed-off-by: Laurent Dufour --- include/linux/mm.h | 6 ++ mm/hugetlb.c | 2 ++ mm/khugepaged.c| 2 ++ mm/memory.c

[PATCH v9 13/24] mm: Introduce __lru_cache_add_active_or_unevictable

2018-03-13 Thread Laurent Dufour
pointer. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/swap.h | 10 -- mm/memory.c | 8 mm/swap.c| 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h

[PATCH v9 13/24] mm: Introduce __lru_cache_add_active_or_unevictable

2018-03-13 Thread Laurent Dufour
pointer. Signed-off-by: Laurent Dufour --- include/linux/swap.h | 10 -- mm/memory.c | 8 mm/swap.c| 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 1985940af479..a7dc37e0e405 100644

[PATCH v9 10/24] mm: Protect SPF handler against anon_vma changes

2018-03-13 Thread Laurent Dufour
sequence counter which is updated in unmap_page_range() before locking the pte, and then in free_pgtables() so when locking the pte the change will be detected. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- mm/memory.c | 4 1 file changed, 4 insertions(+) diff --git

[PATCH v9 10/24] mm: Protect SPF handler against anon_vma changes

2018-03-13 Thread Laurent Dufour
sequence counter which is updated in unmap_page_range() before locking the pte, and then in free_pgtables() so when locking the pte the change will be detected. Signed-off-by: Laurent Dufour --- mm/memory.c | 4 1 file changed, 4 insertions(+) diff --git a/mm/memory.c b/mm/memor

[PATCH v9 15/24] mm: Introduce __vm_normal_page()

2018-03-13 Thread Laurent Dufour
value as parameter. Note: The speculative path is turned on for architecture providing support for special PTE flag. So only the first block of vm_normal_page is used during the speculative path. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/mm.h | 7 +

[PATCH v9 15/24] mm: Introduce __vm_normal_page()

2018-03-13 Thread Laurent Dufour
value as parameter. Note: The speculative path is turned on for architecture providing support for special PTE flag. So only the first block of vm_normal_page is used during the speculative path. Signed-off-by: Laurent Dufour --- include/linux/mm.h | 7 +-- mm/memory.c| 18

[PATCH v9 16/24] mm: Introduce __page_add_new_anon_rmap()

2018-03-13 Thread Laurent Dufour
still valid as explained above. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/rmap.h | 12 ++-- mm/memory.c | 8 mm/rmap.c| 5 ++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/linux/rmap.h b/include/

[PATCH v9 17/24] mm: Protect mm_rb tree with a rwlock

2018-03-13 Thread Laurent Dufour
ess speculative page fault. [1] https://patchwork.kernel.org/patch/5108281/ Cc: Peter Zijlstra (Intel) <pet...@infradead.org> Cc: Matthew Wilcox <wi...@infradead.org> Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/mm_types.h | 4 ++ kernel/fork.c

[PATCH v9 16/24] mm: Introduce __page_add_new_anon_rmap()

2018-03-13 Thread Laurent Dufour
still valid as explained above. Signed-off-by: Laurent Dufour --- include/linux/rmap.h | 12 ++-- mm/memory.c | 8 mm/rmap.c| 5 ++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 988d176472df..

[PATCH v9 17/24] mm: Protect mm_rb tree with a rwlock

2018-03-13 Thread Laurent Dufour
ess speculative page fault. [1] https://patchwork.kernel.org/patch/5108281/ Cc: Peter Zijlstra (Intel) Cc: Matthew Wilcox Signed-off-by: Laurent Dufour --- include/linux/mm_types.h | 4 ++ kernel/fork.c| 3 ++ mm/init-mm.c | 3 ++ mm/internal.h| 6 +++

[PATCH v9 18/24] mm: Provide speculative fault infrastructure

2018-03-13 Thread Laurent Dufour
D against concurrent collapsing operation] [Try spin lock the pte during the speculative path to avoid deadlock with other CPU's invalidating the TLB and requiring this CPU to catch the inter processor's interrupt] Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/hug

[PATCH v9 18/24] mm: Provide speculative fault infrastructure

2018-03-13 Thread Laurent Dufour
lock the pte during the speculative path to avoid deadlock with other CPU's invalidating the TLB and requiring this CPU to catch the inter processor's interrupt] Signed-off-by: Laurent Dufour --- include/linux/hugetlb_inline.h | 2 +- include/linux/mm.h | 8 + include/linux/pagemap.h

[PATCH v9 20/24] perf: Add a speculative page fault sw event

2018-03-13 Thread Laurent Dufour
Add a new software event to count succeeded speculative page faults. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/uapi/linux/perf_event.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h

[PATCH v9 20/24] perf: Add a speculative page fault sw event

2018-03-13 Thread Laurent Dufour
Add a new software event to count succeeded speculative page faults. Signed-off-by: Laurent Dufour --- include/uapi/linux/perf_event.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h index 6f873503552d..a6ddab9edeec 100644

[PATCH v9 21/24] perf tools: Add support for the SPF perf event

2018-03-13 Thread Laurent Dufour
Add support for the new speculative faults event. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- tools/include/uapi/linux/perf_event.h | 1 + tools/perf/util/evsel.c | 1 + tools/perf/util/parse-events.c| 4 tools/perf/util/parse-events.l

[PATCH v9 21/24] perf tools: Add support for the SPF perf event

2018-03-13 Thread Laurent Dufour
Add support for the new speculative faults event. Signed-off-by: Laurent Dufour --- tools/include/uapi/linux/perf_event.h | 1 + tools/perf/util/evsel.c | 1 + tools/perf/util/parse-events.c| 4 tools/perf/util/parse-events.l| 1 + tools/perf/util/python.c

[PATCH v9 22/24] mm: Speculative page fault handler return VMA

2018-03-13 Thread Laurent Dufour
matched the passed address and release the reference on the VMA so that it can be freed if needed. In the case the VMA is freed, can_reuse_spf_vma() will have returned false as the VMA is no more in the RB tree. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/mm.h

[PATCH v9 22/24] mm: Speculative page fault handler return VMA

2018-03-13 Thread Laurent Dufour
matched the passed address and release the reference on the VMA so that it can be freed if needed. In the case the VMA is freed, can_reuse_spf_vma() will have returned false as the VMA is no more in the RB tree. Signed-off-by: Laurent Dufour --- include/linux/mm.h | 5 +- mm/memory.c| 136

[PATCH v9 24/24] powerpc/mm: Add speculative page fault

2018-03-13 Thread Laurent Dufour
for multithreaded process as there is no risk of contention on the mmap_sem otherwise. Build on if CONFIG_SPECULATIVE_PAGE_FAULT is defined (currently for BOOK3S_64 && SMP). Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- arch/powerpc/mm/fault.c | 31

[PATCH v9 24/24] powerpc/mm: Add speculative page fault

2018-03-13 Thread Laurent Dufour
for multithreaded process as there is no risk of contention on the mmap_sem otherwise. Build on if CONFIG_SPECULATIVE_PAGE_FAULT is defined (currently for BOOK3S_64 && SMP). Signed-off-by: Laurent Dufour --- arch/powerpc/mm/fault.c | 31 ++- 1 file changed, 30 in

[PATCH v9 23/24] x86/mm: Add speculative pagefault handling

2018-03-13 Thread Laurent Dufour
cesses] [Try to the VMA fetch during the speculative path in case of retry] Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- arch/x86/mm/fault.c | 38 +- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/fault.c b/arch/x8

[PATCH v9 23/24] x86/mm: Add speculative pagefault handling

2018-03-13 Thread Laurent Dufour
in case of retry] Signed-off-by: Laurent Dufour --- arch/x86/mm/fault.c | 38 +- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index e6af2b464c3d..a73cf227edd6 100644 --- a/arch/x86/mm/fault.c +++ b/arch

[PATCH v9 19/24] mm: Adding speculative page fault failure trace events

2018-03-13 Thread Laurent Dufour
This patch a set of new trace events to collect the speculative page fault event failures. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/trace/events/pagefault.h | 87 mm/memory.c

[PATCH v9 14/24] mm: Introduce __maybe_mkwrite()

2018-03-13 Thread Laurent Dufour
() service which can be called by passing the value of the vm_flags field. There is no change functional changes expected for the other callers of maybe_mkwrite(). Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/mm.h | 9 +++-- mm/memory.c| 6 +++--- 2

[PATCH v9 19/24] mm: Adding speculative page fault failure trace events

2018-03-13 Thread Laurent Dufour
This patch a set of new trace events to collect the speculative page fault event failures. Signed-off-by: Laurent Dufour --- include/trace/events/pagefault.h | 87 mm/memory.c | 62 ++-- 2 files changed, 136

[PATCH v9 14/24] mm: Introduce __maybe_mkwrite()

2018-03-13 Thread Laurent Dufour
() service which can be called by passing the value of the vm_flags field. There is no change functional changes expected for the other callers of maybe_mkwrite(). Signed-off-by: Laurent Dufour --- include/linux/mm.h | 9 +++-- mm/memory.c| 6 +++--- 2 files changed, 10 insertions(+), 5

[PATCH v9 09/24] mm: protect mremap() against SPF hanlder

2018-03-13 Thread Laurent Dufour
d by calling vm_raw_write_end() by the callee once the ptes have been moved. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/mm.h | 16 mm/mmap.c | 47 --- mm/mremap.c| 13 + 3

[PATCH v9 09/24] mm: protect mremap() against SPF hanlder

2018-03-13 Thread Laurent Dufour
d by calling vm_raw_write_end() by the callee once the ptes have been moved. Signed-off-by: Laurent Dufour --- include/linux/mm.h | 16 mm/mmap.c | 47 --- mm/mremap.c| 13 + 3 files changed, 61 insertions(+),

[PATCH v9 02/24] x86/mm: Define CONFIG_SPECULATIVE_PAGE_FAULT

2018-03-13 Thread Laurent Dufour
Introduce CONFIG_SPECULATIVE_PAGE_FAULT which turns on the Speculative Page Fault handler when building for 64bits with SMP. Cc: Thomas Gleixner <t...@linutronix.de> Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- arch/x86/Kconfig | 1 + 1 file changed, 1 insertion(+)

[PATCH v9 02/24] x86/mm: Define CONFIG_SPECULATIVE_PAGE_FAULT

2018-03-13 Thread Laurent Dufour
Introduce CONFIG_SPECULATIVE_PAGE_FAULT which turns on the Speculative Page Fault handler when building for 64bits with SMP. Cc: Thomas Gleixner Signed-off-by: Laurent Dufour --- arch/x86/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index

[PATCH v9 05/24] mm: Introduce pte_spinlock for FAULT_FLAG_SPECULATIVE

2018-03-13 Thread Laurent Dufour
When handling page fault without holding the mmap_sem the fetch of the pte lock pointer and the locking will have to be done while ensuring that the VMA is not touched in our back. So move the fetch and locking operations in a dedicated function. Signed-off-by: Laurent Dufour <l

[PATCH v9 05/24] mm: Introduce pte_spinlock for FAULT_FLAG_SPECULATIVE

2018-03-13 Thread Laurent Dufour
When handling page fault without holding the mmap_sem the fetch of the pte lock pointer and the locking will have to be done while ensuring that the VMA is not touched in our back. So move the fetch and locking operations in a dedicated function. Signed-off-by: Laurent Dufour --- mm/memory.c

[PATCH v9 00/24] Speculative page faults

2018-03-13 Thread Laurent Dufour
nce events to report number of successful and failed speculative events. [1] http://linux-kernel.2935.n7.nabble.com/RFC-PATCH-0-6-Another-go-at-speculative-page-faults-tt965642.html#none [2] https://patchwork.kernel.org/patch/687/ Laurent Dufour (20): mm: Introduce CONFIG_SPECULATIVE_

[PATCH v9 00/24] Speculative page faults

2018-03-13 Thread Laurent Dufour
nce events to report number of successful and failed speculative events. [1] http://linux-kernel.2935.n7.nabble.com/RFC-PATCH-0-6-Another-go-at-speculative-page-faults-tt965642.html#none [2] https://patchwork.kernel.org/patch/687/ Laurent Dufour (20): mm: Introduce CONFIG_SPECULATIVE_

Re: [PATCH v8 18/24] mm: Provide speculative fault infrastructure

2018-03-05 Thread Laurent Dufour
> > On 02/16/2018 10:25 AM, Laurent Dufour wrote: >> +static bool pte_map_lock(struct vm_fault *vmf) >> +{ > ...snip... >> +    if (!pmd_same(pmdval, vmf->orig_pmd)) >> +    goto out; > > Since SPF can now call pmd_same without THP, maybe the way to fi

Re: [PATCH v8 18/24] mm: Provide speculative fault infrastructure

2018-03-05 Thread Laurent Dufour
> > On 02/16/2018 10:25 AM, Laurent Dufour wrote: >> +static bool pte_map_lock(struct vm_fault *vmf) >> +{ > ...snip... >> +    if (!pmd_same(pmdval, vmf->orig_pmd)) >> +    goto out; > > Since SPF can now call pmd_same without THP, maybe the way to fi

[PATCH v8 05/24] mm: Introduce pte_spinlock for FAULT_FLAG_SPECULATIVE

2018-02-16 Thread Laurent Dufour
When handling page fault without holding the mmap_sem the fetch of the pte lock pointer and the locking will have to be done while ensuring that the VMA is not touched in our back. So move the fetch and locking operations in a dedicated function. Signed-off-by: Laurent Dufour <l

[PATCH v8 05/24] mm: Introduce pte_spinlock for FAULT_FLAG_SPECULATIVE

2018-02-16 Thread Laurent Dufour
When handling page fault without holding the mmap_sem the fetch of the pte lock pointer and the locking will have to be done while ensuring that the VMA is not touched in our back. So move the fetch and locking operations in a dedicated function. Signed-off-by: Laurent Dufour --- mm/memory.c

[PATCH v8 02/24] x86/mm: Define CONFIG_SPECULATIVE_PAGE_FAULT

2018-02-16 Thread Laurent Dufour
Introduce CONFIG_SPECULATIVE_PAGE_FAULT which turns on the Speculative Page Fault handler when building for 64bits with SMP. Cc: Thomas Gleixner <t...@linutronix.de> Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- arch/x86/Kconfig | 1 + 1 file changed, 1 insertion(+)

[PATCH v8 02/24] x86/mm: Define CONFIG_SPECULATIVE_PAGE_FAULT

2018-02-16 Thread Laurent Dufour
Introduce CONFIG_SPECULATIVE_PAGE_FAULT which turns on the Speculative Page Fault handler when building for 64bits with SMP. Cc: Thomas Gleixner Signed-off-by: Laurent Dufour --- arch/x86/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index

[PATCH v8 06/24] mm: make pte_unmap_same compatible with SPF

2018-02-16 Thread Laurent Dufour
is then trapped in cow_user_page(). If VM_FAULT_RETRY is returned, it is passed up to the callers to retry the page fault while holding the mmap_sem. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/mm.h | 1 + mm/memory.c| 37 ++--- 2

[PATCH v8 06/24] mm: make pte_unmap_same compatible with SPF

2018-02-16 Thread Laurent Dufour
is then trapped in cow_user_page(). If VM_FAULT_RETRY is returned, it is passed up to the callers to retry the page fault while holding the mmap_sem. Signed-off-by: Laurent Dufour --- include/linux/mm.h | 1 + mm/memory.c| 37 ++--- 2 files changed, 27 insertions(+), 11

[PATCH v8 09/24] mm: protect mremap() against SPF hanlder

2018-02-16 Thread Laurent Dufour
d by calling vm_raw_write_end() by the callee once the ptes have been moved. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/mm.h | 16 mm/mmap.c | 47 --- mm/mremap.c| 13 + 3

[PATCH v8 09/24] mm: protect mremap() against SPF hanlder

2018-02-16 Thread Laurent Dufour
d by calling vm_raw_write_end() by the callee once the ptes have been moved. Signed-off-by: Laurent Dufour --- include/linux/mm.h | 16 mm/mmap.c | 47 --- mm/mremap.c| 13 + 3 files changed, 61 insertions(+),

[PATCH v8 08/24] mm: Protect VMA modifications using VMA sequence count

2018-02-16 Thread Laurent Dufour
to prevent write to be split and intermediate values to be pushed to other CPUs. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- fs/proc/task_mmu.c | 5 - fs/userfaultfd.c | 17 + mm/khugepaged.c| 3 +++ mm/madvise.c | 6 +- mm/mempo

[PATCH v8 08/24] mm: Protect VMA modifications using VMA sequence count

2018-02-16 Thread Laurent Dufour
to prevent write to be split and intermediate values to be pushed to other CPUs. Signed-off-by: Laurent Dufour --- fs/proc/task_mmu.c | 5 - fs/userfaultfd.c | 17 + mm/khugepaged.c| 3 +++ mm/madvise.c | 6 +- mm/mempolicy.c | 51

[PATCH v8 12/24] mm/migrate: Pass vm_fault pointer to migrate_misplaced_page()

2018-02-16 Thread Laurent Dufour
migrate_misplaced_page() is only called during the page fault handling so it's better to pass the pointer to the struct vm_fault instead of the vma. This way during the speculative page fault path the saved vma->vm_flags could be used. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.i

[PATCH v8 12/24] mm/migrate: Pass vm_fault pointer to migrate_misplaced_page()

2018-02-16 Thread Laurent Dufour
migrate_misplaced_page() is only called during the page fault handling so it's better to pass the pointer to the struct vm_fault instead of the vma. This way during the speculative page fault path the saved vma->vm_flags could be used. Signed-off-by: Laurent Dufour --- include/linux/migrat

[PATCH v8 11/24] mm: Cache some VMA fields in the vm_fault structure

2018-02-16 Thread Laurent Dufour
hanges. This patch also set the fields in hugetlb_no_page() and __collapse_huge_page_swapin even if it is not need for the callee. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/mm.h | 6 ++ mm/hugetlb.c | 2 ++ mm/khugepaged.c| 2 ++ mm/memory.c

[PATCH v8 11/24] mm: Cache some VMA fields in the vm_fault structure

2018-02-16 Thread Laurent Dufour
hanges. This patch also set the fields in hugetlb_no_page() and __collapse_huge_page_swapin even if it is not need for the callee. Signed-off-by: Laurent Dufour --- include/linux/mm.h | 6 ++ mm/hugetlb.c | 2 ++ mm/khugepaged.c| 2 ++ mm/memory.c

[PATCH v8 14/24] mm: Introduce __maybe_mkwrite()

2018-02-16 Thread Laurent Dufour
() service which can be called by passing the value of the vm_flags field. There is no change functional changes expected for the other callers of maybe_mkwrite(). Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/mm.h | 9 +++-- mm/memory.c| 6 +++--- 2

[PATCH v8 14/24] mm: Introduce __maybe_mkwrite()

2018-02-16 Thread Laurent Dufour
() service which can be called by passing the value of the vm_flags field. There is no change functional changes expected for the other callers of maybe_mkwrite(). Signed-off-by: Laurent Dufour --- include/linux/mm.h | 9 +++-- mm/memory.c| 6 +++--- 2 files changed, 10 insertions(+), 5

[PATCH v8 13/24] mm: Introduce __lru_cache_add_active_or_unevictable

2018-02-16 Thread Laurent Dufour
pointer. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/swap.h | 10 -- mm/memory.c | 8 mm/swap.c| 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h

[PATCH v8 13/24] mm: Introduce __lru_cache_add_active_or_unevictable

2018-02-16 Thread Laurent Dufour
pointer. Signed-off-by: Laurent Dufour --- include/linux/swap.h | 10 -- mm/memory.c | 8 mm/swap.c| 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index a1a3f4ed94ce..99377b66ea93 100644

[PATCH v8 17/24] mm: Protect mm_rb tree with a rwlock

2018-02-16 Thread Laurent Dufour
ess speculative page fault. [1] https://patchwork.kernel.org/patch/5108281/ Cc: Peter Zijlstra (Intel) <pet...@infradead.org> Cc: Matthew Wilcox <wi...@infradead.org> Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/mm_types.h | 4 ++ kernel/fork.c

[PATCH v8 17/24] mm: Protect mm_rb tree with a rwlock

2018-02-16 Thread Laurent Dufour
ess speculative page fault. [1] https://patchwork.kernel.org/patch/5108281/ Cc: Peter Zijlstra (Intel) Cc: Matthew Wilcox Signed-off-by: Laurent Dufour --- include/linux/mm_types.h | 4 ++ kernel/fork.c| 3 ++ mm/init-mm.c | 3 ++ mm/internal.h| 6 +++

[PATCH v8 18/24] mm: Provide speculative fault infrastructure

2018-02-16 Thread Laurent Dufour
D against concurrent collapsing operation] [Try spin lock the pte during the speculative path to avoid deadlock with other CPU's invalidating the TLB and requiring this CPU to catch the inter processor's interrupt] Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/hug

[PATCH v8 18/24] mm: Provide speculative fault infrastructure

2018-02-16 Thread Laurent Dufour
lock the pte during the speculative path to avoid deadlock with other CPU's invalidating the TLB and requiring this CPU to catch the inter processor's interrupt] Signed-off-by: Laurent Dufour --- include/linux/hugetlb_inline.h | 2 +- include/linux/mm.h | 8 + include/linux/pagemap.h

[PATCH v8 21/24] perf tools: Add support for the SPF perf event

2018-02-16 Thread Laurent Dufour
Add support for the new speculative faults event. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- tools/include/uapi/linux/perf_event.h | 1 + tools/perf/util/evsel.c | 1 + tools/perf/util/parse-events.c| 4 tools/perf/util/parse-events.l

[PATCH v8 21/24] perf tools: Add support for the SPF perf event

2018-02-16 Thread Laurent Dufour
Add support for the new speculative faults event. Signed-off-by: Laurent Dufour --- tools/include/uapi/linux/perf_event.h | 1 + tools/perf/util/evsel.c | 1 + tools/perf/util/parse-events.c| 4 tools/perf/util/parse-events.l| 1 + tools/perf/util/python.c

[PATCH v8 24/24] powerpc/mm: Add speculative page fault

2018-02-16 Thread Laurent Dufour
for multithreaded process as there is no risk of contention on the mmap_sem otherwise. Build on if CONFIG_SPECULATIVE_PAGE_FAULT is defined (currently for BOOK3S_64 && SMP). Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- arch/powerpc/mm/fault.c | 31

[PATCH v8 24/24] powerpc/mm: Add speculative page fault

2018-02-16 Thread Laurent Dufour
for multithreaded process as there is no risk of contention on the mmap_sem otherwise. Build on if CONFIG_SPECULATIVE_PAGE_FAULT is defined (currently for BOOK3S_64 && SMP). Signed-off-by: Laurent Dufour --- arch/powerpc/mm/fault.c | 31 ++- 1 file changed, 30 in

[PATCH v8 19/24] mm: Adding speculative page fault failure trace events

2018-02-16 Thread Laurent Dufour
This patch a set of new trace events to collect the speculative page fault event failures. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/trace/events/pagefault.h | 87 mm/memory.c

[PATCH v8 22/24] mm: Speculative page fault handler return VMA

2018-02-16 Thread Laurent Dufour
matched the passed address and release the reference on the VMA so that it can be freed if needed. In the case the VMA is freed, can_reuse_spf_vma() will have returned false as the VMA is no more in the RB tree. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/linux/mm.h

[PATCH v8 19/24] mm: Adding speculative page fault failure trace events

2018-02-16 Thread Laurent Dufour
This patch a set of new trace events to collect the speculative page fault event failures. Signed-off-by: Laurent Dufour --- include/trace/events/pagefault.h | 87 mm/memory.c | 62 ++-- 2 files changed, 136

[PATCH v8 22/24] mm: Speculative page fault handler return VMA

2018-02-16 Thread Laurent Dufour
matched the passed address and release the reference on the VMA so that it can be freed if needed. In the case the VMA is freed, can_reuse_spf_vma() will have returned false as the VMA is no more in the RB tree. Signed-off-by: Laurent Dufour --- include/linux/mm.h | 5 +- mm/memory.c| 136

[PATCH v8 20/24] perf: Add a speculative page fault sw event

2018-02-16 Thread Laurent Dufour
Add a new software event to count succeeded speculative page faults. Signed-off-by: Laurent Dufour <lduf...@linux.vnet.ibm.com> --- include/uapi/linux/perf_event.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h

<    1   2   3   4   5   6   7   8   9   10   >