diff mbox series

[v4,18/66] xen: Use vma_lookup() in privcmd_ioctl_mmap()

Message ID 20211201142918.921493-19-Liam.Howlett@oracle.com (mailing list archive)
State New
Headers show
Series Introducing the Maple Tree | expand

Commit Message

Liam R. Howlett Dec. 1, 2021, 2:29 p.m. UTC
From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>

vma_lookup() walks the VMA tree for a specific value, find_vma() will
search the tree after walking to a specific value.  It is more efficient
to only walk to the requested value as this case requires the address to
equal the vm_start.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
 drivers/xen/privcmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Vlastimil Babka Jan. 12, 2022, 4:01 p.m. UTC | #1
On 12/1/21 15:29, Liam Howlett wrote:
> From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
> 
> vma_lookup() walks the VMA tree for a specific value, find_vma() will
> search the tree after walking to a specific value.  It is more efficient
> to only walk to the requested value as this case requires the address to
> equal the vm_start.

By that you mean the privcmd_ioctl_mmap() code checks msg->va !=
vma->vm_start and thus we know it's never interested the next vma, that
find_vma() can return if no vma covers the address?

> Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>  drivers/xen/privcmd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
> index 3369734108af..ad17166b0ef6 100644
> --- a/drivers/xen/privcmd.c
> +++ b/drivers/xen/privcmd.c
> @@ -282,7 +282,7 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata)
>  						     struct page, lru);
>  		struct privcmd_mmap_entry *msg = page_address(page);
>  
> -		vma = find_vma(mm, msg->va);
> +		vma = vma_lookup(mm, msg->va);
>  		rc = -EINVAL;
>  
>  		if (!vma || (msg->va != vma->vm_start) || vma->vm_private_data)
Liam R. Howlett Jan. 18, 2022, 12:01 a.m. UTC | #2
* Vlastimil Babka <vbabka@suse.cz> [220112 11:01]:
> On 12/1/21 15:29, Liam Howlett wrote:
> > From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
> > 
> > vma_lookup() walks the VMA tree for a specific value, find_vma() will
> > search the tree after walking to a specific value.  It is more efficient
> > to only walk to the requested value as this case requires the address to
> > equal the vm_start.
> 
> By that you mean the privcmd_ioctl_mmap() code checks msg->va !=
> vma->vm_start and thus we know it's never interested the next vma, that
> find_vma() can return if no vma covers the address?

Yes.  I will reword the commit message.

> 
> > Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
> 
> Acked-by: Vlastimil Babka <vbabka@suse.cz>
> 
> > ---
> >  drivers/xen/privcmd.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
> > index 3369734108af..ad17166b0ef6 100644
> > --- a/drivers/xen/privcmd.c
> > +++ b/drivers/xen/privcmd.c
> > @@ -282,7 +282,7 @@ static long privcmd_ioctl_mmap(struct file *file, void __user *udata)
> >  						     struct page, lru);
> >  		struct privcmd_mmap_entry *msg = page_address(page);
> >  
> > -		vma = find_vma(mm, msg->va);
> > +		vma = vma_lookup(mm, msg->va);
> >  		rc = -EINVAL;
> >  
> >  		if (!vma || (msg->va != vma->vm_start) || vma->vm_private_data)
>
diff mbox series

Patch

diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
index 3369734108af..ad17166b0ef6 100644
--- a/drivers/xen/privcmd.c
+++ b/drivers/xen/privcmd.c
@@ -282,7 +282,7 @@  static long privcmd_ioctl_mmap(struct file *file, void __user *udata)
 						     struct page, lru);
 		struct privcmd_mmap_entry *msg = page_address(page);
 
-		vma = find_vma(mm, msg->va);
+		vma = vma_lookup(mm, msg->va);
 		rc = -EINVAL;
 
 		if (!vma || (msg->va != vma->vm_start) || vma->vm_private_data)