diff options
author | Jan Beulich <jbeulich@novell.com> | 2011-05-01 13:17:44 +0100 |
---|---|---|
committer | Jan Beulich <jbeulich@novell.com> | 2011-05-01 13:17:44 +0100 |
commit | 76ce27755b87aa5a91ce0f5a02e560ab5c0515e4 (patch) | |
tree | f2a7fcbd31e863d8a0238782c12a716bbc0f21e9 /xen/common/domain.c | |
parent | f22f2fe48d144141fffd42a380383f45efbea8e3 (diff) | |
download | xen-76ce27755b87aa5a91ce0f5a02e560ab5c0515e4.tar.gz xen-76ce27755b87aa5a91ce0f5a02e560ab5c0515e4.tar.bz2 xen-76ce27755b87aa5a91ce0f5a02e560ab5c0515e4.zip |
replace d->nr_pirqs sized arrays with radix tree
With this it is questionable whether retaining struct domain's
nr_pirqs is actually necessary - the value now only serves for bounds
checking, and this boundary could easily be nr_irqs.
Another thing to consider is whether it's worth storing the pirq
number in struct pirq, to avoid passing the number and a pointer to
quite a number of functions.
Note that ia64, the build of which is broken currently anyway, is only
partially fixed up.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Diffstat (limited to 'xen/common/domain.c')
-rw-r--r-- | xen/common/domain.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/xen/common/domain.c b/xen/common/domain.c index 852c968bba..40a2833762 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -290,13 +290,7 @@ struct domain *domain_create( if ( d->nr_pirqs > nr_irqs ) d->nr_pirqs = nr_irqs; - d->pirq_to_evtchn = xmalloc_array(u16, d->nr_pirqs); - d->pirq_mask = xmalloc_array( - unsigned long, BITS_TO_LONGS(d->nr_pirqs)); - if ( (d->pirq_to_evtchn == NULL) || (d->pirq_mask == NULL) ) - goto fail; - memset(d->pirq_to_evtchn, 0, d->nr_pirqs * sizeof(*d->pirq_to_evtchn)); - bitmap_zero(d->pirq_mask, d->nr_pirqs); + INIT_RADIX_TREE(&d->pirq_tree, 0); if ( evtchn_init(d) != 0 ) goto fail; @@ -346,6 +340,7 @@ struct domain *domain_create( { evtchn_destroy(d); evtchn_destroy_final(d); + radix_tree_destroy(&d->pirq_tree, free_pirq_struct, NULL); } if ( init_status & INIT_rangeset ) rangeset_domain_destroy(d); @@ -353,8 +348,6 @@ struct domain *domain_create( watchdog_domain_destroy(d); if ( init_status & INIT_xsm ) xsm_free_security_domain(d); - xfree(d->pirq_mask); - xfree(d->pirq_to_evtchn); free_cpumask_var(d->domain_dirty_cpumask); free_domain_struct(d); return NULL; @@ -680,8 +673,7 @@ static void complete_domain_destroy(struct rcu_head *head) evtchn_destroy_final(d); - xfree(d->pirq_mask); - xfree(d->pirq_to_evtchn); + radix_tree_destroy(&d->pirq_tree, free_pirq_struct, NULL); xsm_free_security_domain(d); free_cpumask_var(d->domain_dirty_cpumask); @@ -963,6 +955,20 @@ long vm_assist(struct domain *p, unsigned int cmd, unsigned int type) return -ENOSYS; } +struct pirq *pirq_get_info(struct domain *d, int pirq) +{ + struct pirq *info = pirq_info(d, pirq); + + if ( !info && (info = alloc_pirq_struct(d)) != NULL && + radix_tree_insert(&d->pirq_tree, pirq, info, NULL, NULL) ) + { + free_pirq_struct(info); + info = NULL; + } + + return info; +} + struct migrate_info { long (*func)(void *data); void *data; |