From efda30d5916f8eac538faf59d4338d150e034f1b Mon Sep 17 00:00:00 2001 From: Dario Faggioli Date: Fri, 23 Jun 2017 12:54:52 +0200 Subject: [PATCH] xen: credit2: allocate runqueue data structure dynamically 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 Acked-by: George Dunlap --- 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 b9b928347f..4ae4e4b5d0 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -390,7 +390,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; @@ -3106,9 +3106,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 ) @@ -3118,7 +3120,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; -- 2.30.2