diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-08-07 23:50:08 +0200 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-08-07 23:50:08 +0200 |
commit | 019143b4c068e3f5588d40adf49da16f80482562 (patch) | |
tree | bf3b0e935c7548bb249c2501e5631bcadec1b160 | |
parent | a675efd506d63c2762ed017155e55099fb0dfffc (diff) | |
download | cpufrequtils-019143b4c068e3f5588d40adf49da16f80482562.tar.gz |
cpufreq-info: add support for related_cpus
Add a new command line option "-r" / "--related-cpus" which relates
to the sysfs file related_cpus.
Also clarify the difference between affected CPUs and related CPUs.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
-rw-r--r-- | man/cpufreq-info.1 | 5 | ||||
-rw-r--r-- | utils/info.c | 41 |
2 files changed, 41 insertions, 5 deletions
diff --git a/man/cpufreq-info.1 b/man/cpufreq-info.1 index 2d3e7dd..5bb5089 100644 --- a/man/cpufreq-info.1 +++ b/man/cpufreq-info.1 @@ -35,8 +35,11 @@ Gets the currently used cpufreq policy. \fB\-g\fR \fB\-\-governors\fR Determines available cpufreq governors. .TP +\fB\-a\fR \fB\-\-related\-cpus\fR +Determines which CPUs run at the same hardware frequency. +.TP \fB\-a\fR \fB\-\-affected\-cpus\fR -Determines which CPUs can only switch frequency at the same time. +Determines which CPUs need to coordinate software frequency requirements. .TP \fB\-s\fR \fB\-\-stats\fR Shows cpufreq statistics if available. diff --git a/utils/info.c b/utils/info.c index 05bf9d6..a4ae2a0 100644 --- a/utils/info.c +++ b/utils/info.c @@ -142,9 +142,20 @@ static void debug_output_one(unsigned int cpu) cpufreq_put_driver(driver); } + cpus = cpufreq_get_related_cpus(cpu); + if (cpus) { + printf(gettext (" CPUs which run at the same hardware frequency: ")); + while (cpus->next) { + printf("%d ", cpus->cpu); + cpus = cpus->next; + } + printf("%d\n", cpus->cpu); + cpufreq_put_related_cpus(cpus); + } + cpus = cpufreq_get_affected_cpus(cpu); if (cpus) { - printf(gettext (" CPUs which need to switch frequency at the same time: ")); + printf(gettext (" CPUs which coordinate software frequency requirements: ")); while (cpus->next) { printf("%d ", cpus->cpu); cpus = cpus->next; @@ -335,6 +346,22 @@ static int get_affected_cpus(unsigned int cpu) { return 0; } +/* --related-cpus / -r */ + +static int get_related_cpus(unsigned int cpu) { + struct cpufreq_affected_cpus *cpus = cpufreq_get_related_cpus(cpu); + if (!cpus) + return -EINVAL; + + while (cpus->next) { + printf("%d ", cpus->cpu); + cpus = cpus->next; + } + printf("%d\n", cpus->cpu); + cpufreq_put_related_cpus(cpus); + return 0; +} + /* --stats / -s */ static int get_freq_stats(unsigned int cpu, unsigned int human) { @@ -376,8 +403,9 @@ static void print_help(void) { printf(gettext (" -d, --driver Determines the used cpufreq kernel driver *\n")); printf(gettext (" -p, --policy Gets the currently used cpufreq policy *\n")); printf(gettext (" -g, --governors Determines available cpufreq governors *\n")); - printf(gettext (" -a, --affected-cpus Determines which CPUs can only switch frequency at the\n" - " same time *\n")); + printf(gettext (" -r, --related-cpus Determines which CPUs run at the same hardware frequency *\n")); + printf(gettext (" -a, --affected-cpus Determines which CPUs need to coordinate software frequency\n" + " requirements *\n")); printf(gettext (" -s, --stats Shows cpufreq statistics if available\n")); printf(gettext (" -o, --proc Prints out information like provided by the /proc/cpufreq\n" " interface in 2.4. and early 2.6. kernels\n")); @@ -400,6 +428,7 @@ static struct option info_opts[] = { { .name="driver", .has_arg=no_argument, .flag=NULL, .val='d'}, { .name="policy", .has_arg=no_argument, .flag=NULL, .val='p'}, { .name="governors", .has_arg=no_argument, .flag=NULL, .val='g'}, + { .name="related-cpus", .has_arg=no_argument, .flag=NULL, .val='r'}, { .name="affected-cpus",.has_arg=no_argument, .flag=NULL, .val='a'}, { .name="stats", .has_arg=no_argument, .flag=NULL, .val='s'}, { .name="proc", .has_arg=no_argument, .flag=NULL, .val='o'}, @@ -420,7 +449,7 @@ int main(int argc, char **argv) { textdomain (PACKAGE); do { - ret = getopt_long(argc, argv, "c:hoefwldpgasm", info_opts, NULL); + ret = getopt_long(argc, argv, "c:hoefwldpgrasm", info_opts, NULL); switch (ret) { case '?': output_param = '?'; @@ -435,6 +464,7 @@ int main(int argc, char **argv) { break; case 'o': case 'a': + case 'r': case 'g': case 'p': case 'd': @@ -514,6 +544,9 @@ int main(int argc, char **argv) { case 'a': ret = get_affected_cpus(cpu); break; + case 'r': + ret = get_related_cpus(cpu); + break; case 'g': ret = get_available_governors(cpu); break; |