Re: [PATCH net-next RFC 3/3] virtio-net: conditionally enable tx interrupt

2014-10-13 Thread Jason Wang
On 10/11/2014 10:48 PM, Eric Dumazet wrote: On Sat, 2014-10-11 at 15:16 +0800, Jason Wang wrote: We free transmitted packets in ndo_start_xmit() in the past to get better performance in the past. One side effect is that skb_orphan() needs to be called in ndo_start_xmit() which makes

Re: [PATCH net-next RFC 1/3] virtio: support for urgent descriptors

2014-10-13 Thread Jason Wang
On 10/12/2014 05:27 PM, Michael S. Tsirkin wrote: On Sat, Oct 11, 2014 at 03:16:44PM +0800, Jason Wang wrote: Below should be useful for some experiments Jason is doing. I thought I'd send it out for early review/feedback. event idx feature allows us to defer interrupts until a specific # of

Re: [PATCH RFC 08/11] virtio_blk: use virtio v1.0 endian

2014-10-13 Thread Rusty Russell
Cornelia Huck cornelia.h...@de.ibm.com writes: Note that we care only about the fields still in use for virtio v1.0. Reviewed-by: Thomas Huth th...@linux.vnet.ibm.com Reviewed-by: David Hildenbrand d...@linux.vnet.ibm.com Signed-off-by: Cornelia Huck cornelia.h...@de.ibm.com Hi Cornelia,

Re: [PATCH RFC 03/11] virtio: support more feature bits

2014-10-13 Thread Rusty Russell
Cornelia Huck cornelia.h...@de.ibm.com writes: With virtio-1, we support more than 32 feature bits. Let's make vdev-guest_features depend on the number of supported feature bits, allowing us to grow the feature bits automatically. It's a judgement call, but I would say that simply using

Re: [PATCH 2/2] virtio_balloon: free some memory from baloon on OOM

2014-10-13 Thread Rusty Russell
Denis V. Lunev d...@parallels.com writes: From: Raushaniya Maksudova rmaksud...@parallels.com Excessive virtio_balloon inflation can cause invocation of OOM-killer, when Linux is under severe memory pressure. Various mechanisms are responsible for correct virtio_balloon memory management.

Re: BUG_ON in virtio-ring.c

2014-10-13 Thread Rusty Russell
Alexey Lapitsky lex.pub...@gmail.com writes: Hi, I'm hitting this bug with both ext4 and btrfs. Here's an example of the backtrace: https://gist.github.com/vzctl/e888a821333979120932 I tried raising this BUG only for direct ring and it solved the problem: - BUG_ON(total_sg

Re: [PATCH v3 10/25] virtio: add API to enable VQs early

2014-10-13 Thread Rusty Russell
Michael S. Tsirkin m...@redhat.com writes: virtio spec 0.9.X requires DRIVER_OK to be set before VQs are used, but some drivers use VQs before probe function returns. Since DRIVER_OK is set after probe, this violates the spec. Even though under virtio 1.0 transitional devices support this

Re: [PATCH net-next RFC 1/3] virtio: support for urgent descriptors

2014-10-13 Thread Michael S. Tsirkin
On Mon, Oct 13, 2014 at 02:22:12PM +0800, Jason Wang wrote: On 10/12/2014 05:27 PM, Michael S. Tsirkin wrote: On Sat, Oct 11, 2014 at 03:16:44PM +0800, Jason Wang wrote: Below should be useful for some experiments Jason is doing. I thought I'd send it out for early review/feedback.

Re: [PATCH 2/2] virtio_balloon: free some memory from baloon on OOM

2014-10-13 Thread Michael S. Tsirkin
On Mon, Oct 13, 2014 at 04:02:52PM +1030, Rusty Russell wrote: Denis V. Lunev d...@parallels.com writes: From: Raushaniya Maksudova rmaksud...@parallels.com Excessive virtio_balloon inflation can cause invocation of OOM-killer, when Linux is under severe memory pressure. Various

Re: [PATCH v3 10/25] virtio: add API to enable VQs early

2014-10-13 Thread Michael S. Tsirkin
On Mon, Oct 13, 2014 at 05:22:39PM +1030, Rusty Russell wrote: Michael S. Tsirkin m...@redhat.com writes: virtio spec 0.9.X requires DRIVER_OK to be set before VQs are used, but some drivers use VQs before probe function returns. Since DRIVER_OK is set after probe, this violates the spec.

[PATCH v4 00/25] virtio: fix spec compliance issues

2014-10-13 Thread Michael S. Tsirkin
Changes from v4: rename virtio_enable_vqs_early() to virtio_device_ready() Note: Rusty requested we add a BUG_ON in the virtio_ring code. This can be done by a separate patch on top. Good for bisectability in case BUG_ON starts triggering :) Rusty, please review this, and

[PATCH v4 01/25] virtio_pci: fix virtio spec compliance on restore

