[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 11/12] cpufreq: convert to a single post-init driver (hooks) instance
This reduces the post-init memory footprint, eliminates a pointless level of indirection at the use sites, and allows for subsequent alternatives call patching. Take the opportunity and also add a name to the PowerNow! instance. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> --- v2: New. --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c @@ -53,8 +53,6 @@ enum { struct acpi_cpufreq_data *cpufreq_drv_data[NR_CPUS]; -static struct cpufreq_driver acpi_cpufreq_driver; - static bool __read_mostly acpi_pstate_strict; boolean_param("acpi_pstate_strict", acpi_pstate_strict); @@ -355,7 +353,7 @@ static void feature_detect(void *info) if ( cpu_has_aperfmperf ) { policy->aperf_mperf = 1; - acpi_cpufreq_driver.getavg = get_measured_perf; + cpufreq_driver.getavg = get_measured_perf; } eax = cpuid_eax(6); @@ -593,7 +591,7 @@ acpi_cpufreq_cpu_init(struct cpufreq_pol policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu); break; case ACPI_ADR_SPACE_FIXED_HARDWARE: - acpi_cpufreq_driver.get = get_cur_freq_on_cpu; + cpufreq_driver.get = get_cur_freq_on_cpu; policy->cur = get_cur_freq_on_cpu(cpu); break; default: @@ -635,7 +633,7 @@ static int acpi_cpufreq_cpu_exit(struct return 0; } -static struct cpufreq_driver acpi_cpufreq_driver = { +static const struct cpufreq_driver __initconstrel acpi_cpufreq_driver = { .name = "acpi-cpufreq", .verify = acpi_cpufreq_verify, .target = acpi_cpufreq_target, @@ -656,7 +654,7 @@ static int __init cpufreq_driver_init(vo return ret; } -__initcall(cpufreq_driver_init); +presmp_initcall(cpufreq_driver_init); int cpufreq_cpu_init(unsigned int cpuid) { --- a/xen/arch/x86/acpi/cpufreq/powernow.c +++ b/xen/arch/x86/acpi/cpufreq/powernow.c @@ -52,8 +52,6 @@ #define ARCH_CPU_FLAG_RESUME 1 -static struct cpufreq_driver powernow_cpufreq_driver; - static void transition_pstate(void *pstate) { wrmsrl(MSR_PSTATE_CTRL, *(unsigned int *)pstate); @@ -215,7 +213,7 @@ static void feature_detect(void *info) if ( cpu_has_aperfmperf ) { policy->aperf_mperf = 1; - powernow_cpufreq_driver.getavg = get_measured_perf; + cpufreq_driver.getavg = get_measured_perf; } edx = cpuid_edx(CPUID_FREQ_VOLT_CAPABILITIES); @@ -347,7 +345,8 @@ static int powernow_cpufreq_cpu_exit(str return 0; } -static struct cpufreq_driver powernow_cpufreq_driver = { +static const struct cpufreq_driver __initconstrel powernow_cpufreq_driver = { + .name = "powernow", .verify = powernow_cpufreq_verify, .target = powernow_cpufreq_target, .init = powernow_cpufreq_cpu_init, --- a/xen/drivers/acpi/pmstat.c +++ b/xen/drivers/acpi/pmstat.c @@ -64,7 +64,7 @@ int do_get_pm_info(struct xen_sysctl_get case PMSTAT_PX: if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_PX) ) return -ENODEV; - if ( !cpufreq_driver ) + if ( !cpufreq_driver.init ) return -ENODEV; if ( !pmpt || !(pmpt->perf.init & XEN_PX_INIT) ) return -EINVAL; @@ -255,16 +255,16 @@ static int get_cpufreq_para(struct xen_s return ret; op->u.get_para.cpuinfo_cur_freq = - cpufreq_driver->get ? cpufreq_driver->get(op->cpuid) : policy->cur; + cpufreq_driver.get ? cpufreq_driver.get(op->cpuid) : policy->cur; op->u.get_para.cpuinfo_max_freq = policy->cpuinfo.max_freq; op->u.get_para.cpuinfo_min_freq = policy->cpuinfo.min_freq; op->u.get_para.scaling_cur_freq = policy->cur; op->u.get_para.scaling_max_freq = policy->max; op->u.get_para.scaling_min_freq = policy->min; - if ( cpufreq_driver->name[0] ) + if ( cpufreq_driver.name[0] ) strlcpy(op->u.get_para.scaling_driver, - cpufreq_driver->name, CPUFREQ_NAME_LEN); + cpufreq_driver.name, CPUFREQ_NAME_LEN); else strlcpy(op->u.get_para.scaling_driver, "Unknown", CPUFREQ_NAME_LEN); --- a/xen/drivers/cpufreq/cpufreq.c +++ b/xen/drivers/cpufreq/cpufreq.c @@ -172,7 +172,7 @@ int cpufreq_add_cpu(unsigned int cpu) if ( !(perf->init & XEN_PX_INIT) ) return -EINVAL; - if (!cpufreq_driver) + if (!cpufreq_driver.init) return 0; if (per_cpu(cpufreq_cpu_policy, cpu)) @@ -239,7 +239,7 @@ int cpufreq_add_cpu(unsigned int cpu) policy->cpu = cpu; per_cpu(cpufreq_cpu_policy, cpu) = policy; - ret = cpufreq_driver->init(policy); + ret = cpufreq_driver.init(policy); if (ret) { free_cpumask_var(policy->cpus); xfree(policy); @@ -298,7 +298,7 @@ err1: cpumask_clear_cpu(cpu, cpufreq_dom->map); if (cpumask_empty(policy->cpus)) { - cpufreq_driver->exit(policy); + cpufreq_driver.exit(policy); free_cpumask_var(policy->cpus); xfree(policy); } @@ -362,7 +362,7 @@ int cpufreq_del_cpu(unsigned int cpu) cpumask_clear_cpu(cpu, cpufreq_dom->map); if (cpumask_empty(policy->cpus)) { - cpufreq_driver->exit(policy); + cpufreq_driver.exit(policy); free_cpumask_var(policy->cpus); xfree(policy); } @@ -663,17 +663,17 @@ static int __init cpufreq_presmp_init(vo } presmp_initcall(cpufreq_presmp_init); -int __init cpufreq_register_driver(struct cpufreq_driver *driver_data) +int __init cpufreq_register_driver(const struct cpufreq_driver *driver_data) { if ( !driver_data || !driver_data->init || !driver_data->verify || !driver_data->exit || (!driver_data->target == !driver_data->setpolicy) ) return -EINVAL; - if ( cpufreq_driver ) + if ( cpufreq_driver.init ) return -EBUSY; - cpufreq_driver = driver_data; + cpufreq_driver = *driver_data; return 0; } --- a/xen/drivers/cpufreq/utility.c +++ b/xen/drivers/cpufreq/utility.c @@ -31,7 +31,7 @@ #include <acpi/cpufreq/cpufreq.h> #include <public/sysctl.h> -struct cpufreq_driver *cpufreq_driver; +struct cpufreq_driver __read_mostly cpufreq_driver; struct processor_pminfo *__read_mostly processor_pminfo[NR_CPUS]; DEFINE_PER_CPU_READ_MOSTLY(struct cpufreq_policy *, cpufreq_cpu_policy); @@ -360,11 +360,11 @@ int __cpufreq_driver_target(struct cpufr { int retval = -EINVAL; - if (cpu_online(policy->cpu) && cpufreq_driver->target) + if (cpu_online(policy->cpu) && cpufreq_driver.target) { unsigned int prev_freq = policy->cur; - retval = cpufreq_driver->target(policy, target_freq, relation); + retval = cpufreq_driver.target(policy, target_freq, relation); if ( retval == 0 ) TRACE_2D(TRC_PM_FREQ_CHANGE, prev_freq/1000, policy->cur/1000); } @@ -380,9 +380,9 @@ int cpufreq_driver_getavg(unsigned int c if (!cpu_online(cpu) || !(policy = per_cpu(cpufreq_cpu_policy, cpu))) return 0; - if (cpufreq_driver->getavg) + if (cpufreq_driver.getavg) { - freq_avg = cpufreq_driver->getavg(cpu, flag); + freq_avg = cpufreq_driver.getavg(cpu, flag); if (freq_avg > 0) return freq_avg; } @@ -412,9 +412,9 @@ int cpufreq_update_turbo(int cpuid, int return 0; policy->turbo = new_state; - if (cpufreq_driver->update) + if (cpufreq_driver.update) { - ret = cpufreq_driver->update(cpuid, policy); + ret = cpufreq_driver.update(cpuid, policy); if (ret) policy->turbo = curr_state; } @@ -450,15 +450,15 @@ int __cpufreq_set_policy(struct cpufreq_ return -EINVAL; /* verify the cpu speed can be set within this limit */ - ret = cpufreq_driver->verify(policy); + ret = cpufreq_driver.verify(policy); if (ret) return ret; data->min = policy->min; data->max = policy->max; data->limits = policy->limits; - if (cpufreq_driver->setpolicy) - return cpufreq_driver->setpolicy(data); + if (cpufreq_driver.setpolicy) + return cpufreq_driver.setpolicy(data); if (policy->governor != data->governor) { /* save old, working values */ --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -153,7 +153,7 @@ __cpufreq_governor(struct cpufreq_policy #define CPUFREQ_RELATION_H 1 /* highest frequency below or at target */ struct cpufreq_driver { - char name[CPUFREQ_NAME_LEN]; + const char *name; int (*init)(struct cpufreq_policy *policy); int (*verify)(struct cpufreq_policy *policy); int (*setpolicy)(struct cpufreq_policy *policy); @@ -166,9 +166,9 @@ struct cpufreq_driver { int (*exit)(struct cpufreq_policy *policy); }; -extern struct cpufreq_driver *cpufreq_driver; +extern struct cpufreq_driver cpufreq_driver; -int cpufreq_register_driver(struct cpufreq_driver *); +int cpufreq_register_driver(const struct cpufreq_driver *); static __inline__ void cpufreq_verify_within_limits(struct cpufreq_policy *policy, _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |