netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] vhost-net: revert vhost_exceeds_maxpend logic to its original
@ 2017-08-19  6:41 Koichiro Den
  2017-08-21  3:06 ` Jason Wang
  0 siblings, 1 reply; 5+ messages in thread
From: Koichiro Den @ 2017-08-19  6:41 UTC (permalink / raw)
  To: mst, jasowang; +Cc: kvm, virtualization, netdev

To depend on vq.num and the usage of VHOST_MAX_PEND is not succinct
and in some case unexpected, so revert its logic part only.

Signed-off-by: Koichiro Den <den@klaipeden.com>
---
 drivers/vhost/net.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 06d044862e58..99cf99b308a7 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -433,11 +433,15 @@ static int vhost_net_tx_get_vq_desc(struct vhost_net *net,
 
 static bool vhost_exceeds_maxpend(struct vhost_net *net)
 {
+	int num_pends;
 	struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_TX];
 	struct vhost_virtqueue *vq = &nvq->vq;
 
-	return (nvq->upend_idx + vq->num - VHOST_MAX_PEND) % UIO_MAXIOV
-		== nvq->done_idx;
+	num_pends = likely(nvq->upend_idx >= nvq->done_idx) ?
+		(nvq->upend_idx - nvq->done_idx) :
+		(nvq->upend_idx + UIO_MAXIOV - nvq->done_idx);
+
+	return num_pends > VHOST_MAX_PEND;
 }
 
 /* Expects to be always run from workqueue - which acts as
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] vhost-net: revert vhost_exceeds_maxpend logic to its original
  2017-08-19  6:41 [PATCH 2/2] vhost-net: revert vhost_exceeds_maxpend logic to its original Koichiro Den
@ 2017-08-21  3:06 ` Jason Wang
  2017-08-21 12:40   ` Jason Wang
  2017-08-21 13:30   ` Koichiro Den
  0 siblings, 2 replies; 5+ messages in thread
From: Jason Wang @ 2017-08-21  3:06 UTC (permalink / raw)
  To: Koichiro Den, mst; +Cc: netdev, kvm, virtualization



On 2017年08月19日 14:41, Koichiro Den wrote:
> To depend on vq.num and the usage of VHOST_MAX_PEND is not succinct
> and in some case unexpected, so revert its logic part only.

Hi:

Could you explain a little bit more on the case that is was not sufficent?

Thanks

