Re: [PATCH V2 5/6] vhost_net: poll vhost queue after marking DMA is done

2014-02-12 Thread Jason Wang
On 02/12/2014 03:38 PM, Qin Chuanyu wrote: On 2013/8/30 12:29, Jason Wang wrote: We used to poll vhost queue before making DMA is done, this is racy if vhost thread were waked up before marking DMA is done which can result the signal to be missed. Fix this by always poll the vhost thread

Re: [PATCH net] vhost_net: do not report a used len larger than receive buffer size

2014-02-12 Thread Michael S. Tsirkin
On Wed, Feb 12, 2014 at 01:57:46PM +0800, Jason Wang wrote: Currently, even if the packet were truncated by lower socket, we still report the packet size as the used len which may confuse guest driver. Fixes this by returning the size of guest receive buffer instead. Fixes

Re: [PATCH net] virtio-net: alloc big buffers also when guest can receive UFO

2014-02-12 Thread Michael S. Tsirkin
On Wed, Feb 12, 2014 at 01:43:28PM +0800, Jason Wang wrote: We should alloc big buffers also when guest can receive UFO pakcets. Otherwise the big packets will be truncated when mergeable rx buffer is disabled. Not truncated, they will be dropped. Fixes

Re: [PATCH V2 5/6] vhost_net: poll vhost queue after marking DMA is done

2014-02-12 Thread Michael S. Tsirkin
On Wed, Feb 12, 2014 at 03:38:18PM +0800, Qin Chuanyu wrote: another question is that vhost_zerocopy_callback is called by kfree_skb, it may called in different thread context. vhost_poll_queue is called decided by ubufs-kref.refcount, this may cause there isn't any thread call

[PATCH net 3/3] vhost: fix a theoretical race in device cleanup

2014-02-12 Thread Michael S. Tsirkin
vhost_zerocopy_callback accesses VQ right after it drops the last ubuf reference. In theory, this could race with device removal which waits on the ubuf kref, and crash on use after free. Do all accesses within rcu read side critical section, and all synchronize on release. Since callbacks are

[PATCH net 0/3] vhost fixes for 3.14, -stable

2014-02-12 Thread Michael S. Tsirkin
This fixes a deadlock with vhost reported in the field, as well as a theoretical race issue found by code review. Patches 1+2 are needed for stable. Thanks to Qin Chuanyu for reporting the issue! Michael S. Tsirkin (3): kref: add kref_sub_return vhost: fix ref cnt checking deadlock vhost:

[PATCH net 2/3] vhost: fix ref cnt checking deadlock

2014-02-12 Thread Michael S. Tsirkin
vhost checked the counter within the refcnt before decrementing. It really wanted to know that there aren't too many references, as a way to batch freeing resources a bit more efficiently. This works well but it we now access the ref counter twice so there's a race: all users might see a high

[PATCH net 1/3] kref: add kref_sub_return

2014-02-12 Thread Michael S. Tsirkin
It is sometimes useful to get the value of the reference count after decrement. For example, vhost wants to execute some periodic cleanup operations once number of references drops below a specific value, before it reaches zero (for efficiency). Add an API to do this atomically and efficiently

Re: [PATCH V2 5/6] vhost_net: poll vhost queue after marking DMA is done

2014-02-12 Thread Qin Chuanyu
On 2013/8/30 12:29, Jason Wang wrote: We used to poll vhost queue before making DMA is done, this is racy if vhost thread were waked up before marking DMA is done which can result the signal to be missed. Fix this by always poll the vhost thread before DMA is done. Signed-off-by: Jason Wang

Re: [PATCH net 1/3] kref: add kref_sub_return

2014-02-12 Thread Greg Kroah-Hartman
On Wed, Feb 12, 2014 at 06:38:21PM +0200, Michael S. Tsirkin wrote: It is sometimes useful to get the value of the reference count after decrement. For example, vhost wants to execute some periodic cleanup operations once number of references drops below a specific value, before it reaches

Re: [PATCH net 1/3] kref: add kref_sub_return

2014-02-12 Thread Michael S. Tsirkin
On Wed, Feb 12, 2014 at 08:56:30AM -0800, Greg Kroah-Hartman wrote: On Wed, Feb 12, 2014 at 06:38:21PM +0200, Michael S. Tsirkin wrote: It is sometimes useful to get the value of the reference count after decrement. For example, vhost wants to execute some periodic cleanup operations once

Re: [PATCH net 1/3] kref: add kref_sub_return

2014-02-12 Thread Greg Kroah-Hartman
On Wed, Feb 12, 2014 at 07:35:24PM +0200, Michael S. Tsirkin wrote: On Wed, Feb 12, 2014 at 08:56:30AM -0800, Greg Kroah-Hartman wrote: On Wed, Feb 12, 2014 at 06:38:21PM +0200, Michael S. Tsirkin wrote: It is sometimes useful to get the value of the reference count after decrement.

Re: [PATCH net 1/3] kref: add kref_sub_return

2014-02-12 Thread Anatol Pomozov
Hi On Wed, Feb 12, 2014 at 9:35 AM, Michael S. Tsirkin m...@redhat.com wrote: On Wed, Feb 12, 2014 at 08:56:30AM -0800, Greg Kroah-Hartman wrote: On Wed, Feb 12, 2014 at 06:38:21PM +0200, Michael S. Tsirkin wrote: It is sometimes useful to get the value of the reference count after

Re: [PATCH net 1/3] kref: add kref_sub_return

2014-02-12 Thread Jörn Engel
On Wed, 12 February 2014 19:06:37 -0500, David Miller wrote: It isn't being used to determine when to destroy things. They use it to as a heuristic of when to trigger polling. Each ubuf attached gets a kref to the higher level virtio_net buffer holding object, they want to trigger

Re: [PATCH net 1/3] kref: add kref_sub_return

2014-02-12 Thread Greg KH
On Wed, Feb 12, 2014 at 07:06:37PM -0500, David Miller wrote: From: Greg Kroah-Hartman gre...@linuxfoundation.org Date: Wed, 12 Feb 2014 08:56:30 -0800 On Wed, Feb 12, 2014 at 06:38:21PM +0200, Michael S. Tsirkin wrote: It is sometimes useful to get the value of the reference count after

Re: [PATCH net] virtio-net: alloc big buffers also when guest can receive UFO

2014-02-12 Thread Jason Wang
On 02/12/2014 07:59 PM, Michael S. Tsirkin wrote: On Wed, Feb 12, 2014 at 01:43:28PM +0800, Jason Wang wrote: We should alloc big buffers also when guest can receive UFO pakcets. Otherwise the big packets will be truncated when mergeable rx buffer is disabled. Not truncated, they will be

Re: [PATCH net 1/3] kref: add kref_sub_return

2014-02-12 Thread David Miller
From: Greg KH gre...@linuxfoundation.org Date: Wed, 12 Feb 2014 17:39:02 -0800 Yes, that's horrible as well, but as was already pointed out in this thread, you can't rely on that value to really be 1 after reading it due to the way krefs work, what happened if someone else just grabbed it?

Re: [PATCH net 1/3] kref: add kref_sub_return

2014-02-12 Thread David Miller
From: David Miller da...@davemloft.net Date: Wed, 12 Feb 2014 23:05:06 -0500 (EST) From: Greg KH gre...@linuxfoundation.org Date: Wed, 12 Feb 2014 17:39:02 -0800 Yes, that's horrible as well, but as was already pointed out in this thread, you can't rely on that value to really be 1 after

Re: [PATCH 0/3] tools/virtio: build fixes for virtio_test

2014-02-12 Thread Rusty Russell
Michael S. Tsirkin m...@redhat.com writes: On Tue, Feb 11, 2014 at 04:58:17PM +1030, Joel Stanley wrote: Recent changes to drivers/virtio broke compilation for the tests in tools/virtio. The following patches are build fixes for those changes, as well as a fix for a typo that would have

Re: [PATCH 0/3] tools/virtio: build fixes for virtio_test

2014-02-12 Thread Rusty Russell
Michael S. Tsirkin m...@redhat.com writes: On Tue, Feb 11, 2014 at 04:58:17PM +1030, Joel Stanley wrote: Recent changes to drivers/virtio broke compilation for the tests in tools/virtio. The following patches are build fixes for those changes, as well as a fix for a typo that would have

Re: [PATCH net] virtio-net: alloc big buffers also when guest can receive UFO

2014-02-12 Thread Michael S. Tsirkin
On Thu, Feb 13, 2014 at 11:02:13AM +0800, Jason Wang wrote: On 02/12/2014 07:59 PM, Michael S. Tsirkin wrote: On Wed, Feb 12, 2014 at 01:43:28PM +0800, Jason Wang wrote: We should alloc big buffers also when guest can receive UFO pakcets. Otherwise the big packets will be truncated when