2014-10-13 Thread Michael S. Tsirkin
On restore, virtio pci does the following: + set features + init vqs etc - device can be used at this point! + set ACKNOWLEDGE,DRIVER and DRIVER_OK status bits This is in violation of the virtio spec, which requires the following order: - ACKNOWLEDGE - DRIVER - init vqs - DRIVER_OK This

[PATCH v4 02/25] virtio: unify config_changed handling

2014-10-13 Thread Michael S. Tsirkin
Replace duplicated code in all transports with a single wrapper in virtio.c. The only functional change is in virtio_mmio.c: if a buggy device sends us an interrupt before driver is set, we previously returned IRQ_NONE, now we return IRQ_HANDLED. As this must not happen in practice, this does

[PATCH v4 05/25] virtio_blk: drop config_enable

2014-10-13 Thread Michael S. Tsirkin
Now that virtio core ensures config changes don't arrive during probing, drop config_enable flag in virtio blk. On removal, flush is now sufficient to guarantee that no change work is queued. This help simplify the driver, and will allow setting DRIVER_OK earlier without losing config change

[PATCH v4 04/25] virtio: defer config changed notifications

2014-10-13 Thread Michael S. Tsirkin
Defer config changed notifications that arrive during probe/scan/freeze/restore. This will allow drivers to set DRIVER_OK earlier, without worrying about racing with config change interrupts. This change will also benefit old hypervisors (before 2009) that send interrupts without checking

[PATCH v4 06/25] virtio-blk: drop config_mutex

2014-10-13 Thread Michael S. Tsirkin
config_mutex served two purposes: prevent multiple concurrent config change handlers, and synchronize access to config_enable flag. Since commit dbf2576e37da0fcc7aacbfbb9fd5d3de7888a3c1 workqueue: make all workqueues non-reentrant all workqueues are non-reentrant, and config_enable is now

[PATCH v4 08/25] virtio-net: drop config_mutex

2014-10-13 Thread Michael S. Tsirkin
config_mutex served two purposes: prevent multiple concurrent config change handlers, and synchronize access to config_enable flag. Since commit dbf2576e37da0fcc7aacbfbb9fd5d3de7888a3c1 workqueue: make all workqueues non-reentrant all workqueues are non-reentrant, and config_enable is now

[PATCH v4 09/25] virtio_net: minor cleanup

2014-10-13 Thread Michael S. Tsirkin
goto done; done: return; is ugly, it was put there to make diff review easier. replace by open-coded return. Signed-off-by: Michael S. Tsirkin m...@redhat.com Acked-by: Cornelia Huck cornelia.h...@de.ibm.com --- drivers/net/virtio_net.c | 6 ++ 1 file changed, 2

[PATCH v4 07/25] virtio_net: drop config_enable

2014-10-13 Thread Michael S. Tsirkin
Now that virtio core ensures config changes don't arrive during probing, drop config_enable flag in virtio net. On removal, flush is now sufficient to guarantee that no change work is queued. This help simplify the driver, and will allow setting DRIVER_OK earlier without losing config change

[PATCH v4 12/25] virtio_blk: enable VQs early

2014-10-13 Thread Michael S. Tsirkin
virtio spec requires drivers to set DRIVER_OK before using VQs. This is set automatically after probe returns, virtio block violated this rule by calling add_disk, which causes the VQ to be used directly within probe. To fix, call virtio_device_ready before using VQs. Signed-off-by: Michael S.

[PATCH v4 11/25] virtio_net: enable VQs early

2014-10-13 Thread Michael S. Tsirkin
virtio spec requires drivers to set DRIVER_OK before using VQs. This is set automatically after probe returns, virtio net violated this rule by using receive VQs within probe. To fix, call virtio_device_ready before using VQs. Signed-off-by: Michael S. Tsirkin m...@redhat.com Reviewed-by:

[PATCH v4 13/25] virtio_console: enable VQs early

2014-10-13 Thread Michael S. Tsirkin
virtio spec requires drivers to set DRIVER_OK before using VQs. This is set automatically after probe returns, virtio console violated this rule by adding inbufs, which causes the VQ to be used directly within probe. To fix, call virtio_device_ready before using VQs. Signed-off-by: Michael S.

[PATCH v4 15/25] virtio_net: fix use after free on allocation failure

2014-10-13 Thread Michael S. Tsirkin
In the extremely unlikely event that driver initialization fails after RX buffers are added, virtio net frees RX buffers while VQs are still active, potentially causing device to use a freed buffer. To fix, reset device first - same as we do on device removal. Signed-off-by: Michael S. Tsirkin

[PATCH v4 14/25] 9p/trans_virtio: enable VQs early

2014-10-13 Thread Michael S. Tsirkin
virtio spec requires drivers to set DRIVER_OK before using VQs. This is set automatically after probe returns, but virtio 9p device adds self to channel list within probe, at which point VQ can be used in violation of the spec. To fix, call virtio_device_ready before using VQs. Signed-off-by:

[PATCH v4 17/25] virtio_blk: enable VQs early on restore

