# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1259310161 0
# Node ID 8c5708bc87adb3ae7dd5f0ccc7a84bb57f7ca8f4
# Parent 455c6392747f8a4801b2dcced1265ad4cc9086fe
PoD: Handle operations properly when domain is dying
No populate-on-demand activities should happen when a domain is dying.
Especially, it is a bug for memory to be added to the PoD cache when
d->is_dying is non-zero, since if this happens after the cache has
been emptied, these pages will never be freed. This may cause "zombie
domains" to linger.
Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
xen-unstable changeset: 20426:368cfc61e7b6
xen-unstable date: Thu Nov 12 11:39:51 2009 +0000
---
xen/arch/x86/mm/p2m.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletion(-)
diff -r 455c6392747f -r 8c5708bc87ad xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c Tue Nov 10 15:04:00 2009 +0000
+++ b/xen/arch/x86/mm/p2m.c Fri Nov 27 08:22:41 2009 +0000
@@ -292,6 +292,8 @@ p2m_pod_cache_add(struct domain *d,
default:
BUG();
}
+
+ BUG_ON(d->is_dying);
spin_unlock(&d->page_alloc_lock);
@@ -493,6 +495,10 @@ p2m_pod_set_mem_target(struct domain *d,
if ( p2md->pod.entry_count == 0 )
goto out;
+ /* Don't do anything if the domain is being torn down */
+ if ( d->is_dying )
+ goto out;
+
/* T' < B: Don't reduce the cache size; let the balloon driver
* take care of it. */
if ( target < d->tot_pages )
@@ -572,7 +578,7 @@ p2m_pod_decrease_reservation(struct doma
/* If we don't have any outstanding PoD entries, let things take their
* course */
- if ( p2md->pod.entry_count == 0 )
+ if ( p2md->pod.entry_count == 0 || unlikely(d->is_dying) )
goto out;
/* Figure out if we need to steal some freed memory for our cache */
@@ -1008,6 +1014,12 @@ p2m_pod_demand_populate(struct domain *d
return 0;
}
+ /* This check is done with the p2m lock held. This will make sure that
+ * even if d->is_dying changes under our feet, empty_pod_cache() won't
start
+ * until we're done. */
+ if ( unlikely(d->is_dying) )
+ goto out_fail;
+
/* If we're low, start a sweep */
if ( order == 9 && page_list_empty(&p2md->pod.super) )
p2m_pod_emergency_sweep_super(d);
@@ -1077,6 +1089,7 @@ out_of_memory:
p2m_unlock(p2md);
printk("%s: Out of populate-on-demand memory!\n", __func__);
domain_crash(d);
+out_fail:
return -1;
remap_and_retry:
BUG_ON(order != 9);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|