qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Roman Kagan <rkagan@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: "Denis V. Lunev" <den@openvz.org>,
	Roman Kagan <rkagan@virtuozzo.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PATCH 3/4] virtio-balloon: don't restart stats timer in callback
Date: Thu, 18 Aug 2016 21:27:53 +0300	[thread overview]
Message-ID: <1471544874-26996-4-git-send-email-rkagan@virtuozzo.com> (raw)
In-Reply-To: <1471544874-26996-1-git-send-email-rkagan@virtuozzo.com>

There's no need to restart the stats timer in its callback.  If the
callback happens to run when there's nothing to do just do nothing and
return.

The timer is armed either in receive handler or initially when
periodic stats collection is enabled via QMP.

While at this, observe that the presence of ->stats_vq_elem is enough to
indicate there's work to do here, and drop the check for the stats
feature.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
---
 hw/virtio/virtio-balloon.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 0baf4b3..b56fecd 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -68,12 +68,6 @@ static inline void reset_stats(VirtIOBalloon *dev)
     for (i = 0; i < VIRTIO_BALLOON_S_NR; dev->stats[i++] = -1);
 }
 
-static bool balloon_stats_supported(const VirtIOBalloon *s)
-{
-    VirtIODevice *vdev = VIRTIO_DEVICE(s);
-    return virtio_vdev_has_feature(vdev, VIRTIO_BALLOON_F_STATS_VQ);
-}
-
 static bool balloon_stats_enabled(const VirtIOBalloon *s)
 {
     return s->stats_poll_interval > 0;
@@ -99,9 +93,10 @@ static void balloon_stats_poll_cb(void *opaque)
     VirtIOBalloon *s = opaque;
     VirtIODevice *vdev = VIRTIO_DEVICE(s);
 
-    if (s->stats_vq_elem == NULL || !balloon_stats_supported(s)) {
-        /* re-schedule */
-        balloon_stats_change_timer(s, s->stats_poll_interval);
+    if (!s->stats_vq_elem) {
+        /* The guest hasn't sent the stats yet (either not enabled or we came
+         * too early), nothing to do.  Once the guest starts sending stats the
+         * timer will get armed in receive handler */
         return;
     }
 
-- 
2.7.4

  parent reply	other threads:[~2016-08-19  0:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-18 18:27 [Qemu-devel] [PATCH 0/4] virtio-balloon: assorted fixes Roman Kagan
2016-08-18 18:27 ` [Qemu-devel] [PATCH 1/4] virtio: assert on ->inuse underflow Roman Kagan
2016-08-18 18:27 ` [Qemu-devel] [PATCH 2/4] virtio-balloon: make stats virtqueue length 1 Roman Kagan
2016-08-19 10:05   ` Ladi Prosek
2016-08-19 11:04     ` Roman Kagan
2016-08-19 13:44   ` Stefan Hajnoczi
2016-08-19 14:38     ` Roman Kagan
2016-08-18 18:27 ` Roman Kagan [this message]
2016-08-18 18:27 ` [Qemu-devel] [PATCH 4/4] virtio-balloon: keep collecting stats on save/restore Roman Kagan
2016-08-19  9:57   ` Ladi Prosek
2016-08-19 11:37     ` Roman Kagan
2016-08-19 12:08       ` Ladi Prosek
2016-08-19 14:45         ` Roman Kagan
2016-08-19 19:01           ` Ladi Prosek
2016-08-19 13:41 ` [Qemu-devel] [PATCH 0/4] virtio-balloon: assorted fixes Stefan Hajnoczi

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=1471544874-26996-4-git-send-email-rkagan@virtuozzo.com \
    --to=rkagan@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=mst@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).