[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 3/6] virtio-balloon: don't restart stats timer in
From: |
Roman Kagan |
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 |
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 <address@hidden>
Cc: "Michael S. Tsirkin" <address@hidden>
Cc: Ladi Prosek <address@hidden>
Cc: Stefan Hajnoczi <address@hidden>
---
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
- [Qemu-devel] [PATCH v2 0/6] virtio-balloon: assorted fixes, Roman Kagan, 2016/08/19
- [Qemu-devel] [PATCH v2 2/6] virtio-balloon: make stats virtqueue length 1, Roman Kagan, 2016/08/19
- [Qemu-devel] [PATCH v2 4/6] virtio-balloon: keep collecting stats on save/restore, Roman Kagan, 2016/08/19
- Re: [Qemu-devel] [PATCH v2 0/6] virtio-balloon: assorted fixes, Roman Kagan, 2016/08/19
- [Qemu-devel] [PATCH v2 5/6] virtio-balloon: drop ->stats_vq_offset, Roman Kagan, 2016/08/19
- [Qemu-devel] [PATCH v2 6/6] virtio-balloon: drop reset handler, Roman Kagan, 2016/08/19
- [Qemu-devel] [PATCH v2 6/6] virtio-ballon: drop reset handler, Roman Kagan, 2016/08/19
- [Qemu-devel] [PATCH v2 3/6] virtio-balloon: don't restart stats timer in callback,
Roman Kagan <=
- [Qemu-devel] [PATCH v2 1/6] virtio: assert on ->inuse underflow, Roman Kagan, 2016/08/19