aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorJérôme Glisse <jglisse@redhat.com>2018-12-28 03:38:05 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-12-28 15:11:50 -0500
commit5d6527a784f7a6d247961e046e830de8d71b47d1 (patch)
tree9326a7abb7aab8983770840a4d52e07becb76c6d /drivers/xen
parentb15c87263a69272423771118c653e9a1d0672caa (diff)
mm/mmu_notifier: use structure for invalidate_range_start/end callback
Patch series "mmu notifier contextual informations", v2. This patchset adds contextual information, why an invalidation is happening, to mmu notifier callback. This is necessary for user of mmu notifier that wish to maintains their own data structure without having to add new fields to struct vm_area_struct (vma). For instance device can have they own page table that mirror the process address space. When a vma is unmap (munmap() syscall) the device driver can free the device page table for the range. Today we do not have any information on why a mmu notifier call back is happening and thus device driver have to assume that it is always an munmap(). This is inefficient at it means that it needs to re-allocate device page table on next page fault and rebuild the whole device driver data structure for the range. Other use case beside munmap() also exist, for instance it is pointless for device driver to invalidate the device page table when the invalidation is for the soft dirtyness tracking. Or device driver can optimize away mprotect() that change the page table permission access for the range. This patchset enables all this optimizations for device drivers. I do not include any of those in this series but another patchset I am posting will leverage this. The patchset is pretty simple from a code point of view. The first two patches consolidate all mmu notifier arguments into a struct so that it is easier to add/change arguments. The last patch adds the contextual information (munmap, protection, soft dirty, clear, ...). This patch (of 3): 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. [akpm@linux-foundation.org: fix drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c kerneldoc] Link: http://lkml.kernel.org/r/20181205053628.3210-2-jglisse@redhat.com Signed-off-by: Jérôme Glisse <jglisse@redhat.com> Acked-by: Jan Kara <jack@suse.cz> Acked-by: Jason Gunthorpe <jgg@mellanox.com> [infiniband] Cc: Matthew Wilcox <mawilcox@microsoft.com> Cc: Ross Zwisler <zwisler@kernel.org> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Radim Krcmar <rkrcmar@redhat.com> Cc: Michal Hocko <mhocko@kernel.org> Cc: Christian Koenig <christian.koenig@amd.com> Cc: Felix Kuehling <felix.kuehling@amd.com> Cc: Ralph Campbell <rcampbell@nvidia.com> Cc: John Hubbard <jhubbard@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/gntdev.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index b0b02a501167..5efc5eee9544 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -520,26 +520,26 @@ static int unmap_if_in_range(struct gntdev_grant_map *map,
520} 520}
521 521
522static int mn_invl_range_start(struct mmu_notifier *mn, 522static int mn_invl_range_start(struct mmu_notifier *mn,
523 struct mm_struct *mm, 523 const struct mmu_notifier_range *range)
524 unsigned long start, unsigned long end,
525 bool blockable)
526{ 524{
527 struct gntdev_priv *priv = container_of(mn, struct gntdev_priv, mn); 525 struct gntdev_priv *priv = container_of(mn, struct gntdev_priv, mn);
528 struct gntdev_grant_map *map; 526 struct gntdev_grant_map *map;
529 int ret = 0; 527 int ret = 0;
530 528
531 if (blockable) 529 if (range->blockable)
532 mutex_lock(&priv->lock); 530 mutex_lock(&priv->lock);
533 else if (!mutex_trylock(&priv->lock)) 531 else if (!mutex_trylock(&priv->lock))
534 return -EAGAIN; 532 return -EAGAIN;
535 533
536 list_for_each_entry(map, &priv->maps, next) { 534 list_for_each_entry(map, &priv->maps, next) {
537 ret = unmap_if_in_range(map, start, end, blockable); 535 ret = unmap_if_in_range(map, range->start, range->end,
536 range->blockable);
538 if (ret) 537 if (ret)
539 goto out_unlock; 538 goto out_unlock;
540 } 539 }
541 list_for_each_entry(map, &priv->freeable_maps, next) { 540 list_for_each_entry(map, &priv->freeable_maps, next) {
542 ret = unmap_if_in_range(map, start, end, blockable); 541 ret = unmap_if_in_range(map, range->start, range->end,
542 range->blockable);
543 if (ret) 543 if (ret)
544 goto out_unlock; 544 goto out_unlock;
545 } 545 }