From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: [PATCH 5/8] evtchn: dynamically allocate d->evtchn Date: Fri, 9 Aug 2013 19:08:37 +0100 Message-ID: <1376071720-17644-6-git-send-email-david.vrabel@citrix.com> References: <1376071720-17644-1-git-send-email-david.vrabel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1376071720-17644-1-git-send-email-david.vrabel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Wei Liu , Keir Fraser , David Vrabel List-Id: xen-devel@lists.xenproject.org From: Wei Liu As we move to extended evtchn ABI we need bigger d->evtchn, as a result this will bloat struct domain. So move this array out of struct domain and allocate a dedicated array for it. Signed-off-by: Wei Liu Signed-off-by: David Vrabel --- xen/common/event_channel.c | 13 +++++++++++++ xen/include/xen/sched.h | 2 +- 2 files changed, 14 insertions(+), 1 deletions(-) diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 1a1636e..126cf84 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -1163,15 +1163,26 @@ int evtchn_init(struct domain *d) /* Default to N-level ABI. */ evtchn_2l_init(d); + BUILD_BUG_ON(sizeof(struct evtchn *) * NR_EVTCHN_BUCKETS > PAGE_SIZE); + d->evtchn = xzalloc_array(struct evtchn *, NR_EVTCHN_BUCKETS); + if ( d->evtchn == NULL ) + return -ENOMEM; + spin_lock_init(&d->event_lock); if ( get_free_port(d) != 0 ) + { + xfree(d->evtchn); return -EINVAL; + } evtchn_from_port(d, 0)->state = ECS_RESERVED; #if MAX_VIRT_CPUS > BITS_PER_LONG d->poll_mask = xmalloc_array(unsigned long, BITS_TO_LONGS(MAX_VIRT_CPUS)); if ( !d->poll_mask ) + { + xfree(d->evtchn); return -ENOMEM; + } bitmap_zero(d->poll_mask, MAX_VIRT_CPUS); #endif @@ -1205,6 +1216,8 @@ void evtchn_destroy(struct domain *d) spin_unlock(&d->event_lock); clear_global_virq_handlers(d); + + xfree(d->evtchn); } diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 0ca984d..3070555 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -272,7 +272,7 @@ struct domain spinlock_t rangesets_lock; /* Event channel information. */ - struct evtchn *evtchn[NR_EVTCHN_BUCKETS]; + struct evtchn **evtchn; unsigned max_evtchns; spinlock_t event_lock; const struct evtchn_port_ops *evtchn_port_ops; -- 1.7.2.5