2014-10-13 Thread Michael S. Tsirkin
virtio spec requires drivers to set DRIVER_OK before using VQs. This is set automatically after restore returns, virtio block violated this rule on restore by restarting queues, which might in theory cause the VQ to be used directly within restore. To fix, call virtio_device_ready before using

[PATCH v4 18/25] virtio_scsi: enable VQs early on restore

2014-10-13 Thread Michael S. Tsirkin
virtio spec requires drivers to set DRIVER_OK before using VQs. This is set automatically after restore returns, virtio scsi violated this rule on restore by kicking event vq within restore. To fix, call virtio_device_ready before using event queue. Signed-off-by: Michael S. Tsirkin

[PATCH v4 16/25] virtio_scsi: move kick event out from virtscsi_init

2014-10-13 Thread Michael S. Tsirkin
We currently kick event within virtscsi_init, before host is fully initialized. This can in theory confuse guest if device consumes the buffers immediately. To fix, move virtscsi_kick_event_all out to scan/restore. Signed-off-by: Michael S. Tsirkin m...@redhat.com ---

[PATCH v4 20/25] virtio_net: enable VQs early on restore

2014-10-13 Thread Michael S. Tsirkin
virtio spec requires drivers to set DRIVER_OK before using VQs. This is set automatically after restore returns, virtio net violated this rule by using receive VQs within restore. To fix, call virtio_device_ready before using VQs. Signed-off-by: Michael S. Tsirkin m...@redhat.com Reviewed-by:

[PATCH v4 19/25] virtio_console: enable VQs early on restore

2014-10-13 Thread Michael S. Tsirkin
virtio spec requires drivers to set DRIVER_OK before using VQs. This is set automatically after resume returns, virtio console violated this rule by adding inbufs, which causes the VQ to be used directly within restore. To fix, call virtio_device_ready before using VQs. Signed-off-by: Michael S.

[PATCH v4 22/25] virtio_scsi: fix race on device removal

2014-10-13 Thread Michael S. Tsirkin
We cancel event work on device removal, but an interrupt could trigger immediately after this, and queue it again. To fix, set a flag. Loosely based on patch by Paolo Bonzini Signed-off-by: Paolo Bonzini pbonz...@redhat.com Signed-off-by: Michael S. Tsirkin m...@redhat.com ---

[PATCH v4 21/25] virito_scsi: use freezable WQ for events

2014-10-13 Thread Michael S. Tsirkin
From: Paolo Bonzini pbonz...@redhat.com Michael S. Tsirkin noticed a race condition: we reset device on freeze, but system WQ is still running so it might try adding bufs to a VQ meanwhile. To fix, switch to handling events from the freezable WQ. Reported-by: Michael S. Tsirkin m...@redhat.com

[PATCH v4 24/25] virtio_scsi: drop scan callback

2014-10-13 Thread Michael S. Tsirkin
Enable VQs early like we do for restore. This makes it possible to drop the scan callback, moving scanning into the probe function, and making code simpler. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/scsi/virtio_scsi.c | 23 +++ 1 file changed, 7

[PATCH v4 23/25] virtio_balloon: enable VQs early on restore

2014-10-13 Thread Michael S. Tsirkin
virtio spec requires drivers to set DRIVER_OK before using VQs. This is set automatically after resume returns, virtio balloon violated this rule by adding bufs, which causes the VQ to be used directly within restore. To fix, call virtio_device_ready before using VQ. Signed-off-by: Michael S.

[PATCH v4 25/25] virtio-rng: refactor probe error handling

2014-10-13 Thread Michael S. Tsirkin
Code like vi-vq = NULL; kfree(vi) does not make sense. Clean it up, use goto error labels for cleanup. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- drivers/char/hw_random/virtio-rng.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git

Re: [PATCH RFC 08/11] virtio_blk: use virtio v1.0 endian

2014-10-13 Thread Cornelia Huck
On Mon, 13 Oct 2014 16:28:32 +1030 Rusty Russell ru...@rustcorp.com.au wrote: Cornelia Huck cornelia.h...@de.ibm.com writes: Note that we care only about the fields still in use for virtio v1.0. Reviewed-by: Thomas Huth th...@linux.vnet.ibm.com Reviewed-by: David Hildenbrand

Re: [PATCH RFC 03/11] virtio: support more feature bits

2014-10-13 Thread Cornelia Huck
On Mon, 13 Oct 2014 16:23:58 +1030 Rusty Russell ru...@rustcorp.com.au wrote: Cornelia Huck cornelia.h...@de.ibm.com writes: With virtio-1, we support more than 32 feature bits. Let's make vdev-guest_features depend on the number of supported feature bits, allowing us to grow the feature

Re: [PATCH 2/2] virtio_balloon: free some memory from baloon on OOM

2014-10-13 Thread Denis V. Lunev
On 13/10/14 09:32, Rusty Russell wrote: Denis V. Lunev d...@parallels.com writes: From: Raushaniya Maksudova rmaksud...@parallels.com Excessive virtio_balloon inflation can cause invocation of OOM-killer, when Linux is under severe memory pressure. Various mechanisms are responsible for