Commit 8aa84ad8d6c740a04386f599694609ee4998e82e
Committed by
Dave Jones
1 parent
4bfa042cd3
Exists in
master
and in
7 other branches
[CPUFREQ] Introduce global, not per core: /sys/devices/system/cpu/cpufreq
Currently everything in the cpufreq layer is per core based. This does not reflect reality, for example ondemand on conservative governors have global sysfs variables. Introduce a global cpufreq directory and add the kobject to the governor struct, so that governors can easily access it. The directory is initialized in the cpufreq_core_init initcall and thus will always be created if cpufreq is compiled in, even if no cpufreq driver is active later. Signed-off-by: Thomas Renninger <trenn@suse.de> Signed-off-by: Dave Jones <davej@redhat.com>
Showing 2 changed files with 18 additions and 1 deletions Side-by-side Diff
drivers/cpufreq/cpufreq.c
... | ... | @@ -686,6 +686,9 @@ |
686 | 686 | NULL |
687 | 687 | }; |
688 | 688 | |
689 | +struct kobject *cpufreq_global_kobject; | |
690 | +EXPORT_SYMBOL(cpufreq_global_kobject); | |
691 | + | |
689 | 692 | #define to_policy(k) container_of(k, struct cpufreq_policy, kobj) |
690 | 693 | #define to_attr(a) container_of(a, struct freq_attr, attr) |
691 | 694 | |
692 | 695 | |
... | ... | @@ -1935,8 +1938,12 @@ |
1935 | 1938 | per_cpu(policy_cpu, cpu) = -1; |
1936 | 1939 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); |
1937 | 1940 | } |
1941 | + | |
1942 | + cpufreq_global_kobject = kobject_create_and_add("cpufreq", | |
1943 | + &cpu_sysdev_class.kset.kobj); | |
1944 | + BUG_ON(!cpufreq_global_kobject); | |
1945 | + | |
1938 | 1946 | return 0; |
1939 | 1947 | } |
1940 | - | |
1941 | 1948 | core_initcall(cpufreq_core_init); |
include/linux/cpufreq.h
... | ... | @@ -65,6 +65,9 @@ |
65 | 65 | |
66 | 66 | struct cpufreq_governor; |
67 | 67 | |
68 | +/* /sys/devices/system/cpu/cpufreq: entry point for global variables */ | |
69 | +extern struct kobject *cpufreq_global_kobject; | |
70 | + | |
68 | 71 | #define CPUFREQ_ETERNAL (-1) |
69 | 72 | struct cpufreq_cpuinfo { |
70 | 73 | unsigned int max_freq; |
... | ... | @@ -274,6 +277,13 @@ |
274 | 277 | ssize_t (*store)(struct cpufreq_policy *, const char *, size_t count); |
275 | 278 | }; |
276 | 279 | |
280 | +struct global_attr { | |
281 | + struct attribute attr; | |
282 | + ssize_t (*show)(struct kobject *kobj, | |
283 | + struct attribute *attr, char *buf); | |
284 | + ssize_t (*store)(struct kobject *a, struct attribute *b, | |
285 | + const char *c, size_t count); | |
286 | +}; | |
277 | 287 | |
278 | 288 | /********************************************************************* |
279 | 289 | * CPUFREQ 2.6. INTERFACE * |