All of lore.kernel.org
 help / color / mirror / Atom feed
From: P J P <ppandit@redhat.com>
To: qemu-devel@nongnu.org
Cc: Dmitry Fleytman <dmitry@daynix.com>,
	Qinghao Tang <luodalongde@gmail.com>,
	Jason Wang <jasowang@redhat.com>
Subject: Re: [Qemu-devel] net: vmxnet3: memory leakage issue
Date: Tue, 8 Dec 2015 15:47:53 +0530 (IST)	[thread overview]
Message-ID: <alpine.LFD.2.20.1512081526300.26684@wniryva> (raw)
In-Reply-To: <566105A2.6040508@redhat.com>

  Hello Jason,

+-- On Fri, 4 Dec 2015, Jason Wang wrote --+
| Better with "git send-email".

  Okay.

| What if guest deactivate the device before re-activate the device?
|Looks like it could be done through methods:
|
|1) VMXNET3_CMD_QUIESCE_DEV

  IIUC, it is used to pause the device when the receiver end is unable to 
keee-up with the incoming flow. After a brief period, the operation could be 
resumed again.

|2) VMXNET3_REG_DSAL

   Shared memory between a driver and the device appears to be set in two 
steps. Firs low address, followed by the high address(VMXNET3_REG_DSAH). I 
guess 's->device_active' needs to be enabled again while setting the higher 
part of the address.

|So looks like need to free both tx_pkt and rx_pkt during deactivating?

  I think freeing 'tx_pkt' & 'rx_pkt' during pause wouldn't be good. It needs 
to call something like - 'vmxnet3_resume_device'.

Please see the patch below for the above two cases, does it look okay?

===
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 37373e5..4b2305b 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1198,6 +1198,12 @@ static void vmxnet3_deactivate_device(VMXNET3State *s)
     s->device_active = false;
 }
 
+static void vmxnet3_resume_device(VMXNET3State *s)
+{
+    VMW_CBPRN("Resuming vmxnet3...");
+    s->device_active = true;
+}
+
 static void vmxnet3_reset(VMXNET3State *s)
 {
     VMW_CBPRN("Resetting vmxnet3...");
@@ -1627,8 +1633,13 @@ static void vmxnet3_handle_command(VMXNET3State *s, uint64_t cmd)
         break;
 
     case VMXNET3_CMD_QUIESCE_DEV:
-        VMW_CBPRN("Set: VMXNET3_CMD_QUIESCE_DEV - pause the device");
-        vmxnet3_deactivate_device(s);
+        if (s->device_active) {
+            VMW_CBPRN("Set: VMXNET3_CMD_QUIESCE_DEV - pause the device");
+            vmxnet3_deactivate_device(s);
+        } else {
+            VMW_CBPRN("Set: VMXNET3_CMD_QUIESCE_DEV - resume the device");
+            vmxnet3_resume_device(s);
+        }
         break;
 
     case VMXNET3_CMD_GET_CONF_INTR:
@@ -1756,6 +1767,9 @@ vmxnet3_io_bar1_write(void *opaque,
          * We already should have low address part.
          */
         s->drv_shmem = s->temp_shared_guest_driver_memory | (val << 32);
+        if (s->drv_shmem) {
+            s->device_active = true;
+        }
         break;
 
     /* Command */
===


Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F

  reply	other threads:[~2015-12-08 10:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-02 12:17 [Qemu-devel] net: vmxnet3: memory leakage issue P J P
2015-12-03  7:17 ` Dmitry Fleytman
2015-12-03 11:20   ` P J P
2015-12-04  3:16   ` Jason Wang
2015-12-08 10:17     ` P J P [this message]
2015-12-09 15:28       ` P J P
2015-12-11  9:10         ` Jason Wang
2015-12-11  9:34           ` Dmitry Fleytman
2015-12-11 10:04           ` P J P
2015-12-13  8:27             ` Dmitry Fleytman
2015-12-13  9:45         ` Dmitry Fleytman
2015-12-14 11:58           ` P J P
2015-12-14 17:27             ` Dmitry Fleytman
2015-12-15  6:57               ` P J P
2015-12-15  7:01                 ` Dmitry Fleytman
2015-12-15  8:00                   ` P J P
2015-12-15  8:24                     ` Jason Wang
2015-12-15  8:50                       ` P J P
2015-12-15  8:43             ` Miao Yan
2015-12-15 10:08               ` P J P
2015-12-04  2:22 ` Jason Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.20.1512081526300.26684@wniryva \
    --to=ppandit@redhat.com \
    --cc=dmitry@daynix.com \
    --cc=jasowang@redhat.com \
    --cc=luodalongde@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.