Re: [PATCH 1/6] mmu_notifier: add event information to address invalidation v6

2015-01-12 Thread Jerome Glisse
On Sun, Jan 11, 2015 at 02:24:01PM +0200, Oded Gabbay wrote:
> 
> 
> On 01/06/2015 12:44 AM, j.gli...@gmail.com wrote:
> > From: Jérôme Glisse 
> > 
> > The event information will be useful for new user of mmu_notifier API.
> > The event argument differentiate between a vma disappearing, a page
> > being write protected or simply a page being unmaped. This allow new
> > user to take different path for different event for instance on unmap
> > the resource used to track a vma are still valid and should stay around.
> > While if the event is saying that a vma is being destroy it means that any
> > resources used to track this vma can be free.
> > 
> > Changed since v1:
> >   - renamed action into event (updated commit message too).
> >   - simplified the event names and clarified their usage
> > also documenting what exceptation the listener can have in
> > respect to each event.
> > 
> > Changed since v2:
> >   - Avoid crazy name.
> >   - Do not move code that do not need to move.
> > 
> > Changed since v3:
> >   - Separate hugue page split from mlock/munlock and softdirty.
> > 
> > Changed since v4:
> >   - Rebase (no other changes).
> > 
> > Changed since v5:
> >   - Typo fix.
> >   - Changed zap_page_range from MMU_MUNMAP to MMU_MIGRATE to reflect the
> > fact that the address range is still valid just the page backing it
> > are no longer.
> > 
> > Signed-off-by: Jérôme Glisse 
> > Reviewed-by: Rik van Riel 
> > ---
> >  drivers/gpu/drm/i915/i915_gem_userptr.c |   3 +-
> >  drivers/gpu/drm/radeon/radeon_mn.c  |   3 +-
> >  drivers/infiniband/core/umem_odp.c  |   9 ++-
> >  drivers/iommu/amd_iommu_v2.c|   3 +-
> >  drivers/misc/sgi-gru/grutlbpurge.c  |   9 ++-
> >  drivers/xen/gntdev.c|   9 ++-
> >  fs/proc/task_mmu.c  |   6 +-
> >  include/linux/mmu_notifier.h| 131 
> > ++--
> >  kernel/events/uprobes.c |  10 ++-
> >  mm/filemap_xip.c|   2 +-
> >  mm/huge_memory.c|  39 ++
> >  mm/hugetlb.c|  23 +++---
> >  mm/ksm.c|  18 +++--
> >  mm/madvise.c|   4 +-
> >  mm/memory.c |  27 ---
> >  mm/migrate.c|   9 ++-
> >  mm/mmu_notifier.c   |  28 ---
> >  mm/mprotect.c   |   6 +-
> >  mm/mremap.c |   6 +-
> >  mm/rmap.c   |  24 --
> >  virt/kvm/kvm_main.c |  12 ++-
> >  21 files changed, 274 insertions(+), 107 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c 
> > b/drivers/gpu/drm/i915/i915_gem_userptr.c
> > index d182058..20dbd26 100644
> > --- a/drivers/gpu/drm/i915/i915_gem_userptr.c
> > +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
> > @@ -129,7 +129,8 @@ restart:
> >  static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier 
> > *_mn,
> >struct mm_struct *mm,
> >unsigned long start,
> > -  unsigned long end)
> > +  unsigned long end,
> > +  enum mmu_event event)
> >  {
> > struct i915_mmu_notifier *mn = container_of(_mn, struct 
> > i915_mmu_notifier, mn);
> > struct interval_tree_node *it = NULL;
> > diff --git a/drivers/gpu/drm/radeon/radeon_mn.c 
> > b/drivers/gpu/drm/radeon/radeon_mn.c
> > index a69bd44..daf53d3 100644
> > --- a/drivers/gpu/drm/radeon/radeon_mn.c
> > +++ b/drivers/gpu/drm/radeon/radeon_mn.c
> > @@ -109,7 +109,8 @@ static void radeon_mn_release(struct mmu_notifier *mn,
> >  static void radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
> >  struct mm_struct *mm,
> >  unsigned long start,
> > -unsigned long end)
> > +unsigned long end,
> > +enum mmu_event event)
> >  {
> > struct radeon_mn *rmn = container_of(mn, struct radeon_mn, mn);
> > struct interval_tree_node *it;
> > diff --git a/drivers/infiniband/core/umem_odp.c 
> > b/drivers/infiniband/core/umem_odp.c
> > index 6095872..bc36e8c 100644
> > --- a/drivers/infiniband/core/umem_odp.c
> > +++ b/drivers/infiniband/core/umem_odp.c
> > @@ -165,7 +165,8 @@ static int invalidate_page_trampoline(struct ib_umem 
> > *item, u64 start,
> >  
> >  static void ib_umem_notifier_invalidate_page(struct mmu_notifier *mn,
> >  struct mm_struct *mm,
> > -unsigned long address)
> > + 

Re: [PATCH 1/6] mmu_notifier: add event information to address invalidation v6

2015-01-12 Thread Jerome Glisse
On Sun, Jan 11, 2015 at 02:24:01PM +0200, Oded Gabbay wrote:
 
 
 On 01/06/2015 12:44 AM, j.gli...@gmail.com wrote:
  From: Jérôme Glisse jgli...@redhat.com
  
  The event information will be useful for new user of mmu_notifier API.
  The event argument differentiate between a vma disappearing, a page
  being write protected or simply a page being unmaped. This allow new
  user to take different path for different event for instance on unmap
  the resource used to track a vma are still valid and should stay around.
  While if the event is saying that a vma is being destroy it means that any
  resources used to track this vma can be free.
  
  Changed since v1:
- renamed action into event (updated commit message too).
- simplified the event names and clarified their usage
  also documenting what exceptation the listener can have in
  respect to each event.
  
  Changed since v2:
- Avoid crazy name.
- Do not move code that do not need to move.
  
  Changed since v3:
- Separate hugue page split from mlock/munlock and softdirty.
  
  Changed since v4:
- Rebase (no other changes).
  
  Changed since v5:
- Typo fix.
- Changed zap_page_range from MMU_MUNMAP to MMU_MIGRATE to reflect the
  fact that the address range is still valid just the page backing it
  are no longer.
  
  Signed-off-by: Jérôme Glisse jgli...@redhat.com
  Reviewed-by: Rik van Riel r...@redhat.com
  ---
   drivers/gpu/drm/i915/i915_gem_userptr.c |   3 +-
   drivers/gpu/drm/radeon/radeon_mn.c  |   3 +-
   drivers/infiniband/core/umem_odp.c  |   9 ++-
   drivers/iommu/amd_iommu_v2.c|   3 +-
   drivers/misc/sgi-gru/grutlbpurge.c  |   9 ++-
   drivers/xen/gntdev.c|   9 ++-
   fs/proc/task_mmu.c  |   6 +-
   include/linux/mmu_notifier.h| 131 
  ++--
   kernel/events/uprobes.c |  10 ++-
   mm/filemap_xip.c|   2 +-
   mm/huge_memory.c|  39 ++
   mm/hugetlb.c|  23 +++---
   mm/ksm.c|  18 +++--
   mm/madvise.c|   4 +-
   mm/memory.c |  27 ---
   mm/migrate.c|   9 ++-
   mm/mmu_notifier.c   |  28 ---
   mm/mprotect.c   |   6 +-
   mm/mremap.c |   6 +-
   mm/rmap.c   |  24 --
   virt/kvm/kvm_main.c |  12 ++-
   21 files changed, 274 insertions(+), 107 deletions(-)
  
  diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c 
  b/drivers/gpu/drm/i915/i915_gem_userptr.c
  index d182058..20dbd26 100644
  --- a/drivers/gpu/drm/i915/i915_gem_userptr.c
  +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
  @@ -129,7 +129,8 @@ restart:
   static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier 
  *_mn,
 struct mm_struct *mm,
 unsigned long start,
  -  unsigned long end)
  +  unsigned long end,
  +  enum mmu_event event)
   {
  struct i915_mmu_notifier *mn = container_of(_mn, struct 
  i915_mmu_notifier, mn);
  struct interval_tree_node *it = NULL;
  diff --git a/drivers/gpu/drm/radeon/radeon_mn.c 
  b/drivers/gpu/drm/radeon/radeon_mn.c
  index a69bd44..daf53d3 100644
  --- a/drivers/gpu/drm/radeon/radeon_mn.c
  +++ b/drivers/gpu/drm/radeon/radeon_mn.c
  @@ -109,7 +109,8 @@ static void radeon_mn_release(struct mmu_notifier *mn,
   static void radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
   struct mm_struct *mm,
   unsigned long start,
  -unsigned long end)
  +unsigned long end,
  +enum mmu_event event)
   {
  struct radeon_mn *rmn = container_of(mn, struct radeon_mn, mn);
  struct interval_tree_node *it;
  diff --git a/drivers/infiniband/core/umem_odp.c 
  b/drivers/infiniband/core/umem_odp.c
  index 6095872..bc36e8c 100644
  --- a/drivers/infiniband/core/umem_odp.c
  +++ b/drivers/infiniband/core/umem_odp.c
  @@ -165,7 +165,8 @@ static int invalidate_page_trampoline(struct ib_umem 
  *item, u64 start,
   
   static void ib_umem_notifier_invalidate_page(struct mmu_notifier *mn,
   struct mm_struct *mm,
  -unsigned long address)
  +unsigned long address,
  +enum mmu_event event)
   {
  struct ib_ucontext *context = container_of(mn, 

Re: [PATCH 1/6] mmu_notifier: add event information to address invalidation v6

2015-01-11 Thread Oded Gabbay


On 01/11/2015 02:24 PM, Oded Gabbay wrote:
> 
> 
> On 01/06/2015 12:44 AM, j.gli...@gmail.com wrote:
>> From: Jérôme Glisse 
>>
>> The event information will be useful for new user of mmu_notifier API.
>> The event argument differentiate between a vma disappearing, a page
>> being write protected or simply a page being unmaped. This allow new
>> user to take different path for different event for instance on unmap
>> the resource used to track a vma are still valid and should stay around.
>> While if the event is saying that a vma is being destroy it means that any
>> resources used to track this vma can be free.
>>
>> Changed since v1:
>>   - renamed action into event (updated commit message too).
>>   - simplified the event names and clarified their usage
>> also documenting what exceptation the listener can have in
>> respect to each event.
>>
>> Changed since v2:
>>   - Avoid crazy name.
>>   - Do not move code that do not need to move.
>>
>> Changed since v3:
>>   - Separate hugue page split from mlock/munlock and softdirty.
>>
>> Changed since v4:
>>   - Rebase (no other changes).
>>
>> Changed since v5:
>>   - Typo fix.
>>   - Changed zap_page_range from MMU_MUNMAP to MMU_MIGRATE to reflect the
>> fact that the address range is still valid just the page backing it
>> are no longer.
>>
>> Signed-off-by: Jérôme Glisse 
>> Reviewed-by: Rik van Riel 
>> ---
>>  drivers/gpu/drm/i915/i915_gem_userptr.c |   3 +-
>>  drivers/gpu/drm/radeon/radeon_mn.c  |   3 +-
>>  drivers/infiniband/core/umem_odp.c  |   9 ++-
>>  drivers/iommu/amd_iommu_v2.c|   3 +-
>>  drivers/misc/sgi-gru/grutlbpurge.c  |   9 ++-
>>  drivers/xen/gntdev.c|   9 ++-
>>  fs/proc/task_mmu.c  |   6 +-
>>  include/linux/mmu_notifier.h| 131 
>> ++--
>>  kernel/events/uprobes.c |  10 ++-
>>  mm/filemap_xip.c|   2 +-
>>  mm/huge_memory.c|  39 ++
>>  mm/hugetlb.c|  23 +++---
>>  mm/ksm.c|  18 +++--
>>  mm/madvise.c|   4 +-
>>  mm/memory.c |  27 ---
>>  mm/migrate.c|   9 ++-
>>  mm/mmu_notifier.c   |  28 ---
>>  mm/mprotect.c   |   6 +-
>>  mm/mremap.c |   6 +-
>>  mm/rmap.c   |  24 --
>>  virt/kvm/kvm_main.c |  12 ++-
>>  21 files changed, 274 insertions(+), 107 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c 
>> b/drivers/gpu/drm/i915/i915_gem_userptr.c
>> index d182058..20dbd26 100644
>> --- a/drivers/gpu/drm/i915/i915_gem_userptr.c
>> +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
>> @@ -129,7 +129,8 @@ restart:
>>  static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier 
>> *_mn,
>> struct mm_struct *mm,
>> unsigned long start,
>> -   unsigned long end)
>> +   unsigned long end,
>> +   enum mmu_event event)
>>  {
>>  struct i915_mmu_notifier *mn = container_of(_mn, struct 
>> i915_mmu_notifier, mn);
>>  struct interval_tree_node *it = NULL;
>> diff --git a/drivers/gpu/drm/radeon/radeon_mn.c 
>> b/drivers/gpu/drm/radeon/radeon_mn.c
>> index a69bd44..daf53d3 100644
>> --- a/drivers/gpu/drm/radeon/radeon_mn.c
>> +++ b/drivers/gpu/drm/radeon/radeon_mn.c
>> @@ -109,7 +109,8 @@ static void radeon_mn_release(struct mmu_notifier *mn,
>>  static void radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
>>   struct mm_struct *mm,
>>   unsigned long start,
>> - unsigned long end)
>> + unsigned long end,
>> + enum mmu_event event)
>>  {
>>  struct radeon_mn *rmn = container_of(mn, struct radeon_mn, mn);
>>  struct interval_tree_node *it;
>> diff --git a/drivers/infiniband/core/umem_odp.c 
>> b/drivers/infiniband/core/umem_odp.c
>> index 6095872..bc36e8c 100644
>> --- a/drivers/infiniband/core/umem_odp.c
>> +++ b/drivers/infiniband/core/umem_odp.c
>> @@ -165,7 +165,8 @@ static int invalidate_page_trampoline(struct ib_umem 
>> *item, u64 start,
>>  
>>  static void ib_umem_notifier_invalidate_page(struct mmu_notifier *mn,
>>   struct mm_struct *mm,
>> - unsigned long address)
>> + unsigned long address,
>> + enum mmu_event event)
>>  {
>> 

Re: [PATCH 1/6] mmu_notifier: add event information to address invalidation v6

2015-01-11 Thread Oded Gabbay


On 01/06/2015 12:44 AM, j.gli...@gmail.com wrote:
> From: Jérôme Glisse 
> 
> The event information will be useful for new user of mmu_notifier API.
> The event argument differentiate between a vma disappearing, a page
> being write protected or simply a page being unmaped. This allow new
> user to take different path for different event for instance on unmap
> the resource used to track a vma are still valid and should stay around.
> While if the event is saying that a vma is being destroy it means that any
> resources used to track this vma can be free.
> 
> Changed since v1:
>   - renamed action into event (updated commit message too).
>   - simplified the event names and clarified their usage
> also documenting what exceptation the listener can have in
> respect to each event.
> 
> Changed since v2:
>   - Avoid crazy name.
>   - Do not move code that do not need to move.
> 
> Changed since v3:
>   - Separate hugue page split from mlock/munlock and softdirty.
> 
> Changed since v4:
>   - Rebase (no other changes).
> 
> Changed since v5:
>   - Typo fix.
>   - Changed zap_page_range from MMU_MUNMAP to MMU_MIGRATE to reflect the
> fact that the address range is still valid just the page backing it
> are no longer.
> 
> Signed-off-by: Jérôme Glisse 
> Reviewed-by: Rik van Riel 
> ---
>  drivers/gpu/drm/i915/i915_gem_userptr.c |   3 +-
>  drivers/gpu/drm/radeon/radeon_mn.c  |   3 +-
>  drivers/infiniband/core/umem_odp.c  |   9 ++-
>  drivers/iommu/amd_iommu_v2.c|   3 +-
>  drivers/misc/sgi-gru/grutlbpurge.c  |   9 ++-
>  drivers/xen/gntdev.c|   9 ++-
>  fs/proc/task_mmu.c  |   6 +-
>  include/linux/mmu_notifier.h| 131 
> ++--
>  kernel/events/uprobes.c |  10 ++-
>  mm/filemap_xip.c|   2 +-
>  mm/huge_memory.c|  39 ++
>  mm/hugetlb.c|  23 +++---
>  mm/ksm.c|  18 +++--
>  mm/madvise.c|   4 +-
>  mm/memory.c |  27 ---
>  mm/migrate.c|   9 ++-
>  mm/mmu_notifier.c   |  28 ---
>  mm/mprotect.c   |   6 +-
>  mm/mremap.c |   6 +-
>  mm/rmap.c   |  24 --
>  virt/kvm/kvm_main.c |  12 ++-
>  21 files changed, 274 insertions(+), 107 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c 
> b/drivers/gpu/drm/i915/i915_gem_userptr.c
> index d182058..20dbd26 100644
> --- a/drivers/gpu/drm/i915/i915_gem_userptr.c
> +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
> @@ -129,7 +129,8 @@ restart:
>  static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier 
> *_mn,
>  struct mm_struct *mm,
>  unsigned long start,
> -unsigned long end)
> +unsigned long end,
> +enum mmu_event event)
>  {
>   struct i915_mmu_notifier *mn = container_of(_mn, struct 
> i915_mmu_notifier, mn);
>   struct interval_tree_node *it = NULL;
> diff --git a/drivers/gpu/drm/radeon/radeon_mn.c 
> b/drivers/gpu/drm/radeon/radeon_mn.c
> index a69bd44..daf53d3 100644
> --- a/drivers/gpu/drm/radeon/radeon_mn.c
> +++ b/drivers/gpu/drm/radeon/radeon_mn.c
> @@ -109,7 +109,8 @@ static void radeon_mn_release(struct mmu_notifier *mn,
>  static void radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
>struct mm_struct *mm,
>unsigned long start,
> -  unsigned long end)
> +  unsigned long end,
> +  enum mmu_event event)
>  {
>   struct radeon_mn *rmn = container_of(mn, struct radeon_mn, mn);
>   struct interval_tree_node *it;
> diff --git a/drivers/infiniband/core/umem_odp.c 
> b/drivers/infiniband/core/umem_odp.c
> index 6095872..bc36e8c 100644
> --- a/drivers/infiniband/core/umem_odp.c
> +++ b/drivers/infiniband/core/umem_odp.c
> @@ -165,7 +165,8 @@ static int invalidate_page_trampoline(struct ib_umem 
> *item, u64 start,
>  
>  static void ib_umem_notifier_invalidate_page(struct mmu_notifier *mn,
>struct mm_struct *mm,
> -  unsigned long address)
> +  unsigned long address,
> +  enum mmu_event event)
>  {
>   struct ib_ucontext *context = container_of(mn, struct ib_ucontext, mn);
>  
> @@ -192,7 +193,8 @@ static int 

Re: [PATCH 1/6] mmu_notifier: add event information to address invalidation v6

2015-01-11 Thread Oded Gabbay


On 01/06/2015 12:44 AM, j.gli...@gmail.com wrote:
 From: Jérôme Glisse jgli...@redhat.com
 
 The event information will be useful for new user of mmu_notifier API.
 The event argument differentiate between a vma disappearing, a page
 being write protected or simply a page being unmaped. This allow new
 user to take different path for different event for instance on unmap
 the resource used to track a vma are still valid and should stay around.
 While if the event is saying that a vma is being destroy it means that any
 resources used to track this vma can be free.
 
 Changed since v1:
   - renamed action into event (updated commit message too).
   - simplified the event names and clarified their usage
 also documenting what exceptation the listener can have in
 respect to each event.
 
 Changed since v2:
   - Avoid crazy name.
   - Do not move code that do not need to move.
 
 Changed since v3:
   - Separate hugue page split from mlock/munlock and softdirty.
 
 Changed since v4:
   - Rebase (no other changes).
 
 Changed since v5:
   - Typo fix.
   - Changed zap_page_range from MMU_MUNMAP to MMU_MIGRATE to reflect the
 fact that the address range is still valid just the page backing it
 are no longer.
 
 Signed-off-by: Jérôme Glisse jgli...@redhat.com
 Reviewed-by: Rik van Riel r...@redhat.com
 ---
  drivers/gpu/drm/i915/i915_gem_userptr.c |   3 +-
  drivers/gpu/drm/radeon/radeon_mn.c  |   3 +-
  drivers/infiniband/core/umem_odp.c  |   9 ++-
  drivers/iommu/amd_iommu_v2.c|   3 +-
  drivers/misc/sgi-gru/grutlbpurge.c  |   9 ++-
  drivers/xen/gntdev.c|   9 ++-
  fs/proc/task_mmu.c  |   6 +-
  include/linux/mmu_notifier.h| 131 
 ++--
  kernel/events/uprobes.c |  10 ++-
  mm/filemap_xip.c|   2 +-
  mm/huge_memory.c|  39 ++
  mm/hugetlb.c|  23 +++---
  mm/ksm.c|  18 +++--
  mm/madvise.c|   4 +-
  mm/memory.c |  27 ---
  mm/migrate.c|   9 ++-
  mm/mmu_notifier.c   |  28 ---
  mm/mprotect.c   |   6 +-
  mm/mremap.c |   6 +-
  mm/rmap.c   |  24 --
  virt/kvm/kvm_main.c |  12 ++-
  21 files changed, 274 insertions(+), 107 deletions(-)
 
 diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c 
 b/drivers/gpu/drm/i915/i915_gem_userptr.c
 index d182058..20dbd26 100644
 --- a/drivers/gpu/drm/i915/i915_gem_userptr.c
 +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
 @@ -129,7 +129,8 @@ restart:
  static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier 
 *_mn,
  struct mm_struct *mm,
  unsigned long start,
 -unsigned long end)
 +unsigned long end,
 +enum mmu_event event)
  {
   struct i915_mmu_notifier *mn = container_of(_mn, struct 
 i915_mmu_notifier, mn);
   struct interval_tree_node *it = NULL;
 diff --git a/drivers/gpu/drm/radeon/radeon_mn.c 
 b/drivers/gpu/drm/radeon/radeon_mn.c
 index a69bd44..daf53d3 100644
 --- a/drivers/gpu/drm/radeon/radeon_mn.c
 +++ b/drivers/gpu/drm/radeon/radeon_mn.c
 @@ -109,7 +109,8 @@ static void radeon_mn_release(struct mmu_notifier *mn,
  static void radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
struct mm_struct *mm,
unsigned long start,
 -  unsigned long end)
 +  unsigned long end,
 +  enum mmu_event event)
  {
   struct radeon_mn *rmn = container_of(mn, struct radeon_mn, mn);
   struct interval_tree_node *it;
 diff --git a/drivers/infiniband/core/umem_odp.c 
 b/drivers/infiniband/core/umem_odp.c
 index 6095872..bc36e8c 100644
 --- a/drivers/infiniband/core/umem_odp.c
 +++ b/drivers/infiniband/core/umem_odp.c
 @@ -165,7 +165,8 @@ static int invalidate_page_trampoline(struct ib_umem 
 *item, u64 start,
  
  static void ib_umem_notifier_invalidate_page(struct mmu_notifier *mn,
struct mm_struct *mm,
 -  unsigned long address)
 +  unsigned long address,
 +  enum mmu_event event)
  {
   struct ib_ucontext *context = container_of(mn, struct ib_ucontext, mn);
  
 @@ -192,7 +193,8 @@ static int invalidate_range_start_trampoline(struct 
 ib_umem *item, u64 start,
  

Re: [PATCH 1/6] mmu_notifier: add event information to address invalidation v6

2015-01-11 Thread Oded Gabbay


On 01/11/2015 02:24 PM, Oded Gabbay wrote:
 
 
 On 01/06/2015 12:44 AM, j.gli...@gmail.com wrote:
 From: Jérôme Glisse jgli...@redhat.com

 The event information will be useful for new user of mmu_notifier API.
 The event argument differentiate between a vma disappearing, a page
 being write protected or simply a page being unmaped. This allow new
 user to take different path for different event for instance on unmap
 the resource used to track a vma are still valid and should stay around.
 While if the event is saying that a vma is being destroy it means that any
 resources used to track this vma can be free.

 Changed since v1:
   - renamed action into event (updated commit message too).
   - simplified the event names and clarified their usage
 also documenting what exceptation the listener can have in
 respect to each event.

 Changed since v2:
   - Avoid crazy name.
   - Do not move code that do not need to move.

 Changed since v3:
   - Separate hugue page split from mlock/munlock and softdirty.

 Changed since v4:
   - Rebase (no other changes).

 Changed since v5:
   - Typo fix.
   - Changed zap_page_range from MMU_MUNMAP to MMU_MIGRATE to reflect the
 fact that the address range is still valid just the page backing it
 are no longer.

 Signed-off-by: Jérôme Glisse jgli...@redhat.com
 Reviewed-by: Rik van Riel r...@redhat.com
 ---
  drivers/gpu/drm/i915/i915_gem_userptr.c |   3 +-
  drivers/gpu/drm/radeon/radeon_mn.c  |   3 +-
  drivers/infiniband/core/umem_odp.c  |   9 ++-
  drivers/iommu/amd_iommu_v2.c|   3 +-
  drivers/misc/sgi-gru/grutlbpurge.c  |   9 ++-
  drivers/xen/gntdev.c|   9 ++-
  fs/proc/task_mmu.c  |   6 +-
  include/linux/mmu_notifier.h| 131 
 ++--
  kernel/events/uprobes.c |  10 ++-
  mm/filemap_xip.c|   2 +-
  mm/huge_memory.c|  39 ++
  mm/hugetlb.c|  23 +++---
  mm/ksm.c|  18 +++--
  mm/madvise.c|   4 +-
  mm/memory.c |  27 ---
  mm/migrate.c|   9 ++-
  mm/mmu_notifier.c   |  28 ---
  mm/mprotect.c   |   6 +-
  mm/mremap.c |   6 +-
  mm/rmap.c   |  24 --
  virt/kvm/kvm_main.c |  12 ++-
  21 files changed, 274 insertions(+), 107 deletions(-)

 diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c 
 b/drivers/gpu/drm/i915/i915_gem_userptr.c
 index d182058..20dbd26 100644
 --- a/drivers/gpu/drm/i915/i915_gem_userptr.c
 +++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
 @@ -129,7 +129,8 @@ restart:
  static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier 
 *_mn,
 struct mm_struct *mm,
 unsigned long start,
 -   unsigned long end)
 +   unsigned long end,
 +   enum mmu_event event)
  {
  struct i915_mmu_notifier *mn = container_of(_mn, struct 
 i915_mmu_notifier, mn);
  struct interval_tree_node *it = NULL;
 diff --git a/drivers/gpu/drm/radeon/radeon_mn.c 
 b/drivers/gpu/drm/radeon/radeon_mn.c
 index a69bd44..daf53d3 100644
 --- a/drivers/gpu/drm/radeon/radeon_mn.c
 +++ b/drivers/gpu/drm/radeon/radeon_mn.c
 @@ -109,7 +109,8 @@ static void radeon_mn_release(struct mmu_notifier *mn,
  static void radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
   struct mm_struct *mm,
   unsigned long start,
 - unsigned long end)
 + unsigned long end,
 + enum mmu_event event)
  {
  struct radeon_mn *rmn = container_of(mn, struct radeon_mn, mn);
  struct interval_tree_node *it;
 diff --git a/drivers/infiniband/core/umem_odp.c 
 b/drivers/infiniband/core/umem_odp.c
 index 6095872..bc36e8c 100644
 --- a/drivers/infiniband/core/umem_odp.c
 +++ b/drivers/infiniband/core/umem_odp.c
 @@ -165,7 +165,8 @@ static int invalidate_page_trampoline(struct ib_umem 
 *item, u64 start,
  
  static void ib_umem_notifier_invalidate_page(struct mmu_notifier *mn,
   struct mm_struct *mm,
 - unsigned long address)
 + unsigned long address,
 + enum mmu_event event)
  {
  struct ib_ucontext *context = container_of(mn, struct ib_ucontext, mn);
  
 @@ -192,7 +193,8 @@ static int invalidate_range_start_trampoline(struct 
 ib_umem 

[PATCH 1/6] mmu_notifier: add event information to address invalidation v6

2015-01-05 Thread j . glisse
From: Jérôme Glisse 

The event information will be useful for new user of mmu_notifier API.
The event argument differentiate between a vma disappearing, a page
being write protected or simply a page being unmaped. This allow new
user to take different path for different event for instance on unmap
the resource used to track a vma are still valid and should stay around.
While if the event is saying that a vma is being destroy it means that any
resources used to track this vma can be free.

Changed since v1:
  - renamed action into event (updated commit message too).
  - simplified the event names and clarified their usage
also documenting what exceptation the listener can have in
respect to each event.

Changed since v2:
  - Avoid crazy name.
  - Do not move code that do not need to move.

Changed since v3:
  - Separate hugue page split from mlock/munlock and softdirty.

Changed since v4:
  - Rebase (no other changes).

Changed since v5:
  - Typo fix.
  - Changed zap_page_range from MMU_MUNMAP to MMU_MIGRATE to reflect the
fact that the address range is still valid just the page backing it
are no longer.

Signed-off-by: Jérôme Glisse 
Reviewed-by: Rik van Riel 
---
 drivers/gpu/drm/i915/i915_gem_userptr.c |   3 +-
 drivers/gpu/drm/radeon/radeon_mn.c  |   3 +-
 drivers/infiniband/core/umem_odp.c  |   9 ++-
 drivers/iommu/amd_iommu_v2.c|   3 +-
 drivers/misc/sgi-gru/grutlbpurge.c  |   9 ++-
 drivers/xen/gntdev.c|   9 ++-
 fs/proc/task_mmu.c  |   6 +-
 include/linux/mmu_notifier.h| 131 ++--
 kernel/events/uprobes.c |  10 ++-
 mm/filemap_xip.c|   2 +-
 mm/huge_memory.c|  39 ++
 mm/hugetlb.c|  23 +++---
 mm/ksm.c|  18 +++--
 mm/madvise.c|   4 +-
 mm/memory.c |  27 ---
 mm/migrate.c|   9 ++-
 mm/mmu_notifier.c   |  28 ---
 mm/mprotect.c   |   6 +-
 mm/mremap.c |   6 +-
 mm/rmap.c   |  24 --
 virt/kvm/kvm_main.c |  12 ++-
 21 files changed, 274 insertions(+), 107 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c 
b/drivers/gpu/drm/i915/i915_gem_userptr.c
index d182058..20dbd26 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -129,7 +129,8 @@ restart:
 static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier 
*_mn,
   struct mm_struct *mm,
   unsigned long start,
-  unsigned long end)
+  unsigned long end,
+  enum mmu_event event)
 {
struct i915_mmu_notifier *mn = container_of(_mn, struct 
i915_mmu_notifier, mn);
struct interval_tree_node *it = NULL;
diff --git a/drivers/gpu/drm/radeon/radeon_mn.c 
b/drivers/gpu/drm/radeon/radeon_mn.c
index a69bd44..daf53d3 100644
--- a/drivers/gpu/drm/radeon/radeon_mn.c
+++ b/drivers/gpu/drm/radeon/radeon_mn.c
@@ -109,7 +109,8 @@ static void radeon_mn_release(struct mmu_notifier *mn,
 static void radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
 struct mm_struct *mm,
 unsigned long start,
-unsigned long end)
+unsigned long end,
+enum mmu_event event)
 {
struct radeon_mn *rmn = container_of(mn, struct radeon_mn, mn);
struct interval_tree_node *it;
diff --git a/drivers/infiniband/core/umem_odp.c 
b/drivers/infiniband/core/umem_odp.c
index 6095872..bc36e8c 100644
--- a/drivers/infiniband/core/umem_odp.c
+++ b/drivers/infiniband/core/umem_odp.c
@@ -165,7 +165,8 @@ static int invalidate_page_trampoline(struct ib_umem *item, 
u64 start,
 
 static void ib_umem_notifier_invalidate_page(struct mmu_notifier *mn,
 struct mm_struct *mm,
-unsigned long address)
+unsigned long address,
+enum mmu_event event)
 {
struct ib_ucontext *context = container_of(mn, struct ib_ucontext, mn);
 
@@ -192,7 +193,8 @@ static int invalidate_range_start_trampoline(struct ib_umem 
*item, u64 start,
 static void ib_umem_notifier_invalidate_range_start(struct mmu_notifier *mn,
struct mm_struct *mm,
   

[PATCH 1/6] mmu_notifier: add event information to address invalidation v6

2015-01-05 Thread j . glisse
From: Jérôme Glisse jgli...@redhat.com

The event information will be useful for new user of mmu_notifier API.
The event argument differentiate between a vma disappearing, a page
being write protected or simply a page being unmaped. This allow new
user to take different path for different event for instance on unmap
the resource used to track a vma are still valid and should stay around.
While if the event is saying that a vma is being destroy it means that any
resources used to track this vma can be free.

Changed since v1:
  - renamed action into event (updated commit message too).
  - simplified the event names and clarified their usage
also documenting what exceptation the listener can have in
respect to each event.

Changed since v2:
  - Avoid crazy name.
  - Do not move code that do not need to move.

Changed since v3:
  - Separate hugue page split from mlock/munlock and softdirty.

Changed since v4:
  - Rebase (no other changes).

Changed since v5:
  - Typo fix.
  - Changed zap_page_range from MMU_MUNMAP to MMU_MIGRATE to reflect the
fact that the address range is still valid just the page backing it
are no longer.

Signed-off-by: Jérôme Glisse jgli...@redhat.com
Reviewed-by: Rik van Riel r...@redhat.com
---
 drivers/gpu/drm/i915/i915_gem_userptr.c |   3 +-
 drivers/gpu/drm/radeon/radeon_mn.c  |   3 +-
 drivers/infiniband/core/umem_odp.c  |   9 ++-
 drivers/iommu/amd_iommu_v2.c|   3 +-
 drivers/misc/sgi-gru/grutlbpurge.c  |   9 ++-
 drivers/xen/gntdev.c|   9 ++-
 fs/proc/task_mmu.c  |   6 +-
 include/linux/mmu_notifier.h| 131 ++--
 kernel/events/uprobes.c |  10 ++-
 mm/filemap_xip.c|   2 +-
 mm/huge_memory.c|  39 ++
 mm/hugetlb.c|  23 +++---
 mm/ksm.c|  18 +++--
 mm/madvise.c|   4 +-
 mm/memory.c |  27 ---
 mm/migrate.c|   9 ++-
 mm/mmu_notifier.c   |  28 ---
 mm/mprotect.c   |   6 +-
 mm/mremap.c |   6 +-
 mm/rmap.c   |  24 --
 virt/kvm/kvm_main.c |  12 ++-
 21 files changed, 274 insertions(+), 107 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c 
b/drivers/gpu/drm/i915/i915_gem_userptr.c
index d182058..20dbd26 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -129,7 +129,8 @@ restart:
 static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier 
*_mn,
   struct mm_struct *mm,
   unsigned long start,
-  unsigned long end)
+  unsigned long end,
+  enum mmu_event event)
 {
struct i915_mmu_notifier *mn = container_of(_mn, struct 
i915_mmu_notifier, mn);
struct interval_tree_node *it = NULL;
diff --git a/drivers/gpu/drm/radeon/radeon_mn.c 
b/drivers/gpu/drm/radeon/radeon_mn.c
index a69bd44..daf53d3 100644
--- a/drivers/gpu/drm/radeon/radeon_mn.c
+++ b/drivers/gpu/drm/radeon/radeon_mn.c
@@ -109,7 +109,8 @@ static void radeon_mn_release(struct mmu_notifier *mn,
 static void radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
 struct mm_struct *mm,
 unsigned long start,
-unsigned long end)
+unsigned long end,
+enum mmu_event event)
 {
struct radeon_mn *rmn = container_of(mn, struct radeon_mn, mn);
struct interval_tree_node *it;
diff --git a/drivers/infiniband/core/umem_odp.c 
b/drivers/infiniband/core/umem_odp.c
index 6095872..bc36e8c 100644
--- a/drivers/infiniband/core/umem_odp.c
+++ b/drivers/infiniband/core/umem_odp.c
@@ -165,7 +165,8 @@ static int invalidate_page_trampoline(struct ib_umem *item, 
u64 start,
 
 static void ib_umem_notifier_invalidate_page(struct mmu_notifier *mn,
 struct mm_struct *mm,
-unsigned long address)
+unsigned long address,
+enum mmu_event event)
 {
struct ib_ucontext *context = container_of(mn, struct ib_ucontext, mn);
 
@@ -192,7 +193,8 @@ static int invalidate_range_start_trampoline(struct ib_umem 
*item, u64 start,
 static void ib_umem_notifier_invalidate_range_start(struct mmu_notifier *mn,