This way we can arrange for core_parking_{performance,power}()'s ENDBR
to also be zapped.
For the decision to be taken before the 2nd alternative patching pass,
the initcall needs to become a pre-SMP one, though.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/common/core_parking.c
+++ b/xen/common/core_parking.c
@@ -30,10 +30,11 @@ 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 const struct cp_policy {
+struct cp_policy {
char name[30];
unsigned int (*next)(unsigned int event);
-} *__read_mostly core_parking_policy;
+};
+static struct cp_policy __ro_after_init core_parking_policy;
static enum core_parking_controller {
POWER_FIRST,
@@ -175,12 +176,13 @@ long cf_check core_parking_helper(void *
unsigned int cpu;
int ret = 0;
- if ( !core_parking_policy )
+ if ( !core_parking_policy.next )
return -EINVAL;
while ( cur_idle_nums < idle_nums )
{
- cpu = core_parking_policy->next(CORE_PARKING_INCREMENT);
+ cpu = alternative_call(core_parking_policy.next,
+ CORE_PARKING_INCREMENT);
ret = cpu_down(cpu);
if ( ret )
return ret;
@@ -193,7 +195,8 @@ long cf_check core_parking_helper(void *
while ( cur_idle_nums > idle_nums )
{
- cpu = core_parking_policy->next(CORE_PARKING_DECREMENT);
+ cpu = alternative_call(core_parking_policy.next,
+ CORE_PARKING_DECREMENT);
ret = cpu_up(cpu);
if ( ret )
return ret;
@@ -239,12 +242,12 @@ uint32_t get_cur_idle_nums(void)
return cur_idle_nums;
}
-static const struct cp_policy power_first = {
+static const struct cp_policy __initconst_cf_clobber power_first = {
.name = "power",
.next = core_parking_power,
};
-static const struct cp_policy performance_first = {
+static const struct cp_policy __initconst_cf_clobber performance_first = {
.name = "performance",
.next = core_parking_performance,
};
@@ -254,7 +257,7 @@ static int __init register_core_parking_
if ( !policy || !policy->next )
return -EINVAL;
- core_parking_policy = policy;
+ core_parking_policy = *policy;
return 0;
}
@@ -269,4 +272,4 @@ static int __init cf_check core_parking_
return ret;
}
-__initcall(core_parking_init);
+presmp_initcall(core_parking_init);
On 17/01/2024 9:29 am, Jan Beulich wrote: > This way we can arrange for core_parking_{performance,power}()'s ENDBR > to also be zapped. > > For the decision to be taken before the 2nd alternative patching pass, > the initcall needs to become a pre-SMP one, though. > > Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
© 2016 - 2024 Red Hat, Inc.