[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] cpufreq: eliminate unnecessary NR_CPUS-sized arrays
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1278674681 -3600 # Node ID 2cb6d755a08b2f51ac018bfd82ead1faff82ab52 # Parent e9aaeb8b83b4ba6e5240c2b88f08813b5eb41f55 cpufreq: eliminate unnecessary NR_CPUS-sized arrays Replace them with per-CPU data. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx> --- xen/arch/x86/acpi/cpufreq/cpufreq.c | 15 ++++++++------ xen/drivers/acpi/pmstat.c | 10 ++++----- xen/drivers/cpufreq/cpufreq.c | 28 +++++++++++++-------------- xen/drivers/cpufreq/cpufreq_misc_governors.c | 6 ++--- xen/drivers/cpufreq/cpufreq_ondemand.c | 14 ++++++------- xen/drivers/cpufreq/utility.c | 25 +++++++++++------------- xen/include/acpi/cpufreq/cpufreq.h | 2 - xen/include/acpi/cpufreq/processor_perf.h | 2 - 8 files changed, 52 insertions(+), 50 deletions(-) diff -r e9aaeb8b83b4 -r 2cb6d755a08b xen/arch/x86/acpi/cpufreq/cpufreq.c --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c Fri Jul 09 12:24:15 2010 +0100 +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c Fri Jul 09 12:24:41 2010 +0100 @@ -210,10 +210,10 @@ static u32 get_cur_val(cpumask_t mask) if (!cpu_isset(cpu, mask)) cpu = first_cpu(mask); - if (cpu >= NR_CPUS) - return 0; - - policy = cpufreq_cpu_policy[cpu]; + if (cpu >= NR_CPUS || !cpu_online(cpu)) + return 0; + + policy = per_cpu(cpufreq_cpu_policy, cpu); if (!policy || !drv_data[policy->cpu]) return 0; @@ -281,7 +281,7 @@ unsigned int get_measured_perf(unsigned if (!cpu_online(cpu)) return 0; - policy = cpufreq_cpu_policy[cpu]; + policy = per_cpu(cpufreq_cpu_policy, cpu); if (!policy || !policy->aperf_mperf) return 0; @@ -366,7 +366,10 @@ static unsigned int get_cur_freq_on_cpu( struct acpi_cpufreq_data *data; unsigned int freq; - policy = cpufreq_cpu_policy[cpu]; + if (!cpu_online(cpu)) + return 0; + + policy = per_cpu(cpufreq_cpu_policy, cpu); if (!policy) return 0; diff -r e9aaeb8b83b4 -r 2cb6d755a08b xen/drivers/acpi/pmstat.c --- a/xen/drivers/acpi/pmstat.c Fri Jul 09 12:24:15 2010 +0100 +++ b/xen/drivers/acpi/pmstat.c Fri Jul 09 12:24:41 2010 +0100 @@ -43,7 +43,7 @@ #include <acpi/cpufreq/cpufreq.h> #include <xen/pmstat.h> -struct pm_px *__read_mostly cpufreq_statistic_data[NR_CPUS]; +DEFINE_PER_CPU_READ_MOSTLY(struct pm_px *, cpufreq_statistic_data); extern struct list_head cpufreq_governor_list; @@ -92,7 +92,7 @@ int do_get_pm_info(struct xen_sysctl_get spin_lock(cpufreq_statistic_lock); - pxpt = cpufreq_statistic_data[op->cpuid]; + pxpt = per_cpu(cpufreq_statistic_data, op->cpuid); if ( !pxpt || !pxpt->u.pt || !pxpt->u.trans_pt ) { spin_unlock(cpufreq_statistic_lock); @@ -204,7 +204,7 @@ static int get_cpufreq_para(struct xen_s if ( !op || !cpu_online(op->cpuid) ) return -EINVAL; pmpt = processor_pminfo[op->cpuid]; - policy = cpufreq_cpu_policy[op->cpuid]; + policy = per_cpu(cpufreq_cpu_policy, op->cpuid); if ( !pmpt || !pmpt->perf.states || !policy || !policy->governor ) @@ -313,7 +313,7 @@ static int set_cpufreq_gov(struct xen_sy if ( !op || !cpu_online(op->cpuid) ) return -EINVAL; - old_policy = cpufreq_cpu_policy[op->cpuid]; + old_policy = per_cpu(cpufreq_cpu_policy, op->cpuid); if ( !old_policy ) return -EINVAL; @@ -333,7 +333,7 @@ static int set_cpufreq_para(struct xen_s if ( !op || !cpu_online(op->cpuid) ) return -EINVAL; - policy = cpufreq_cpu_policy[op->cpuid]; + policy = per_cpu(cpufreq_cpu_policy, op->cpuid); if ( !policy || !policy->governor ) return -EINVAL; diff -r e9aaeb8b83b4 -r 2cb6d755a08b xen/drivers/cpufreq/cpufreq.c --- a/xen/drivers/cpufreq/cpufreq.c Fri Jul 09 12:24:15 2010 +0100 +++ b/xen/drivers/cpufreq/cpufreq.c Fri Jul 09 12:24:41 2010 +0100 @@ -90,8 +90,7 @@ int cpufreq_register_governor(struct cpu int cpufreq_unregister_governor(struct cpufreq_governor *governor) { - int cpu = smp_processor_id(); - struct cpufreq_policy *policy = cpufreq_cpu_policy[cpu]; + struct cpufreq_policy *policy = this_cpu(cpufreq_cpu_policy); if (!governor || !policy) return -EINVAL; @@ -110,10 +109,11 @@ int cpufreq_limit_change(unsigned int cp int cpufreq_limit_change(unsigned int cpu) { struct processor_performance *perf = &processor_pminfo[cpu]->perf; - struct cpufreq_policy *data = cpufreq_cpu_policy[cpu]; + struct cpufreq_policy *data; struct cpufreq_policy policy; - if (!cpu_online(cpu) || !data || !processor_pminfo[cpu]) + if (!cpu_online(cpu) || !(data = per_cpu(cpufreq_cpu_policy, cpu)) || + !processor_pminfo[cpu]) return -ENODEV; if ((perf->platform_limit < 0) || @@ -149,7 +149,7 @@ int cpufreq_add_cpu(unsigned int cpu) if (!cpufreq_driver) return 0; - if (cpufreq_cpu_policy[cpu]) + if (per_cpu(cpufreq_cpu_policy, cpu)) return 0; if (perf->shared_type == CPUFREQ_SHARED_TYPE_HW) @@ -200,21 +200,21 @@ int cpufreq_add_cpu(unsigned int cpu) memset(policy, 0, sizeof(struct cpufreq_policy)); policy->cpu = cpu; - cpufreq_cpu_policy[cpu] = policy; + per_cpu(cpufreq_cpu_policy, cpu) = policy; ret = cpufreq_driver->init(policy); if (ret) { xfree(policy); - cpufreq_cpu_policy[cpu] = NULL; + per_cpu(cpufreq_cpu_policy, cpu) = NULL; return ret; } if (cpufreq_verbose) printk("CPU %u initialization completed\n", cpu); } else { firstcpu = first_cpu(cpufreq_dom->map); - policy = cpufreq_cpu_policy[firstcpu]; - - cpufreq_cpu_policy[cpu] = policy; + policy = per_cpu(cpufreq_cpu_policy, firstcpu); + + per_cpu(cpufreq_cpu_policy, cpu) = policy; if (cpufreq_verbose) printk("adding CPU %u\n", cpu); } @@ -255,7 +255,7 @@ err2: err2: cpufreq_statistic_exit(cpu); err1: - cpufreq_cpu_policy[cpu] = NULL; + per_cpu(cpufreq_cpu_policy, cpu) = NULL; cpu_clear(cpu, policy->cpus); cpu_clear(cpu, cpufreq_dom->map); @@ -287,14 +287,14 @@ int cpufreq_del_cpu(unsigned int cpu) !cpu_online(cpu)) return -EINVAL; - if (!cpufreq_cpu_policy[cpu]) + if (!per_cpu(cpufreq_cpu_policy, cpu)) return 0; if (perf->shared_type == CPUFREQ_SHARED_TYPE_HW) hw_all = 1; dom = perf->domain_info.domain; - policy = cpufreq_cpu_policy[cpu]; + policy = per_cpu(cpufreq_cpu_policy, cpu); list_for_each(pos, &cpufreq_dom_list_head) { cpufreq_dom = list_entry(pos, struct cpufreq_dom, node); @@ -314,7 +314,7 @@ int cpufreq_del_cpu(unsigned int cpu) __cpufreq_governor(policy, CPUFREQ_GOV_STOP); cpufreq_statistic_exit(cpu); - cpufreq_cpu_policy[cpu] = NULL; + per_cpu(cpufreq_cpu_policy, cpu) = NULL; cpu_clear(cpu, policy->cpus); cpu_clear(cpu, cpufreq_dom->map); diff -r e9aaeb8b83b4 -r 2cb6d755a08b xen/drivers/cpufreq/cpufreq_misc_governors.c --- a/xen/drivers/cpufreq/cpufreq_misc_governors.c Fri Jul 09 12:24:15 2010 +0100 +++ b/xen/drivers/cpufreq/cpufreq_misc_governors.c Fri Jul 09 12:24:41 2010 +0100 @@ -63,9 +63,9 @@ static int cpufreq_governor_userspace(st int write_userspace_scaling_setspeed(unsigned int cpu, unsigned int freq) { - struct cpufreq_policy *policy = cpufreq_cpu_policy[cpu]; - - if (!cpu_online(cpu) || !policy) + struct cpufreq_policy *policy; + + if (!cpu_online(cpu) || !(policy = per_cpu(cpufreq_cpu_policy, cpu))) return -EINVAL; cpu_set_freq[cpu] = freq; diff -r e9aaeb8b83b4 -r 2cb6d755a08b xen/drivers/cpufreq/cpufreq_ondemand.c --- a/xen/drivers/cpufreq/cpufreq_ondemand.c Fri Jul 09 12:24:15 2010 +0100 +++ b/xen/drivers/cpufreq/cpufreq_ondemand.c Fri Jul 09 12:24:41 2010 +0100 @@ -56,7 +56,7 @@ static struct dbs_tuners { .powersave_bias = 0, }; -static struct timer dbs_timer[NR_CPUS]; +static DEFINE_PER_CPU(struct timer, dbs_timer); int write_ondemand_sampling_rate(unsigned int sampling_rate) { @@ -181,7 +181,7 @@ static void do_dbs_timer(void *dbs) dbs_check_cpu(dbs_info); - set_timer(&dbs_timer[dbs_info->cpu], + set_timer(&per_cpu(dbs_timer, dbs_info->cpu), align_timer(NOW() , dbs_tuners_ins.sampling_rate)); } @@ -189,10 +189,10 @@ static void dbs_timer_init(struct cpu_db { dbs_info->enable = 1; - init_timer(&dbs_timer[dbs_info->cpu], do_dbs_timer, + init_timer(&per_cpu(dbs_timer, dbs_info->cpu), do_dbs_timer, (void *)dbs_info, dbs_info->cpu); - set_timer(&dbs_timer[dbs_info->cpu], NOW()+dbs_tuners_ins.sampling_rate); + set_timer(&per_cpu(dbs_timer, dbs_info->cpu), NOW()+dbs_tuners_ins.sampling_rate); if ( processor_pminfo[dbs_info->cpu]->perf.shared_type == CPUFREQ_SHARED_TYPE_HW ) @@ -205,7 +205,7 @@ static void dbs_timer_exit(struct cpu_db { dbs_info->enable = 0; dbs_info->stoppable = 0; - kill_timer(&dbs_timer[dbs_info->cpu]); + kill_timer(&per_cpu(dbs_timer, dbs_info->cpu)); } int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event) @@ -362,7 +362,7 @@ void cpufreq_dbs_timer_suspend(void) if ( per_cpu(cpu_dbs_info,cpu).stoppable ) { - stop_timer( &dbs_timer[cpu] ); + stop_timer( &per_cpu(dbs_timer, cpu) ); } } @@ -377,7 +377,7 @@ void cpufreq_dbs_timer_resume(void) if ( per_cpu(cpu_dbs_info,cpu).stoppable ) { now = NOW(); - t = &dbs_timer[cpu]; + t = &per_cpu(dbs_timer, cpu); if (t->expires <= now) { t->function(t->data); diff -r e9aaeb8b83b4 -r 2cb6d755a08b xen/drivers/cpufreq/utility.c --- a/xen/drivers/cpufreq/utility.c Fri Jul 09 12:24:15 2010 +0100 +++ b/xen/drivers/cpufreq/utility.c Fri Jul 09 12:24:41 2010 +0100 @@ -34,7 +34,7 @@ struct cpufreq_driver *cpufreq_driver; struct processor_pminfo *__read_mostly processor_pminfo[NR_CPUS]; -struct cpufreq_policy *__read_mostly cpufreq_cpu_policy[NR_CPUS]; +DEFINE_PER_CPU_READ_MOSTLY(struct cpufreq_policy *, cpufreq_cpu_policy); DEFINE_PER_CPU(spinlock_t, cpufreq_statistic_lock); @@ -46,7 +46,7 @@ void cpufreq_residency_update(unsigned i { uint64_t now, total_idle_ns; int64_t delta; - struct pm_px *pxpt = cpufreq_statistic_data[cpu]; + struct pm_px *pxpt = per_cpu(cpufreq_statistic_data, cpu); total_idle_ns = get_cpu_idle_time(cpu); now = NOW(); @@ -70,7 +70,7 @@ void cpufreq_statistic_update(unsigned i spin_lock(cpufreq_statistic_lock); - pxpt = cpufreq_statistic_data[cpu]; + pxpt = per_cpu(cpufreq_statistic_data, cpu); if ( !pxpt || !pmpt ) { spin_unlock(cpufreq_statistic_lock); return; @@ -102,7 +102,7 @@ int cpufreq_statistic_init(unsigned int spin_lock(cpufreq_statistic_lock); - pxpt = cpufreq_statistic_data[cpuid]; + pxpt = per_cpu(cpufreq_statistic_data, cpuid); if ( pxpt ) { spin_unlock(cpufreq_statistic_lock); return 0; @@ -116,7 +116,7 @@ int cpufreq_statistic_init(unsigned int return -ENOMEM; } memset(pxpt, 0, sizeof(*pxpt)); - cpufreq_statistic_data[cpuid] = pxpt; + per_cpu(cpufreq_statistic_data, cpuid) = pxpt; pxpt->u.trans_pt = xmalloc_array(uint64_t, count * count); if (!pxpt->u.trans_pt) { @@ -158,7 +158,7 @@ void cpufreq_statistic_exit(unsigned int spin_lock(cpufreq_statistic_lock); - pxpt = cpufreq_statistic_data[cpuid]; + pxpt = per_cpu(cpufreq_statistic_data, cpuid); if (!pxpt) { spin_unlock(cpufreq_statistic_lock); return; @@ -167,7 +167,7 @@ void cpufreq_statistic_exit(unsigned int xfree(pxpt->u.trans_pt); xfree(pxpt->u.pt); xfree(pxpt); - cpufreq_statistic_data[cpuid] = NULL; + per_cpu(cpufreq_statistic_data, cpuid) = NULL; spin_unlock(cpufreq_statistic_lock); } @@ -182,7 +182,7 @@ void cpufreq_statistic_reset(unsigned in spin_lock(cpufreq_statistic_lock); - pxpt = cpufreq_statistic_data[cpuid]; + pxpt = per_cpu(cpufreq_statistic_data, cpuid); if ( !pmpt || !pxpt || !pxpt->u.pt || !pxpt->u.trans_pt ) { spin_unlock(cpufreq_statistic_lock); return; @@ -382,8 +382,7 @@ int cpufreq_driver_getavg(unsigned int c struct cpufreq_policy *policy; int freq_avg; - policy = cpufreq_cpu_policy[cpu]; - if (!cpu_online(cpu) || !policy) + if (!cpu_online(cpu) || !(policy = per_cpu(cpufreq_cpu_policy, cpu))) return 0; if (cpufreq_driver->getavg) @@ -400,7 +399,7 @@ void cpufreq_enable_turbo(int cpuid) { struct cpufreq_policy *policy; - policy = cpufreq_cpu_policy[cpuid]; + policy = per_cpu(cpufreq_cpu_policy, cpuid); if (policy->turbo != CPUFREQ_TURBO_UNSUPPORTED) policy->turbo = CPUFREQ_TURBO_ENABLED; } @@ -409,7 +408,7 @@ void cpufreq_disable_turbo(int cpuid) { struct cpufreq_policy *policy; - policy = cpufreq_cpu_policy[cpuid]; + policy = per_cpu(cpufreq_cpu_policy, cpuid); if (policy->turbo != CPUFREQ_TURBO_UNSUPPORTED) policy->turbo = CPUFREQ_TURBO_DISABLED; } @@ -418,7 +417,7 @@ int cpufreq_get_turbo_status(int cpuid) { struct cpufreq_policy *policy; - policy = cpufreq_cpu_policy[cpuid]; + policy = per_cpu(cpufreq_cpu_policy, cpuid); return policy->turbo; } diff -r e9aaeb8b83b4 -r 2cb6d755a08b xen/include/acpi/cpufreq/cpufreq.h --- a/xen/include/acpi/cpufreq/cpufreq.h Fri Jul 09 12:24:15 2010 +0100 +++ b/xen/include/acpi/cpufreq/cpufreq.h Fri Jul 09 12:24:41 2010 +0100 @@ -59,7 +59,7 @@ struct cpufreq_policy { * See CPUFREQ_TURBO_* below for defines */ bool_t aperf_mperf; /* CPU has APERF/MPERF MSRs */ }; -extern struct cpufreq_policy *cpufreq_cpu_policy[NR_CPUS]; +DECLARE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_policy); extern int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_policy *policy); diff -r e9aaeb8b83b4 -r 2cb6d755a08b xen/include/acpi/cpufreq/processor_perf.h --- a/xen/include/acpi/cpufreq/processor_perf.h Fri Jul 09 12:24:15 2010 +0100 +++ b/xen/include/acpi/cpufreq/processor_perf.h Fri Jul 09 12:24:41 2010 +0100 @@ -58,7 +58,7 @@ struct pm_px { uint64_t prev_idle_wall; }; -extern struct pm_px *cpufreq_statistic_data[NR_CPUS]; +DECLARE_PER_CPU(struct pm_px *, cpufreq_statistic_data); int cpufreq_cpu_init(unsigned int cpuid); #endif /* __XEN_PROCESSOR_PM_H__ */ _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |