Skip to contentSkip to conversation

Cpufreq: Change sysfs interface cpuinfo_cur_freq access privilege

PATCH In review Lan Tianyu 3 participants 6 messages Nov 25, 2013 CPU frequency scaling framework

lore
Share & tools
lore

Lan Tianyu

author
#0 lore raw

PATCH 1/1 Cpufreq: Change sysfs interface cpuinfo_cur_freq access privilege

Currently, cpuinfo_cur_freq is only accessible for root user while other cpufreq sysfs interfaces(E,G scaling_cur_freq) are available to ordinary user. This seems make no sense. This patch is to change it.

---
 drivers/cpufreq/cpufreq.c | 2 +-
 include/linux/cpufreq.h   | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)
drivers/cpufreq/cpufreq.c +1 -1
index 02d534d..1926465 100644
@@ -605,7 +605,7 @@ static ssize_t show_bios_limit(struct cpufreq_policy *policy, char *buf)
 	return sprintf(buf, "%u\n", policy->cpuinfo.max_freq);
 }
 
-cpufreq_freq_attr_ro_perm(cpuinfo_cur_freq, 0400);
+cpufreq_freq_attr_ro(cpuinfo_cur_freq);
 cpufreq_freq_attr_ro(cpuinfo_min_freq);
 cpufreq_freq_attr_ro(cpuinfo_max_freq);
 cpufreq_freq_attr_ro(cpuinfo_transition_latency);
include/linux/cpufreq.h +0 -4
index 5bd6ab9..b4bb677 100644
@@ -166,10 +166,6 @@ struct freq_attr {
 static struct freq_attr _name =			\
 __ATTR(_name, 0444, show_##_name, NULL)
 
-#define cpufreq_freq_attr_ro_perm(_name, _perm)	\
-static struct freq_attr _name =			\
-__ATTR(_name, _perm, show_##_name, NULL)
-
 #define cpufreq_freq_attr_rw(_name)		\
 static struct freq_attr _name =			\
 __ATTR(_name, 0644, show_##_name, store_##_name)
Signature · 1 line
1.8.4.rc0.1.g8f6a3e5.dirty
maintainer
#1 lore raw
Quoted 4 lines · Lan Tianyu

Currently, cpuinfo_cur_freq is only accessible for root user while other cpufreq sysfs interfaces(E,G scaling_cur_freq) are available to ordinary user. This seems make no sense. This patch is to change it.

There is nothing wrong with the code and so this is more of a design change..

Probably Rafael can help us here as cpufreq_cur_freq will read stuff directly from hardware instead of using cached value in software.

--
viresh

author
#2 lore raw
Quoted 11 lines · Viresh Kumar
Quoted 4 lines · Lan Tianyu

Currently, cpuinfo_cur_freq is only accessible for root user while other cpufreq sysfs interfaces(E,G scaling_cur_freq) are available to ordinary user. This seems make no sense. This patch is to change it.

There is nothing wrong with the code and so this is more of a design change..

Probably Rafael can help us here as cpufreq_cur_freq will read stuff directly from hardware instead of using cached value in software.

I think so, too. I also tried to checking the reason of the privilege by git log but the code was there before linux kernel being migrated to git repository.

Quoted 4 lines

--
viresh

Signature · 2 lines
Best regards
Tianyu Lan
#3 lore raw
Quoted 10 lines · Lan Tianyu
Quoted 9 lines · Viresh Kumar
Quoted 4 lines · Lan Tianyu

Currently, cpuinfo_cur_freq is only accessible for root user while other cpufreq sysfs interfaces(E,G scaling_cur_freq) are available to ordinary user. This seems make no sense. This patch is to change it.

There is nothing wrong with the code and so this is more of a design change..

Quoted 6 lines
Quoted 2 lines

Probably Rafael can help us here as cpufreq_cur_freq will read stuff directly from hardware instead of using cached value in software.

I think so, too. I also tried to checking the reason of the privilege by git log but the code was there before linux kernel being migrated to git repository.

And it has always behaved in the same way? Then I wouldn't change it.

Thanks!

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
author
#4 lore raw
Quoted 11 lines · Rafael J. Wysocki
Quoted 10 lines · Lan Tianyu
Quoted 9 lines · Viresh Kumar
Quoted 4 lines · Lan Tianyu

Currently, cpuinfo_cur_freq is only accessible for root user while other cpufreq sysfs interfaces(E,G scaling_cur_freq) are available to ordinary user. This seems make no sense. This patch is to change it.

There is nothing wrong with the code and so this is more of a design change..

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Probably Rafael can help us here as cpufreq_cur_freq will read stuff directly from hardware instead of using cached value in software.

I think so, too. I also tried to checking the reason of the privilege by git log but the code was there before linux kernel being migrated to git repository.

And it has always behaved in the same way? Then I wouldn't change it.

It has been there since 2.6.12-rc2 or more early. But the cpuinfo_cur_freq is read-only and seems no harmful.

Request from bug 65611.
https://bugzilla.kernel.org/show_bug.cgi?id=65611.

Quoted 2 lines

Thanks!

Signature · 2 lines
Best Regards
Tianyu Lan
#5 lore raw
Quoted 19 lines · Lan Tianyu
Quoted 18 lines · Rafael J. Wysocki
Quoted 16 lines · Lan Tianyu
Quoted 11 lines · Viresh Kumar
Quoted 4 lines · Lan Tianyu

Currently, cpuinfo_cur_freq is only accessible for root user while other cpufreq sysfs interfaces(E,G scaling_cur_freq) are available to ordinary user. This seems make no sense. This patch is to change it.

There is nothing wrong with the code and so this is more of a design change..

Probably Rafael can help us here as cpufreq_cur_freq will read stuff directly from hardware instead of using cached value in software.

I think so, too. I also tried to checking the reason of the privilege by git log but the code was there before linux kernel being migrated to git repository.

Quoted 5 lines
Quoted 2 lines

And it has always behaved in the same way? Then I wouldn't change it.

It has been there since 2.6.12-rc2 or more early. But the cpuinfo_cur_freq is read-only and seems no harmful.

If it reads things directly from hardware, it may not be totally neutral.

Thanks!

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.