[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen stable-4.4] x86/mm: Make {hap, shadow}_teardown() preemptible
commit e19042ffbdf07e217c827eb0f722be5fe1623ea3 Author: Anshul Makkar <anshul.makkar@xxxxxxxxxx> AuthorDate: Thu Sep 10 15:55:23 2015 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Thu Sep 10 15:55:23 2015 +0200 x86/mm: Make {hap, shadow}_teardown() preemptible A domain with sufficient shadow allocation can cause a watchdog timeout during domain destruction. Expand the existing -EAGAIN logic in paging_teardown() to allow {hap/sh}_set_allocation() to become restartable during the DOMCTL_destroydomain hypercall. Signed-off-by: Anshul Makkar <anshul.makkar@xxxxxxxxxx> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Tim Deegan <tim@xxxxxxx> Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx> master commit: 0174da5b79752e2d5d6ca0faed89536e8f3d91c7 master date: 2015-08-06 10:04:43 +0100 --- xen/arch/x86/mm/hap/hap.c | 22 ++++++++-------------- xen/arch/x86/mm/paging.c | 9 ++++++--- xen/arch/x86/mm/shadow/common.c | 24 +++++++++--------------- xen/include/asm-x86/hap.h | 2 +- xen/include/asm-x86/shadow.h | 2 +- 5 files changed, 25 insertions(+), 34 deletions(-) diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index 71227ef..c06369b 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -498,7 +498,7 @@ void hap_final_teardown(struct domain *d) } if ( d->arch.paging.hap.total_pages != 0 ) - hap_teardown(d); + hap_teardown(d, NULL); p2m_teardown(p2m_get_hostp2m(d)); /* Free any memory that the p2m teardown released */ @@ -508,7 +508,7 @@ void hap_final_teardown(struct domain *d) paging_unlock(d); } -void hap_teardown(struct domain *d) +void hap_teardown(struct domain *d, int *preempted) { struct vcpu *v; mfn_t mfn; @@ -536,18 +536,11 @@ void hap_teardown(struct domain *d) if ( d->arch.paging.hap.total_pages != 0 ) { - HAP_PRINTK("teardown of domain %u starts." - " pages total = %u, free = %u, p2m=%u\n", - d->domain_id, - d->arch.paging.hap.total_pages, - d->arch.paging.hap.free_pages, - d->arch.paging.hap.p2m_pages); - hap_set_allocation(d, 0, NULL); - HAP_PRINTK("teardown done." - " pages total = %u, free = %u, p2m=%u\n", - d->arch.paging.hap.total_pages, - d->arch.paging.hap.free_pages, - d->arch.paging.hap.p2m_pages); + hap_set_allocation(d, 0, preempted); + + if ( preempted && *preempted ) + goto out; + ASSERT(d->arch.paging.hap.total_pages == 0); } @@ -556,6 +549,7 @@ void hap_teardown(struct domain *d) xfree(d->arch.hvm_domain.dirty_vram); d->arch.hvm_domain.dirty_vram = NULL; +out: paging_unlock(d); } diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c index fb418fe..72555b3 100644 --- a/xen/arch/x86/mm/paging.c +++ b/xen/arch/x86/mm/paging.c @@ -777,12 +777,15 @@ long paging_domctl_continuation(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) /* Call when destroying a domain */ int paging_teardown(struct domain *d) { - int rc; + int rc, preempted = 0; if ( hap_enabled(d) ) - hap_teardown(d); + hap_teardown(d, &preempted); else - shadow_teardown(d); + shadow_teardown(d, &preempted); + + if ( preempted ) + return -EAGAIN; /* clean up log dirty resources. */ rc = paging_free_log_dirty_bitmap(d, 0); diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index 3ed48c4..90ba4d6 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -3031,7 +3031,7 @@ int shadow_enable(struct domain *d, u32 mode) return rv; } -void shadow_teardown(struct domain *d) +void shadow_teardown(struct domain *d, int *preempted) /* Destroy the shadow pagetables of this domain and free its shadow memory. * Should only be called for dying domains. */ { @@ -3092,23 +3092,16 @@ void shadow_teardown(struct domain *d) if ( d->arch.paging.shadow.total_pages != 0 ) { - SHADOW_PRINTK("teardown of domain %u starts." - " Shadow pages total = %u, free = %u, p2m=%u\n", - d->domain_id, - d->arch.paging.shadow.total_pages, - d->arch.paging.shadow.free_pages, - d->arch.paging.shadow.p2m_pages); /* Destroy all the shadows and release memory to domheap */ - sh_set_allocation(d, 0, NULL); + sh_set_allocation(d, 0, preempted); + + if ( preempted && *preempted ) + goto out; + /* Release the hash table back to xenheap */ if (d->arch.paging.shadow.hash_table) shadow_hash_teardown(d); - /* Should not have any more memory held */ - SHADOW_PRINTK("teardown done." - " Shadow pages total = %u, free = %u, p2m=%u\n", - d->arch.paging.shadow.total_pages, - d->arch.paging.shadow.free_pages, - d->arch.paging.shadow.p2m_pages); + ASSERT(d->arch.paging.shadow.total_pages == 0); } @@ -3139,6 +3132,7 @@ void shadow_teardown(struct domain *d) d->arch.hvm_domain.dirty_vram = NULL; } +out: paging_unlock(d); /* Must be called outside the lock */ @@ -3160,7 +3154,7 @@ void shadow_final_teardown(struct domain *d) * It is possible for a domain that never got domain_kill()ed * to get here with its shadow allocation intact. */ if ( d->arch.paging.shadow.total_pages != 0 ) - shadow_teardown(d); + shadow_teardown(d, NULL); /* It is now safe to pull down the p2m map. */ p2m_teardown(p2m_get_hostp2m(d)); diff --git a/xen/include/asm-x86/hap.h b/xen/include/asm-x86/hap.h index e03f983..e67c08e 100644 --- a/xen/include/asm-x86/hap.h +++ b/xen/include/asm-x86/hap.h @@ -54,7 +54,7 @@ int hap_domctl(struct domain *d, xen_domctl_shadow_op_t *sc, XEN_GUEST_HANDLE_PARAM(void) u_domctl); int hap_enable(struct domain *d, u32 mode); void hap_final_teardown(struct domain *d); -void hap_teardown(struct domain *d); +void hap_teardown(struct domain *d, int *preempted); void hap_vcpu_init(struct vcpu *v); void hap_logdirty_init(struct domain *d); int hap_track_dirty_vram(struct domain *d, diff --git a/xen/include/asm-x86/shadow.h b/xen/include/asm-x86/shadow.h index 348915e..8834213 100644 --- a/xen/include/asm-x86/shadow.h +++ b/xen/include/asm-x86/shadow.h @@ -76,7 +76,7 @@ int shadow_domctl(struct domain *d, XEN_GUEST_HANDLE_PARAM(void) u_domctl); /* Call when destroying a domain */ -void shadow_teardown(struct domain *d); +void shadow_teardown(struct domain *d, int *preempted); /* Call once all of the references to the domain have gone away */ void shadow_final_teardown(struct domain *d); -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.4 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |