Re: Can VFIO pin only a specific region of guest mem when use pass through devices?

2018-10-29 Thread Jason Wang
On 2018/10/29 上午10:42, Simon Guo wrote: Hi, I am using network device pass through mode with qemu x86(-device vfio-pci,host=:xx:yy.z) and “intel_iommu=on” in host kernel command line, and it shows the whole guest memory were pinned(vfio_pin_pages()), viewed by the “top” RES memory

Re: [PATCH] virtio_net: enable tx after resuming from suspend

2018-10-11 Thread Jason Wang
On 2018年10月11日 18:22, ake wrote: On 2018年10月11日 18:44, Jason Wang wrote: On 2018年10月11日 15:51, Ake Koomsin wrote: commit 713a98d90c5e ("virtio-net: serialize tx routine during reset") disabled the virtio tx before going to suspend to avoid a use after free. However, afte

Re: [PATCH net-next V3] virtio_net: ethtool tx napi configuration

2018-10-11 Thread Jason Wang
On 2018年10月11日 13:34, David Miller wrote: From: Jason Wang Date: Tue, 9 Oct 2018 10:06:26 +0800 Implement ethtool .set_coalesce (-C) and .get_coalesce (-c) handlers. Interrupt moderation is currently not supported, so these accept and display the default settings of 0 usec and 1 frame

Re: [PATCH] virtio_net: enable tx after resuming from suspend

2018-10-11 Thread Jason Wang
On 2018年10月11日 15:51, Ake Koomsin wrote: commit 713a98d90c5e ("virtio-net: serialize tx routine during reset") disabled the virtio tx before going to suspend to avoid a use after free. However, after resuming, it causes the virtio_net device to lose its network connectivity. To solve the

Re: [PATCH net V2] vhost-vsock: fix use after free

2018-09-27 Thread Jason Wang
On 2018年09月28日 01:04, Michael S. Tsirkin wrote: On Thu, Sep 27, 2018 at 08:22:04PM +0800, Jason Wang wrote: The access of vsock is not protected by vhost_vsock_lock. This may lead to use after free since vhost_vsock_dev_release() may free the pointer at the same time. Fix this by holding

Re: [PATCH net] vhost-vsock: fix use after free

2018-09-27 Thread Jason Wang
On 2018年09月27日 17:52, Sergei Shtylyov wrote: Hello! On 9/27/2018 11:43 AM, Jason Wang wrote:    Just a couple of typos... The access of vsock is not protected by vhost_vsock_lock. This may lead use after free since vhost_vsock_dev_release() may free the   Lead to use. pointer

[PATCH net V2] vhost-vsock: fix use after free

2018-09-27 Thread Jason Wang
("vhost-vsock: add pkt cancel capability") Fixes: 433fc58e6bf2 ("VSOCK: Introduce vhost_vsock.ko") Cc: Stefan Hajnoczi Signed-off-by: Jason Wang --- - V2: fix typos - The patch is needed for -stable. --- drivers/vhost/vsock.c | 26 +++--- 1 file changed,

[PATCH net-next 8/9] vhost_net: rename VHOST_RX_BATCH to VHOST_NET_BATCH

2018-07-19 Thread Jason Wang
A more generic name which could be used for TX as well. Signed-off-by: Jason Wang --- drivers/vhost/net.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 53d305b..2fd2f0e3 100644 --- a/drivers/vhost/net.c +++ b/drivers

Re: [RFC v6 4/5] virtio_ring: add event idx support in packed ring

