|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] core-parking: shrink core_parking_cpunum[]
commit 5bfd96ddc650513d2ba5b123a3d214e789f96df1
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Mar 11 10:00:46 2026 +0100
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Mar 11 10:00:46 2026 +0100
core-parking: shrink core_parking_cpunum[]
This NR_CPUS-dimensioned array is likely unused on most installations.
Therefore it is especially wasteful for it to consume more space than
really needed. Allocate it dynamically ahead of registering the hooks.
Further the array having all fields set to -1 is actually useless. Nothing
relies on it, and core_parking_remove() doesn't restore the sentinel for
vacated slots. Drop the initializers altogether, rather than replacing
them.
Also take the opportunity and update an adjacent variable's type, where
a fixed-width type was pretty clearly inappropriate to use.
Finally drop the redundant initializer from core_parking_init().
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
xen/common/core_parking.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/xen/common/core_parking.c b/xen/common/core_parking.c
index 7d6a18cdcf..08003a536f 100644
--- a/xen/common/core_parking.c
+++ b/xen/common/core_parking.c
@@ -20,6 +20,7 @@
#include <xen/cpumask.h>
#include <xen/init.h>
#include <xen/param.h>
+#include <xen/xvmalloc.h>
#include <asm/smp.h>
@@ -27,8 +28,8 @@
#define CORE_PARKING_DECREMENT 2
static DEFINE_SPINLOCK(accounting_lock);
-static uint32_t cur_idle_nums;
-static unsigned int core_parking_cpunum[NR_CPUS] = {[0 ... NR_CPUS-1] = -1};
+static unsigned int cur_idle_nums;
+static unsigned int *__ro_after_init core_parking_cpunum;
struct cp_policy {
char name[30];
@@ -188,7 +189,7 @@ long cf_check core_parking_helper(void *data)
return ret;
spin_lock(&accounting_lock);
- BUG_ON(cur_idle_nums >= ARRAY_SIZE(core_parking_cpunum));
+ BUG_ON(cur_idle_nums >= nr_cpu_ids);
core_parking_cpunum[cur_idle_nums++] = cpu;
spin_unlock(&accounting_lock);
}
@@ -263,9 +264,12 @@ static int __init register_core_parking_policy(const
struct cp_policy *policy)
static int __init cf_check core_parking_init(void)
{
- int ret = 0;
+ int ret;
- if ( core_parking_controller == PERFORMANCE_FIRST )
+ core_parking_cpunum = xvzalloc_array(unsigned int, nr_cpu_ids);
+ if ( !core_parking_cpunum )
+ ret = -ENOMEM;
+ else if ( core_parking_controller == PERFORMANCE_FIRST )
ret = register_core_parking_policy(&performance_first);
else
ret = register_core_parking_policy(&power_first);
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |