Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1345492
| From | Jason Wang <jasowang@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH V3 3/3] vhost_net: basic polling support |
| Date | 2016-02-29 06:20 +0100 |
| Message-ID | <r7ops-5Yo-21@gated-at.bofh.it> (permalink) |
| References | <r6mg3-tV-5@gated-at.bofh.it> <r6mg3-tV-11@gated-at.bofh.it> <r7hxD-o4-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 02/29/2016 05:56 AM, Christian Borntraeger wrote:
> On 02/26/2016 09:42 AM, Jason Wang wrote:
>> > This patch tries to poll for new added tx buffer or socket receive
>> > queue for a while at the end of tx/rx processing. The maximum time
>> > spent on polling were specified through a new kind of vring ioctl.
>> >
>> > Signed-off-by: Jason Wang <jasowang@redhat.com>
>> > ---
>> > drivers/vhost/net.c | 79 +++++++++++++++++++++++++++++++++++++++++++---
>> > drivers/vhost/vhost.c | 14 ++++++++
>> > drivers/vhost/vhost.h | 1 +
>> > include/uapi/linux/vhost.h | 6 ++++
>> > 4 files changed, 95 insertions(+), 5 deletions(-)
>> >
>> > diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
>> > index 9eda69e..c91af93 100644
>> > --- a/drivers/vhost/net.c
>> > +++ b/drivers/vhost/net.c
>> > @@ -287,6 +287,44 @@ static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success)
>> > rcu_read_unlock_bh();
>> > }
>> >
>> > +static inline unsigned long busy_clock(void)
>> > +{
>> > + return local_clock() >> 10;
>> > +}
>> > +
>> > +static bool vhost_can_busy_poll(struct vhost_dev *dev,
>> > + unsigned long endtime)
>> > +{
>> > + return likely(!need_resched()) &&
>> > + likely(!time_after(busy_clock(), endtime)) &&
>> > + likely(!signal_pending(current)) &&
>> > + !vhost_has_work(dev) &&
>> > + single_task_running();
>> > +}
>> > +
>> > +static int vhost_net_tx_get_vq_desc(struct vhost_net *net,
>> > + struct vhost_virtqueue *vq,
>> > + struct iovec iov[], unsigned int iov_size,
>> > + unsigned int *out_num, unsigned int *in_num)
>> > +{
>> > + unsigned long uninitialized_var(endtime);
>> > + int r = vhost_get_vq_desc(vq, vq->iov, ARRAY_SIZE(vq->iov),
>> > + out_num, in_num, NULL, NULL);
>> > +
>> > + if (r == vq->num && vq->busyloop_timeout) {
>> > + preempt_disable();
>> > + endtime = busy_clock() + vq->busyloop_timeout;
>> > + while (vhost_can_busy_poll(vq->dev, endtime) &&
>> > + vhost_vq_avail_empty(vq->dev, vq))
>> > + cpu_relax();
> Can you use cpu_relax_lowlatency (which should be the same as cpu_relax for almost
> everybody but s390? cpu_relax (without low latency might give up the time slice
> when running under another hypervisor (like LPAR on s390), which might not be what
> we want here.
Ok, will do this in next version.
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH V3 3/3] vhost_net: basic polling support Jason Wang <jasowang@redhat.com> - 2016-02-26 09:50 +0100
Re: [PATCH V3 3/3] vhost_net: basic polling support "Michael S. Tsirkin" <mst@redhat.com> - 2016-02-28 15:10 +0100
Re: [PATCH V3 3/3] vhost_net: basic polling support Jason Wang <jasowang@redhat.com> - 2016-02-29 06:20 +0100
Re: [PATCH V3 3/3] vhost_net: basic polling support "Michael S. Tsirkin" <mst@redhat.com> - 2016-02-29 10:10 +0100
Re: [PATCH V3 3/3] vhost_net: basic polling support Christian Borntraeger <borntraeger@de.ibm.com> - 2016-02-28 23:00 +0100
Re: [PATCH V3 3/3] vhost_net: basic polling support Jason Wang <jasowang@redhat.com> - 2016-02-29 06:20 +0100
csiph-web