[PATCH net-next V2] tuntap: fix possible deadlock when fail to register netdev

2017-12-07 Thread Jason Wang
) Reported-by: Eric Dumazet <eric.duma...@gmail.com> Cc: Eric Dumazet <eric.duma...@gmail.com> Cc: Willem de Bruijn <will...@google.com> Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/tun.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git

Re: Linux 4.14 - regression: broken tun/tap / bridge network with virtio - bisected

2017-12-08 Thread Jason Wang
On 2017年12月08日 21:13, Andreas Hartmann wrote: On 12/08/2017 at 01:58 PM Michal Kubecek wrote: On Fri, Dec 08, 2017 at 01:45:38PM +0100, Andreas Hartmann wrote: On 12/08/2017 at 12:40 PM Michal Kubecek wrote: On Fri, Dec 08, 2017 at 11:31:50AM +0100, Andreas Hartmann wrote: When will there

[PATCH net-next V3] tun: add eBPF based queue selection method

2017-12-04 Thread Jason Wang
This patch introduces an eBPF based queue selection method. With this, the policy could be offloaded to userspace completely through a new ioctl TUNSETSTEERINGEBPF. Signed-off-by: Jason Wang <jasow...@redhat.com> --- Changes from V2: - call rtnl during netdev free - switch to use ca

Re: [PATCH 1/3] vhost: fix skb leak in handle_rx()

