Skip to contentSkip to conversation

vhost-net: revert vhost_exceeds_maxpend logic to its original

PATCH In review Koichiro Den 2 participants 5 messages Aug 19, 2017 – Aug 21, 2017

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 vhost-net: revert vhost_exceeds_maxpend logic to its original

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.

---
 drivers/vhost/net.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/vhost/net.c +6 -2
index 06d044862e58..99cf99b308a7 100644
@@ -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
Signature · 1 line
2.9.4
#1 lore raw
Quoted 2 lines · Koichiro Den

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

Quoted 18 lines
---
  drivers/vhost/net.c | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
drivers/vhost/net.c +1 -0
index 06d044862e58..99cf99b308a7 100644
@@ -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;
 

drivers/vhost/net.c static int vhost_net_tx_get_vq_desc(struct vhost_net *net, · line 447

Quoted 10 lines
drivers/vhost/net.c +5 -2
-	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
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#2 lore raw
Quoted 11 lines · Jason Wang
Quoted 2 lines · Koichiro Den

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
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#3 lore raw
Quoted 13 lines · Jason Wang
Quoted 11 lines · Jason Wang
Quoted 2 lines · Koichiro Den

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?

Quoted 8 lines
Quoted 1 line

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
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#4 lore raw
In reply to Jason Wang
Quoted 8 lines · Jason Wang
Quoted 2 lines · Koichiro Den

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.

Quoted 24 lines

Thanks

Quoted 21 lines

---
  drivers/vhost/net.c | 8 ++++++--

  1 file changed, 6 insertions(+), 2 deletions(-)
drivers/vhost/net.c +0 -0
index 06d044862e58..99cf99b308a7 100644
@@ -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) {

drivers/vhost/net.c +1 -0
+	int num_pends;

   struct vhost_net_virtqueue *nvq = &net->vqs[VHOST_NET_VQ_TX]; struct vhost_virtqueue *vq = &nvq->vq;

drivers/vhost/net.c +0 -2
-	return (nvq->upend_idx + vq->num - VHOST_MAX_PEND) % UIO_MAXIOV
-		== nvq->done_idx;
Quoted 10 lines
Quoted 8 lines
drivers/vhost/net.c +5 -0
+	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
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization