[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH V6 2/4] x86/mm: introduce p2m_{init, free}_logdirty()
Add logdirty_ranges allocator / deallocator helpers. p2m_init_logdirty() will not re-allocate if p2m->logdirty ranges has already been allocated. Move the rangeset deallocation call from p2m_teardown_hostp2m() to p2m_free_one() - we will want this to apply to altp2ms as well. Signed-off-by: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx> --- CC: George Dunlap <george.dunlap@xxxxxxxxxxxxx> CC: Jan Beulich <jbeulich@xxxxxxxx> CC: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CC: Wei Liu <wei.liu2@xxxxxxxxxx> --- Changes since V5: - Added this new patch by splitting the former second patch for easier review. --- xen/arch/x86/mm/p2m.c | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 6a1abb6..418ff85 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -59,6 +59,28 @@ static void p2m_nestedp2m_init(struct p2m_domain *p2m) #endif } +static int p2m_init_logdirty(struct p2m_domain *p2m) +{ + if ( p2m->logdirty_ranges ) + return 0; + + p2m->logdirty_ranges = rangeset_new(p2m->domain, "log-dirty", + RANGESETF_prettyprint_hex); + if ( !p2m->logdirty_ranges ) + return -ENOMEM; + + return 0; +} + +static void p2m_free_logdirty(struct p2m_domain *p2m) +{ + if ( !p2m->logdirty_ranges ) + return; + + rangeset_destroy(p2m->logdirty_ranges); + p2m->logdirty_ranges = NULL; +} + /* Init the datastructures for later use by the p2m code */ static int p2m_initialise(struct domain *d, struct p2m_domain *p2m) { @@ -107,6 +129,7 @@ free_p2m: static void p2m_free_one(struct p2m_domain *p2m) { + p2m_free_logdirty(p2m); if ( hap_enabled(p2m->domain) && cpu_has_vmx ) ept_p2m_uninit(p2m); free_cpumask_var(p2m->dirty_cpumask); @@ -116,19 +139,19 @@ static void p2m_free_one(struct p2m_domain *p2m) static int p2m_init_hostp2m(struct domain *d) { struct p2m_domain *p2m = p2m_init_one(d); + int rc; - if ( p2m ) - { - p2m->logdirty_ranges = rangeset_new(d, "log-dirty", - RANGESETF_prettyprint_hex); - if ( p2m->logdirty_ranges ) - { - d->arch.p2m = p2m; - return 0; - } + if ( !p2m ) + return -ENOMEM; + + rc = p2m_init_logdirty(p2m); + + if ( !rc ) + d->arch.p2m = p2m; + else p2m_free_one(p2m); - } - return -ENOMEM; + + return rc; } static void p2m_teardown_hostp2m(struct domain *d) @@ -138,7 +161,6 @@ static void p2m_teardown_hostp2m(struct domain *d) if ( p2m ) { - rangeset_destroy(p2m->logdirty_ranges); p2m_free_one(p2m); d->arch.p2m = NULL; } -- 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |