From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: [RFC PATCH V4 03/18] Dynamically allocate d->evtchn Date: Tue, 5 Mar 2013 12:30:25 +0000 Message-ID: <1362486640-14707-4-git-send-email-wei.liu2@citrix.com> References: <1362486640-14707-1-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1362486640-14707-1-git-send-email-wei.liu2@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@xen.org, ian.campbell@citrix.com, jbeulich@suse.com, david.vrabel@citrix.com List-Id: xen-devel@lists.xenproject.org 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 --- xen/common/event_channel.c | 14 ++++++++++++++ xen/include/xen/sched.h | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index dabfa9e..6cb082e 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -1172,15 +1172,27 @@ void notify_via_xen_event_channel(struct domain *ld, int lport) int evtchn_init(struct domain *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 @@ -1214,6 +1226,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 ae3cd07..f869cf1 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -260,7 +260,7 @@ struct domain spinlock_t rangesets_lock; /* Event channel information. */ - struct evtchn *evtchn[NR_EVTCHN_BUCKETS]; + struct evtchn **evtchn; spinlock_t event_lock; struct grant_table *grant_table; -- 1.7.10.4