2017-12-03 Thread Jason Wang
On 2017年12月01日 22:37, Michael S. Tsirkin wrote: On Fri, Dec 01, 2017 at 03:11:05PM +0800, Jason Wang wrote: On 2017年12月01日 13:54, w...@redhat.com wrote: From: Wei Xu <w...@redhat.com> Matthew found a roughly 40% tcp throughput regression with commit c67df11f(vhost_net: try batch d

Re: [PATCH net-next] virtio_net: Disable interrupts if napi_complete_done rescheduled napi

2017-12-06 Thread Jason Wang
the regression I saw was tested with event idx on. And virtqueue_disable_cb() does almost nothing for event idx (or even a little bit slower). The patch looks good. Acked-by: Jason Wang <jasow...@redhat.com> --- drivers/net/virtio_net.c | 9 ++--- 1 file changed, 6 insertions(+)

Re: [PATCH] ptr_ring: add barriers

2017-12-05 Thread Jason Wang
On 2017年12月06日 10:53, Michael S. Tsirkin wrote: On Wed, Dec 06, 2017 at 10:31:39AM +0800, Jason Wang wrote: On 2017年12月06日 03:29, Michael S. Tsirkin wrote: Users of ptr_ring expect that it's safe to give the data structure a pointer and have it be available to consumers, but that actually

Re: [PATCH] ptr_ring: add barriers

2017-12-05 Thread Jason Wang
. Reported-by: George Cherian <george.cher...@cavium.com> Suggested-by: Jason Wang <jasow...@redhat.com> Signed-off-by: Michael S. Tsirkin <m...@redhat.com> --- George, could you pls report whether this patch fixes the issue for you? This seems to be needed in stable as well.

Re: [PATCH net-next V3] tun: add eBPF based queue selection method

2017-12-05 Thread Jason Wang
On 2017年12月06日 01:02, David Miller wrote: From: Jason Wang <jasow...@redhat.com> Date: Mon, 4 Dec 2017 17:31:23 +0800 This patch introduces an eBPF based queue selection method. With this, the policy could be offloaded to userspace completely through a new ioctl TUNSETSTEERINGEBPF.

Re: [PATCH net-next] tun: avoid unnecessary READ_ONCE in tun_net_xmit

2017-12-05 Thread Jason Wang
tfile = rcu_dereference(tun->tfiles[txq]); - numqueues = READ_ONCE(tun->numqueues); /* Drop packet if interface is not attached */ - if (txq >= numqueues) + if (txq >= tun->numqueues) goto drop; if (!rcu_dereference(tun-

Re: [PATCH v2] tap: double-free in error path in tap_open()

2017-10-25 Thread Jason Wang
goto err_put; + } dev_put(tap->dev); rtnl_unlock(); return err; -err_queue: - skb_array_cleanup(>skb_array); -err_array: +err_put: sock_put(>sk); err: if (tap) Acked-by: Jason Wang <jasow...@redhat.com> This patch is needed for -stable. Thanks

Re: v4.14-rc3/arm64 DABT exception in atomic_inc() / __skb_clone()

2017-10-25 Thread Jason Wang
On 2017年10月26日 03:01, Eric Dumazet wrote: On Wed, Oct 25, 2017 at 11:49 AM, Willem de Bruijn wrote: From skb->dev and netdev_priv, the tun device has flags 0x1002 == IFF_TAP | IFF_NO_PI. This kernel precedes the recent support for IFF_NAPI and

Re: [PATCH] tap: double-free in error path in tap_open()

2017-10-24 Thread Jason Wang
On 2017年10月25日 05:41, Girish Moodalbail wrote: Double free of skb_array in tap module is causing kernel panic. When tap_set_queue() fails we free skb_array right away by calling skb_array_cleanup(). However, later on skb_array_cleanup() is called again by tap_sock_destruct through sock_put().

Re: Regression in throughput between kvm guests over virtual bridge

2017-10-31 Thread Jason Wang
On 2017年10月31日 15:07, Wei Xu wrote: BTW, did you see any improvement when running pktgen from the host if no regression was found? Since this can be reproduced with only 1 vcpu for guest, may you try this bind? This might help simplify the problem. vcpu0 -> cpu2 vhost -> cpu3 pktgen

[PATCH net-next] vhost_net: conditionally enable tx polling

2017-10-31 Thread Jason Wang
ew Rosato <mjros...@linux.vnet.ibm.com> Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/vhost/net.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 68677d9..286c3e4 100644 --- a/drivers/vhost/net

[PATCH net-next V2 3/3] tun: add eBPF based queue selection method

2017-10-31 Thread Jason Wang
This patch introduces an eBPF based queue selection method based on the flow steering policy ops. Userspace could load an eBPF program through TUNSETSTEERINGEBPF. This gives much more flexibility compare to simple but hard coded policy in kernel. Signed-off-by: Jason Wang <jasow...@redhat.

[PATCH net-next V2 2/3] tun: introduce ioctls to set and get steering policies

2017-10-31 Thread Jason Wang
This patch introduces new ioctl for change packet steering policy for tun. Only automatic flow steering is supported, more policies will come. Signed-off-by: Jason Wang <jasow...@redhat.com> --- drivers/net/tun.c | 35 ++- include/uapi/linux/if

[PATCH net-next V2 1/3] tun: abstract flow steering logic

2017-10-31 Thread Jason Wang
-by: Jason Wang <jasow...@redhat.com> --- drivers/net/tun.c | 85 +-- 1 file changed, 63 insertions(+), 22 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index ea29da9..bff6259 100644 --- a/drivers/net/tun.c +++ b/drivers/net

[PATCH net-next V2 0/3] support changing steering policies in tuntap

2017-10-31 Thread Jason Wang
processor id example, implement an eBPF based queue selection policy instead Jason Wang (3): tun: abstract flow steering logic tun: introduce ioctls to set and get steering policies tun: add eBPF based queue selection method drivers/net/tun.c | 197

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

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

2018-05-07 Thread Jason Wang
On 2018年05月08日 11:05, Jason Wang wrote: Because in virtqueue_enable_cb_delayed(), we may set an event_off which is bigger than new and both of them have wrapped. And in this case, although new is smaller than event_off (i.e. the third param -- old), new shouldn't add vq->num, and actually

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

2018-05-07 Thread Jason Wang
On 2018年05月03日 21:54, Tiwei Bie wrote: On Thu, May 03, 2018 at 03:25:29PM +0800, Jason Wang wrote: On 2018年05月03日 10:09, Tiwei Bie wrote: So how about we use the straightforward way then? You mean we do new += vq->vring_packed.num instead of event_idx -= vq->vring_packed.num before c

Re: [PATCH net-next] tun: Do SIOCGSKNS out of rtnl_lock()

2018-05-09 Thread Jason Wang
On 2018年05月09日 00:21, Kirill Tkhai wrote: Since net ns of tun device is assigned on the device creation, and it never changes, we do not need to use any lock to get it from alive tun. Signed-off-by: Kirill Tkhai --- drivers/net/tun.c | 18 +++--- 1 file

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

[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日 14:44, Tiwei Bie wrote: On Tue, May 08, 2018 at 01:40:40PM +0800, Jason Wang wrote: On 2018年05月08日 11:05, Jason Wang wrote: Because in virtqueue_enable_cb_delayed(), we may set an event_off which is bigger than new and both of them have wrapped. And in this case, although new

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: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 wrote: On 2018年05月08日 11:05, Jason Wang wrote: Because in virtqueue_enable_cb_delayed(), we may set

Re: [PATCH net-next] tun: Do SIOCGSKNS out of rtnl_lock()

2018-05-09 Thread Jason Wang
On 2018年05月09日 17:00, Kirill Tkhai wrote: Hi, Jason, On 09.05.2018 10:18, Jason Wang wrote: On 2018年05月09日 00:21, Kirill Tkhai wrote: Since net ns of tun device is assigned on the device creation, and it never changes, we do not need to use any lock to get it from alive tun. Signed-off

Re: [PATCH net] vhost: Use kzalloc() to allocate vhost_msg_node

2018-04-27 Thread Jason Wang
On 2018年04月28日 09:51, Kevin Easton wrote: On Fri, Apr 27, 2018 at 09:07:56PM -0400, Kevin Easton wrote: On Fri, Apr 27, 2018 at 07:05:45PM +0300, Michael S. Tsirkin wrote: On Fri, Apr 27, 2018 at 11:45:02AM -0400, Kevin Easton wrote: The struct vhost_msg within struct vhost_msg_node is

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

2018-04-27 Thread Jason Wang
On 2018年04月27日 17:12, Tiwei Bie wrote: On Fri, Apr 27, 2018 at 02:17:51PM +0800, Jason Wang wrote: On 2018年04月27日 12:18, Michael S. Tsirkin wrote: On Fri, Apr 27, 2018 at 11:56:05AM +0800, Jason Wang wrote: On 2018年04月25日 13:15, Tiwei Bie wrote: Hello everyone, This RFC implements packed

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

2018-04-27 Thread Jason Wang
On 2018年04月27日 12:18, Michael S. Tsirkin wrote: On Fri, Apr 27, 2018 at 11:56:05AM +0800, Jason Wang wrote: On 2018年04月25日 13:15, 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

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年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) { +

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: [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: xdp and fragments with virtio

2018-05-17 Thread Jason Wang
On 2018年05月17日 10:55, David Ahern wrote: On 5/16/18 1:24 AM, Jason Wang wrote: On 2018年05月16日 11:51, David Ahern wrote: Hi Jason: I am trying to test MTU changes to the BPF fib_lookup helper and seeing something odd. Hoping you can help. I have a VM with multiple virtio based NICs and tap

Re: linux-next: BUG: KASAN: use-after-free in tun_chr_close

2018-05-16 Thread Jason Wang
tun_detach(). Could you help to test the attached patch? Thanks >From 4b5ad75208e379dcb32abb9ac4790a0446f8558b Mon Sep 17 00:00:00 2001 From: Jason Wang <jasow...@redhat.com> Date: Wed, 16 May 2018 15:26:52 +0800 Subject: [PATCH] tuntap: fix use after free during release After commit b196

Re: xdp and fragments with virtio

2018-05-16 Thread Jason Wang
On 2018年05月16日 11:51, David Ahern wrote: Hi Jason: I am trying to test MTU changes to the BPF fib_lookup helper and seeing something odd. Hoping you can help. I have a VM with multiple virtio based NICs and tap backends. I install the xdp program on eth1 and eth2 to do forwarding. In the

Re: linux-next: BUG: KASAN: use-after-free in tun_chr_close

2018-05-16 Thread Jason Wang
On 2018年05月16日 15:40, Andrei Vagin wrote: On Wed, May 16, 2018 at 03:32:59PM +0800, Jason Wang wrote: On 2018年05月16日 15:12, Andrei Vagin wrote: Hi Jason, I think the problem is in "tun: hold a tun socket during ptr_ring_cleanup". Pls take a look at the attached patch. Yes. It l

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

[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 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 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 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

[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 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

[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

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

[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 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 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 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 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

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

[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 +

[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 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 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 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 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 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 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 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 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 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 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 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(

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 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 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

[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: [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(-)

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: 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

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

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

[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 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 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 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] 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: [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: [PATCH net] tun: Fix NULL pointer dereference in XDP redirect

2018-05-25 Thread Jason Wang
On 2018年05月25日 12:32, Toshiaki Makita wrote: Calling XDP redirection requires preempt/bh disabled. Especially softirq can call another XDP function and redirection functions, then percpu value ri->map can be overwritten to NULL. This is a generic XDP case called from tun. [ 3535.736058] BUG:

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 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: [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: [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

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: [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

[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: [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: [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: [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: [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

<    2   3   4   5   6   7   8   9   10   11   >