[PATCH 08/14] mm: add struct address_space to releasepage() callback

2020-10-06 Thread jglisse
From: Jérôme Glisse This is part of patchset to remove dependency on struct page.mapping field so that we can temporarily update it to point to a special structure tracking temporary page state (note that original mapping pointer is preserved and can still be accessed but at a cost). Add struct

[PATCH 14/14] mm: add struct address_space to is_dirty_writeback() callback

2020-10-06 Thread jglisse
From: Jérôme Glisse This is part of patchset to remove dependency on struct page.mapping field so that we can temporarily update it to point to a special structure tracking temporary page state (note that original mapping pointer is preserved and can still be accessed but at a cost). Add struct

[PATCH 09/14] mm: add struct address_space to freepage() callback

2020-10-06 Thread jglisse
From: Jérôme Glisse This is part of patchset to remove dependency on struct page.mapping field so that we can temporarily update it to point to a special structure tracking temporary page state (note that original mapping pointer is preserved and can still be accessed but at a cost). Add struct

[PATCH 13/14] mm: add struct address_space to isolate_page() callback

2020-10-06 Thread jglisse
From: Jérôme Glisse This is part of patchset to remove dependency on struct page.mapping field so that we can temporarily update it to point to a special structure tracking temporary page state (note that original mapping pointer is preserved and can still be accessed but at a cost). Add struct

[PATCH 12/14] mm: add struct address_space to is_partially_uptodate() callback

2020-10-06 Thread jglisse
From: Jérôme Glisse This is part of patchset to remove dependency on struct page.mapping field so that we can temporarily update it to point to a special structure tracking temporary page state (note that original mapping pointer is preserved and can still be accessed but at a cost). Add struct

[PATCH 11/14] mm: add struct address_space to launder_page() callback

2020-10-06 Thread jglisse
From: Jérôme Glisse This is part of patchset to remove dependency on struct page.mapping field so that we can temporarily update it to point to a special structure tracking temporary page state (note that original mapping pointer is preserved and can still be accessed but at a cost). Add struct

[PATCH 10/14] mm: add struct address_space to putback_page() callback

2020-10-06 Thread jglisse
From: Jérôme Glisse This is part of patchset to remove dependency on struct page.mapping field so that we can temporarily update it to point to a special structure tracking temporary page state (note that original mapping pointer is preserved and can still be accessed but at a cost). Add struct

[PATCH 07/14] mm: add struct address_space to invalidatepage() callback

2020-10-06 Thread jglisse
From: Jérôme Glisse This is part of patchset to remove dependency on struct page.mapping field so that we can temporarily update it to point to a special structure tracking temporary page state (note that original mapping pointer is preserved and can still be accessed but at a cost). Add struct

[PATCH 02/14] fs: define filler_t as a function pointer type

2020-10-06 Thread jglisse
From: Jérôme Glisse Coccinelle is confuse by filler_t not being a regular function pointer type. As they are no reason to define filler_t as a non pointer type redefine it as a function pointer type and update function prototype accordingly. Signed-off-by: Jérôme Glisse Cc: linux...@kvack.org

[PATCH 00/14] Small step toward KSM for file back page.

2020-10-06 Thread jglisse
From: Jérôme Glisse This patchset is a step toward a larger objective: generalize existing KSM into a mechanism allowing exclusive write control for a page; either anonymous memory (like KSM today) or file back page (modulo GUP which would block that like it does today for KSM). Exclusive write

[PATCH 04/14] mm: add struct address_space to readpage() callback

2020-10-06 Thread jglisse
From: Jérôme Glisse This is part of patchset to remove dependency on struct page.mapping field so that we can temporarily update it to point to a special structure tracking temporary page state (note that original mapping pointer is preserved and can still be accessed but at a cost). Add struct

[PATCH 01/14] mm/pxa: page exclusive access add header file for all helpers.

2020-10-06 Thread jglisse
From: Jérôme Glisse Add include/linux/page-xa.h where all helpers related to Page eXclusive Acces (PXA) will be added (in following patches). Also introduce MAPPING_NULL as a temporary define use to simplify the mass modifications to stop relying on struct page.mapping and instead pass down

[PATCH 05/14] mm: add struct address_space to writepage() callback

2020-10-06 Thread jglisse
From: Jérôme Glisse This is part of patchset to remove dependency on struct page.mapping field so that we can temporarily update it to point to a special structure tracking temporary page state (note that original mapping pointer is preserved and can still be accessed but at a cost). Add struct

[PATCH 06/14] mm: add struct address_space to set_page_dirty() callback

2020-10-06 Thread jglisse
From: Jérôme Glisse This is part of patchset to remove dependency on struct page.mapping field so that we can temporarily update it to point to a special structure tracking temporary page state (note that original mapping pointer is preserved and can still be accessed but at a cost). Add struct

