[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [RFC PATCH V3 02/22] Dynamically allocate d->evtchn



>>> On 27.02.13 at 15:33, Wei Liu <wei.liu2@xxxxxxxxxx> wrote:
> --- a/xen/common/event_channel.c
> +++ b/xen/common/event_channel.c
> @@ -1172,15 +1172,26 @@ 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 = alloc_xenheap_page();

You may not have monitored other changes that were done
meanwhile. With fb034f42648ecac835a1666def468f673edd2725,
please use xmalloc_array() here (but keep the BUILD_BUG_ON()).

> +
> +    if ( d->evtchn == NULL )
> +        return -ENOMEM;
> +    clear_page(d->evtchn);
> +
>      spin_lock_init(&d->event_lock);
> -    if ( get_free_port(d) != 0 )
> +    if ( get_free_port(d) != 0 ) {

The opening brace belongs on its own line.

> +        free_xenheap_page(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 )
> +    if ( !d->poll_mask ) {

And here again. Please also check your other patches whether
there are further instances of this.

Jan

> +        free_xenheap_page(d->evtchn);
>          return -ENOMEM;
> +    }
>      bitmap_zero(d->poll_mask, MAX_VIRT_CPUS);
>  #endif
>  
> @@ -1214,6 +1225,8 @@ void evtchn_destroy(struct domain *d)
>      spin_unlock(&d->event_lock);
>  
>      clear_global_virq_handlers(d);
> +
> +    free_xenheap_page(d->evtchn);
>  }
>  
>  
> diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
> index f6846d4..812bd87 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




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.