Disallow writing to /proc/acpi/processor/xy/performance
Subsystems (2)
PATCH 1/1 Disallow writing to /proc/acpi/processor/xy/performance
Makes the cpufreq stuff at least a bit easier...
Compile tested, patched against 2.6.18-rc2
Disallow writing to /proc/acpi/processor/xy/performance
The preferred interface to switch CPU frequency steps is /sys/.../cpufreq. This is known since the beginning of 2.6 kernels.
Writing to this file may interfere with thermal or _PPC limits. If writing to the file is done while frequency is limited, frequency will get stuck to this limit.
drivers/acpi/processor_perflib.c | 44 --------------------------------------- drivers/cpufreq/cpufreq.c | 5 +--- include/linux/cpufreq.h | 1 3 files changed, 2 insertions(+), 48 deletions(-)
drivers/acpi/processor_perflib.c +0 -44
@@ -447,49 +447,6 @@ static int acpi_processor_perf_open_fs(s PDE(inode)->data); } -static ssize_t -acpi_processor_write_performance (struct file *file, -const char __user * buffer, -size_t count,loff_t * data) -{ -int result =0 ; -struct seq_file *m = (struct seq_file *)file->private_data; -struct acpi_processor *pr = (struct acpi_processor *)m->private; -struct acpi_processor_performance *perf; -char state_string[12 ] = {'\0' }; -unsigned int new_state =0 ; -struct cpufreq_policy policy; - - -if (!pr || (count >sizeof (state_string) -1 )) -return -EINVAL ; - - perf = pr->performance; -if (!perf) -return -EINVAL ; - -if (copy_from_user (state_string, buffer, count)) -return -EFAULT ; - - state_string[count] ='\0' ; - new_state =simple_strtoul (state_string,NULL ,0 ); - -if (new_state >= perf->state_count) -return -EINVAL ; - -cpufreq_get_policy (&policy, pr->id); - - policy.cpu = pr->id; - policy.min = perf->states[new_state].core_frequency *1000 ; - policy.max = perf->states[new_state].core_frequency *1000 ; - - result =cpufreq_set_policy (&policy); -if (result) -return result; - -return count; -} -static void acpi_cpufreq_add_file (struct acpi_processor *pr) {struct proc_dir_entry *entry =NULL ;
@@ -504,7 +461,6 @@ static void acpi_cpufreq_add_file(structS_IFREG |S_IRUGO |S_IWUSR , acpi_device_dir(device));if (entry){ - acpi_processor_perf_fops.write = acpi_processor_write_performance; entry->proc_fops = &acpi_processor_perf_fops; entry->data =acpi_driver_data (device); entry->owner =THIS_MODULE ;
drivers/cpufreq/cpufreq.c +2 -3
@@ -375,6 +375,7 @@ show_one(scaling_max_freq, max);show_one (scaling_cur_freq, cur);static int __cpufreq_set_policy (struct cpufreq_policy *data,struct cpufreq_policy *policy); +static int cpufreq_set_policy (struct cpufreq_policy *policy);/** * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access
@@ -1448,7 +1449,7 @@ error_out:* * Sets a new CPU frequency and voltage scaling policy. */ -int cpufreq_set_policy (struct cpufreq_policy *policy) +static int cpufreq_set_policy (struct cpufreq_policy *policy) {int ret =0 ;struct cpufreq_policy *data;
@@ -1478,8 +1479,6 @@ int cpufreq_set_policy(struct cpufreq_poreturn ret; } -EXPORT_SYMBOL (cpufreq_set_policy); -/** * cpufreq_update_policy - re-evaluate an existing cpufreq policy
include/linux/cpufreq.h +0 -1
@@ -252,7 +252,6 @@ struct freq_attr {/********************************************************************* * CPUFREQ 2.6. INTERFACE * *********************************************************************/ -int cpufreq_set_policy (struct cpufreq_policy *policy);int cpufreq_get_policy (struct cpufreq_policy *policy,unsigned int cpu);int cpufreq_update_policy (unsigned int cpu);
Disallow writing to /proc/acpi/processor/xy/performance
The preferred interface to switch CPU frequency steps is /sys/.../cpufreq. This is known since the beginning of 2.6 kernels.
Writing to this file may interfere with thermal or _PPC limits. If writing to the file is done while frequency is limited, frequency will get stuck to this limit.
drivers/acpi/processor_perflib.c | 44 --------------------------------------- drivers/cpufreq/cpufreq.c | 5 +--- include/linux/cpufreq.h | 1 3 files changed, 2 insertions(+), 48 deletions(-)
drivers/acpi/processor_perflib.c +0 -44
56 lines not on this page · raw message
drivers/cpufreq/cpufreq.c +2 -3
@@ -375,6 +375,7 @@ show_one(scaling_max_freq, max);show_one (scaling_cur_freq, cur);static int __cpufreq_set_policy (struct cpufreq_policy *data,struct cpufreq_policy *policy); +static int cpufreq_set_policy (struct cpufreq_policy *policy);/** * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access
@@ -1448,7 +1449,7 @@ error_out:* * Sets a new CPU frequency and voltage scaling policy. */ -int cpufreq_set_policy (struct cpufreq_policy *policy) +static int cpufreq_set_policy (struct cpufreq_policy *policy) {int ret =0 ;struct cpufreq_policy *data;
@@ -1478,8 +1479,6 @@ int cpufreq_set_policy(struct cpufreq_poreturn ret; } -EXPORT_SYMBOL (cpufreq_set_policy); -/** * cpufreq_update_policy - re-evaluate an existing cpufreq policy
include/linux/cpufreq.h +0 -1
@@ -252,7 +252,6 @@ struct freq_attr {/********************************************************************* * CPUFREQ 2.6. INTERFACE * *********************************************************************/ -int cpufreq_set_policy (struct cpufreq_policy *policy);int cpufreq_get_policy (struct cpufreq_policy *policy,unsigned int cpu);int cpufreq_update_policy (unsigned int cpu);
Quoted 3 lines · Thomas Renninger
Makes the cpufreq stuff at least a bit easier...
Compile tested, patched against 2.6.18-rc2
patched against 2.6.18-rc4
Hi,
Quoted 4 lines · Thomas Renninger
Quoted 3 lines · Thomas Renninger
Makes the cpufreq stuff at least a bit easier...
Compile tested, patched against 2.6.18-rc2
Somehow I like this patch. What's the status on it?
Thanks,
Dominik