Skip to contentSkip to conversation

virtio balloon: kill tell-host-first logic

RFC PATCH Applied Dave Hansen 5 participants 22 messages Apr 7, 2011 – Apr 19, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 virtio balloon: kill tell-host-first logic

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, we must always tell the host before we free pages back to the allocator. Without this we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

But, if the bit is _not_ set, we are under no obligation to reverse the order. Furthermore, all modern qemus set this bit. So, the "tell second" code is completely unused and untestable. Quoting Anthony: "untested code is broken code".

This _also_ means that we don't have to preserve a pfn list after the pages are freed, which should let us get rid of some temporary storage (vb->pfns) eventually.

---

 linux-2.6.git-dave/drivers/virtio/virtio_balloon.c |   21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/virtio/virtio_balloon.c renamed from drivers/virtio/virtio_balloon.c~kill-tell-host-first-logic +8 -13
diff -puN drivers/virtio/virtio_balloon.c~kill-tell-host-first-logic drivers/virtio/virtio_balloon.c
@@ -40,9 +40,6 @@ struct virtio_balloon
 	/* Waiting for host to ack the pages we released. */
 	struct completion acked;
 
-	/* Do we have to tell Host *before* we reuse pages? */
-	bool tell_host_first;
-
 	/* The pages we've told the Host we're not using. */
 	unsigned int num_pages;
 	struct list_head pages;
@@ -151,13 +148,14 @@ static void leak_balloon(struct virtio_b
 		vb->num_pages--;
 	}
 
-	if (vb->tell_host_first) {
-		tell_host(vb, vb->deflate_vq);
-		release_pages_by_pfn(vb->pfns, vb->num_pfns);
-	} else {
-		release_pages_by_pfn(vb->pfns, vb->num_pfns);
-		tell_host(vb, vb->deflate_vq);
-	}
+
+	/*
+	 * Note that if
+	 * virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);
+	 * is true, we *have* to do it in this order
+	 */
+	tell_host(vb, vb->deflate_vq);
+	release_pages_by_pfn(vb->pfns, vb->num_pfns);
 }
 
 static inline void update_stat(struct virtio_balloon *vb, int idx,
@@ -325,9 +323,6 @@ static int virtballoon_probe(struct virt
 		goto out_del_vqs;
 	}
 
-	vb->tell_host_first
-		= virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);
-
 	return 0;
 
 out_del_vqs:

_

#1 lore raw
Quoted 12 lines · Dave Hansen

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, we must always tell the host before we free pages back to the allocator. Without this we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

But, if the bit is _not_ set, we are under no obligation to reverse the order. Furthermore, all modern qemus set this bit. So, the "tell second" code is completely unused and untestable. Quoting Anthony: "untested code is broken code".

Quoted 5 lines

This _also_ means that we don't have to preserve a pfn list after the pages are freed, which should let us get rid of some temporary storage (vb->pfns) eventually.

Thanks, applied!

Rusty.

#2 lore raw
In reply to Dave Hansen
Quoted 12 lines · Dave Hansen

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, we must always tell the host before we free pages back to the allocator. Without this we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

But, if the bit is _not_ set, we are under no obligation to reverse the order. Furthermore, all modern qemus set this bit. So, the "tell second" code is completely unused and untestable. Quoting Anthony: "untested code is broken code".

Quoted 5 lines

This _also_ means that we don't have to preserve a pfn list after the pages are freed, which should let us get rid of some temporary storage (vb->pfns) eventually.

Thanks, applied!

Rusty.

#3 lore raw
In reply to Dave Hansen
Quoted 9 lines · Dave Hansen

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, we must always tell the host before we free pages back to the allocator. Without this we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

But, if the bit is _not_ set, we are under no obligation to reverse the order. Furthermore, all modern qemus set this bit.

Which qemus do this, specifically? Amit Shah just pointed out to me that upstream qemu.git and qemu-kvm.git don't seem to do this.

Which qemu did you test this with?

Quoted 60 lines

So, the "tell second" code is completely unused and untestable. Quoting Anthony: "untested code is broken code".

This _also_ means that we don't have to preserve a pfn list after the pages are freed, which should let us get rid of some temporary storage (vb->pfns) eventually.

---

 linux-2.6.git-dave/drivers/virtio/virtio_balloon.c |   21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff -puN drivers/virtio/virtio_balloon.c~kill-tell-host-first-logic drivers/virtio/virtio_balloon.c

