Commit a879211b authored by Daniel De Graaf's avatar Daniel De Graaf Committed by Konrad Rzeszutek Wilk

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: default avatarDaniel De Graaf <dgdegra@tycho.nsa.gov>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
parent ef91082e
...@@ -167,23 +167,6 @@ static struct grant_map *gntdev_find_map_index(struct gntdev_priv *priv, ...@@ -167,23 +167,6 @@ static struct grant_map *gntdev_find_map_index(struct gntdev_priv *priv,
return NULL; return NULL;
} }
static struct grant_map *gntdev_find_map_vaddr(struct gntdev_priv *priv,
unsigned long vaddr)
{
struct grant_map *map;
list_for_each_entry(map, &priv->maps, next) {
if (!map->vma)
continue;
if (vaddr < map->vma->vm_start)
continue;
if (vaddr >= map->vma->vm_end)
continue;
return map;
}
return NULL;
}
static int gntdev_del_map(struct grant_map *map) static int gntdev_del_map(struct grant_map *map)
{ {
int i; int i;
...@@ -494,22 +477,23 @@ static long gntdev_ioctl_get_offset_for_vaddr(struct gntdev_priv *priv, ...@@ -494,22 +477,23 @@ static long gntdev_ioctl_get_offset_for_vaddr(struct gntdev_priv *priv,
struct ioctl_gntdev_get_offset_for_vaddr __user *u) struct ioctl_gntdev_get_offset_for_vaddr __user *u)
{ {
struct ioctl_gntdev_get_offset_for_vaddr op; struct ioctl_gntdev_get_offset_for_vaddr op;
struct vm_area_struct *vma;
struct grant_map *map; struct grant_map *map;
if (copy_from_user(&op, u, sizeof(op)) != 0) if (copy_from_user(&op, u, sizeof(op)) != 0)
return -EFAULT; return -EFAULT;
pr_debug("priv %p, offset for vaddr %lx\n", priv, (unsigned long)op.vaddr); pr_debug("priv %p, offset for vaddr %lx\n", priv, (unsigned long)op.vaddr);
spin_lock(&priv->lock); vma = find_vma(current->mm, op.vaddr);
map = gntdev_find_map_vaddr(priv, op.vaddr); if (!vma || vma->vm_ops != &gntdev_vmops)
if (map == NULL ||
map->vma->vm_start != op.vaddr) {
spin_unlock(&priv->lock);
return -EINVAL; return -EINVAL;
}
map = vma->vm_private_data;
if (!map)
return -EINVAL;
op.offset = map->index << PAGE_SHIFT; op.offset = map->index << PAGE_SHIFT;
op.count = map->count; op.count = map->count;
spin_unlock(&priv->lock);
if (copy_to_user(u, &op, sizeof(op)) != 0) if (copy_to_user(u, &op, sizeof(op)) != 0)
return -EFAULT; return -EFAULT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment