Displaying 20 results from an estimated 100 matches for "vhost_exceeds_weight".
2019 May 17
0
[PATCH V2 1/4] vhost: introduce vhost_exceeds_weight()
We used to have vhost_exceeds_weight() for vhost-net to:
- prevent vhost kthread from hogging the cpu
- balance the time spent between TX and RX
This function could be useful for vsock and scsi as well. So move it
to vhost.c. Device must specify a weight which counts the number of
requests, or it can also specific a byte_weight whic...
2018 May 21
1
[RFC PATCH net-next 02/12] vhost_net: introduce vhost_exceeds_weight()
...t a/drivers/vhost/net.c b/drivers/vhost/net.c
> index 15d191a..de544ee 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -479,6 +479,12 @@ static size_t init_iov_iter(struct vhost_virtqueue *vq, struct iov_iter *iter,
> return len;
> }
>
> +static bool vhost_exceeds_weight(int pkts, int total_len)
> +{
> + return unlikely(total_len >= VHOST_NET_WEIGHT) ||
> + unlikely(pkts >= VHOST_NET_PKT_WEIGHT);
I was going to say just one unlikely, but then the caller of this
function also says unlikely(vhost_exceeds...), so I think you should
just drop the...
2019 Sep 25
0
[PATCH] vhost: It's better to use size_t for the 3rd parameter of vhost_exceeds_weight()
...t; To: wangxu (AE) <wangxu72 at huawei.com>
> Cc: jasowang at redhat.com; kvm at vger.kernel.org; virtualization at lists.linux-foundation.org; netdev at vger.kernel.org; linux-kernel at vger.kernel.org
> Subject: Re: [PATCH] vhost: It's better to use size_t for the 3rd parameter of vhost_exceeds_weight()
>
> On Mon, Sep 23, 2019 at 03:46:41PM +0800, wangxu wrote:
>> From: Wang Xu <wangxu72 at huawei.com>
>>
>> Caller of vhost_exceeds_weight(..., total_len) in drivers/vhost/net.c
>> usually pass size_t total_len, which may be affected by rx/tx package.
>>...
2019 May 16
6
[PATCH net 0/4] Prevent vhost kthread from hogging CPU
...CPU hogging through
vhost kthread. This is done by introducing and checking the weight
after each requrest. The patch has been tested with reproducer of
vsock and virtio-net. Only compile test is done for vhost-scsi.
Please review.
This addresses CVE-2019-3900.
Jason Wang (4):
vhost: introduce vhost_exceeds_weight()
vhost_net: fix possible infinite loop
vhost: vsock: add weight support
vhost: scsi: add weight support
drivers/vhost/net.c | 41 ++++++++++++++---------------------------
drivers/vhost/scsi.c | 21 ++++++++++++++-------
drivers/vhost/vhost.c | 20 +++++++++++++++++++-
drivers/vhost/vho...
2019 Sep 23
0
[PATCH] vhost: It's better to use size_t for the 3rd parameter of vhost_exceeds_weight()
On Mon, Sep 23, 2019 at 03:46:41PM +0800, wangxu wrote:
> From: Wang Xu <wangxu72 at huawei.com>
>
> Caller of vhost_exceeds_weight(..., total_len) in drivers/vhost/net.c
> usually pass size_t total_len, which may be affected by rx/tx package.
>
> Signed-off-by: Wang Xu <wangxu72 at huawei.com>
Puts a bit more pressure on the register file ...
why do we care? Is there some way that it can
exceed INT_MAX?
>...
2019 May 17
9
[PATCH V2 0/4] Prevent vhost kthread from hogging CPU
...troducing and checking the weight
after each requrest. The patch has been tested with reproducer of
vsock and virtio-net. Only compile test is done for vhost-scsi.
Please review.
This addresses CVE-2019-3900.
Changs from V1:
- fix user-ater-free in vosck patch
Jason Wang (4):
vhost: introduce vhost_exceeds_weight()
vhost_net: fix possible infinite loop
vhost: vsock: add weight support
vhost: scsi: add weight support
drivers/vhost/net.c | 41 ++++++++++++++---------------------------
drivers/vhost/scsi.c | 21 ++++++++++++++-------
drivers/vhost/vhost.c | 20 +++++++++++++++++++-
drivers/vhost/vho...
2019 May 17
9
[PATCH V2 0/4] Prevent vhost kthread from hogging CPU
...troducing and checking the weight
after each requrest. The patch has been tested with reproducer of
vsock and virtio-net. Only compile test is done for vhost-scsi.
Please review.
This addresses CVE-2019-3900.
Changs from V1:
- fix user-ater-free in vosck patch
Jason Wang (4):
vhost: introduce vhost_exceeds_weight()
vhost_net: fix possible infinite loop
vhost: vsock: add weight support
vhost: scsi: add weight support
drivers/vhost/net.c | 41 ++++++++++++++---------------------------
drivers/vhost/scsi.c | 21 ++++++++++++++-------
drivers/vhost/vhost.c | 20 +++++++++++++++++++-
drivers/vhost/vho...
2018 May 21
0
[RFC PATCH net-next 02/12] vhost_net: introduce vhost_exceeds_weight()
...insertions(+), 5 deletions(-)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 15d191a..de544ee 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -479,6 +479,12 @@ static size_t init_iov_iter(struct vhost_virtqueue *vq, struct iov_iter *iter,
return len;
}
+static bool vhost_exceeds_weight(int pkts, int total_len)
+{
+ return unlikely(total_len >= VHOST_NET_WEIGHT) ||
+ unlikely(pkts >= VHOST_NET_PKT_WEIGHT);
+}
+
/* Expects to be always run from workqueue - which acts as
* read-size critical section for our kind of RCU. */
static void handle_tx(struct vhost_net *net...
2019 Apr 25
2
[PATCH net] vhost_net: fix possible infinite loop
...busyloop_intr = false;
if (nvq->done_idx == VHOST_NET_BATCH)
@@ -845,11 +846,10 @@ static void handle_tx_copy(struct vhost_net *net, struct socket *sock)
vq->heads[nvq->done_idx].id = cpu_to_vhost32(vq, head);
vq->heads[nvq->done_idx].len = 0;
++nvq->done_idx;
- if (vhost_exceeds_weight(++sent_pkts, total_len)) {
- vhost_poll_queue(&vq->poll);
- break;
- }
- }
+ } while (!(next_round = vhost_exceeds_weight(++sent_pkts, total_len)));
+
+ if (next_round)
+ vhost_poll_queue(&vq->poll);
vhost_tx_batch(net, nvq, sock, &msg);
}
@@ -873,8 +873,9 @@ static voi...
2019 Apr 25
2
[PATCH net] vhost_net: fix possible infinite loop
...busyloop_intr = false;
if (nvq->done_idx == VHOST_NET_BATCH)
@@ -845,11 +846,10 @@ static void handle_tx_copy(struct vhost_net *net, struct socket *sock)
vq->heads[nvq->done_idx].id = cpu_to_vhost32(vq, head);
vq->heads[nvq->done_idx].len = 0;
++nvq->done_idx;
- if (vhost_exceeds_weight(++sent_pkts, total_len)) {
- vhost_poll_queue(&vq->poll);
- break;
- }
- }
+ } while (!(next_round = vhost_exceeds_weight(++sent_pkts, total_len)));
+
+ if (next_round)
+ vhost_poll_queue(&vq->poll);
vhost_tx_batch(net, nvq, sock, &msg);
}
@@ -873,8 +873,9 @@ static voi...
2019 Apr 26
2
[PATCH net] vhost_net: fix possible infinite loop
...== VHOST_NET_BATCH)
>> @@ -845,11 +846,10 @@ static void handle_tx_copy(struct vhost_net *net, struct socket *sock)
>> vq->heads[nvq->done_idx].id = cpu_to_vhost32(vq, head);
>> vq->heads[nvq->done_idx].len = 0;
>> ++nvq->done_idx;
>> - if (vhost_exceeds_weight(++sent_pkts, total_len)) {
>> - vhost_poll_queue(&vq->poll);
>> - break;
>> - }
>> - }
>> + } while (!(next_round = vhost_exceeds_weight(++sent_pkts, total_len)));
>> +
>> + if (next_round)
>> + vhost_poll_queue(&vq->poll);
>>...
2019 Apr 26
2
[PATCH net] vhost_net: fix possible infinite loop
...== VHOST_NET_BATCH)
>> @@ -845,11 +846,10 @@ static void handle_tx_copy(struct vhost_net *net, struct socket *sock)
>> vq->heads[nvq->done_idx].id = cpu_to_vhost32(vq, head);
>> vq->heads[nvq->done_idx].len = 0;
>> ++nvq->done_idx;
>> - if (vhost_exceeds_weight(++sent_pkts, total_len)) {
>> - vhost_poll_queue(&vq->poll);
>> - break;
>> - }
>> - }
>> + } while (!(next_round = vhost_exceeds_weight(++sent_pkts, total_len)));
>> +
>> + if (next_round)
>> + vhost_poll_queue(&vq->poll);
>>...
2019 May 12
2
[PATCH net] vhost_net: fix possible infinite loop
...t; > > > vhost_net *net, struct socket *sock)
> > > > ????????? vq->heads[nvq->done_idx].id = cpu_to_vhost32(vq, head);
> > > > ????????? vq->heads[nvq->done_idx].len = 0;
> > > > ????????? ++nvq->done_idx;
> > > > -??????? if (vhost_exceeds_weight(++sent_pkts, total_len)) {
> > > > -??????????? vhost_poll_queue(&vq->poll);
> > > > -??????????? break;
> > > > -??????? }
> > > > -??? }
> > > > +??? } while (!(next_round = vhost_exceeds_weight(++sent_pkts,
> > > > to...
2019 May 12
2
[PATCH net] vhost_net: fix possible infinite loop
...t; > > > vhost_net *net, struct socket *sock)
> > > > ????????? vq->heads[nvq->done_idx].id = cpu_to_vhost32(vq, head);
> > > > ????????? vq->heads[nvq->done_idx].len = 0;
> > > > ????????? ++nvq->done_idx;
> > > > -??????? if (vhost_exceeds_weight(++sent_pkts, total_len)) {
> > > > -??????????? vhost_poll_queue(&vq->poll);
> > > > -??????????? break;
> > > > -??????? }
> > > > -??? }
> > > > +??? } while (!(next_round = vhost_exceeds_weight(++sent_pkts,
> > > > to...
2018 May 21
1
[RFC PATCH net-next 03/12] vhost_net: introduce vhost_has_more_pkts()
...> drivers/vhost/net.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> index de544ee..4ebac76 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -485,6 +485,13 @@ static bool vhost_exceeds_weight(int pkts, int total_len)
> unlikely(pkts >= VHOST_NET_PKT_WEIGHT);
> }
>
> +static bool vhost_has_more_pkts(struct vhost_net *net,
> + struct vhost_virtqueue *vq)
> +{
> + return !vhost_vq_avail_empty(&net->dev, vq) &&
> + likely(!vhos...
2019 May 05
0
[PATCH net] vhost_net: fix possible infinite loop
...atic void handle_tx_copy(struct vhost_net
>>> *net, struct socket *sock)
>>> ????????? vq->heads[nvq->done_idx].id = cpu_to_vhost32(vq, head);
>>> ????????? vq->heads[nvq->done_idx].len = 0;
>>> ????????? ++nvq->done_idx;
>>> -??????? if (vhost_exceeds_weight(++sent_pkts, total_len)) {
>>> -??????????? vhost_poll_queue(&vq->poll);
>>> -??????????? break;
>>> -??????? }
>>> -??? }
>>> +??? } while (!(next_round = vhost_exceeds_weight(++sent_pkts,
>>> total_len)));
>>> +
>>> +...
2019 Apr 25
0
[PATCH net] vhost_net: fix possible infinite loop
...if (nvq->done_idx == VHOST_NET_BATCH)
> @@ -845,11 +846,10 @@ static void handle_tx_copy(struct vhost_net *net, struct socket *sock)
> vq->heads[nvq->done_idx].id = cpu_to_vhost32(vq, head);
> vq->heads[nvq->done_idx].len = 0;
> ++nvq->done_idx;
> - if (vhost_exceeds_weight(++sent_pkts, total_len)) {
> - vhost_poll_queue(&vq->poll);
> - break;
> - }
> - }
> + } while (!(next_round = vhost_exceeds_weight(++sent_pkts, total_len)));
> +
> + if (next_round)
> + vhost_poll_queue(&vq->poll);
>
> vhost_tx_batch(net, nvq,...
2019 May 13
0
[PATCH net] vhost_net: fix possible infinite loop
...t;>> vhost_net *net, struct socket *sock)
>>>>> ????????? vq->heads[nvq->done_idx].id = cpu_to_vhost32(vq, head);
>>>>> ????????? vq->heads[nvq->done_idx].len = 0;
>>>>> ????????? ++nvq->done_idx;
>>>>> -??????? if (vhost_exceeds_weight(++sent_pkts, total_len)) {
>>>>> -??????????? vhost_poll_queue(&vq->poll);
>>>>> -??????????? break;
>>>>> -??????? }
>>>>> -??? }
>>>>> +??? } while (!(next_round = vhost_exceeds_weight(++sent_pkts,
>>>>&...
2019 May 14
1
[PATCH net] vhost_net: fix possible infinite loop
...cket *sock)
> > > > > > ????????? vq->heads[nvq->done_idx].id = cpu_to_vhost32(vq, head);
> > > > > > ????????? vq->heads[nvq->done_idx].len = 0;
> > > > > > ????????? ++nvq->done_idx;
> > > > > > -??????? if (vhost_exceeds_weight(++sent_pkts, total_len)) {
> > > > > > -??????????? vhost_poll_queue(&vq->poll);
> > > > > > -??????????? break;
> > > > > > -??????? }
> > > > > > -??? }
> > > > > > +??? } while (!(next_round = vhost_...
2018 May 21
0
[RFC PATCH net-next 03/12] vhost_net: introduce vhost_has_more_pkts()
...Wang <jasowang at redhat.com>
---
drivers/vhost/net.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index de544ee..4ebac76 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -485,6 +485,13 @@ static bool vhost_exceeds_weight(int pkts, int total_len)
unlikely(pkts >= VHOST_NET_PKT_WEIGHT);
}
+static bool vhost_has_more_pkts(struct vhost_net *net,
+ struct vhost_virtqueue *vq)
+{
+ return !vhost_vq_avail_empty(&net->dev, vq) &&
+ likely(!vhost_exceeds_maxpend(net));
+}
+
/* Expect...