[PATCH 03/14] fs: directly use a_ops->freepage() instead of a local copy of it.

2020-10-06 Thread jglisse
From: Jérôme Glisse Coccinelle is confuse with function pointer, convert to directly use a_ops->freepage() to be nice to coccinelle. Signed-off-by: Jérôme Glisse Cc: linux-fsde...@vger.kernel.org Cc: linux...@kvack.org Cc: Alexander Viro Cc: Tejun Heo Cc: Jan Kara Cc: Josef Bacik Cc:

[PATCH] mm/hmm: move THP and hugetlbfs code path behind #if KCONFIG

2019-04-22 Thread jglisse
From: Jérôme Glisse To avoid any undefined symbol build warning or error, move THP and hugetlbfs code behind kconfig #if/#else/#endif against appropriate Kconfig option. Signed-off-by: Jérôme Glisse Cc: Ralph Campbell Cc: John Hubbard Cc: Andrew Morton --- mm/hmm.c | 9 + 1 file

[PATCH] mm/hmm: add ARCH_HAS_HMM_MIRROR ARCH_HAS_HMM_DEVICE Kconfig

2019-04-17 Thread jglisse
From: Jérôme Glisse This patch just add 2 new Kconfig that are _not use_ by anyone. I check that various make ARCH=somearch allmodconfig do work and do not complain. This new Kconfig need to be added first so that device driver that do depend on HMM can be updated. Once drivers are updated then

[PATCH v4 1/1] RDMA/odp: convert to use HMM for ODP v4

2019-04-11 Thread jglisse
From: Jérôme Glisse Convert ODP to use HMM so that we can build on common infrastructure for different class of devices that want to mirror a process address space into a device. There is no functional changes. Changes since v3: - fix Kconfig to properly depends on HMM, also make sure

[PATCH v4 0/1] Use HMM for ODP v4

2019-04-11 Thread jglisse
From: Jérôme Glisse Just fixed Kconfig and build when ODP was not enabled, other than that this is the same as v3. Here is previous cover letter: Git tree with all prerequisite: https://cgit.freedesktop.org/~glisse/linux/log/?h=rdma-odp-hmm-v4 This patchset convert RDMA ODP to use HMM

[PATCH] mm/hmm: kconfig split HMM address space mirroring from device memory

2019-04-11 Thread jglisse
From: Jérôme Glisse To allow building device driver that only care about address space mirroring (like RDMA ODP) on platform that do not have all the pre- requisite for HMM device memory (like ZONE_DEVICE on ARM) split the HMM_MIRROR option dependency from the HMM_DEVICE dependency.

[PATCH] cifs: fix page reference leak with readv/writev

2019-04-10 Thread jglisse
From: Jérôme Glisse CIFS can leak pages reference gotten through GUP (get_user_pages*() through iov_iter_get_pages()). This happen if cifs_send_async_read() or cifs_write_from_iter() calls fail from within __cifs_readv() and __cifs_writev() respectively. This patch move page unreference to

[PATCH v3 1/1] RDMA/odp: convert to use HMM for ODP v3

2019-04-10 Thread jglisse
From: Jérôme Glisse Convert ODP to use HMM so that we can build on common infrastructure for different class of devices that want to mirror a process address space into a device. There is no functional changes. Changes since v2: - rebase on top of newer HMM patchset and mmu notifier

[PATCH v3 0/1] Use HMM for ODP v3

2019-04-10 Thread jglisse
From: Jérôme Glisse Changes since v1/v2 are about rebase and better comments in the code. Previous cover letter slightly updated. This patchset convert RDMA ODP to use HMM underneath this is motivated by stronger code sharing for same feature (share virtual memory SVM or Share Virtual Address

[PATCH] mm/hmm: fix hmm_range_dma_map()/hmm_range_dma_unmap()

2019-04-09 Thread jglisse
From: Jérôme Glisse Was using wrong field and wrong enum for read only versus read and write mapping. Signed-off-by: Jérôme Glisse Cc: Andrew Morton Cc: Ralph Campbell Cc: John Hubbard --- mm/hmm.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/hmm.c

[PATCH] zram: pass down the bvec we need to read into in the work struct

2019-04-08 Thread jglisse
From: Jérôme Glisse When scheduling work item to read page we need to pass down the proper bvec struct which point to the page to read into. Before this patch it uses randomly initialized bvec (only if PAGE_SIZE != 4096) which is wrong. Signed-off-by: Jérôme Glisse Cc: Minchan Kim Cc: Nitin

[PATCH v3 12/12] mm/hmm: convert various hmm_pfn_* to device_entry which is a better name

2019-04-03 Thread jglisse
From: Jérôme Glisse Convert hmm_pfn_* to device_entry_* as here we are dealing with device driver specific entry format and hmm provide helpers to allow differents components (including HMM) to create/parse device entry. We keep wrapper with the old name so that we can convert driver to use the

[PATCH v3 05/12] mm/hmm: improve and rename hmm_vma_fault() to hmm_range_fault() v3

2019-04-03 Thread jglisse
From: Jérôme Glisse Minor optimization around hmm_pte_need_fault(). Rename for consistency between code, comments and documentation. Also improves the comments on all the possible returns values. Improve the function by returning the number of populated entries in pfns array. Changes since v2:

[PATCH v3 02/12] mm/hmm: use reference counting for HMM struct v3

2019-04-03 Thread jglisse
From: Jérôme Glisse Every time i read the code to check that the HMM structure does not vanish before it should thanks to the many lock protecting its removal i get a headache. Switch to reference counting instead it is much easier to follow and harder to break. This also remove some code that

[PATCH v3 10/12] mm/hmm: add helpers to test if mm is still alive or not

2019-04-03 Thread jglisse
From: Jérôme Glisse The device driver can have kernel thread or worker doing work against a process mm and it is useful for those to test wether the mm is dead or alive to avoid doing useless work. Add an helper to test that so that driver can bail out early if a process is dying. Note that the

[PATCH v3 09/12] mm/hmm: allow to mirror vma of a file on a DAX backed filesystem v3

2019-04-03 Thread jglisse
From: Jérôme Glisse HMM mirror is a device driver helpers to mirror range of virtual address. It means that the process jobs running on the device can access the same virtual address as the CPU threads of that process. This patch adds support for mirroring mapping of file that are on a DAX block

[PATCH v3 06/12] mm/hmm: improve driver API to work and wait over a range v3

2019-04-03 Thread jglisse
From: Jérôme Glisse A common use case for HMM mirror is user trying to mirror a range and before they could program the hardware it get invalidated by some core mm event. Instead of having user re-try right away to mirror the range provide a completion mechanism for them to wait for any active

[PATCH v3 11/12] mm/hmm: add an helper function that fault pages and map them to a device v3

2019-04-03 Thread jglisse
From: Jérôme Glisse This is a all in one helper that fault pages in a range and map them to a device so that every single device driver do not have to re-implement this common pattern. This is taken from ODP RDMA in preparation of ODP RDMA convertion. It will be use by nouveau and other

[PATCH v3 03/12] mm/hmm: do not erase snapshot when a range is invalidated

2019-04-03 Thread jglisse
From: Jérôme Glisse Users of HMM might be using the snapshot information to do preparatory step like dma mapping pages to a device before checking for invalidation through hmm_vma_range_done() so do not erase that information and assume users will do the right thing. Signed-off-by: Jérôme

[PATCH v3 04/12] mm/hmm: improve and rename hmm_vma_get_pfns() to hmm_range_snapshot() v2

2019-04-03 Thread jglisse
From: Jérôme Glisse Rename for consistency between code, comments and documentation. Also improves the comments on all the possible returns values. Improve the function by returning the number of populated entries in pfns array. Changes since v1: - updated documentation - reformated

[PATCH v3 08/12] mm/hmm: mirror hugetlbfs (snapshoting, faulting and DMA mapping) v3

2019-04-03 Thread jglisse
From: Jérôme Glisse HMM mirror is a device driver helpers to mirror range of virtual address. It means that the process jobs running on the device can access the same virtual address as the CPU threads of that process. This patch adds support for hugetlbfs mapping (ie range of virtual address

[PATCH v3 07/12] mm/hmm: add default fault flags to avoid the need to pre-fill pfns arrays v2

2019-04-03 Thread jglisse
From: Jérôme Glisse The HMM mirror API can be use in two fashions. The first one where the HMM user coalesce multiple page faults into one request and set flags per pfns for of those faults. The second one where the HMM user want to pre-fault a range with specific flags. For the latter one it is

[PATCH v3 00/12] Improve HMM driver API v3

2019-04-03 Thread jglisse
From: Jérôme Glisse Changes since v2: - Improved the documentations - Added more comments in the code to explain things - Renamed bunch of functions from popular demands This patchset improves the HMM driver API and add support for mirroring virtual address that are mmap of

[PATCH v3 01/12] mm/hmm: select mmu notifier when selecting HMM v2

2019-04-03 Thread jglisse
From: Jérôme Glisse To avoid random config build issue, select mmu notifier when HMM is selected. In any cases when HMM get selected it will be by users that will also wants the mmu notifier. Changes since v1: - remove select MMU_NOTIFIER from HMM_MIRROR as it select HMM which select

[PATCH v2 10/11] mm/hmm: add helpers for driver to safely take the mmap_sem v2

2019-03-25 Thread jglisse
From: Jérôme Glisse The device driver context which holds reference to mirror and thus to core hmm struct might outlive the mm against which it was created. To avoid every driver to check for that case provide an helper that check if mm is still alive and take the mmap_sem in read mode if so. If

[PATCH v2 11/11] mm/hmm: add an helper function that fault pages and map them to a device v2

2019-03-25 Thread jglisse
From: Jérôme Glisse This is a all in one helper that fault pages in a range and map them to a device so that every single device driver do not have to re-implement this common pattern. This is taken from ODP RDMA in preparation of ODP RDMA convertion. It will be use by nouveau and other

[PATCH v2 05/11] mm/hmm: improve and rename hmm_vma_fault() to hmm_range_fault() v2

2019-03-25 Thread jglisse
From: Jérôme Glisse Rename for consistency between code, comments and documentation. Also improves the comments on all the possible returns values. Improve the function by returning the number of populated entries in pfns array. Changes since v1: - updated documentation - reformated

[PATCH v2 07/11] mm/hmm: add default fault flags to avoid the need to pre-fill pfns arrays.

2019-03-25 Thread jglisse
From: Jérôme Glisse The HMM mirror API can be use in two fashions. The first one where the HMM user coalesce multiple page faults into one request and set flags per pfns for of those faults. The second one where the HMM user want to pre-fault a range with specific flags. For the latter one it is

[PATCH v2 04/11] mm/hmm: improve and rename hmm_vma_get_pfns() to hmm_range_snapshot() v2

2019-03-25 Thread jglisse
From: Jérôme Glisse Rename for consistency between code, comments and documentation. Also improves the comments on all the possible returns values. Improve the function by returning the number of populated entries in pfns array. Changes since v1: - updated documentation - reformated

[PATCH v2 01/11] mm/hmm: select mmu notifier when selecting HMM

2019-03-25 Thread jglisse
From: Jérôme Glisse To avoid random config build issue, select mmu notifier when HMM is selected. In any cases when HMM get selected it will be by users that will also wants the mmu notifier. Signed-off-by: Jérôme Glisse Acked-by: Balbir Singh Cc: Ralph Campbell Cc: Andrew Morton Cc: John

[PATCH v2 00/11] Improve HMM driver API v2

2019-03-25 Thread jglisse
From: Jérôme Glisse This patchset improves the HMM driver API and add support for mirroring virtual address that are mmap of hugetlbfs or of a file in a filesystem on a DAX block device. You can find a tree with all the patches [1] This patchset is necessary for converting ODP to HMM and patch

[PATCH v2 06/11] mm/hmm: improve driver API to work and wait over a range v2

2019-03-25 Thread jglisse
From: Jérôme Glisse A common use case for HMM mirror is user trying to mirror a range and before they could program the hardware it get invalidated by some core mm event. Instead of having user re-try right away to mirror the range provide a completion mechanism for them to wait for any active

[PATCH v2 09/11] mm/hmm: allow to mirror vma of a file on a DAX backed filesystem v2

2019-03-25 Thread jglisse
From: Jérôme Glisse HMM mirror is a device driver helpers to mirror range of virtual address. It means that the process jobs running on the device can access the same virtual address as the CPU threads of that process. This patch adds support for mirroring mapping of file that are on a DAX block

[PATCH v2 03/11] mm/hmm: do not erase snapshot when a range is invalidated

2019-03-25 Thread jglisse
From: Jérôme Glisse Users of HMM might be using the snapshot information to do preparatory step like dma mapping pages to a device before checking for invalidation through hmm_vma_range_done() so do not erase that information and assume users will do the right thing. Signed-off-by: Jérôme

[PATCH v2 08/11] mm/hmm: mirror hugetlbfs (snapshoting, faulting and DMA mapping) v2

2019-03-25 Thread jglisse
From: Jérôme Glisse HMM mirror is a device driver helpers to mirror range of virtual address. It means that the process jobs running on the device can access the same virtual address as the CPU threads of that process. This patch adds support for hugetlbfs mapping (ie range of virtual address

[PATCH v2 02/11] mm/hmm: use reference counting for HMM struct v2

2019-03-25 Thread jglisse
From: Jérôme Glisse Every time i read the code to check that the HMM structure does not vanish before it should thanks to the many lock protecting its removal i get a headache. Switch to reference counting instead it is much easier to follow and harder to break. This also remove some code that

[PATCH v2 1/1] RDMA/odp: convert to use HMM for ODP v2

2019-03-21 Thread jglisse
From: Jérôme Glisse Convert ODP to use HMM so that we can build on common infrastructure for different class of devices that want to mirror a process address space into a device. There is no functional changes. Changes since v1: - improved comments - simplified page alignment

[PATCH v2 0/1] Use HMM for ODP v2

2019-03-21 Thread jglisse
From: Jérôme Glisse This is just a rebase with minor changes and better comments in the code. Previous cover letter (slightly improved): This patchset convert RDMA ODP to use HMM underneath this is motivated by stronger code sharing for same feature (share virtual memory SVM or Share Virtual

[PATCH v2 0/1] Restore change_pte optimization

2019-02-20 Thread jglisse
From: Jérôme Glisse This patch is on top of my patchset to add context information to mmu notifier [1] you can find a branch with everything [2]. It has been tested with qemu/KVM building kernel within the guest and also running a benchmark which the result are given below. The change_pte()

[PATCH v2 1/1] kvm/mmu_notifier: re-enable the change_pte() optimization.

2019-02-20 Thread jglisse
From: Jérôme Glisse Since changes to mmu notifier the change_pte() optimization was lost for kvm. This re-enable it, when ever a pte is going from read and write to read only with same pfn, or from read only to read and write with different pfn. It is safe to update the secondary MMUs, because

[PATCH v5 8/9] mm/mmu_notifier: mmu_notifier_range_update_to_read_only() helper

2019-02-19 Thread jglisse
From: Jérôme Glisse Helper to test if a range is updated to read only (it is still valid to read from the range). This is useful for device driver or anyone who wish to optimize out update when they know that they already have the range map read only. Signed-off-by: Jérôme Glisse Cc: Christian

[PATCH v5 9/9] mm/mmu_notifier: set MMU_NOTIFIER_USE_CHANGE_PTE flag where appropriate v2

2019-02-19 Thread jglisse
From: Jérôme Glisse When notifying change for a range use MMU_NOTIFIER_USE_CHANGE_PTE flag for page table update that use set_pte_at_notify() and where the we are going either from read and write to read only with same pfn or read only to read and write with new pfn. Note that

[PATCH v5 6/9] mm/mmu_notifier: use correct mmu_notifier events for each invalidation

2019-02-19 Thread jglisse
From: Jérôme Glisse This update each existing invalidation to use the correct mmu notifier event that represent what is happening to the CPU page table. See the patch which introduced the events to see the rational behind this. Signed-off-by: Jérôme Glisse Cc: Christian König Cc: Joonas

[PATCH v5 7/9] mm/mmu_notifier: pass down vma and reasons why mmu notifier is happening v2

2019-02-19 Thread jglisse
From: Jérôme Glisse CPU page table update can happens for many reasons, not only as a result of a syscall (munmap(), mprotect(), mremap(), madvise(), ...) but also as a result of kernel activities (memory compression, reclaim, migration, ...). Users of mmu notifier API track changes to the CPU

[PATCH v5 4/9] mm/mmu_notifier: contextual information for event enums

2019-02-19 Thread jglisse
From: Jérôme Glisse CPU page table update can happens for many reasons, not only as a result of a syscall (munmap(), mprotect(), mremap(), madvise(), ...) but also as a result of kernel activities (memory compression, reclaim, migration, ...). This patch introduce a set of enums that can be

[PATCH v5 5/9] mm/mmu_notifier: contextual information for event triggering invalidation v2

2019-02-19 Thread jglisse
From: Jérôme Glisse CPU page table update can happens for many reasons, not only as a result of a syscall (munmap(), mprotect(), mremap(), madvise(), ...) but also as a result of kernel activities (memory compression, reclaim, migration, ...). Users of mmu notifier API track changes to the CPU

[PATCH v5 0/9] mmu notifier provide context informations

2019-02-19 Thread jglisse
From: Jérôme Glisse Since last version [4] i added the extra bits needed for the change_pte optimization (which is a KSM thing). Here i am not posting users of this, they will be posted to the appropriate sub-systems (KVM, GPU, RDMA, ...) once this serie get upstream. If you want to look at

[PATCH v5 3/9] mm/mmu_notifier: convert mmu_notifier_range->blockable to a flags

2019-02-19 Thread jglisse
From: Jérôme Glisse Use an unsigned field for flags other than blockable and convert the blockable field to be one of those flags. Signed-off-by: Jérôme Glisse Cc: Christian König Cc: Joonas Lahtinen Cc: Jani Nikula Cc: Rodrigo Vivi Cc: Jan Kara Cc: Andrea Arcangeli Cc: Peter Xu Cc:

[PATCH v5 2/9] mm/mmu_notifier: convert user range->blockable to helper function

2019-02-19 Thread jglisse
From: Jérôme Glisse Use the mmu_notifier_range_blockable() helper function instead of directly dereferencing the range->blockable field. This is done to make it easier to change the mmu_notifier range field. This patch is the outcome of the following coccinelle patch:

[PATCH v5 1/9] mm/mmu_notifier: helper to test if a range invalidation is blockable

2019-02-19 Thread jglisse
From: Jérôme Glisse Simple helpers to test if range invalidation is blockable. Latter patches use cocinnelle to convert all direct dereference of range-> blockable to use this function instead so that we can convert the blockable field to an unsigned for more flags. Signed-off-by: Jérôme Glisse

[RFC PATCH 1/4] uprobes: use set_pte_at() not set_pte_at_notify()

2019-01-31 Thread jglisse
From: Jérôme Glisse Using set_pte_at_notify() trigger useless calls to change_pte() so just use set_pte_at() instead. The reason is that set_pte_at_notify() should only be use when going from either a read and write pte to read only pte with same pfn, or from read only to read and write with a

[RFC PATCH 3/4] mm/mmu_notifier: set MMU_NOTIFIER_USE_CHANGE_PTE flag where appropriate

2019-01-31 Thread jglisse
From: Jérôme Glisse When notifying change for a range use MMU_NOTIFIER_USE_CHANGE_PTE flag for page table update that use set_pte_at_notify() and where the we are going either from read and write to read only with same pfn or read only to read and write with new pfn. Note that

[RFC PATCH 2/4] mm/mmu_notifier: use unsigned for event field in range struct

2019-01-31 Thread jglisse
From: Jérôme Glisse Use unsigned for event field in range struct so that we can also set flags with the event. This patch change the field and introduce the helper. Signed-off-by: Jérôme Glisse Cc: Andrea Arcangeli Cc: Peter Xu Cc: Andrew Morton Cc: Paolo Bonzini Cc: Radim Krčmář Cc:

[RFC PATCH 4/4] kvm/mmu_notifier: re-enable the change_pte() optimization.

2019-01-31 Thread jglisse
From: Jérôme Glisse Since changes to mmu notifier the change_pte() optimization was lost for kvm. This re-enable it, when ever a pte is going from read and write to read only with same pfn, or from read only to read and write with different pfn. It is safe to update the secondary MMUs, because

[RFC PATCH 0/4] Restore change_pte optimization to its former glory

2019-01-31 Thread jglisse
From: Jérôme Glisse This patchset is on top of my patchset to add context information to mmu notifier [1] you can find a branch with everything [2]. I have not tested it but i wanted to get the discussion started. I believe it is correct but i am not sure what kind of kvm test i can run to

[RFC PATCH 4/5] mm/hmm: add support for peer to peer to HMM device memory

2019-01-29 Thread jglisse
From: Jérôme Glisse Signed-off-by: Jérôme Glisse Cc: Logan Gunthorpe Cc: Greg Kroah-Hartman Cc: Rafael J. Wysocki Cc: Bjorn Helgaas Cc: Christian Koenig Cc: Felix Kuehling Cc: Jason Gunthorpe Cc: linux-...@vger.kernel.org Cc: dri-de...@lists.freedesktop.org Cc: Christoph Hellwig Cc:

[RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma

2019-01-29 Thread jglisse
From: Jérôme Glisse Allow mmap of device file to export device memory to peer to peer devices. This will allow for instance a network device to access a GPU memory or to access a storage device queue directly. The common case will be a vma created by userspace device driver that is then share

[RFC PATCH 5/5] mm/hmm: add support for peer to peer to special device vma

2019-01-29 Thread jglisse
From: Jérôme Glisse Special device vma (mmap of a device file) can correspond to device driver object that some device driver might want to share with other device (giving access to). This add support for HMM to map those special device vma if the owning device (exporter) allows it.

[RFC PATCH 1/5] pci/p2p: add a function to test peer to peer capability

2019-01-29 Thread jglisse
From: Jérôme Glisse device_test_p2p() return true if two devices can peer to peer to each other. We add a generic function as different inter-connect can support peer to peer and we want to genericaly test this no matter what the inter-connect might be. However this version only support PCIE for

[RFC PATCH 2/5] drivers/base: add a function to test peer to peer capability

2019-01-29 Thread jglisse
From: Jérôme Glisse device_test_p2p() return true if two devices can peer to peer to each other. We add a generic function as different inter-connect can support peer to peer and we want to genericaly test this no matter what the inter-connect might be. However this version only support PCIE for

[RFC PATCH 0/5] Device peer to peer (p2p) through vma

2019-01-29 Thread jglisse
From: Jérôme Glisse This patchset add support for peer to peer between device in two manner. First for device memory use through HMM in process regular address space (ie inside a regular vma that is not an mmap of device file or special file). Second for special vma ie mmap of a device file, in

[PATCH 1/1] RDMA/odp: convert to use HMM for ODP

2019-01-29 Thread jglisse
From: Jérôme Glisse Convert ODP to use HMM so that we can build on common infrastructure for different class of devices that want to mirror a process address space into a device. There is no functional changes. Signed-off-by: Jérôme Glisse Cc: linux-r...@vger.kernel.org Cc: Jason Gunthorpe

[RFC PATCH 0/1] Use HMM for ODP

2019-01-29 Thread jglisse
From: Jérôme Glisse This patchset convert RDMA ODP to use HMM underneath this is motivated by stronger code sharing for same feature (share virtual memory SVM or Share Virtual Address SVA) and also stronger integration with mm code to achieve that. It depends on HMM patchset posted for inclusion

[PATCH 06/10] mm/hmm: add default fault flags to avoid the need to pre-fill pfns arrays.

2019-01-29 Thread jglisse
From: Jérôme Glisse The HMM mirror API can be use in two fashions. The first one where the HMM user coalesce multiple page faults into one request and set flags per pfns for of those faults. The second one where the HMM user want to pre-fault a range with specific flags. For the latter one it is

[PATCH 01/10] mm/hmm: use reference counting for HMM struct

2019-01-29 Thread jglisse
From: Jérôme Glisse Every time i read the code to check that the HMM structure does not vanish before it should thanks to the many lock protecting its removal i get a headache. Switch to reference counting instead it is much easier to follow and harder to break. This also remove some code that

[PATCH 03/10] mm/hmm: improve and rename hmm_vma_get_pfns() to hmm_range_snapshot()

2019-01-29 Thread jglisse
From: Jérôme Glisse Rename for consistency between code, comments and documentation. Also improves the comments on all the possible returns values. Improve the function by returning the number of populated entries in pfns array. Signed-off-by: Jérôme Glisse Cc: Andrew Morton Cc: Ralph

[PATCH 04/10] mm/hmm: improve and rename hmm_vma_fault() to hmm_range_fault()

2019-01-29 Thread jglisse
From: Jérôme Glisse Rename for consistency between code, comments and documentation. Also improves the comments on all the possible returns values. Improve the function by returning the number of populated entries in pfns array. Signed-off-by: Jérôme Glisse Cc: Andrew Morton Cc: Ralph

[PATCH 09/10] mm/hmm: allow to mirror vma of a file on a DAX backed filesystem

2019-01-29 Thread jglisse
From: Jérôme Glisse This add support to mirror vma which is an mmap of a file which is on a filesystem that using a DAX block device. There is no reason not to support that case. Note that unlike GUP code we do not take page reference hence when we back-off we have nothing to undo.

[PATCH 02/10] mm/hmm: do not erase snapshot when a range is invalidated

2019-01-29 Thread jglisse
From: Jérôme Glisse Users of HMM might be using the snapshot information to do preparatory step like dma mapping pages to a device before checking for invalidation through hmm_vma_range_done() so do not erase that information and assume users will do the right thing. Signed-off-by: Jérôme

[PATCH 07/10] mm/hmm: add an helper function that fault pages and map them to a device

2019-01-29 Thread jglisse
From: Jérôme Glisse This is a all in one helper that fault pages in a range and map them to a device so that every single device driver do not have to re-implement this common pattern. Signed-off-by: Jérôme Glisse Cc: Andrew Morton Cc: Ralph Campbell Cc: John Hubbard ---

[PATCH 10/10] mm/hmm: add helpers for driver to safely take the mmap_sem

2019-01-29 Thread jglisse
From: Jérôme Glisse The device driver context which holds reference to mirror and thus to core hmm struct might outlive the mm against which it was created. To avoid every driver to check for that case provide an helper that check if mm is still alive and take the mmap_sem in read mode if so. If

[PATCH 05/10] mm/hmm: improve driver API to work and wait over a range

2019-01-29 Thread jglisse
From: Jérôme Glisse A common use case for HMM mirror is user trying to mirror a range and before they could program the hardware it get invalidated by some core mm event. Instead of having user re-try right away to mirror the range provide a completion mechanism for them to wait for any active

[PATCH 08/10] mm/hmm: support hugetlbfs (snap shoting, faulting and DMA mapping)

2019-01-29 Thread jglisse
From: Jérôme Glisse This adds support for hugetlbfs so that HMM user can map mirror range of virtual address back by hugetlbfs. Note that now the range allows user to optimize DMA mapping of such page so that we can map a huge page as one chunk. Signed-off-by: Jérôme Glisse Cc: Andrew Morton

[PATCH 00/10] HMM updates for 5.1

2019-01-29 Thread jglisse
From: Jérôme Glisse This patchset improves the HMM driver API and add support for hugetlbfs and DAX mirroring. The improvement motivation was to make the ODP to HMM conversion easier [1]. Because we have nouveau bits schedule for 5.1 and to avoid any multi-tree synchronization this patchset adds

[PATCH v4 5/9] mm/mmu_notifier: mmu_notifier_range_update_to_read_only() helper

2019-01-23 Thread jglisse
From: Jérôme Glisse Helper to test if a range is updated to read only (it is still valid to read from the range). This is useful for device driver or anyone who wish to optimize out update when they know that they already have the range map read only. Signed-off-by: Jérôme Glisse Cc: Christian

[PATCH v4 9/9] RDMA/umem_odp: optimize out the case when a range is updated to read only

2019-01-23 Thread jglisse
From: Jérôme Glisse When range of virtual address is updated read only and corresponding user ptr object are already read only it is pointless to do anything. Optimize this case out. Signed-off-by: Jérôme Glisse Cc: Christian König Cc: Jan Kara Cc: Felix Kuehling Cc: Jason Gunthorpe Cc:

[PATCH v4 4/9] mm/mmu_notifier: pass down vma and reasons why mmu notifier is happening

2019-01-23 Thread jglisse
From: Jérôme Glisse CPU page table update can happens for many reasons, not only as a result of a syscall (munmap(), mprotect(), mremap(), madvise(), ...) but also as a result of kernel activities (memory compression, reclaim, migration, ...). Users of mmu notifier API track changes to the CPU

[PATCH v4 6/9] gpu/drm/radeon: optimize out the case when a range is updated to read only

2019-01-23 Thread jglisse
From: Jérôme Glisse When range of virtual address is updated read only and corresponding user ptr object are already read only it is pointless to do anything. Optimize this case out. Signed-off-by: Jérôme Glisse Cc: Christian König Cc: Jan Kara Cc: Felix Kuehling Cc: Jason Gunthorpe Cc:

[PATCH v4 2/9] mm/mmu_notifier: contextual information for event triggering invalidation

2019-01-23 Thread jglisse
From: Jérôme Glisse CPU page table update can happens for many reasons, not only as a result of a syscall (munmap(), mprotect(), mremap(), madvise(), ...) but also as a result of kernel activities (memory compression, reclaim, migration, ...). Users of mmu notifier API track changes to the CPU

[PATCH v4 7/9] gpu/drm/amdgpu: optimize out the case when a range is updated to read only

2019-01-23 Thread jglisse
From: Jérôme Glisse When range of virtual address is updated read only and corresponding user ptr object are already read only it is pointless to do anything. Optimize this case out. Signed-off-by: Jérôme Glisse Cc: Christian König Cc: Jan Kara Cc: Felix Kuehling Cc: Jason Gunthorpe Cc:

[PATCH v4 3/9] mm/mmu_notifier: use correct mmu_notifier events for each invalidation

2019-01-23 Thread jglisse
From: Jérôme Glisse This update each existing invalidation to use the correct mmu notifier event that represent what is happening to the CPU page table. See the patch which introduced the events to see the rational behind this. Signed-off-by: Jérôme Glisse Cc: Christian König Cc: Jan Kara

[PATCH v4 1/9] mm/mmu_notifier: contextual information for event enums

2019-01-23 Thread jglisse
From: Jérôme Glisse CPU page table update can happens for many reasons, not only as a result of a syscall (munmap(), mprotect(), mremap(), madvise(), ...) but also as a result of kernel activities (memory compression, reclaim, migration, ...). This patch introduce a set of enums that can be

[PATCH v4 8/9] gpu/drm/i915: optimize out the case when a range is updated to read only

2019-01-23 Thread jglisse
From: Jérôme Glisse When range of virtual address is updated read only and corresponding user ptr object are already read only it is pointless to do anything. Optimize this case out. Signed-off-by: Jérôme Glisse Cc: Christian König Cc: Jan Kara Cc: Felix Kuehling Cc: Jason Gunthorpe Cc:

[PATCH v4 0/9] mmu notifier provide context informations

2019-01-23 Thread jglisse
From: Jérôme Glisse Hi Andrew, i see that you still have my event patch in you queue [1]. This patchset replace that single patch and is broken down in further step so that it is easier to review and ascertain that no mistake were made during mechanical changes. Here are the step: Patch 1 -

[PATCH v3 3/3] mm/mmu_notifier: contextual information for event triggering invalidation v2

2018-12-13 Thread jglisse
From: Jérôme Glisse CPU page table update can happens for many reasons, not only as a result of a syscall (munmap(), mprotect(), mremap(), madvise(), ...) but also as a result of kernel activities (memory compression, reclaim, migration, ...). Users of mmu notifier API track changes to the CPU

[PATCH v3 1/3] mm/mmu_notifier: use structure for invalidate_range_start/end callback v2

2018-12-13 Thread jglisse
From: Jérôme Glisse To avoid having to change many callback definition everytime we want to add a parameter use a structure to group all parameters for the mmu_notifier invalidate_range_start/end callback. No functional changes with this patch. Changed since v1: - fix make htmldocs warning

  1   2   3   4   5   >