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

Re: [Xen-devel] [PATCH 1/6] xen: credit2: allocate runqueue data structure dynamically



On 06/23/2017 11:54 AM, Dario Faggioli wrote:
> Instead of keeping an NR_CPUS big array of csched2_runqueue_data
> elements, directly inside the csched2_private structure, allocate
> it dynamically.
> 
> This has two positive effects:
> - reduces the size of csched2_private sensibly, which is
>   especially good in case there are more instance of Credit2
>   (in different cpupools), and is also good from the point
>   of view of fitting the struct into CPU caches;
> - we can use nr_cpu_ids as array size, which may be sensibly
>   smaller than NR_CPUS
> 
> Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>

Looks good, thanks:

Acked-by: George Dunlap <george.dunlap@xxxxxxxxxx>



> ---
> Cc: George Dunlap <george.dunlap@xxxxxxxxxx>
> Cc: Anshul Makkar <anshulmakkar@xxxxxxxxx>
> ---
>  xen/common/sched_credit2.c |   16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
> index 126417c..10d9488 100644
> --- a/xen/common/sched_credit2.c
> +++ b/xen/common/sched_credit2.c
> @@ -385,7 +385,7 @@ struct csched2_private {
>  
>      int runq_map[NR_CPUS];
>      cpumask_t active_queues; /* Queues which may have active cpus */
> -    struct csched2_runqueue_data rqd[NR_CPUS];
> +    struct csched2_runqueue_data *rqd;
>  
>      unsigned int load_precision_shift;
>      unsigned int load_window_shift;
> @@ -3099,9 +3099,11 @@ csched2_init(struct scheduler *ops)
>      printk(XENLOG_INFO "load tracking window length %llu ns\n",
>             1ULL << opt_load_window_shift);
>  
> -    /* Basically no CPU information is available at this point; just
> +    /*
> +     * Basically no CPU information is available at this point; just
>       * set up basic structures, and a callback when the CPU info is
> -     * available. */
> +     * available.
> +     */
>  
>      prv = xzalloc(struct csched2_private);
>      if ( prv == NULL )
> @@ -3111,7 +3113,13 @@ csched2_init(struct scheduler *ops)
>      rwlock_init(&prv->lock);
>      INIT_LIST_HEAD(&prv->sdom);
>  
> -    /* But un-initialize all runqueues */
> +    /* Allocate all runqueues and mark them as un-initialized */
> +    prv->rqd = xzalloc_array(struct csched2_runqueue_data, nr_cpu_ids);
> +    if ( !prv->rqd )
> +    {
> +        xfree(prv);
> +        return -ENOMEM;
> +    }
>      for ( i = 0; i < nr_cpu_ids; i++ )
>      {
>          prv->runq_map[i] = -1;
> 


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

 


Rackspace

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