Patchwork [PATCHv3,4/6] virtio-net: stop/start bh when appropriate

login
register
mail settings
Submitter Michael S. Tsirkin
Date Dec. 2, 2010, 6:27 p.m.
Message ID <20101202182722.GA7211@redhat.com>
Download mbox | patch
Permalink /patch/74010/
State New
Headers show

Comments

Michael S. Tsirkin - Dec. 2, 2010, 6:27 p.m.
On Thu, Dec 02, 2010 at 10:19:55PM +0800, Jason Wang wrote:
> Michael S. Tsirkin writes:
>  > On Thu, Dec 02, 2010 at 08:56:30PM +0800, Jason Wang wrote:
>  > > Michael S. Tsirkin writes:
>  > >  > On Wed, Dec 01, 2010 at 01:45:09PM +0800, Jason Wang wrote:
>  > >  > > Michael S. Tsirkin writes:
>  > >  > >  > Avoid sending out packets, and modifying
>  > >  > >  > device state, when VM is stopped.
>  > >  > >  > Add assert statements to verify this does not happen.
>  > >  > >  > 
>  > >  > >  > Avoid scheduling bh when vhost-net is started.
>  > >  > >  > 
>  > >  > >  > Stop bh when driver disabled bus mastering
>  > >  > >  > (we must not access memory after this).
>  > >  > >  > 
>  > >  > >  > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>  > >  > >  > 
>  > >  > > 
>  > >  > > There's no need to disable it bh we call qemu_aio_flush() after
>  > >  > > vm_state_notify() in do_vm_stop(). And for timer, looks like every device should
>  > >  > > stop its timer in vm state change handler, not only for virtio-net?
>  > >  > 
>  > >  > BTW I fixed some typos. Here a fixed version.
>  > >  > Jason, could you review/test please?
>  > >  > 
>  > > 
>  > > Have done the test, it's more stable than before but still get small deltas in
>  > > cpu section.
>  > 
>  > And just to clarify: no more deltas in the memory section?
>  > 
> 
> Yes.
> 
> And the offset for cpu section is 1161-1165 and sometimes I get deltas for ide
> section at offset 295 and 314.


Kevin, could you take a look please?

Jason, does the following do anything?

Subject: ide: cancel bh on vm stop

If bh is running on vm stop, ide state might change
after vm stop is completed. Solve by deleting bh on stop.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Kevin Wolf - Dec. 3, 2010, 8:39 a.m.
Am 02.12.2010 19:27, schrieb Michael S. Tsirkin:
> On Thu, Dec 02, 2010 at 10:19:55PM +0800, Jason Wang wrote:
>> Michael S. Tsirkin writes:
>>  > On Thu, Dec 02, 2010 at 08:56:30PM +0800, Jason Wang wrote:
>>  > > Michael S. Tsirkin writes:
>>  > >  > On Wed, Dec 01, 2010 at 01:45:09PM +0800, Jason Wang wrote:
>>  > >  > > Michael S. Tsirkin writes:
>>  > >  > >  > Avoid sending out packets, and modifying
>>  > >  > >  > device state, when VM is stopped.
>>  > >  > >  > Add assert statements to verify this does not happen.
>>  > >  > >  > 
>>  > >  > >  > Avoid scheduling bh when vhost-net is started.
>>  > >  > >  > 
>>  > >  > >  > Stop bh when driver disabled bus mastering
>>  > >  > >  > (we must not access memory after this).
>>  > >  > >  > 
>>  > >  > >  > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>>  > >  > >  > 
>>  > >  > > 
>>  > >  > > There's no need to disable it bh we call qemu_aio_flush() after
>>  > >  > > vm_state_notify() in do_vm_stop(). And for timer, looks like every device should
>>  > >  > > stop its timer in vm state change handler, not only for virtio-net?
>>  > >  > 
>>  > >  > BTW I fixed some typos. Here a fixed version.
>>  > >  > Jason, could you review/test please?
>>  > >  > 
>>  > > 
>>  > > Have done the test, it's more stable than before but still get small deltas in
>>  > > cpu section.
>>  > 
>>  > And just to clarify: no more deltas in the memory section?
>>  > 
>>
>> Yes.
>>
>> And the offset for cpu section is 1161-1165 and sometimes I get deltas for ide
>> section at offset 295 and 314.
> 
> 
> Kevin, could you take a look please?
> 
> Jason, does the following do anything?
> 
> Subject: ide: cancel bh on vm stop
> 
> If bh is running on vm stop, ide state might change
> after vm stop is completed. Solve by deleting bh on stop.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> 
> diff --git a/hw/ide/core.c b/hw/ide/core.c
> index 484e0ca..8d86114 100644
> --- a/hw/ide/core.c
> +++ b/hw/ide/core.c
> @@ -698,8 +698,13 @@ void ide_dma_restart_cb(void *opaque, int running, int reason)
>  {
>      BMDMAState *bm = opaque;
>  
> -    if (!running)
> +    if (!running) {
> +        if (bm->bh) {
> +            qemu_bh_delete(bm->bh);
> +            bm->bh = NULL;
> +        }
>          return;
> +    }
>  
>      if (!bm->bh) {
>          bm->bh = qemu_bh_new(ide_dma_restart_bh, bm);

Doesn't look incorrect to me, though I would be surprised if you ever
hit the case where bm->bh is not NULL. It would mean that immediately
after a cont the VM is stopped again. This bottom half is only ever used
in the vm_change_handler.

Considering that above was mentioned that a qemu_aio_flush() is run, I
also don't think that it makes any difference.

Kevin

Patch

diff --git a/hw/ide/core.c b/hw/ide/core.c
index 484e0ca..8d86114 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -698,8 +698,13 @@  void ide_dma_restart_cb(void *opaque, int running, int reason)
 {
     BMDMAState *bm = opaque;
 
-    if (!running)
+    if (!running) {
+        if (bm->bh) {
+            qemu_bh_delete(bm->bh);
+            bm->bh = NULL;
+        }
         return;
+    }
 
     if (!bm->bh) {
         bm->bh = qemu_bh_new(ide_dma_restart_bh, bm);