]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
xen: credit2: allocate runqueue data structure dynamically
authorDario Faggioli <dario.faggioli@citrix.com>
Fri, 23 Jun 2017 10:54:52 +0000 (12:54 +0200)
committerGeorge Dunlap <george.dunlap@citrix.com>
Fri, 21 Jul 2017 17:21:23 +0000 (18:21 +0100)
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@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
xen/common/sched_credit2.c

index b9b928347f89fadfd8049b357c725c16c55bec69..4ae4e4b5d01c6632111766900e0e9374b706ab57 100644 (file)
@@ -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;