From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org, peterx@redhat.com, cohuck@redhat.com,
mst@redhat.com, david@redhat.com
Subject: [Qemu-devel] [PATCH v2 1/4] balloon: Allow nested inhibits
Date: Mon, 30 Jul 2018 17:13:46 -0600 [thread overview]
Message-ID: <153299242656.14411.14216251294160965283.stgit@gimli.home> (raw)
In-Reply-To: <153299204130.14411.11438396195753743913.stgit@gimli.home>
A simple true/false internal state does not allow multiple users. Fix
this within the existing interface by converting to a counter, so long
as the counter is elevated, ballooning is inhibited.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
balloon.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/balloon.c b/balloon.c
index 6bf0a9681377..931987983858 100644
--- a/balloon.c
+++ b/balloon.c
@@ -26,6 +26,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
+#include "qemu/atomic.h"
#include "exec/cpu-common.h"
#include "sysemu/kvm.h"
#include "sysemu/balloon.h"
@@ -37,16 +38,22 @@
static QEMUBalloonEvent *balloon_event_fn;
static QEMUBalloonStatus *balloon_stat_fn;
static void *balloon_opaque;
-static bool balloon_inhibited;
+static int balloon_inhibit_count;
bool qemu_balloon_is_inhibited(void)
{
- return balloon_inhibited;
+ return atomic_read(&balloon_inhibit_count) > 0;
}
void qemu_balloon_inhibit(bool state)
{
- balloon_inhibited = state;
+ if (state) {
+ atomic_inc(&balloon_inhibit_count);
+ } else {
+ atomic_dec(&balloon_inhibit_count);
+ }
+
+ assert(atomic_read(&balloon_inhibit_count) >= 0);
}
static bool have_balloon(Error **errp)
next prev parent reply other threads:[~2018-07-30 23:14 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 23:13 [Qemu-devel] [PATCH v2 0/4] Balloon inhibit enhancements, vfio restriction Alex Williamson
2018-07-30 23:13 ` Alex Williamson [this message]
2018-07-31 8:25 ` [Qemu-devel] [PATCH v2 1/4] balloon: Allow nested inhibits David Hildenbrand
2018-08-07 12:56 ` Peter Xu
2018-08-07 14:20 ` Cornelia Huck
2018-07-30 23:14 ` [Qemu-devel] [PATCH v2 2/4] kvm: Use inhibit to prevent ballooning without synchronous mmu Alex Williamson
2018-07-31 8:24 ` David Hildenbrand
2018-08-07 12:56 ` Peter Xu
2018-08-07 14:24 ` Cornelia Huck
2018-07-30 23:14 ` [Qemu-devel] [PATCH v2 3/4] vfio: Inhibit ballooning based on group attachment to a container Alex Williamson
2018-08-07 13:10 ` Peter Xu
2018-08-07 16:35 ` Alex Williamson
2018-08-08 3:22 ` Peter Xu
2018-07-30 23:14 ` [Qemu-devel] [PATCH v2 4/4] vfio/ccw/pci: Allow devices to opt-in for ballooning Alex Williamson
2018-08-07 14:15 ` Cornelia Huck
2018-07-31 12:29 ` [Qemu-devel] [PATCH v2 0/4] Balloon inhibit enhancements, vfio restriction Michael S. Tsirkin
2018-07-31 14:44 ` Alex Williamson
2018-07-31 15:07 ` Dr. David Alan Gilbert
2018-07-31 21:50 ` Alex Williamson
2018-08-03 18:42 ` Michael S. Tsirkin
2018-08-03 20:12 ` Alex Williamson
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=153299242656.14411.14216251294160965283.stgit@gimli.home \
--to=alex.williamson@redhat.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=peterx@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).