>
> Signed-off-by: Koichiro Den <den@klaipeden.com>
> ---
>   drivers/vhost/net.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> index 06d044862e58..99cf99b308a7 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -433,11 +433,15 @@ static int vhost_net_tx_get_vq_desc(struct vhost_net *net,
>   
>   static bool vhost_exceeds_maxpend(struct vhost_net *net)
>   {
> +	int num_pends;
>   	struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_TX];
>   	struct vhost_virtqueue *vq = &nvq->vq;
>   
> -	return (nvq->upend_idx + vq->num - VHOST_MAX_PEND) % UIO_MAXIOV
> -		== nvq->done_idx;
> +	num_pends = likely(nvq->upend_idx >= nvq->done_idx) ?
> +		(nvq->upend_idx - nvq->done_idx) :
> +		(nvq->upend_idx + UIO_MAXIOV - nvq->done_idx);
> +
> +	return num_pends > VHOST_MAX_PEND;
>   }
>   
>   /* Expects to be always run from workqueue - which acts as

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] vhost-net: revert vhost_exceeds_maxpend logic to its original
  2017-08-21  3:06 ` Jason Wang
@ 2017-08-21 12:40   ` Jason Wang
  2017-08-21 13:32     ` Koichiro Den
  2017-08-21 13:30   ` Koichiro Den
  1 sibling, 1 reply; 5+ messages in thread
From: Jason Wang @ 2017-08-21 12:40 UTC (permalink / raw)
  To: Koichiro Den, mst; +Cc: netdev, kvm, virtualization



On 2017年08月21日 11:06, Jason Wang wrote:
>
>
> On 2017年08月19日 14:41, Koichiro Den wrote:
>> To depend on vq.num and the usage of VHOST_MAX_PEND is not succinct
>> and in some case unexpected, so revert its logic part only.
>
> Hi:
>
> Could you explain a little bit more on the case that is was not 
> sufficent?
>
> Thanks

Just have another thought.

I wonder whether or not just use ulimit(memlock) is better here. It 
looks more flexible.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] vhost-net: revert vhost_exceeds_maxpend logic to its original
  2017-08-21  3:06 ` Jason Wang
  2017-08-21 12:40   ` Jason Wang
@ 2017-08-21 13:30   ` Koichiro Den
  1 sibling, 0 replies; 5+ messages in thread
From: Koichiro Den @ 2017-08-21 13:30 UTC (permalink / raw)
  To: Jason Wang, mst; +Cc: netdev, kvm, virtualization

On Mon, 2017-08-21 at 11:06 +0800, Jason Wang wrote:
> 
> On 2017年08月19日 14:41, Koichiro Den wrote:
> > To depend on vq.num and the usage of VHOST_MAX_PEND is not succinct
> > and in some case unexpected, so revert its logic part only.
> 
> Hi:
> 
> Could you explain a little bit more on the case that is was not sufficent?
It's just because vq.num could theoretically be around VHOST_MAX_PEND, that
could lead to an unexpected situation. Plus, I thought its name and usage is not
intrinsic. Its actual functioning in normal vq.num == 256 case is I think good
enough. Thanks.
> 
> Thanks
> 
> > 
> > Signed-off-by: Koichiro Den <den@klaipeden.com>
> > ---
> >   drivers/vhost/net.c | 8 ++++++--
> >   1 file changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> > index 06d044862e58..99cf99b308a7 100644
> > --- a/drivers/vhost/net.c
> > +++ b/drivers/vhost/net.c
> > @@ -433,11 +433,15 @@ static int vhost_net_tx_get_vq_desc(struct vhost_net
> > *net,
> >   
> >   static bool vhost_exceeds_maxpend(struct vhost_net *net)
> >   {
> > +	int num_pends;
> >   	struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_TX];
> >   	struct vhost_virtqueue *vq = &nvq->vq;
> >   
> > -	return (nvq->upend_idx + vq->num - VHOST_MAX_PEND) % UIO_MAXIOV
> > -		== nvq->done_idx;
> > +	num_pends = likely(nvq->upend_idx >= nvq->done_idx) ?
> > +		(nvq->upend_idx - nvq->done_idx) :
> > +		(nvq->upend_idx + UIO_MAXIOV - nvq->done_idx);
> > +
> > +	return num_pends > VHOST_MAX_PEND;
> >   }
> >   
> >   /* Expects to be always run from workqueue - which acts as
> 
> 

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] vhost-net: revert vhost_exceeds_maxpend logic to its original
  2017-08-21 12:40   ` Jason Wang
@ 2017-08-21 13:32     ` Koichiro Den
  0 siblings, 0 replies; 5+ messages in thread
From: Koichiro Den @ 2017-08-21 13:32 UTC (permalink / raw)
  To: Jason Wang, mst; +Cc: netdev, kvm, virtualization

On Mon, 2017-08-21 at 20:40 +0800, Jason Wang wrote:
> 
> On 2017年08月21日 11:06, Jason Wang wrote:
> > 
> > 
> > On 2017年08月19日 14:41, Koichiro Den wrote:
> > > To depend on vq.num and the usage of VHOST_MAX_PEND is not succinct
> > > and in some case unexpected, so revert its logic part only.
> > 
> > Hi:
> > 
> > Could you explain a little bit more on the case that is was not 
> > sufficent?
> > 
> > Thanks
> 
> Just have another thought.
> 
> I wonder whether or not just use ulimit(memlock) is better here. It 
> looks more flexible.
> 
> Thanks
It sounds a better approach, though at present I have got no idea how much
portion it should be.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-21 13:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-19  6:41 [PATCH 2/2] vhost-net: revert vhost_exceeds_maxpend logic to its original Koichiro Den
2017-08-21  3:06 ` Jason Wang
2017-08-21 12:40   ` Jason Wang
2017-08-21 13:32     ` Koichiro Den
2017-08-21 13:30   ` Koichiro Den

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).