drivers/virtio/virtio_balloon.c renamed from drivers/virtio/virtio_balloon.c~kill-tell-host-first-logic +8 -13
@@ -40,9 +40,6 @@ struct virtio_balloon
 	/* Waiting for host to ack the pages we released. */
 	struct completion acked;
 
-	/* Do we have to tell Host *before* we reuse pages? */
-	bool tell_host_first;
-
 	/* The pages we've told the Host we're not using. */
 	unsigned int num_pages;
 	struct list_head pages;
@@ -151,13 +148,14 @@ static void leak_balloon(struct virtio_b
 		vb->num_pages--;
 	}
 
-	if (vb->tell_host_first) {
-		tell_host(vb, vb->deflate_vq);
-		release_pages_by_pfn(vb->pfns, vb->num_pfns);
-	} else {
-		release_pages_by_pfn(vb->pfns, vb->num_pfns);
-		tell_host(vb, vb->deflate_vq);
-	}
+
+	/*
+	 * Note that if
+	 * virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);
+	 * is true, we *have* to do it in this order
+	 */
+	tell_host(vb, vb->deflate_vq);
+	release_pages_by_pfn(vb->pfns, vb->num_pfns);
 }
 
 static inline void update_stat(struct virtio_balloon *vb, int idx,
@@ -325,9 +323,6 @@ static int virtballoon_probe(struct virt
 		goto out_del_vqs;
 	}
 
-	vb->tell_host_first
-		= virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);
-
 	return 0;
 
 out_del_vqs:

_

#4 lore raw
In reply to Dave Hansen
Quoted 9 lines · Dave Hansen

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, we must always tell the host before we free pages back to the allocator. Without this we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

But, if the bit is _not_ set, we are under no obligation to reverse the order. Furthermore, all modern qemus set this bit.

Which qemus do this, specifically? Amit Shah just pointed out to me that upstream qemu.git and qemu-kvm.git don't seem to do this.

Which qemu did you test this with?

Quoted 60 lines

So, the "tell second" code is completely unused and untestable. Quoting Anthony: "untested code is broken code".

This _also_ means that we don't have to preserve a pfn list after the pages are freed, which should let us get rid of some temporary storage (vb->pfns) eventually.

---

 linux-2.6.git-dave/drivers/virtio/virtio_balloon.c |   21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff -puN drivers/virtio/virtio_balloon.c~kill-tell-host-first-logic drivers/virtio/virtio_balloon.c

drivers/virtio/virtio_balloon.c renamed from drivers/virtio/virtio_balloon.c~kill-tell-host-first-logic +8 -13
@@ -40,9 +40,6 @@ struct virtio_balloon
 	/* Waiting for host to ack the pages we released. */
 	struct completion acked;
 
-	/* Do we have to tell Host *before* we reuse pages? */
-	bool tell_host_first;
-
 	/* The pages we've told the Host we're not using. */
 	unsigned int num_pages;
 	struct list_head pages;
@@ -151,13 +148,14 @@ static void leak_balloon(struct virtio_b
 		vb->num_pages--;
 	}
 
-	if (vb->tell_host_first) {
-		tell_host(vb, vb->deflate_vq);
-		release_pages_by_pfn(vb->pfns, vb->num_pfns);
-	} else {
-		release_pages_by_pfn(vb->pfns, vb->num_pfns);
-		tell_host(vb, vb->deflate_vq);
-	}
+
+	/*
+	 * Note that if
+	 * virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);
+	 * is true, we *have* to do it in this order
+	 */
+	tell_host(vb, vb->deflate_vq);
+	release_pages_by_pfn(vb->pfns, vb->num_pfns);
 }
 
 static inline void update_stat(struct virtio_balloon *vb, int idx,
@@ -325,9 +323,6 @@ static int virtballoon_probe(struct virt
 		goto out_del_vqs;
 	}
 
-	vb->tell_host_first
-		= virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);
-
 	return 0;
 
 out_del_vqs:

_

#5 lore raw
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Dave Hansen

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, we must always tell the host before we free pages back to the allocator. Without this we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

Quoted 5 lines
Quoted 2 lines

But, if the bit is _not_ set, we are under no obligation to reverse the order. Furthermore, all modern qemus set this bit.

