diff mbox series

[v2,6/6] xen/cpupool: Allow cpupool0 to use different scheduler

Message ID 20220310171019.6170-7-luca.fancellu@arm.com (mailing list archive)
State Superseded
Headers show
Series Boot time cpupools | expand

Commit Message

Luca Fancellu March 10, 2022, 5:10 p.m. UTC
Currently cpupool0 can use only the default scheduler, and
cpupool_create has an harcoded behavior when creating the pool 0
that doesn't allocate new memory for the scheduler, but uses the
default scheduler structure in memory.

With this commit it is possible to allocate a different scheduler for
the cpupool0 when using the boot time cpupool.
To achieve this the hardcoded behavior in cpupool_create is removed
and the cpupool0 creation is moved.

When compiling without boot time cpupools enabled, the current
behavior is maintained (except that cpupool0 scheduler memory will be
allocated).

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
---
Changes in v2:
- new patch
---
 xen/common/boot_cpupools.c | 39 ++++++++++++++++++--------------------
 xen/common/sched/cpupool.c |  8 +-------
 xen/include/xen/sched.h    |  5 ++++-
 3 files changed, 23 insertions(+), 29 deletions(-)

Comments

Jürgen Groß March 11, 2022, 8:25 a.m. UTC | #1
On 10.03.22 18:10, Luca Fancellu wrote:
> Currently cpupool0 can use only the default scheduler, and
> cpupool_create has an harcoded behavior when creating the pool 0

Nit: s/harcoded/hardcoded/

> that doesn't allocate new memory for the scheduler, but uses the
> default scheduler structure in memory.
> 
> With this commit it is possible to allocate a different scheduler for
> the cpupool0 when using the boot time cpupool.
> To achieve this the hardcoded behavior in cpupool_create is removed
> and the cpupool0 creation is moved.
> 
> When compiling without boot time cpupools enabled, the current
> behavior is maintained (except that cpupool0 scheduler memory will be
> allocated).
> 
> Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen
diff mbox series

Patch

diff --git a/xen/common/boot_cpupools.c b/xen/common/boot_cpupools.c
index 01a69f894f14..a8ae8c5b7852 100644
--- a/xen/common/boot_cpupools.c
+++ b/xen/common/boot_cpupools.c
@@ -189,31 +189,28 @@  void __init btcpupools_allocate_pools(const cpumask_t *cpu_online_map)
     {
         struct cpupool *pool = NULL;
         int pool_id, sched_id;
+        unsigned int i;
 
         pool_id = pool_cpu_map[cpu_num].pool_id;
         sched_id = pool_cpu_map[cpu_num].sched_id;
 
-        if ( pool_id )
-        {
-            unsigned int i;
-
-            /* Look for previously created pool with id pool_id */
-            for ( i = 0; i < cpu_num; i++ )
-                if ( (pool_cpu_map[i].pool_id == pool_id) &&
-                     pool_cpu_map[i].pool )
-                {
-                    pool = pool_cpu_map[i].pool;
-                    break;
-                }
-
-            /* If no pool was created before, create it */
-            if ( !pool )
-                pool = cpupool_create_pool(pool_id, sched_id);
-            if ( !pool )
-                panic("Error creating pool id %u!\n", pool_id);
-        }
-        else
-            pool = cpupool0;
+        /* Look for previously created pool with id pool_id */
+        for ( i = 0; i < cpu_num; i++ )
+            if ( (pool_cpu_map[i].pool_id == pool_id) && pool_cpu_map[i].pool )
+            {
+                pool = pool_cpu_map[i].pool;
+                break;
+            }
+
+        /* If no pool was created before, create it */
+        if ( !pool )
+            pool = cpupool_create_pool(pool_id, sched_id);
+        if ( !pool )
+            panic("Error creating pool id %u!\n", pool_id);
+
+        /* Keep track of cpupool id 0 with the global cpupool0 */
+        if ( !pool_id )
+            cpupool0 = pool;
 
         pool_cpu_map[cpu_num].pool = pool;
         printk(XENLOG_INFO "Logical CPU %u in Pool-%u.\n", cpu_num, pool_id);
diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c
index b2495ad6d03e..3d458a4932b2 100644
--- a/xen/common/sched/cpupool.c
+++ b/xen/common/sched/cpupool.c
@@ -312,10 +312,7 @@  static struct cpupool *cpupool_create(unsigned int poolid,
         c->cpupool_id = q->cpupool_id + 1;
     }
 
-    if ( poolid == 0 )
-        c->sched = scheduler_get_default();
-    else
-        c->sched = scheduler_alloc(sched_id);
+    c->sched = scheduler_alloc(sched_id);
     if ( IS_ERR(c->sched) )
     {
         ret = PTR_ERR(c->sched);
@@ -1242,9 +1239,6 @@  static int __init cf_check cpupool_init(void)
 
     cpupool_hypfs_init();
 
-    cpupool0 = cpupool_create(0, 0);
-    BUG_ON(IS_ERR(cpupool0));
-    cpupool_put(cpupool0);
     register_cpu_notifier(&cpu_nfb);
 
     btcpupools_dtb_parse();
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 30a6538452bc..4007a3df4c1c 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -1188,7 +1188,10 @@  static inline void btcpupools_dtb_parse(void) {}
 #endif
 
 #else
-static inline void btcpupools_allocate_pools(const cpumask_t *cpu_online_map) {}
+static inline void btcpupools_allocate_pools(const cpumask_t *cpu_online_map)
+{
+    cpupool0 = cpupool_create_pool(0, -1);
+}
 static inline void btcpupools_dtb_parse(void) {}
 static inline struct cpupool *btcpupools_get_cpupool(unsigned int cpu)
 {