# \[PATCH 1/2\] vhost: remove the possible fruitless search on iotlb prefetch

- Subsystems: VIRTIO HOST (VHOST), THE REST
- Maintainers: Michael S. Tsirkin, Jason Wang, Eugenio Pérez, Linus Torvalds
- List: netdev
- 4 messages, 3 authors
- Page: https://ratatoskr.run/netdev/2017/08/11063401/t

## \[PATCH 1/2\] vhost: remove the possible fruitless search on iotlb prefetch

- From: Koichiro Den \<hidden\>
- Date: 2017-08-19 06:41:14 
- Message: https://ratatoskr.run/netdev/2017/08/11063401.md

```text
Signed-off-by: Koichiro Den <redacted>
---
 drivers/vhost/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index e4613a3c362d..93e909afc1c3 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1184,7 +1184,7 @@ static int iotlb_access_ok(struct vhost_virtqueue *vq,
 	while (len > s) {
 		node = vhost_umem_interval_tree_iter_first(&umem->umem_tree,
 							   addr,
-							   addr + len - 1);
+							   addr + len - s - 1);
 		if (node == NULL || node->start > addr) {
 			vhost_iotlb_miss(vq, addr, access);
 			return false;
-- 
2.9.4
```

## Re: \[PATCH 1/2\] vhost: remove the possible fruitless search on iotlb prefetch

- From: Jason Wang \<hidden\>
- Date: 2017-08-21 03:09:07 
- Message: https://ratatoskr.run/netdev/2017/08/11063480.md

```text


On 2017年08月19日 14:41, Koichiro Den wrote:
> Signed-off-by: Koichiro Den <redacted>
> ---
>   drivers/vhost/vhost.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index e4613a3c362d..93e909afc1c3 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -1184,7 +1184,7 @@ static int iotlb_access_ok(struct vhost_virtqueue *vq,
>   	while (len > s) {
>   		node = vhost_umem_interval_tree_iter_first(&umem->umem_tree,
>   							   addr,
> -							   addr + len - 1);
> +							   addr + len - s - 1);
>   		if (node == NULL || node->start > addr) {
>   			vhost_iotlb_miss(vq, addr, access);
>   			return false;

Acked-by: Jason Wang <redacted>
```

## Re: \[PATCH 1/2\] vhost: remove the possible fruitless search on iotlb prefetch

- From: Michael S. Tsirkin \<mst@redhat.com\>
- Date: 2017-08-21 19:45:59 
- Message: https://ratatoskr.run/netdev/2017/08/11063608.md

```text
On Sat, Aug 19, 2017 at 03:41:14PM +0900, Koichiro Den wrote:
> Signed-off-by: Koichiro Den <redacted>
> ---
>  drivers/vhost/vhost.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index e4613a3c362d..93e909afc1c3 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -1184,7 +1184,7 @@ static int iotlb_access_ok(struct vhost_virtqueue *vq,
>  	while (len > s) {
>  		node = vhost_umem_interval_tree_iter_first(&umem->umem_tree,
>  							   addr,
> -							   addr + len - 1);
> +							   addr + len - s - 1);
>  		if (node == NULL || node->start > addr) {
>  			vhost_iotlb_miss(vq, addr, access);
>  			return false;

This works but it probably makes sense to just refactor the code to make end of
range a variable. I posted a patch like this, pls take a look.

> -- 
> 2.9.4
> 
```

## Re: \[PATCH 1/2\] vhost: remove the possible fruitless search on iotlb prefetch

- From: Koichiro Den \<hidden\>
- Date: 2017-08-22 14:09:44 
- Message: https://ratatoskr.run/netdev/2017/08/11063687.md

```text
On Mon, 2017-08-21 at 22:45 +0300, Michael S. Tsirkin wrote:
> On Sat, Aug 19, 2017 at 03:41:14PM +0900, Koichiro Den wrote:
> > Signed-off-by: Koichiro Den <redacted>
> > ---
> >  drivers/vhost/vhost.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> > index e4613a3c362d..93e909afc1c3 100644
> > --- a/drivers/vhost/vhost.c
> > +++ b/drivers/vhost/vhost.c
> > @@ -1184,7 +1184,7 @@ static int iotlb_access_ok(struct vhost_virtqueue *vq,
> >  	while (len > s) {
> >  		node = vhost_umem_interval_tree_iter_first(&umem-
> > >umem_tree,
> >  							   addr,
> > -							   addr + len - 1);
> > +							   addr + len - s -
> > 1);
> >  		if (node == NULL || node->start > addr) {
> >  			vhost_iotlb_miss(vq, addr, access);
> >  			return false;
> 
> This works but it probably makes sense to just refactor the code to make end
> of
> range a variable. I posted a patch like this, pls take a look.
> 
> > -- 
> > 2.9.4
> > 
Ok, thanks.

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
```
