Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq

* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq:
[CPUFREQ] cpufreq: remove CVS keywords
[CPUFREQ] change cpu freq arrays to per_cpu variables

+42 -43
-1
arch/x86/kernel/cpu/cpufreq/powernow-k7.h
··· 1 1 /* 2 - * $Id: powernow-k7.h,v 1.2 2003/02/10 18:26:01 davej Exp $ 3 2 * (C) 2003 Dave Jones. 4 3 * 5 4 * Licensed under the terms of the GNU GPL License version 2.
+24 -21
drivers/cpufreq/cpufreq.c
··· 38 38 * also protects the cpufreq_cpu_data array. 39 39 */ 40 40 static struct cpufreq_driver *cpufreq_driver; 41 - static struct cpufreq_policy *cpufreq_cpu_data[NR_CPUS]; 41 + static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); 42 42 #ifdef CONFIG_HOTPLUG_CPU 43 43 /* This one keeps track of the previously set governor of a removed CPU */ 44 - static struct cpufreq_governor *cpufreq_cpu_governor[NR_CPUS]; 44 + static DEFINE_PER_CPU(struct cpufreq_governor *, cpufreq_cpu_governor); 45 45 #endif 46 46 static DEFINE_SPINLOCK(cpufreq_driver_lock); 47 47 ··· 135 135 struct cpufreq_policy *data; 136 136 unsigned long flags; 137 137 138 - if (cpu >= NR_CPUS) 138 + if (cpu >= nr_cpu_ids) 139 139 goto err_out; 140 140 141 141 /* get the cpufreq driver */ ··· 149 149 150 150 151 151 /* get the CPU */ 152 - data = cpufreq_cpu_data[cpu]; 152 + data = per_cpu(cpufreq_cpu_data, cpu); 153 153 154 154 if (!data) 155 155 goto err_out_put_module; ··· 327 327 dprintk("notification %u of frequency transition to %u kHz\n", 328 328 state, freqs->new); 329 329 330 - policy = cpufreq_cpu_data[freqs->cpu]; 330 + policy = per_cpu(cpufreq_cpu_data, freqs->cpu); 331 331 switch (state) { 332 332 333 333 case CPUFREQ_PRECHANGE: ··· 828 828 #ifdef CONFIG_SMP 829 829 830 830 #ifdef CONFIG_HOTPLUG_CPU 831 - if (cpufreq_cpu_governor[cpu]){ 832 - policy->governor = cpufreq_cpu_governor[cpu]; 831 + if (per_cpu(cpufreq_cpu_governor, cpu)) { 832 + policy->governor = per_cpu(cpufreq_cpu_governor, cpu); 833 833 dprintk("Restoring governor %s for cpu %d\n", 834 834 policy->governor->name, cpu); 835 835 } ··· 854 854 855 855 spin_lock_irqsave(&cpufreq_driver_lock, flags); 856 856 managed_policy->cpus = policy->cpus; 857 - cpufreq_cpu_data[cpu] = managed_policy; 857 + per_cpu(cpufreq_cpu_data, cpu) = managed_policy; 858 858 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 859 859 860 860 dprintk("CPU already managed, adding link\n"); ··· 899 899 900 900 spin_lock_irqsave(&cpufreq_driver_lock, flags); 901 901 for_each_cpu_mask(j, policy->cpus) { 902 - cpufreq_cpu_data[j] = policy; 902 + per_cpu(cpufreq_cpu_data, j) = policy; 903 903 per_cpu(policy_cpu, j) = policy->cpu; 904 904 } 905 905 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); ··· 946 946 err_out_unregister: 947 947 spin_lock_irqsave(&cpufreq_driver_lock, flags); 948 948 for_each_cpu_mask(j, policy->cpus) 949 - cpufreq_cpu_data[j] = NULL; 949 + per_cpu(cpufreq_cpu_data, j) = NULL; 950 950 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 951 951 952 952 kobject_put(&policy->kobj); ··· 989 989 dprintk("unregistering CPU %u\n", cpu); 990 990 991 991 spin_lock_irqsave(&cpufreq_driver_lock, flags); 992 - data = cpufreq_cpu_data[cpu]; 992 + data = per_cpu(cpufreq_cpu_data, cpu); 993 993 994 994 if (!data) { 995 995 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); ··· 997 997 unlock_policy_rwsem_write(cpu); 998 998 return -EINVAL; 999 999 } 1000 - cpufreq_cpu_data[cpu] = NULL; 1000 + per_cpu(cpufreq_cpu_data, cpu) = NULL; 1001 1001 1002 1002 1003 1003 #ifdef CONFIG_SMP ··· 1019 1019 #ifdef CONFIG_SMP 1020 1020 1021 1021 #ifdef CONFIG_HOTPLUG_CPU 1022 - cpufreq_cpu_governor[cpu] = data->governor; 1022 + per_cpu(cpufreq_cpu_governor, cpu) = data->governor; 1023 1023 #endif 1024 1024 1025 1025 /* if we have other CPUs still registered, we need to unlink them, 1026 1026 * or else wait_for_completion below will lock up. Clean the 1027 - * cpufreq_cpu_data[] while holding the lock, and remove the sysfs 1028 - * links afterwards. 1027 + * per_cpu(cpufreq_cpu_data) while holding the lock, and remove 1028 + * the sysfs links afterwards. 1029 1029 */ 1030 1030 if (unlikely(cpus_weight(data->cpus) > 1)) { 1031 1031 for_each_cpu_mask(j, data->cpus) { 1032 1032 if (j == cpu) 1033 1033 continue; 1034 - cpufreq_cpu_data[j] = NULL; 1034 + per_cpu(cpufreq_cpu_data, j) = NULL; 1035 1035 } 1036 1036 } 1037 1037 ··· 1043 1043 continue; 1044 1044 dprintk("removing link for cpu %u\n", j); 1045 1045 #ifdef CONFIG_HOTPLUG_CPU 1046 - cpufreq_cpu_governor[j] = data->governor; 1046 + per_cpu(cpufreq_cpu_governor, j) = data->governor; 1047 1047 #endif 1048 1048 cpu_sys_dev = get_cpu_sysdev(j); 1049 1049 sysfs_remove_link(&cpu_sys_dev->kobj, "cpufreq"); ··· 1153 1153 1154 1154 static unsigned int __cpufreq_get(unsigned int cpu) 1155 1155 { 1156 - struct cpufreq_policy *policy = cpufreq_cpu_data[cpu]; 1156 + struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); 1157 1157 unsigned int ret_freq = 0; 1158 1158 1159 1159 if (!cpufreq_driver->get) ··· 1822 1822 cpufreq_driver = driver_data; 1823 1823 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 1824 1824 1825 - ret = sysdev_driver_register(&cpu_sysdev_class,&cpufreq_sysdev_driver); 1825 + ret = sysdev_driver_register(&cpu_sysdev_class, 1826 + &cpufreq_sysdev_driver); 1826 1827 1827 1828 if ((!ret) && !(cpufreq_driver->flags & CPUFREQ_STICKY)) { 1828 1829 int i; 1829 1830 ret = -ENODEV; 1830 1831 1831 1832 /* check for at least one working CPU */ 1832 - for (i=0; i<NR_CPUS; i++) 1833 - if (cpufreq_cpu_data[i]) 1833 + for (i = 0; i < nr_cpu_ids; i++) 1834 + if (cpu_possible(i) && per_cpu(cpufreq_cpu_data, i)) { 1834 1835 ret = 0; 1836 + break; 1837 + } 1835 1838 1836 1839 /* if all ->init() calls failed, unregister */ 1837 1840 if (ret) {
+12 -12
drivers/cpufreq/cpufreq_stats.c
··· 43 43 #endif 44 44 }; 45 45 46 - static struct cpufreq_stats *cpufreq_stats_table[NR_CPUS]; 46 + static DEFINE_PER_CPU(struct cpufreq_stats *, cpufreq_stats_table); 47 47 48 48 struct cpufreq_stats_attribute { 49 49 struct attribute attr; ··· 58 58 59 59 cur_time = get_jiffies_64(); 60 60 spin_lock(&cpufreq_stats_lock); 61 - stat = cpufreq_stats_table[cpu]; 61 + stat = per_cpu(cpufreq_stats_table, cpu); 62 62 if (stat->time_in_state) 63 63 stat->time_in_state[stat->last_index] = 64 64 cputime64_add(stat->time_in_state[stat->last_index], ··· 71 71 static ssize_t 72 72 show_total_trans(struct cpufreq_policy *policy, char *buf) 73 73 { 74 - struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu]; 74 + struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); 75 75 if (!stat) 76 76 return 0; 77 77 return sprintf(buf, "%d\n", 78 - cpufreq_stats_table[stat->cpu]->total_trans); 78 + per_cpu(cpufreq_stats_table, stat->cpu)->total_trans); 79 79 } 80 80 81 81 static ssize_t ··· 83 83 { 84 84 ssize_t len = 0; 85 85 int i; 86 - struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu]; 86 + struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); 87 87 if (!stat) 88 88 return 0; 89 89 cpufreq_stats_update(stat->cpu); ··· 101 101 ssize_t len = 0; 102 102 int i, j; 103 103 104 - struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu]; 104 + struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, policy->cpu); 105 105 if (!stat) 106 106 return 0; 107 107 cpufreq_stats_update(stat->cpu); ··· 170 170 171 171 static void cpufreq_stats_free_table(unsigned int cpu) 172 172 { 173 - struct cpufreq_stats *stat = cpufreq_stats_table[cpu]; 173 + struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, cpu); 174 174 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); 175 175 if (policy && policy->cpu == cpu) 176 176 sysfs_remove_group(&policy->kobj, &stats_attr_group); ··· 178 178 kfree(stat->time_in_state); 179 179 kfree(stat); 180 180 } 181 - cpufreq_stats_table[cpu] = NULL; 181 + per_cpu(cpufreq_stats_table, cpu) = NULL; 182 182 if (policy) 183 183 cpufreq_cpu_put(policy); 184 184 } ··· 192 192 struct cpufreq_policy *data; 193 193 unsigned int alloc_size; 194 194 unsigned int cpu = policy->cpu; 195 - if (cpufreq_stats_table[cpu]) 195 + if (per_cpu(cpufreq_stats_table, cpu)) 196 196 return -EBUSY; 197 197 if ((stat = kzalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL) 198 198 return -ENOMEM; ··· 207 207 goto error_out; 208 208 209 209 stat->cpu = cpu; 210 - cpufreq_stats_table[cpu] = stat; 210 + per_cpu(cpufreq_stats_table, cpu) = stat; 211 211 212 212 for (i=0; table[i].frequency != CPUFREQ_TABLE_END; i++) { 213 213 unsigned int freq = table[i].frequency; ··· 251 251 cpufreq_cpu_put(data); 252 252 error_get_fail: 253 253 kfree(stat); 254 - cpufreq_stats_table[cpu] = NULL; 254 + per_cpu(cpufreq_stats_table, cpu) = NULL; 255 255 return ret; 256 256 } 257 257 ··· 284 284 if (val != CPUFREQ_POSTCHANGE) 285 285 return 0; 286 286 287 - stat = cpufreq_stats_table[freq->cpu]; 287 + stat = per_cpu(cpufreq_stats_table, freq->cpu); 288 288 if (!stat) 289 289 return 0; 290 290
+6 -6
drivers/cpufreq/freq_table.c
··· 174 174 } 175 175 EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target); 176 176 177 - static struct cpufreq_frequency_table *show_table[NR_CPUS]; 177 + static DEFINE_PER_CPU(struct cpufreq_frequency_table *, show_table); 178 178 /** 179 179 * show_available_freqs - show available frequencies for the specified CPU 180 180 */ ··· 185 185 ssize_t count = 0; 186 186 struct cpufreq_frequency_table *table; 187 187 188 - if (!show_table[cpu]) 188 + if (!per_cpu(show_table, cpu)) 189 189 return -ENODEV; 190 190 191 - table = show_table[cpu]; 191 + table = per_cpu(show_table, cpu); 192 192 193 193 for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { 194 194 if (table[i].frequency == CPUFREQ_ENTRY_INVALID) ··· 217 217 unsigned int cpu) 218 218 { 219 219 dprintk("setting show_table for cpu %u to %p\n", cpu, table); 220 - show_table[cpu] = table; 220 + per_cpu(show_table, cpu) = table; 221 221 } 222 222 EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_attr); 223 223 224 224 void cpufreq_frequency_table_put_attr(unsigned int cpu) 225 225 { 226 226 dprintk("clearing show_table for cpu %u\n", cpu); 227 - show_table[cpu] = NULL; 227 + per_cpu(show_table, cpu) = NULL; 228 228 } 229 229 EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr); 230 230 231 231 struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu) 232 232 { 233 - return show_table[cpu]; 233 + return per_cpu(show_table, cpu); 234 234 } 235 235 EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table); 236 236
-3
include/linux/cpufreq.h
··· 4 4 * Copyright (C) 2001 Russell King 5 5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 6 6 * 7 - * 8 - * $Id: cpufreq.h,v 1.36 2003/01/20 17:31:48 db Exp $ 9 - * 10 7 * This program is free software; you can redistribute it and/or modify 11 8 * it under the terms of the GNU General Public License version 2 as 12 9 * published by the Free Software Foundation.