2018-06-07 Thread Jason Wang
On 2018年06月05日 15:40, Tiwei Bie wrote: static bool virtqueue_enable_cb_delayed_packed(struct virtqueue *_vq) { struct vring_virtqueue *vq = to_vvq(_vq); + u16 bufs, used_idx, wrap_counter; START_USE(vq); /* We optimistically turn back on interrupts, then check if

[PATCH net] vhost_net: flush batched heads before trying to busy polling

2018-05-29 Thread Jason Wang
busy loop. 1 byte TCP_RR performance recovers from 13107.83 to 50402.65. Fixes: e2b3b35eb989 ("vhost_net: batch used ring update in rx") Signed-off-by: Jason Wang --- drivers/vhost/net.c | 37 - 1 file changed, 24 insertions(+), 13 deletions(-)

Re: [RFC v5 3/5] virtio_ring: add packed ring support

2018-05-29 Thread Jason Wang
On 2018年05月29日 13:11, Tiwei Bie wrote: On Tue, May 29, 2018 at 11:18:57AM +0800, Jason Wang wrote: On 2018年05月22日 16:16, Tiwei Bie wrote: [...] +static void detach_buf_packed(struct vring_virtqueue *vq, + unsigned int id, void **ctx) +{ + struct

Re: [RFC v5 2/5] virtio_ring: support creating packed ring

2018-05-29 Thread Jason Wang
On 2018年05月29日 13:24, Tiwei Bie wrote: On Tue, May 29, 2018 at 10:49:11AM +0800, Jason Wang wrote: On 2018年05月22日 16:16, Tiwei Bie wrote: This commit introduces the support for creating packed ring. All split ring specific functions are added _split suffix. Some necessary stubs for packed

Re: [RFC v5 3/5] virtio_ring: add packed ring support

2018-05-28 Thread Jason Wang
On 2018年05月22日 16:16, Tiwei Bie wrote: This commit introduces the support (without EVENT_IDX) for packed ring. Signed-off-by: Tiwei Bie --- drivers/virtio/virtio_ring.c | 474 ++- 1 file changed, 468 insertions(+), 6 deletions(-) diff --git

Re: [RFC v5 2/5] virtio_ring: support creating packed ring

2018-05-28 Thread Jason Wang
On 2018年05月22日 16:16, Tiwei Bie wrote: This commit introduces the support for creating packed ring. All split ring specific functions are added _split suffix. Some necessary stubs for packed ring are also added. Signed-off-by: Tiwei Bie --- drivers/virtio/virtio_ring.c | 801

[RFC V5 PATCH 3/8] vhost: do not use vring_used_elem

2018-05-28 Thread Jason Wang
Instead of depending on the exported vring_used_elem, this patch switches to use a new internal structure vhost_used_elem which embed vring_used_elem in itself. This could be used to let vhost to record extra metadata for the incoming packed ring layout. Signed-off-by: Jason Wang --- drivers

[RFC V5 PATCH 7/8] vhost: packed ring support

2018-05-28 Thread Jason Wang
Signed-off-by: Jason Wang --- drivers/vhost/net.c | 13 +- drivers/vhost/vhost.c | 585 ++ drivers/vhost/vhost.h | 13 +- 3 files changed, 566 insertions(+), 45 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 30273ad

[RFC V5 PATCH 8/8] vhost: event suppression for packed ring

2018-05-28 Thread Jason Wang
This patch introduces basic support for event suppression aka driver and device area. Signed-off-by: Jason Wang --- drivers/vhost/vhost.c| 191 --- drivers/vhost/vhost.h| 10 +- include/uapi/linux/virtio_ring.h | 19 3 files

[RFC V5 PATCH 5/8] vhost: vhost_put_user() can accept metadata type

2018-05-28 Thread Jason Wang
We assumes used ring update is the only user for vhost_put_user() in the past. This may not be the case for the incoming packed ring which may update the descriptor ring for used. So introduce a new type parameter. Signed-off-by: Jason Wang --- drivers/vhost/vhost.c | 14 +++--- 1 file

[RFC V5 PATCH 6/8] virtio: introduce packed ring defines

2018-05-28 Thread Jason Wang
Signed-off-by: Jason Wang --- include/uapi/linux/virtio_config.h | 9 + include/uapi/linux/virtio_ring.h | 13 + 2 files changed, 22 insertions(+) diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h index 308e209..5903d51 100644

[RFC V5 PATCH 0/8] Packed ring layout for vhost

2018-05-28 Thread Jason Wang
pile test only). - Zerocopy support. - vIOMMU support. - SCSI/VSOCK support (compile test only). - Fix several bugs Jason Wang (8): vhost: move get_rx_bufs to vhost.c vhost: hide used ring layout from device vhost: do not use vring_used_elem vhost_net: do not explicitly manipu

[RFC V5 PATCH 2/8] vhost: hide used ring layout from device

2018-05-28 Thread Jason Wang
by - letting vhost_get_vq_desc() return pointer to struct vring_used_elem - accepting pointer to struct vring_used_elem in vhost_add_used() and vhost_add_used_and_signal() This could help to hide used ring layout and make it easier to implement packed ring on top. Signed-off-by: Jason Wang --- drivers

[RFC V5 PATCH 4/8] vhost_net: do not explicitly manipulate vhost_used_elem

2018-05-28 Thread Jason Wang
Two helpers of setting/getting used len were introduced to avoid explicitly manipulating vhost_used_elem in zerocopy code. This will be used to hide used_elem internals and simplify packed ring implementation. Signed-off-by: Jason Wang --- drivers/vhost/net.c | 11 +-- drivers/vhost

[RFC V5 PATCH 1/8] vhost: move get_rx_bufs to vhost.c

2018-05-28 Thread Jason Wang
Move get_rx_bufs() to vhost.c and rename it to vhost_get_bufs(). This helps to hide vring internal layout from specific device implementation. Packed ring implementation will benefit from this. Signed-off-by: Jason Wang --- drivers/vhost/net.c | 83

Re: [RFC v5 0/5] virtio: support packed ring

2018-05-24 Thread Jason Wang
On 2018年05月22日 16:16, Tiwei Bie wrote: Hello everyone, This RFC implements packed ring support in virtio driver. Some simple functional tests have been done with Jason's packed ring implementation in vhost (RFC v4): https://lkml.org/lkml/2018/5/16/501 Both of ping and netperf worked as

Re: [RFC V4 PATCH 8/8] vhost: event suppression for packed ring

2018-05-24 Thread Jason Wang
On 2018年05月16日 20:32, Jason Wang wrote: +static bool vhost_notify_packed(struct vhost_dev *dev, + struct vhost_virtqueue *vq) +{ + __virtio16 event_off_wrap, event_flags; + __u16 old, new, off_wrap; + bool v; + + /* Flush out used

Re: [RFC V4 PATCH 7/8] vhost: packed ring support

2018-05-23 Thread Jason Wang
On 2018年05月23日 15:17, Wei Xu wrote: On Wed, May 23, 2018 at 09:39:28AM +0800, Jason Wang wrote: On 2018年05月23日 00:54, Wei Xu wrote: On Wed, May 16, 2018 at 08:32:20PM +0800, Jason Wang wrote: Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c | 3 +- d

Re: [RFC V4 PATCH 7/8] vhost: packed ring support

2018-05-22 Thread Jason Wang
On 2018年05月23日 00:54, Wei Xu wrote: On Wed, May 16, 2018 at 08:32:20PM +0800, Jason Wang wrote: Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c | 3 +- drivers/vhost/vhost.c | 539 ++ drivers/vhost/vhost.h

Re: [RFC PATCH net-next 10/12] vhost_net: build xdp buff

2018-05-22 Thread Jason Wang
and then can disable premmption for several XDP buffs to achieve batching from XDP. TODO: reserve headroom based on the TUN XDP. Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c | 74 + 1 file changed, 74 inse

Re: [RFC PATCH net-next 04/12] vhost_net: split out datacopy logic

2018-05-22 Thread Jason Wang
-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c | 111 +++- 1 file changed, 102 insertions(+), 9 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 4ebac76..4682fcc 100644 --- a/drivers/vhost/net.c

Re: [RFC PATCH net-next 03/12] vhost_net: introduce vhost_has_more_pkts()

2018-05-22 Thread Jason Wang
On 2018年05月22日 00:39, Jesse Brandeburg wrote: On Mon, 21 May 2018 17:04:24 +0800 Jason wrote: Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost

Re: [RFC PATCH net-next 02/12] vhost_net: introduce vhost_exceeds_weight()

2018-05-22 Thread Jason Wang
On 2018年05月22日 00:29, Jesse Brandeburg wrote: On Mon, 21 May 2018 17:04:23 +0800 Jason wrote: Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost

Re: [RFC PATCH net-next 01/12] vhost_net: introduce helper to initialize tx iov iter

2018-05-22 Thread Jason Wang
On 2018年05月22日 00:24, Jesse Brandeburg wrote: Hi Jason, a few nits. On Mon, 21 May 2018 17:04:22 +0800 Jason wrote: Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c | 34 +++--- 1 file changed, 23 insertions(+), 11 deletions(-)

[PATCH net] vhost: synchronize IOTLB message with dev cleanup

2018-05-22 Thread Jason Wang
m, fixing by protecting vhost_process_iotlb_msg() with dev mutex. Reported-by: DaeRyong Jeong <threeear...@gmail.com> Fixes: 6b1e6cc7855b0 ("vhost: new device IOTLB API") Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/vhost.c | 3 +++ 1 file changed, 3 insertions

Re: KASAN: use-after-free Read in vhost_chr_write_iter

2018-05-22 Thread Jason Wang
On 2018年05月22日 16:38, DaeRyong Jeong wrote: On Mon, May 21, 2018 at 10:38:10AM +0800, Jason Wang wrote: On 2018年05月18日 17:24, Jason Wang wrote: On 2018年05月17日 21:45, DaeRyong Jeong wrote: We report the crash: KASAN: use-after-free Read in vhost_chr_write_iter This crash has been found

[PATCH net] tuntap: correctly set SOCKWQ_ASYNC_NOSPACE

2018-05-22 Thread Jason Wang
Sowa <han...@stressinduktion.org> Cc: Eric Dumazet <eduma...@google.com> Fixes: 1bd4978a88ac2 ("tun: honor IFF_UP in tun_get_user()") Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/tun.c | 19 +++ 1 file changed, 15 insertions(+)

Re: [PATCH net] tuntap: raise EPOLLOUT on device up

2018-05-21 Thread Jason Wang
On 2018年05月22日 11:46, Michael S. Tsirkin wrote: On Tue, May 22, 2018 at 11:22:11AM +0800, Jason Wang wrote: On 2018年05月22日 06:08, Michael S. Tsirkin wrote: On Mon, May 21, 2018 at 11:47:42AM -0400, David Miller wrote: From: Jason Wang <jasow...@redhat.com> Date: Fri, 18 May 2018 21

Re: KASAN: use-after-free Read in vhost_chr_write_iter

2018-05-21 Thread Jason Wang
On 2018年05月21日 22:42, Michael S. Tsirkin wrote: On Mon, May 21, 2018 at 10:38:10AM +0800, Jason Wang wrote: On 2018年05月18日 17:24, Jason Wang wrote: On 2018年05月17日 21:45, DaeRyong Jeong wrote: We report the crash: KASAN: use-after-free Read in vhost_chr_write_iter This crash has been found

[PATCH net V2 2/4] virtio-net: correctly transmit XDP buff after linearizing

2018-05-21 Thread Jason Wang
("virtio_net: xdp, add slowpath case for non contiguous buffers") Cc: John Fastabend <john.fastab...@gmail.com> Acked-by: Michael S. Tsirkin <m...@redhat.com> Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+

[PATCH net V2 4/4] virtio-net: fix leaking page for gso packet during mergeable XDP

2018-05-21 Thread Jason Wang
t: xdp, add slowpath case for non contiguous buffers") Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/virtio_net.c | 15 +++ 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 3

[PATCH net V2 3/4] virtio-net: correctly check num_buf during err path

2018-05-21 Thread Jason Wang
("virtio-net: do not reset during XDP set") Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 6260d65..326e247 100644 --- a/drivers/

[PATCH net V2 1/4] virtio-net: correctly redirect linearized packet

2018-05-21 Thread Jason Wang
) Reported-by: David Ahern <dsah...@gmail.com> Tested-by: David Ahern <dsah...@gmail.com> Acked-by: Michael S. Tsirkin <m...@redhat.com> Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH net V2 0/4] Fix several issues of virtio-net mergeable XDP

2018-05-21 Thread Jason Wang
Hi: Please review the patches that tries to fix sevreal issues of virtio-net mergeable XDP. Changes from V1: - check against 1 before decreasing instead of resetting to 1 - typoe fixes Jason Wang (4): virtio-net: correctly redirect linearized packet virtio-net: correctly transmit XDP buff

Re: [PATCH net 4/4] virito-net: fix leaking page for gso packet during mergeable XDP

2018-05-21 Thread Jason Wang
On 2018年05月21日 23:01, Michael S. Tsirkin wrote: On Mon, May 21, 2018 at 04:35:06PM +0800, Jason Wang wrote: We need to drop refcnt to xdp_page if we see a gso packet. Otherwise it will be leaked. Fixing this by moving the check of gso packet above the linearizing logic. Cc: John Fastabend

Re: [PATCH net 3/4] virtio-net: reset num_buf to 1 after linearizing packet

2018-05-21 Thread Jason Wang
On 2018年05月21日 22:59, Michael S. Tsirkin wrote: On Mon, May 21, 2018 at 04:35:05PM +0800, Jason Wang wrote: If we successfully linearize the packets, num_buf were set to zero which was wrong since we now have only 1 buffer to be used for e.g in the error path of receive_mergeable(). Zero

Re: [PATCH net] tuntap: raise EPOLLOUT on device up

2018-05-21 Thread Jason Wang
On 2018年05月22日 06:08, Michael S. Tsirkin wrote: On Mon, May 21, 2018 at 11:47:42AM -0400, David Miller wrote: From: Jason Wang <jasow...@redhat.com> Date: Fri, 18 May 2018 21:00:43 +0800 We return -EIO on device down but can not raise EPOLLOUT after it was up. This may confuse use

[RFC PATCH net-next 03/12] vhost_net: introduce vhost_has_more_pkts()

2018-05-21 Thread Jason Wang
Signed-off-by: Jason Wang <jasow...@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 +

[RFC PATCH net-next 04/12] vhost_net: split out datacopy logic

2018-05-21 Thread Jason Wang
Instead of mixing zerocopy and datacopy logics, this patch tries to split datacopy logic out. This results for a more compact code and specific optimization could be done on top more easily. Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c

[RFC PATCH net-next 01/12] vhost_net: introduce helper to initialize tx iov iter

2018-05-21 Thread Jason Wang
Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c | 34 +++--- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index c4b49fc..15d191a 100644 --- a/drivers/vhost/net.c +++ b/drivers

[RFC PATCH net-next 07/12] tuntap: simplify error handling in tun_build_skb()

2018-05-21 Thread Jason Wang
Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/tun.c | 36 ++-- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 24ecd82..f6e0f96 100644 --- a/drivers/net/tun.c +++ b/drivers/net

[RFC PATCH net-next 09/12] tuntap: split out XDP logic

2018-05-21 Thread Jason Wang
This patch split out XDP logic into a single function. This make it to be reused by XDP batching path in the following patch. Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/tun.c | 85 +-- 1 file changed, 51 insertions(

[RFC PATCH net-next 06/12] tuntap: enable premmption early

2018-05-21 Thread Jason Wang
Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/tun.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 44d4f3d..24ecd82 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1697,6 +1697,8 @@ static

[RFC PATCH net-next 08/12] tuntap: tweak on the path of non-xdp case in tun_build_skb()

2018-05-21 Thread Jason Wang
If we're sure not to go native XDP, there's no need for several things like touching preemption counter and rcu stuffs. Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/tun.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/tun.c b/d

[RFC PATCH net-next 11/12] vhost_net: passing raw xdp buff to tun

2018-05-21 Thread Jason Wang
XDP buff to TUN. This could be used to implement accepting an array of XDP buffs from vhost_net in the following patches. Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/tun.c | 91 +- drivers/vhost/net.c

[RFC PATCH net-next 05/12] vhost_net: batch update used ring for datacopy TX

2018-05-21 Thread Jason Wang
to 3.2Mpps. Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 4682fcc..f0639d7 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c

[RFC PATCH net-next 12/12] vhost_net: batch submitting XDP buffers to underlayer sockets

2018-05-21 Thread Jason Wang
. Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/tun.c | 36 +-- drivers/vhost/net.c | 71 - 2 files changed, 71 insertions(+), 36 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index b

[RFC PATCH net-next 10/12] vhost_net: build xdp buff

2018-05-21 Thread Jason Wang
headroom based on the TUN XDP. Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c | 74 + 1 file changed, 74 insertions(+) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index f0639d7..1209e84 100644 --- a/d

[RFC PATCH net-next 00/12] XDP batching for TUN/vhost_net

2018-05-21 Thread Jason Wang
doing xdp_redirect_map between TAP and ixgbe. Thanks Jason Wang (12): vhost_net: introduce helper to initialize tx iov iter vhost_net: introduce vhost_exceeds_weight() vhost_net: introduce vhost_has_more_pkts() vhost_net: split out datacopy logic vhost_net: batch update used ring

[RFC PATCH net-next 02/12] vhost_net: introduce vhost_exceeds_weight()

2018-05-21 Thread Jason Wang
Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c | 13 - 1 file changed, 8 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 +

[PATCH net 1/4] virtio-net: correctly redirect linearized packet

2018-05-21 Thread Jason Wang
) Reported-by: David Ahern <dsah...@gmail.com> Tested-by: David Ahern <dsah...@gmail.com> Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_

[PATCH net 3/4] virtio-net: reset num_buf to 1 after linearizing packet

2018-05-21 Thread Jason Wang
successfully linearize the packet. Fixes: 4941d472bf95 ("virtio-net: do not reset during XDP set") Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/virtio_net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net

[PATCH net 4/4] virito-net: fix leaking page for gso packet during mergeable XDP

2018-05-21 Thread Jason Wang
us buffers") Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/virtio_net.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 165a922..f8db809 100644 --- a/drivers/net/virtio_n

[PATCH net 2/4] virtio-net: correctly transmit XDP buff after linearizing

2018-05-21 Thread Jason Wang
("virtio_net: xdp, add slowpath case for non contiguous buffers") Cc: John Fastabend <john.fastab...@gmail.com> Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/dr

[PATCH net 0/4] Fix several issues of virtio-net mergeable XDP

2018-05-21 Thread Jason Wang
Hi: Please review the patches that tries to fix sevreal issues of virtio-net mergeable XDP. Thanks Jason Wang (4): virtio-net: correctly redirect linearized packet virtio-net: correctly transmit XDP buff after linearizing virtio-net: reset num_buf to 1 after linearizing packet virito

Re: KASAN: use-after-free Read in vhost_chr_write_iter

2018-05-20 Thread Jason Wang
On 2018年05月18日 17:24, Jason Wang wrote: On 2018年05月17日 21:45, DaeRyong Jeong wrote: We report the crash: KASAN: use-after-free Read in vhost_chr_write_iter This crash has been found in v4.17-rc1 using RaceFuzzer (a modified version of Syzkaller), which we describe more at the end

Re: [RFC V4 PATCH 0/8] Packed ring layout for vhost

2018-05-20 Thread Jason Wang
On 2018年05月21日 00:25, Wei Xu wrote: On Wed, May 16, 2018 at 08:32:13PM +0800, Jason Wang wrote: Hi all: This RFC implement packed ring layout. The code were tested with Tiwei's RFC V3 ahttps://lkml.org/lkml/2018/4/25/34. Some fixups and tweaks were needed on top of Tiwei's code to make

Re: [RFC v4 3/5] virtio_ring: add packed ring support

2018-05-20 Thread Jason Wang
On 2018年05月19日 10:29, Tiwei Bie wrote: I don't hope so. I agreed driver should track the DMA addrs or some other necessary things from the very beginning. And I also repeated the spec to emphasize that it does make sense. And I'd like to do that. What I was saying is that, to support OOO,

Re: [RFC v4 3/5] virtio_ring: add packed ring support

2018-05-18 Thread Jason Wang
On 2018年05月18日 22:33, Tiwei Bie wrote: On Fri, May 18, 2018 at 09:17:05PM +0800, Jason Wang wrote: On 2018年05月18日 19:29, Tiwei Bie wrote: On Thu, May 17, 2018 at 08:01:52PM +0800, Jason Wang wrote: On 2018年05月16日 22:33, Tiwei Bie wrote: On Wed, May 16, 2018 at 10:05:44PM +0800, Jason Wang

Re: [PATCH net] tuntap: raise EPOLLOUT on device up

2018-05-18 Thread Jason Wang
On 2018年05月18日 22:46, Michael S. Tsirkin wrote: On Fri, May 18, 2018 at 10:11:54PM +0800, Jason Wang wrote: On 2018年05月18日 22:06, Michael S. Tsirkin wrote: On Fri, May 18, 2018 at 10:00:31PM +0800, Jason Wang wrote: On 2018年05月18日 21:26, Jason Wang wrote: On 2018年05月18日 21:13, Michael S

Re: [PATCH net] tuntap: raise EPOLLOUT on device up

2018-05-18 Thread Jason Wang
On 2018年05月18日 22:06, Michael S. Tsirkin wrote: On Fri, May 18, 2018 at 10:00:31PM +0800, Jason Wang wrote: On 2018年05月18日 21:26, Jason Wang wrote: On 2018年05月18日 21:13, Michael S. Tsirkin wrote: On Fri, May 18, 2018 at 09:00:43PM +0800, Jason Wang wrote: We return -EIO on device down

Re: [PATCH net] tuntap: raise EPOLLOUT on device up

2018-05-18 Thread Jason Wang
On 2018年05月18日 21:26, Jason Wang wrote: On 2018年05月18日 21:13, Michael S. Tsirkin wrote: On Fri, May 18, 2018 at 09:00:43PM +0800, Jason Wang wrote: We return -EIO on device down but can not raise EPOLLOUT after it was up. This may confuse user like vhost which expects tuntap to raise

Re: [PATCH net] tuntap: raise EPOLLOUT on device up

2018-05-18 Thread Jason Wang
On 2018年05月18日 21:13, Michael S. Tsirkin wrote: On Fri, May 18, 2018 at 09:00:43PM +0800, Jason Wang wrote: We return -EIO on device down but can not raise EPOLLOUT after it was up. This may confuse user like vhost which expects tuntap to raise EPOLLOUT to re-enable its TX routine after

Re: [RFC v4 3/5] virtio_ring: add packed ring support

2018-05-18 Thread Jason Wang
On 2018年05月18日 19:29, Tiwei Bie wrote: On Thu, May 17, 2018 at 08:01:52PM +0800, Jason Wang wrote: On 2018年05月16日 22:33, Tiwei Bie wrote: On Wed, May 16, 2018 at 10:05:44PM +0800, Jason Wang wrote: On 2018年05月16日 21:45, Tiwei Bie wrote: On Wed, May 16, 2018 at 08:51:43PM +0800, Jason Wang

[PATCH net] tuntap: raise EPOLLOUT on device up

2018-05-18 Thread Jason Wang
. Fixing this by set SOCKWQ_ASYNC_NOSPACE on -EIO. Cc: Hannes Frederic Sowa <han...@stressinduktion.org> Cc: Eric Dumazet <eduma...@google.com> Fixes: 1bd4978a88ac2 ("tun: honor IFF_UP in tun_get_user()") Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/tun.c

Re: KASAN: use-after-free Read in vhost_chr_write_iter

2018-05-18 Thread Jason Wang
On 2018年05月17日 21:45, DaeRyong Jeong wrote: We report the crash: KASAN: use-after-free Read in vhost_chr_write_iter This crash has been found in v4.17-rc1 using RaceFuzzer (a modified version of Syzkaller), which we describe more at the end of this report. Our analysis shows that the race

Re: [RFC v4 3/5] virtio_ring: add packed ring support

2018-05-17 Thread Jason Wang
On 2018年05月16日 22:33, Tiwei Bie wrote: On Wed, May 16, 2018 at 10:05:44PM +0800, Jason Wang wrote: On 2018年05月16日 21:45, Tiwei Bie wrote: On Wed, May 16, 2018 at 08:51:43PM +0800, Jason Wang wrote: On 2018年05月16日 20:39, Tiwei Bie wrote: On Wed, May 16, 2018 at 07:50:16PM +0800, Jason Wang

Re: [RFC v4 3/5] virtio_ring: add packed ring support

2018-05-16 Thread Jason Wang
On 2018年05月16日 21:45, Tiwei Bie wrote: On Wed, May 16, 2018 at 08:51:43PM +0800, Jason Wang wrote: On 2018年05月16日 20:39, Tiwei Bie wrote: On Wed, May 16, 2018 at 07:50:16PM +0800, Jason Wang wrote: On 2018年05月16日 16:37, Tiwei Bie wrote: [...] struct vring_virtqueue { @@ -116,6 +117,9

Re: [RFC v4 4/5] virtio_ring: add event idx support in packed ring

2018-05-16 Thread Jason Wang
On 2018年05月16日 20:58, Tiwei Bie wrote: On Wed, May 16, 2018 at 08:17:21PM +0800, Jason Wang wrote: On 2018年05月16日 16:37, Tiwei Bie wrote: [...] @@ -1160,15 +1186,27 @@ static void virtqueue_disable_cb_packed(struct virtqueue *_vq) static unsigned virtqueue_enable_cb_prepare_packed

Re: [RFC v4 3/5] virtio_ring: add packed ring support

2018-05-16 Thread Jason Wang
On 2018年05月16日 20:39, Tiwei Bie wrote: On Wed, May 16, 2018 at 07:50:16PM +0800, Jason Wang wrote: On 2018年05月16日 16:37, Tiwei Bie wrote: [...] struct vring_virtqueue { @@ -116,6 +117,9 @@ struct vring_virtqueue { /* Last written value to driver->fl

[PATCH net] tuntap: fix use after free during release

2018-05-16 Thread Jason Wang
reference of the socket in __tun_detach(). Reported-by: Andrei Vagin <ava...@virtuozzo.com> Acked-by: Andrei Vagin <ava...@virtuozzo.com> Fixes: b196d88aba8a ("tun: fix use after free for ptr_ring") Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/tun

[RFC V4 PATCH 4/8] vhost_net: do not explicitly manipulate vhost_used_elem

2018-05-16 Thread Jason Wang
Two helpers of setting/getting used len were introduced to avoid explicitly manipulating vhost_used_elem in zerocopy code. This will be used to hide used_elem internals and simplify packed ring implementation. Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c

[RFC V4 PATCH 6/8] virtio: introduce packed ring defines

2018-05-16 Thread Jason Wang
Signed-off-by: Jason Wang <jasow...@redhat.com> --- include/uapi/linux/virtio_config.h | 9 + include/uapi/linux/virtio_ring.h | 13 + 2 files changed, 22 insertions(+) diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h index 3

[RFC V4 PATCH 8/8] vhost: event suppression for packed ring

2018-05-16 Thread Jason Wang
This patch introduces basic support for event suppression aka driver and device area. Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/vhost.c| 168 --- drivers/vhost/vhost.h| 10 ++- include/uapi/linux/virtio_

[RFC V4 PATCH 7/8] vhost: packed ring support

2018-05-16 Thread Jason Wang
Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c | 3 +- drivers/vhost/vhost.c | 539 ++ drivers/vhost/vhost.h | 8 +- 3 files changed, 513 insertions(+), 37 deletions(-) diff --git a/drivers/vhost/net.c b/drivers

[RFC V4 PATCH 5/8] vhost: vhost_put_user() can accept metadata type

2018-05-16 Thread Jason Wang
We assumes used ring update is the only user for vhost_put_user() in the past. This may not be the case for the incoming packed ring which may update the descriptor ring for used. So introduce a new type parameter. Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/vhost.

[RFC V4 PATCH 3/8] vhost: do not use vring_used_elem

2018-05-16 Thread Jason Wang
Instead of depending on the exported vring_used_elem, this patch switches to use a new internal structure vhost_used_elem which embed vring_used_elem in itself. This could be used to let vhost to record extra metadata for the incoming packed ring layout. Signed-off-by: Jason Wang <ja

[RFC V4 PATCH 2/8] vhost: hide used ring layout from device

2018-05-16 Thread Jason Wang
by - letting vhost_get_vq_desc() return pointer to struct vring_used_elem - accepting pointer to struct vring_used_elem in vhost_add_used() and vhost_add_used_and_signal() This could help to hide used ring layout and make it easier to implement packed ring on top. Signed-off-by: Jason Wang <ja

[RFC V4 PATCH 0/8] Packed ring layout for vhost

2018-05-16 Thread Jason Wang
pile test only). - Fix several bugs Jason Wang (8): vhost: move get_rx_bufs to vhost.c vhost: hide used ring layout from device vhost: do not use vring_used_elem vhost_net: do not explicitly manipulate vhost_used_elem vhost: vhost_put_user() can accept metadata type virtio: introduce pa

[RFC V4 PATCH 1/8] vhost: move get_rx_bufs to vhost.c

2018-05-16 Thread Jason Wang
Move get_rx_bufs() to vhost.c and rename it to vhost_get_bufs(). This helps to hide vring internal layout from specific device implementation. Packed ring implementation will benefit from this. Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c

Re: [RFC v4 4/5] virtio_ring: add event idx support in packed ring

2018-05-16 Thread Jason Wang
On 2018年05月16日 16:37, Tiwei Bie wrote: This commit introduces the event idx support in packed ring. Signed-off-by: Tiwei Bie --- drivers/virtio/virtio_ring.c | 75 +--- 1 file changed, 70 insertions(+), 5 deletions(-) diff --git

Re: [RFC v4 3/5] virtio_ring: add packed ring support

2018-05-16 Thread Jason Wang
On 2018年05月16日 16:37, Tiwei Bie wrote: This commit introduces the basic support (without EVENT_IDX) for packed ring. Signed-off-by: Tiwei Bie --- drivers/virtio/virtio_ring.c | 491 ++- 1 file changed, 481 insertions(+), 10 deletions(-)

Re: [RFC v3 4/5] virtio_ring: add event idx support in packed ring

2018-05-15 Thread Jason Wang
On 2018年04月25日 13:15, Tiwei Bie wrote: This commit introduces the event idx support in packed ring. This feature is temporarily disabled, because the implementation in this patch may not work as expected, and some further discussions on the implementation are needed, e.g. do we have to check

Re: [PATCH net V2] tun: fix use after free for ptr_ring

2018-05-13 Thread Jason Wang
On 2018年05月12日 01:39, Cong Wang wrote: On Thu, May 10, 2018 at 7:49 PM, Jason Wang <jasow...@redhat.com> wrote: static void __tun_detach(struct tun_file *tfile, bool clean) { struct tun_file *ntfile; @@ -736,7 +727,8 @@ static void __tun_detach(struct tun_file *tfile, bool

[PATCH net V2] tun: fix use after free for ptr_ring

2018-05-10 Thread Jason Wang
;). Reported-by: syzbot+e8b902c3c3fadf0a9...@syzkaller.appspotmail.com Cc: Eric Dumazet <eric.duma...@gmail.com> Cc: Cong Wang <xiyou.wangc...@gmail.com> Cc: Michael S. Tsirkin <m...@redhat.com> Fixes: 1576d9860599 ("tun: switch to use skb array for tx") Signed-off-by: Jason Wa

Re: [PATCH net] tun: fix use after free for ptr_ring

2018-05-10 Thread Jason Wang
On 2018年05月11日 02:08, Cong Wang wrote: On Tue, May 8, 2018 at 11:59 PM, Jason Wang <jasow...@redhat.com> wrote: We used to initialize ptr_ring during TUNSETIFF, this is because its size depends on the tx_queue_len of netdevice. And we try to clean it up when socket were detache

Re: [RFC v3 3/5] virtio_ring: add packed ring support

2018-05-10 Thread Jason Wang
On 2018年05月10日 16:56, Tiwei Bie wrote: On Thu, May 10, 2018 at 03:34:50PM +0800, Jason Wang wrote: On 2018年05月10日 15:32, Jason Wang wrote: On 2018年04月25日 13:15, Tiwei Bie wrote: +    /* We're using some buffers from the free list. */ +    vq->vq.num_free -= descs_used; + +    /* Update f

Re: [RFC v3 3/5] virtio_ring: add packed ring support

2018-05-10 Thread Jason Wang
On 2018年05月10日 15:32, Jason Wang wrote: On 2018年04月25日 13:15, Tiwei Bie wrote: +    /* We're using some buffers from the free list. */ +    vq->vq.num_free -= descs_used; + +    /* Update free pointer */ +    if (indirect) { +    n = head + 1; +    if (n >= vq->vring_p

Re: [RFC v3 3/5] virtio_ring: add packed ring support

2018-05-10 Thread Jason Wang
On 2018年04月25日 13:15, Tiwei Bie wrote: + /* We're using some buffers from the free list. */ + vq->vq.num_free -= descs_used; + + /* Update free pointer */ + if (indirect) { + n = head + 1; + if (n >= vq->vring_packed.num) { +

[PATCH net] tun: fix use after free for ptr_ring

2018-05-09 Thread Jason Wang
;). Reported-by: syzbot+e8b902c3c3fadf0a9...@syzkaller.appspotmail.com Cc: Eric Dumazet <eric.duma...@gmail.com> Cc: Cong Wang <xiyou.wangc...@gmail.com> Cc: Michael S. Tsirkin <m...@redhat.com> Fixes: 1576d9860599 ("tun: switch to use skb array for tx") Signed-off-by: Jason Wa

Re: [RFC v3 4/5] virtio_ring: add event idx support in packed ring

2018-05-08 Thread Jason Wang
On 2018年05月08日 17:44, Tiwei Bie wrote: On Tue, May 08, 2018 at 05:34:40PM +0800, Jason Wang wrote: On 2018年05月08日 17:16, Tiwei Bie wrote: On Tue, May 08, 2018 at 03:16:53PM +0800, Jason Wang wrote: On 2018年05月08日 14:44, Tiwei Bie wrote: On Tue, May 08, 2018 at 01:40:40PM +0800, Jason Wang

Re: BUG: spinlock bad magic in tun_do_read

2018-05-08 Thread Jason Wang
On 2018年05月09日 10:50, Cong Wang wrote: On Mon, May 7, 2018 at 11:04 PM, Eric Dumazet wrote: On 05/07/2018 10:54 PM, Cong Wang wrote: Yeah, we should return early before hitting this uninitialized ptr ring... Something like: diff --git a/drivers/net/tun.c

  1   2   3   4   5   6   7   8   9   10   >