From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Cc: xen-devel@lists.xensource.com, Ian.Campbell@citrix.com
Subject: Re: [PATCH 4/6] xen-gntdev: Use find_vma rather than iterating our vma list manually
Date: Tue, 14 Dec 2010 13:20:50 -0800 [thread overview]
Message-ID: <4D07DFB2.2040104@goop.org> (raw)
In-Reply-To: <1292338553-20575-5-git-send-email-dgdegra@tycho.nsa.gov>
On 12/14/2010 06:55 AM, Daniel De Graaf wrote:
> This should be faster if many mappings exist,
Yes, seems reasonable.
> and also removes
> the only user of vma that is not related to PTE modification.
What do you mean? Oh, you mean map->vma?
> Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
> ---
> drivers/xen/gntdev.c | 34 ++++++++++------------------------
> 1 files changed, 10 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
> index 773b76c..a73f07c 100644
> --- a/drivers/xen/gntdev.c
> +++ b/drivers/xen/gntdev.c
> @@ -74,6 +74,8 @@ struct grant_map {
> struct granted_page pages[0];
> };
>
> +static struct vm_operations_struct gntdev_vmops;
Is it OK for this to be all NULL?
> +
> /* ------------------------------------------------------------------ */
>
> static void gntdev_print_maps(struct gntdev_priv *priv,
> @@ -142,23 +144,6 @@ static struct grant_map *gntdev_find_map_index(struct gntdev_priv *priv, int ind
> 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)
> {
> int i;
> @@ -510,6 +495,7 @@ 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 op;
> + struct vm_area_struct *vma;
> struct grant_map *map;
>
> if (copy_from_user(&op, u, sizeof(op)) != 0)
> @@ -518,16 +504,16 @@ static long gntdev_ioctl_get_offset_for_vaddr(struct gntdev_priv *priv,
> printk("%s: priv %p, offset for vaddr %lx\n", __FUNCTION__, priv,
> (unsigned long)op.vaddr);
>
> - spin_lock(&priv->lock);
> - map = gntdev_find_map_vaddr(priv, op.vaddr);
> - if (map == NULL ||
> - map->vma->vm_start != op.vaddr) {
> - spin_unlock(&priv->lock);
> + vma = find_vma(current->mm, op.vaddr);
> + if (!vma)
> return -EINVAL;
> - }
> +
> + map = vma->vm_private_data;
> + if (vma->vm_ops != &gntdev_vmops || !map)
> + return -EINVAL;
I know this is perfectly OK, but I'd be happier if you don't refer to
vm_private_data as "map" until the vma has been confirmed to be a gntdev
one.
> +
> op.offset = map->index << PAGE_SHIFT;
> op.count = map->count;
> - spin_unlock(&priv->lock);
>
> if (copy_to_user(u, &op, sizeof(op)) != 0)
> return -EFAULT;
J
next prev parent reply other threads:[~2010-12-14 21:20 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-14 14:55 [PATCH v2] Userspace grant communication Daniel De Graaf
2010-12-14 14:55 ` [PATCH 1/6] xen-gntdev: Fix circular locking dependency Daniel De Graaf
2010-12-14 21:11 ` Jeremy Fitzhardinge
2010-12-14 21:40 ` Daniel De Graaf
2010-12-15 9:47 ` Ian Campbell
2010-12-16 0:28 ` Jeremy Fitzhardinge
2010-12-16 15:09 ` Stefano Stabellini
2010-12-14 14:55 ` [PATCH 2/6] xen-gntdev: Change page limit to be global instead of per-open Daniel De Graaf
2010-12-14 21:12 ` Jeremy Fitzhardinge
2010-12-14 21:42 ` Daniel De Graaf
2010-12-15 9:50 ` Ian Campbell
2010-12-16 0:27 ` Jeremy Fitzhardinge
2010-12-14 14:55 ` [PATCH 3/6] xen-gntdev: Remove unneeded structures from grant_map tracking data Daniel De Graaf
2010-12-14 21:15 ` Jeremy Fitzhardinge
2010-12-14 21:52 ` Daniel De Graaf
2010-12-14 21:56 ` Jeremy Fitzhardinge
2010-12-14 21:54 ` Jeremy Fitzhardinge
2010-12-14 14:55 ` [PATCH 4/6] xen-gntdev: Use find_vma rather than iterating our vma list manually Daniel De Graaf
2010-12-14 21:20 ` Jeremy Fitzhardinge [this message]
2010-12-15 9:58 ` Ian Campbell
2010-12-16 0:29 ` Jeremy Fitzhardinge
2010-12-14 14:55 ` [PATCH 5/6] xen-gntalloc: Userspace grant allocation driver Daniel De Graaf
2010-12-14 21:42 ` Jeremy Fitzhardinge
2010-12-14 22:06 ` Daniel De Graaf
2010-12-14 22:40 ` Jeremy Fitzhardinge
2010-12-15 14:18 ` Daniel De Graaf
2010-12-16 1:05 ` Jeremy Fitzhardinge
2010-12-16 15:22 ` Daniel De Graaf
2010-12-16 19:14 ` Jeremy Fitzhardinge
2010-12-14 14:55 ` [PATCH 6/6] xen-gntdev: Introduce HVM version of gntdev Daniel De Graaf
2010-12-14 21:45 ` Jeremy Fitzhardinge
2010-12-14 22:27 ` Daniel De Graaf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D07DFB2.2040104@goop.org \
--to=jeremy@goop.org \
--cc=Ian.Campbell@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.