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>,
	Ladi Prosek <lprosek@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH v2 3/6] virtio-balloon: don't restart stats timer in callback
Date: Fri, 19 Aug 2016 16:39:22 +0300	[thread overview]
Message-ID: <1471613966-7267-4-git-send-email-rkagan@virtuozzo.com> (raw)
In-Reply-To: <1471613966-7267-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>
Cc: Ladi Prosek <lprosek@redhat.com>
Cc: Stefan Hajnoczi <stefanha@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 fb8784e..6d4c57c 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 19:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-19 13:39 [Qemu-devel] [PATCH v2 0/6] virtio-balloon: assorted fixes Roman Kagan
2016-08-19 13:39 ` [Qemu-devel] [PATCH v2 1/6] virtio: assert on ->inuse underflow Roman Kagan
2016-08-23 21:03   ` Stefan Hajnoczi
2016-08-24  2:42     ` Michael S. Tsirkin
2016-08-19 13:39 ` [Qemu-devel] [PATCH v2 2/6] virtio-balloon: make stats virtqueue length 1 Roman Kagan
2016-08-22  1:57   ` Michael S. Tsirkin
2016-08-19 13:39 ` Roman Kagan [this message]
2016-08-19 13:39 ` [Qemu-devel] [PATCH v2 4/6] virtio-balloon: keep collecting stats on save/restore Roman Kagan
2016-09-01  8:35   ` Ladi Prosek
2016-09-01 14:17     ` Roman Kagan
2016-09-01 15:43       ` Ladi Prosek
2016-09-01 16:18         ` Michael S. Tsirkin
2016-09-01 18:03         ` Roman Kagan
2016-08-19 13:39 ` [Qemu-devel] [PATCH v2 5/6] virtio-balloon: drop ->stats_vq_offset Roman Kagan
2016-08-19 13:39 ` [Qemu-devel] [PATCH v2 6/6] virtio-ballon: drop reset handler Roman Kagan
2016-08-19 13:43   ` Roman Kagan
2016-08-19 13:39 ` [Qemu-devel] [PATCH v2 6/6] virtio-balloon: " Roman Kagan
2016-08-19 14:48 ` [Qemu-devel] [PATCH v2 0/6] virtio-balloon: assorted fixes Roman Kagan

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=1471613966-7267-4-git-send-email-rkagan@virtuozzo.com \
    --to=rkagan@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=lprosek@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).