aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>2011-02-03 12:19:00 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-02-14 14:08:50 -0500
commita879211bf1d70339e429603805c014450c275f2a (patch)
tree6382aaee07a5e1aa3bbb7c9e35273f789a39cbd1 /drivers/xen
parentef91082e90491ac99343a13f9aeff4669835c6cc (diff)
xen-gntdev: Use find_vma rather than iterating our vma list manually
This should be faster if many mappings exist, and also removes the only user of map->vma not related to PTE modification. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/gntdev.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 23d208a219fa..ce8c37c2b673 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -167,23 +167,6 @@ static struct grant_map *gntdev_find_map_index(struct gntdev_priv *priv,
167 return NULL; 167 return NULL;
168} 168}
169 169
170static struct grant_map *gntdev_find_map_vaddr(struct gntdev_priv *priv,
171 unsigned long vaddr)
172{
173 struct grant_map *map;
174
175 list_for_each_entry(map, &priv->maps, next) {
176 if (!map->vma)
177 continue;
178 if (vaddr < map->vma->vm_start)
179 continue;
180 if (vaddr >= map->vma->vm_end)
181 continue;
182 return map;
183 }
184 return NULL;
185}
186
187static int gntdev_del_map(struct grant_map *map) 170static int gntdev_del_map(struct grant_map *map)
188{ 171{
189 int i; 172 int i;
@@ -494,22 +477,23 @@ static long gntdev_ioctl_get_offset_for_vaddr(struct gntdev_priv *priv,
494 struct ioctl_gntdev_get_offset_for_vaddr __user *u) 477 struct ioctl_gntdev_get_offset_for_vaddr __user *u)
495{ 478{
496 struct ioctl_gntdev_get_offset_for_vaddr op; 479 struct ioctl_gntdev_get_offset_for_vaddr op;
480 struct vm_area_struct *vma;
497 struct grant_map *map; 481 struct grant_map *map;
498 482
499 if (copy_from_user(&op, u, sizeof(op)) != 0) 483 if (copy_from_user(&op, u, sizeof(op)) != 0)
500 return -EFAULT; 484 return -EFAULT;
501 pr_debug("priv %p, offset for vaddr %lx\n", priv, (unsigned long)op.vaddr); 485 pr_debug("priv %p, offset for vaddr %lx\n", priv, (unsigned long)op.vaddr);
502 486
503 spin_lock(&priv->lock); 487 vma = find_vma(current->mm, op.vaddr);
504 map = gntdev_find_map_vaddr(priv, op.vaddr); 488 if (!vma || vma->vm_ops != &gntdev_vmops)
505 if (map == NULL ||
506 map->vma->vm_start != op.vaddr) {
507 spin_unlock(&priv->lock);
508 return -EINVAL; 489 return -EINVAL;
509 } 490
491 map = vma->vm_private_data;
492 if (!map)
493 return -EINVAL;
494
510 op.offset = map->index << PAGE_SHIFT; 495 op.offset = map->index << PAGE_SHIFT;
511 op.count = map->count; 496 op.count = map->count;
512 spin_unlock(&priv->lock);
513 497
514 if (copy_to_user(u, &op, sizeof(op)) != 0) 498 if (copy_to_user(u, &op, sizeof(op)) != 0)
515 return -EFAULT; 499 return -EFAULT;