Which qemus do this, specifically? Amit Shah just pointed out to me that upstream qemu.git and qemu-kvm.git don't seem to do this.

I had a conversation with Anthony about it, and I think I managed to confuse myself somewhere. Just to be clear, all that I see in the qemu-kvm git tree right now (df85c051d780bca0ee2462cfeb8ef6d9552a19b0) is this:

hw/virtio-balloon.h:#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */

Quoted 1 line

Which qemu did you test this with?

Probably a week or two old qemu-kvm.

My changelog could probably use some work, but the patch still stands. The only requirement we have is that when VIRTIO_BALLOON_F_MUST_TELL_HOST is set we *MUST* tell the host, first. But, when it's not set, we can do whatever we want.

So, we might as well always have the ...F_MUST_TELL_HOST behavior all the time.

-- Dave

#6 lore raw
In reply to Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Dave Hansen

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, we must always tell the host before we free pages back to the allocator. Without this we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

Quoted 5 lines
Quoted 2 lines

But, if the bit is _not_ set, we are under no obligation to reverse the order. Furthermore, all modern qemus set this bit.

Which qemus do this, specifically? Amit Shah just pointed out to me that upstream qemu.git and qemu-kvm.git don't seem to do this.

I had a conversation with Anthony about it, and I think I managed to confuse myself somewhere. Just to be clear, all that I see in the qemu-kvm git tree right now (df85c051d780bca0ee2462cfeb8ef6d9552a19b0) is this:

hw/virtio-balloon.h:#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */

Quoted 1 line

Which qemu did you test this with?

Probably a week or two old qemu-kvm.

My changelog could probably use some work, but the patch still stands. The only requirement we have is that when VIRTIO_BALLOON_F_MUST_TELL_HOST is set we *MUST* tell the host, first. But, when it's not set, we can do whatever we want.

So, we might as well always have the ...F_MUST_TELL_HOST behavior all the time.

-- Dave

#7 lore raw
Quoted 25 lines · Dave Hansen
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Dave Hansen

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, we must always tell the host before we free pages back to the allocator. Without this we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

Quoted 5 lines
Quoted 2 lines

But, if the bit is _not_ set, we are under no obligation to reverse the order. Furthermore, all modern qemus set this bit.

Which qemus do this, specifically? Amit Shah just pointed out to me that upstream qemu.git and qemu-kvm.git don't seem to do this.

I had a conversation with Anthony about it, and I think I managed to confuse myself somewhere. Just to be clear, all that I see in the qemu-kvm git tree right now (df85c051d780bca0ee2462cfeb8ef6d9552a19b0) is this:

hw/virtio-balloon.h:#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */

Quoted 1 line

Which qemu did you test this with?

Probably a week or two old qemu-kvm.

Quoted 7 lines

My changelog could probably use some work, but the patch still stands. The only requirement we have is that when VIRTIO_BALLOON_F_MUST_TELL_HOST is set we *MUST* tell the host, first. But, when it's not set, we can do whatever we want.

So, we might as well always have the ...F_MUST_TELL_HOST behavior all the time.

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

Thanks,

Amit

#8 lore raw
In reply to Dave Hansen
Quoted 25 lines · Dave Hansen
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Dave Hansen

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, we must always tell the host before we free pages back to the allocator. Without this we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

Quoted 5 lines
Quoted 2 lines

But, if the bit is _not_ set, we are under no obligation to reverse the order. Furthermore, all modern qemus set this bit.

Which qemus do this, specifically? Amit Shah just pointed out to me that upstream qemu.git and qemu-kvm.git don't seem to do this.

I had a conversation with Anthony about it, and I think I managed to confuse myself somewhere. Just to be clear, all that I see in the qemu-kvm git tree right now (df85c051d780bca0ee2462cfeb8ef6d9552a19b0) is this:

hw/virtio-balloon.h:#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */

Quoted 1 line

Which qemu did you test this with?

Probably a week or two old qemu-kvm.

Quoted 7 lines

My changelog could probably use some work, but the patch still stands. The only requirement we have is that when VIRTIO_BALLOON_F_MUST_TELL_HOST is set we *MUST* tell the host, first. But, when it's not set, we can do whatever we want.

So, we might as well always have the ...F_MUST_TELL_HOST behavior all the time.

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

Thanks,

Amit

#9 lore raw
Quoted 3 lines · Amit Shah

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

If Rusty hasn't pushed the commit out anywhere, we can still amend the commit. Otherwise, we're in a _bit_ of a pickle since you can't patch git logs. :)

Whatever is easiest for Rusty works for me.

How about this for a replacement log?

--

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, we must always tell the host before we free pages back to the allocator. Without this feature, we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

But, if the bit is _not_ set, we are under no obligation to reverse the order; we're under no obligation to do _anything_. That's the state of affairs in current qemu:

	#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0

This patch makes the "tell host first" logic the only case. This should make everybody happy, and reduce the amount of untested or untestable code in the kernel.

This _also_ means that we don't have to preserve a pfn list after the pages are freed, which should let us get rid of some temporary storage (vb->pfns) eventually.

-- Dave

#10 lore raw
In reply to Amit Shah
Quoted 3 lines · Amit Shah

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

If Rusty hasn't pushed the commit out anywhere, we can still amend the commit. Otherwise, we're in a _bit_ of a pickle since you can't patch git logs. :)

Whatever is easiest for Rusty works for me.

How about this for a replacement log?

--

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, we must always tell the host before we free pages back to the allocator. Without this feature, we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

But, if the bit is _not_ set, we are under no obligation to reverse the order; we're under no obligation to do _anything_. That's the state of affairs in current qemu:

	#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0

This patch makes the "tell host first" logic the only case. This should make everybody happy, and reduce the amount of untested or untestable code in the kernel.

This _also_ means that we don't have to preserve a pfn list after the pages are freed, which should let us get rid of some temporary storage (vb->pfns) eventually.

-- Dave

#11 lore raw
Quoted 8 lines · Dave Hansen
Quoted 3 lines · Amit Shah

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

If Rusty hasn't pushed the commit out anywhere, we can still amend the commit. Otherwise, we're in a _bit_ of a pickle since you can't patch git logs. :)

I should've been clearer: care to do the qemu patch? :-)

Quoted 12 lines

Whatever is easiest for Rusty works for me.

How about this for a replacement log?

--

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, we must always tell the host before we free pages back to the allocator. Without this feature, we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

Quoted 5 lines

But, if the bit is _not_ set, we are under no obligation to reverse the order; we're under no obligation to do _anything_. That's the state of affairs in current qemu:

	#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0

Actually this is just the bit number; it doesn't get set.

Amit

#12 lore raw
In reply to Dave Hansen
Quoted 8 lines · Dave Hansen
Quoted 3 lines · Amit Shah

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

If Rusty hasn't pushed the commit out anywhere, we can still amend the commit. Otherwise, we're in a _bit_ of a pickle since you can't patch git logs. :)

I should've been clearer: care to do the qemu patch? :-)

Quoted 12 lines

Whatever is easiest for Rusty works for me.

How about this for a replacement log?

--

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, we must always tell the host before we free pages back to the allocator. Without this feature, we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

Quoted 5 lines

But, if the bit is _not_ set, we are under no obligation to reverse the order; we're under no obligation to do _anything_. That's the state of affairs in current qemu:

	#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0

Actually this is just the bit number; it doesn't get set.

Amit

#13 lore raw
Quoted 11 lines · Amit Shah
Quoted 8 lines · Dave Hansen
Quoted 3 lines · Amit Shah

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

If Rusty hasn't pushed the commit out anywhere, we can still amend the commit. Otherwise, we're in a _bit_ of a pickle since you can't patch git logs. :)

I should've been clearer: care to do the qemu patch? :-)

What do we want to do to qemu, though? Set the bit?

-- Dave

#14 lore raw
In reply to Amit Shah
Quoted 11 lines · Amit Shah
Quoted 8 lines · Dave Hansen
Quoted 3 lines · Amit Shah

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

If Rusty hasn't pushed the commit out anywhere, we can still amend the commit. Otherwise, we're in a _bit_ of a pickle since you can't patch git logs. :)

I should've been clearer: care to do the qemu patch? :-)

What do we want to do to qemu, though? Set the bit?

-- Dave

#15 lore raw
Quoted 7 lines · Dave Hansen
Quoted 6 lines · Amit Shah
Quoted 5 lines · Dave Hansen
Quoted 3 lines · Amit Shah

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

If Rusty hasn't pushed the commit out anywhere, we can still amend the commit. Otherwise, we're in a _bit_ of a pickle since you can't patch git logs. :)

I should've been clearer: care to do the qemu patch? :-)

What do we want to do to qemu, though? Set the bit?

Yes, that should ensure older guests behave fine too.

Amit

#16 lore raw
In reply to Dave Hansen
Quoted 7 lines · Dave Hansen
Quoted 6 lines · Amit Shah
Quoted 5 lines · Dave Hansen
Quoted 3 lines · Amit Shah

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

If Rusty hasn't pushed the commit out anywhere, we can still amend the commit. Otherwise, we're in a _bit_ of a pickle since you can't patch git logs. :)

I should've been clearer: care to do the qemu patch? :-)

What do we want to do to qemu, though? Set the bit?

Yes, that should ensure older guests behave fine too.

Amit

#17 lore raw
In reply to Dave Hansen
Quoted 8 lines · Dave Hansen
Quoted 3 lines · Amit Shah

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

If Rusty hasn't pushed the commit out anywhere, we can still amend the commit. Otherwise, we're in a _bit_ of a pickle since you can't patch git logs. :)

I only use git to send patches to Linus, and even if I did, I certainly wouldn't try to publish an non-rebasing tree for exactly this reason.

So send me the new commit, or just the new message...

Thanks,
Rusty.

#18 lore raw
In reply to Dave Hansen
Quoted 8 lines · Dave Hansen
Quoted 3 lines · Amit Shah

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

If Rusty hasn't pushed the commit out anywhere, we can still amend the commit. Otherwise, we're in a _bit_ of a pickle since you can't patch git logs. :)

I only use git to send patches to Linus, and even if I did, I certainly wouldn't try to publish an non-rebasing tree for exactly this reason.

So send me the new commit, or just the new message...

Thanks,
Rusty.

#19 lore raw
Quoted 6 lines · Rusty Russell
Quoted 5 lines · Dave Hansen
Quoted 3 lines · Amit Shah

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

Quoted 8 lines
Quoted 3 lines

If Rusty hasn't pushed the commit out anywhere, we can still amend the commit. Otherwise, we're in a _bit_ of a pickle since you can't patch git logs. :)

I only use git to send patches to Linus, and even if I did, I certainly wouldn't try to publish an non-rebasing tree for exactly this reason.

So send me the new commit, or just the new message...

Here's a new commit message:

--

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, the guest kernel must always tell the host before we free pages back to the allocator. Without this feature, we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

But, if the bit is _not_ set, we are under no obligation to reverse the order; we're under no obligation to do _anything_. As of now, qemu-kvm defines the bit, but doesn't set it.

This patch makes the "tell host first" logic the only case. This should make everybody happy, and reduce the amount of untested or untestable code in the kernel.

This _also_ means that we don't have to preserve a pfn list after the pages are freed, which should let us get rid of some temporary storage (vb->pfns) eventually.

#20 lore raw
In reply to Rusty Russell
Quoted 6 lines · Rusty Russell
Quoted 5 lines · Dave Hansen
Quoted 3 lines · Amit Shah

Sure, the only contention was on the commit message, where you stated modern qemus set this... qemu doesn't, and it should. Care to do a patch for that?

Quoted 8 lines
Quoted 3 lines

If Rusty hasn't pushed the commit out anywhere, we can still amend the commit. Otherwise, we're in a _bit_ of a pickle since you can't patch git logs. :)

I only use git to send patches to Linus, and even if I did, I certainly wouldn't try to publish an non-rebasing tree for exactly this reason.

So send me the new commit, or just the new message...

Here's a new commit message:

--

The virtio balloon driver has a VIRTIO_BALLOON_F_MUST_TELL_HOST feature bit. Whenever the bit is set, the guest kernel must always tell the host before we free pages back to the allocator. Without this feature, we might free a page (and have another user touch it) while the hypervisor is unprepared for it.

But, if the bit is _not_ set, we are under no obligation to reverse the order; we're under no obligation to do _anything_. As of now, qemu-kvm defines the bit, but doesn't set it.

This patch makes the "tell host first" logic the only case. This should make everybody happy, and reduce the amount of untested or untestable code in the kernel.

This _also_ means that we don't have to preserve a pfn list after the pages are freed, which should let us get rid of some temporary storage (vb->pfns) eventually.

#21 lore raw
Quoted 1 line · Dave Hansen

Here's a new commit message:

Applied, thanks.

Rusty.