Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
a1ce5ba2
Commit
a1ce5ba2
authored
Apr 19, 2011
by
Dominik Brodowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cpupowerutils: utils - ConfigStyle bugfixes
Signed-off-by:
Dominik Brodowski
<
linux@dominikbrodowski.net
>
parent
2cd005ca
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
122 additions
and
108 deletions
+122
-108
tools/power/cpupower/utils/cpufreq-info.c
tools/power/cpupower/utils/cpufreq-info.c
+68
-55
tools/power/cpupower/utils/cpufreq-set.c
tools/power/cpupower/utils/cpufreq-set.c
+13
-12
tools/power/cpupower/utils/cpuidle-info.c
tools/power/cpupower/utils/cpuidle-info.c
+13
-14
tools/power/cpupower/utils/cpupower-info.c
tools/power/cpupower/utils/cpupower-info.c
+8
-9
tools/power/cpupower/utils/cpupower-set.c
tools/power/cpupower/utils/cpupower-set.c
+8
-8
tools/power/cpupower/utils/cpupower.c
tools/power/cpupower/utils/cpupower.c
+12
-10
No files found.
tools/power/cpupower/utils/cpufreq-info.c
View file @
a1ce5ba2
...
@@ -27,7 +27,7 @@ static unsigned int count_cpus(void)
...
@@ -27,7 +27,7 @@ static unsigned int count_cpus(void)
unsigned
int
cpunr
=
0
;
unsigned
int
cpunr
=
0
;
fp
=
fopen
(
"/proc/stat"
,
"r"
);
fp
=
fopen
(
"/proc/stat"
,
"r"
);
if
(
!
fp
)
{
if
(
!
fp
)
{
printf
(
_
(
"Couldn't count the number of CPUs (%s: %s), assuming 1
\n
"
),
"/proc/stat"
,
strerror
(
errno
));
printf
(
_
(
"Couldn't count the number of CPUs (%s: %s), assuming 1
\n
"
),
"/proc/stat"
,
strerror
(
errno
));
return
1
;
return
1
;
}
}
...
@@ -48,7 +48,7 @@ static unsigned int count_cpus(void)
...
@@ -48,7 +48,7 @@ static unsigned int count_cpus(void)
fclose
(
fp
);
fclose
(
fp
);
/* cpu count starts from 0, on error return 1 (UP) */
/* cpu count starts from 0, on error return 1 (UP) */
return
(
ret
+
1
)
;
return
ret
+
1
;
}
}
...
@@ -63,7 +63,7 @@ static void proc_cpufreq_output(void)
...
@@ -63,7 +63,7 @@ static void proc_cpufreq_output(void)
printf
(
_
(
" minimum CPU frequency - maximum CPU frequency - governor
\n
"
));
printf
(
_
(
" minimum CPU frequency - maximum CPU frequency - governor
\n
"
));
nr_cpus
=
count_cpus
();
nr_cpus
=
count_cpus
();
for
(
cpu
=
0
;
cpu
<
nr_cpus
;
cpu
++
)
{
for
(
cpu
=
0
;
cpu
<
nr_cpus
;
cpu
++
)
{
policy
=
cpufreq_get_policy
(
cpu
);
policy
=
cpufreq_get_policy
(
cpu
);
if
(
!
policy
)
if
(
!
policy
)
continue
;
continue
;
...
@@ -75,7 +75,8 @@ static void proc_cpufreq_output(void)
...
@@ -75,7 +75,8 @@ static void proc_cpufreq_output(void)
max_pctg
=
(
policy
->
max
*
100
)
/
max
;
max_pctg
=
(
policy
->
max
*
100
)
/
max
;
}
}
printf
(
"CPU%3d %9lu kHz (%3d %%) - %9lu kHz (%3d %%) - %s
\n
"
,
printf
(
"CPU%3d %9lu kHz (%3d %%) - %9lu kHz (%3d %%) - %s
\n
"
,
cpu
,
policy
->
min
,
max
?
min_pctg
:
0
,
policy
->
max
,
max
?
max_pctg
:
0
,
policy
->
governor
);
cpu
,
policy
->
min
,
max
?
min_pctg
:
0
,
policy
->
max
,
max
?
max_pctg
:
0
,
policy
->
governor
);
cpufreq_put_policy
(
policy
);
cpufreq_put_policy
(
policy
);
}
}
...
@@ -89,21 +90,21 @@ static void print_speed(unsigned long speed)
...
@@ -89,21 +90,21 @@ static void print_speed(unsigned long speed)
tmp
=
speed
%
10000
;
tmp
=
speed
%
10000
;
if
(
tmp
>=
5000
)
if
(
tmp
>=
5000
)
speed
+=
10000
;
speed
+=
10000
;
printf
(
"%u.%02u GHz"
,
((
unsigned
int
)
speed
/
1000000
),
printf
(
"%u.%02u GHz"
,
((
unsigned
int
)
speed
/
1000000
),
((
unsigned
int
)
(
speed
%
1000000
)
/
10000
));
((
unsigned
int
)
(
speed
%
1000000
)
/
10000
));
}
else
if
(
speed
>
100000
)
{
}
else
if
(
speed
>
100000
)
{
tmp
=
speed
%
1000
;
tmp
=
speed
%
1000
;
if
(
tmp
>=
500
)
if
(
tmp
>=
500
)
speed
+=
1000
;
speed
+=
1000
;
printf
(
"%u MHz"
,
((
unsigned
int
)
speed
/
1000
));
printf
(
"%u MHz"
,
((
unsigned
int
)
speed
/
1000
));
}
else
if
(
speed
>
1000
)
{
}
else
if
(
speed
>
1000
)
{
tmp
=
speed
%
100
;
tmp
=
speed
%
100
;
if
(
tmp
>=
50
)
if
(
tmp
>=
50
)
speed
+=
100
;
speed
+=
100
;
printf
(
"%u.%01u MHz"
,
((
unsigned
int
)
speed
/
1000
),
printf
(
"%u.%01u MHz"
,
((
unsigned
int
)
speed
/
1000
),
((
unsigned
int
)
(
speed
%
1000
)
/
100
));
((
unsigned
int
)
(
speed
%
1000
)
/
100
));
}
else
}
else
printf
(
"%lu kHz"
,
speed
);
printf
(
"%lu kHz"
,
speed
);
return
;
return
;
}
}
...
@@ -116,28 +117,29 @@ static void print_duration(unsigned long duration)
...
@@ -116,28 +117,29 @@ static void print_duration(unsigned long duration)
tmp
=
duration
%
10000
;
tmp
=
duration
%
10000
;
if
(
tmp
>=
5000
)
if
(
tmp
>=
5000
)
duration
+=
10000
;
duration
+=
10000
;
printf
(
"%u.%02u ms"
,
((
unsigned
int
)
duration
/
1000000
),
printf
(
"%u.%02u ms"
,
((
unsigned
int
)
duration
/
1000000
),
((
unsigned
int
)
(
duration
%
1000000
)
/
10000
));
((
unsigned
int
)
(
duration
%
1000000
)
/
10000
));
}
else
if
(
duration
>
100000
)
{
}
else
if
(
duration
>
100000
)
{
tmp
=
duration
%
1000
;
tmp
=
duration
%
1000
;
if
(
tmp
>=
500
)
if
(
tmp
>=
500
)
duration
+=
1000
;
duration
+=
1000
;
printf
(
"%u us"
,
((
unsigned
int
)
duration
/
1000
));
printf
(
"%u us"
,
((
unsigned
int
)
duration
/
1000
));
}
else
if
(
duration
>
1000
)
{
}
else
if
(
duration
>
1000
)
{
tmp
=
duration
%
100
;
tmp
=
duration
%
100
;
if
(
tmp
>=
50
)
if
(
tmp
>=
50
)
duration
+=
100
;
duration
+=
100
;
printf
(
"%u.%01u us"
,
((
unsigned
int
)
duration
/
1000
),
printf
(
"%u.%01u us"
,
((
unsigned
int
)
duration
/
1000
),
((
unsigned
int
)
(
duration
%
1000
)
/
100
));
((
unsigned
int
)
(
duration
%
1000
)
/
100
));
}
else
}
else
printf
(
"%lu ns"
,
duration
);
printf
(
"%lu ns"
,
duration
);
return
;
return
;
}
}
/* --boost / -b */
/* --boost / -b */
static
int
get_boost_mode
(
unsigned
int
cpu
)
{
static
int
get_boost_mode
(
unsigned
int
cpu
)
{
int
support
,
active
,
b_states
=
0
,
ret
,
pstate_no
,
i
;
int
support
,
active
,
b_states
=
0
,
ret
,
pstate_no
,
i
;
/* ToDo: Make this more global */
/* ToDo: Make this more global */
unsigned
long
pstates
[
MAX_HW_PSTATES
]
=
{
0
,};
unsigned
long
pstates
[
MAX_HW_PSTATES
]
=
{
0
,};
...
@@ -158,7 +160,7 @@ static int get_boost_mode(unsigned int cpu) {
...
@@ -158,7 +160,7 @@ static int get_boost_mode(unsigned int cpu) {
&& (cpuid_edx(0x80000007) & (1 << 7)))
&& (cpuid_edx(0x80000007) & (1 << 7)))
*/
*/
printf
(
_
(
" boost state support:
\n
"
));
printf
(
_
(
" boost state support:
\n
"
));
printf
(
_
(
" Supported: %s
\n
"
),
support
?
_
(
"yes"
)
:
_
(
"no"
));
printf
(
_
(
" Supported: %s
\n
"
),
support
?
_
(
"yes"
)
:
_
(
"no"
));
printf
(
_
(
" Active: %s
\n
"
),
active
?
_
(
"yes"
)
:
_
(
"no"
));
printf
(
_
(
" Active: %s
\n
"
),
active
?
_
(
"yes"
)
:
_
(
"no"
));
...
@@ -196,12 +198,11 @@ static void debug_output_one(unsigned int cpu)
...
@@ -196,12 +198,11 @@ static void debug_output_one(unsigned int cpu)
unsigned
long
total_trans
,
latency
;
unsigned
long
total_trans
,
latency
;
unsigned
long
long
total_time
;
unsigned
long
long
total_time
;
struct
cpufreq_policy
*
policy
;
struct
cpufreq_policy
*
policy
;
struct
cpufreq_available_governors
*
governors
;
struct
cpufreq_available_governors
*
governors
;
struct
cpufreq_stats
*
stats
;
struct
cpufreq_stats
*
stats
;
if
(
cpufreq_cpu_exists
(
cpu
))
{
if
(
cpufreq_cpu_exists
(
cpu
))
return
;
return
;
}
freq_kernel
=
cpufreq_get_freq_kernel
(
cpu
);
freq_kernel
=
cpufreq_get_freq_kernel
(
cpu
);
freq_hardware
=
cpufreq_get_freq_hardware
(
cpu
);
freq_hardware
=
cpufreq_get_freq_hardware
(
cpu
);
...
@@ -294,8 +295,7 @@ static void debug_output_one(unsigned int cpu)
...
@@ -294,8 +295,7 @@ static void debug_output_one(unsigned int cpu)
if
(
freq_hardware
)
{
if
(
freq_hardware
)
{
print_speed
(
freq_hardware
);
print_speed
(
freq_hardware
);
printf
(
_
(
" (asserted by call to hardware)"
));
printf
(
_
(
" (asserted by call to hardware)"
));
}
}
else
else
print_speed
(
freq_kernel
);
print_speed
(
freq_kernel
);
printf
(
".
\n
"
);
printf
(
".
\n
"
);
}
}
...
@@ -322,7 +322,8 @@ static void debug_output_one(unsigned int cpu)
...
@@ -322,7 +322,8 @@ static void debug_output_one(unsigned int cpu)
/* --freq / -f */
/* --freq / -f */
static
int
get_freq_kernel
(
unsigned
int
cpu
,
unsigned
int
human
)
{
static
int
get_freq_kernel
(
unsigned
int
cpu
,
unsigned
int
human
)
{
unsigned
long
freq
=
cpufreq_get_freq_kernel
(
cpu
);
unsigned
long
freq
=
cpufreq_get_freq_kernel
(
cpu
);
if
(
!
freq
)
if
(
!
freq
)
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -337,7 +338,8 @@ static int get_freq_kernel(unsigned int cpu, unsigned int human) {
...
@@ -337,7 +338,8 @@ static int get_freq_kernel(unsigned int cpu, unsigned int human) {
/* --hwfreq / -w */
/* --hwfreq / -w */
static
int
get_freq_hardware
(
unsigned
int
cpu
,
unsigned
int
human
)
{
static
int
get_freq_hardware
(
unsigned
int
cpu
,
unsigned
int
human
)
{
unsigned
long
freq
=
cpufreq_get_freq_hardware
(
cpu
);
unsigned
long
freq
=
cpufreq_get_freq_hardware
(
cpu
);
if
(
!
freq
)
if
(
!
freq
)
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -351,7 +353,8 @@ static int get_freq_hardware(unsigned int cpu, unsigned int human) {
...
@@ -351,7 +353,8 @@ static int get_freq_hardware(unsigned int cpu, unsigned int human) {
/* --hwlimits / -l */
/* --hwlimits / -l */
static
int
get_hardware_limits
(
unsigned
int
cpu
)
{
static
int
get_hardware_limits
(
unsigned
int
cpu
)
{
unsigned
long
min
,
max
;
unsigned
long
min
,
max
;
if
(
cpufreq_get_hardware_limits
(
cpu
,
&
min
,
&
max
))
if
(
cpufreq_get_hardware_limits
(
cpu
,
&
min
,
&
max
))
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -361,7 +364,8 @@ static int get_hardware_limits(unsigned int cpu) {
...
@@ -361,7 +364,8 @@ static int get_hardware_limits(unsigned int cpu) {
/* --driver / -d */
/* --driver / -d */
static
int
get_driver
(
unsigned
int
cpu
)
{
static
int
get_driver
(
unsigned
int
cpu
)
{
char
*
driver
=
cpufreq_get_driver
(
cpu
);
char
*
driver
=
cpufreq_get_driver
(
cpu
);
if
(
!
driver
)
if
(
!
driver
)
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -372,7 +376,8 @@ static int get_driver(unsigned int cpu) {
...
@@ -372,7 +376,8 @@ static int get_driver(unsigned int cpu) {
/* --policy / -p */
/* --policy / -p */
static
int
get_policy
(
unsigned
int
cpu
)
{
static
int
get_policy
(
unsigned
int
cpu
)
{
struct
cpufreq_policy
*
policy
=
cpufreq_get_policy
(
cpu
);
struct
cpufreq_policy
*
policy
=
cpufreq_get_policy
(
cpu
);
if
(
!
policy
)
if
(
!
policy
)
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -383,8 +388,10 @@ static int get_policy(unsigned int cpu) {
...
@@ -383,8 +388,10 @@ static int get_policy(unsigned int cpu) {
/* --governors / -g */
/* --governors / -g */
static
int
get_available_governors
(
unsigned
int
cpu
)
{
static
int
get_available_governors
(
unsigned
int
cpu
)
struct
cpufreq_available_governors
*
governors
=
cpufreq_get_available_governors
(
cpu
);
{
struct
cpufreq_available_governors
*
governors
=
cpufreq_get_available_governors
(
cpu
);
if
(
!
governors
)
if
(
!
governors
)
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -400,7 +407,8 @@ static int get_available_governors(unsigned int cpu) {
...
@@ -400,7 +407,8 @@ static int get_available_governors(unsigned int cpu) {
/* --affected-cpus / -a */
/* --affected-cpus / -a */
static
int
get_affected_cpus
(
unsigned
int
cpu
)
{
static
int
get_affected_cpus
(
unsigned
int
cpu
)
{
struct
cpufreq_affected_cpus
*
cpus
=
cpufreq_get_affected_cpus
(
cpu
);
struct
cpufreq_affected_cpus
*
cpus
=
cpufreq_get_affected_cpus
(
cpu
);
if
(
!
cpus
)
if
(
!
cpus
)
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -416,7 +424,8 @@ static int get_affected_cpus(unsigned int cpu) {
...
@@ -416,7 +424,8 @@ static int get_affected_cpus(unsigned int cpu) {
/* --related-cpus / -r */
/* --related-cpus / -r */
static
int
get_related_cpus
(
unsigned
int
cpu
)
{
static
int
get_related_cpus
(
unsigned
int
cpu
)
{
struct
cpufreq_affected_cpus
*
cpus
=
cpufreq_get_related_cpus
(
cpu
);
struct
cpufreq_affected_cpus
*
cpus
=
cpufreq_get_related_cpus
(
cpu
);
if
(
!
cpus
)
if
(
!
cpus
)
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -432,17 +441,19 @@ static int get_related_cpus(unsigned int cpu) {
...
@@ -432,17 +441,19 @@ static int get_related_cpus(unsigned int cpu) {
/* --stats / -s */
/* --stats / -s */
static
int
get_freq_stats
(
unsigned
int
cpu
,
unsigned
int
human
)
{
static
int
get_freq_stats
(
unsigned
int
cpu
,
unsigned
int
human
)
{
unsigned
long
total_trans
=
cpufreq_get_transitions
(
cpu
);
unsigned
long
total_trans
=
cpufreq_get_transitions
(
cpu
);
unsigned
long
long
total_time
;
unsigned
long
long
total_time
;
struct
cpufreq_stats
*
stats
=
cpufreq_get_stats
(
cpu
,
&
total_time
);
struct
cpufreq_stats
*
stats
=
cpufreq_get_stats
(
cpu
,
&
total_time
);
while
(
stats
)
{
while
(
stats
)
{
if
(
human
)
{
if
(
human
)
{
print_speed
(
stats
->
frequency
);
print_speed
(
stats
->
frequency
);
printf
(
":%.2f%%"
,
(
100
.
0
*
stats
->
time_in_state
)
/
total_time
);
printf
(
":%.2f%%"
,
}
(
100
.
0
*
stats
->
time_in_state
)
/
total_time
);
else
}
else
printf
(
"%lu:%llu"
,
stats
->
frequency
,
stats
->
time_in_state
);
printf
(
"%lu:%llu"
,
stats
->
frequency
,
stats
->
time_in_state
);
stats
=
stats
->
next
;
stats
=
stats
->
next
;
if
(
stats
)
if
(
stats
)
printf
(
", "
);
printf
(
", "
);
...
@@ -455,7 +466,8 @@ static int get_freq_stats(unsigned int cpu, unsigned int human) {
...
@@ -455,7 +466,8 @@ static int get_freq_stats(unsigned int cpu, unsigned int human) {
/* --latency / -y */
/* --latency / -y */
static
int
get_latency
(
unsigned
int
cpu
,
unsigned
int
human
)
{
static
int
get_latency
(
unsigned
int
cpu
,
unsigned
int
human
)
{
unsigned
long
latency
=
cpufreq_get_transition_latency
(
cpu
);
unsigned
long
latency
=
cpufreq_get_transition_latency
(
cpu
);
if
(
!
latency
)
if
(
!
latency
)
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -468,7 +480,8 @@ static int get_latency(unsigned int cpu, unsigned int human) {
...
@@ -468,7 +480,8 @@ static int get_latency(unsigned int cpu, unsigned int human) {
return
0
;
return
0
;
}
}
void
freq_info_help
(
void
)
{
void
freq_info_help
(
void
)
{
printf
(
_
(
"Usage: cpupower freqinfo [options]
\n
"
));
printf
(
_
(
"Usage: cpupower freqinfo [options]
\n
"
));
printf
(
_
(
"Options:
\n
"
));
printf
(
_
(
"Options:
\n
"
));
printf
(
_
(
" -e, --debug Prints out debug information [default]
\n
"
));
printf
(
_
(
" -e, --debug Prints out debug information [default]
\n
"
));
...
@@ -494,26 +507,26 @@ void freq_info_help(void) {
...
@@ -494,26 +507,26 @@ void freq_info_help(void) {
printf
(
"
\n
"
);
printf
(
"
\n
"
);
printf
(
_
(
"If no argument is given, full output about
\n
"
printf
(
_
(
"If no argument is given, full output about
\n
"
"cpufreq is printed which is useful e.g. for reporting bugs.
\n\n
"
));
"cpufreq is printed which is useful e.g. for reporting bugs.
\n\n
"
));
printf
(
_
(
"By default info of CPU 0 is shown which can be overridden
\n
"
printf
(
_
(
"By default info of CPU 0 is shown which can be overridden
\n
"
"with the cpupower --cpu main command option.
\n
"
));
"with the cpupower --cpu main command option.
\n
"
));
}
}
static
struct
option
info_opts
[]
=
{
static
struct
option
info_opts
[]
=
{
{
.
name
=
"debug"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'e'
},
{
.
name
=
"debug"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'e'
},
{
.
name
=
"boost"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'b'
},
{
.
name
=
"boost"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'b'
},
{
.
name
=
"freq"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'f'
},
{
.
name
=
"freq"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'f'
},
{
.
name
=
"hwfreq"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'w'
},
{
.
name
=
"hwfreq"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'w'
},
{
.
name
=
"hwlimits"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'l'
},
{
.
name
=
"hwlimits"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'l'
},
{
.
name
=
"driver"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'd'
},
{
.
name
=
"driver"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'd'
},
{
.
name
=
"policy"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'p'
},
{
.
name
=
"policy"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'p'
},
{
.
name
=
"governors"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'g'
},
{
.
name
=
"governors"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'g'
},
{
.
name
=
"related-cpus"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'r'
},
{
.
name
=
"related-cpus"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'r'
},
{
.
name
=
"affected-cpus"
,.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'a'
},
{
.
name
=
"affected-cpus"
,.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'a'
},
{
.
name
=
"stats"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
's'
},
{
.
name
=
"stats"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
's'
},
{
.
name
=
"latency"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'y'
},
{
.
name
=
"latency"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'y'
},
{
.
name
=
"proc"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'o'
},
{
.
name
=
"proc"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'o'
},
{
.
name
=
"human"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'm'
},
{
.
name
=
"human"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'm'
},
{
.
name
=
"help"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'h'
},
{
.
name
=
"help"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'h'
},
{
},
{
},
};
};
...
@@ -572,7 +585,7 @@ int cmd_freq_info(int argc, char **argv)
...
@@ -572,7 +585,7 @@ int cmd_freq_info(int argc, char **argv)
fprintf
(
stderr
,
"invalid or unknown argument
\n
"
);
fprintf
(
stderr
,
"invalid or unknown argument
\n
"
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
}
while
(
cont
);
}
while
(
cont
);
switch
(
output_param
)
{
switch
(
output_param
)
{
case
'o'
:
case
'o'
:
...
@@ -659,7 +672,7 @@ int cmd_freq_info(int argc, char **argv)
...
@@ -659,7 +672,7 @@ int cmd_freq_info(int argc, char **argv)
break
;
break
;
}
}
if
(
ret
)
if
(
ret
)
return
(
ret
)
;
return
ret
;
}
}
return
ret
;
return
ret
;
}
}
tools/power/cpupower/utils/cpufreq-set.c
View file @
a1ce5ba2
...
@@ -43,12 +43,12 @@ void freq_set_help(void)
...
@@ -43,12 +43,12 @@ void freq_set_help(void)
}
}
static
struct
option
set_opts
[]
=
{
static
struct
option
set_opts
[]
=
{
{
.
name
=
"min"
,
.
has_arg
=
required_argument
,
.
flag
=
NULL
,
.
val
=
'd'
},
{
.
name
=
"min"
,
.
has_arg
=
required_argument
,
.
flag
=
NULL
,
.
val
=
'd'
},
{
.
name
=
"max"
,
.
has_arg
=
required_argument
,
.
flag
=
NULL
,
.
val
=
'u'
},
{
.
name
=
"max"
,
.
has_arg
=
required_argument
,
.
flag
=
NULL
,
.
val
=
'u'
},
{
.
name
=
"governor"
,
.
has_arg
=
required_argument
,
.
flag
=
NULL
,
.
val
=
'g'
},
{
.
name
=
"governor"
,
.
has_arg
=
required_argument
,
.
flag
=
NULL
,
.
val
=
'g'
},
{
.
name
=
"freq"
,
.
has_arg
=
required_argument
,
.
flag
=
NULL
,
.
val
=
'f'
},
{
.
name
=
"freq"
,
.
has_arg
=
required_argument
,
.
flag
=
NULL
,
.
val
=
'f'
},
{
.
name
=
"help"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'h'
},
{
.
name
=
"help"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'h'
},
{
.
name
=
"related"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'r'
},
{
.
name
=
"related"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'r'
},
{
},
{
},
};
};
...
@@ -64,7 +64,7 @@ static void print_error(void)
...
@@ -64,7 +64,7 @@ static void print_error(void)
};
};
struct
freq_units
{
struct
freq_units
{
char
*
str_unit
;
char
*
str_unit
;
int
power_of_ten
;
int
power_of_ten
;
};
};
...
@@ -204,7 +204,8 @@ static int do_one_cpu(unsigned int cpu, struct cpufreq_policy *new_pol,
...
@@ -204,7 +204,8 @@ static int do_one_cpu(unsigned int cpu, struct cpufreq_policy *new_pol,
else
if
(
new_pol
->
max
)
else
if
(
new_pol
->
max
)
return
cpufreq_modify_policy_max
(
cpu
,
new_pol
->
max
);
return
cpufreq_modify_policy_max
(
cpu
,
new_pol
->
max
);
else
if
(
new_pol
->
governor
)
else
if
(
new_pol
->
governor
)
return
cpufreq_modify_policy_governor
(
cpu
,
new_pol
->
governor
);
return
cpufreq_modify_policy_governor
(
cpu
,
new_pol
->
governor
);
default:
default:
/* slow path */
/* slow path */
...
@@ -290,7 +291,7 @@ int cmd_freq_set(int argc, char **argv)
...
@@ -290,7 +291,7 @@ int cmd_freq_set(int argc, char **argv)
new_pol
.
governor
=
gov
;
new_pol
.
governor
=
gov
;
break
;
break
;
}
}
}
while
(
cont
);
}
while
(
cont
);
/* parameter checking */
/* parameter checking */
if
(
double_parm
)
{
if
(
double_parm
)
{
...
...
tools/power/cpupower/utils/cpuidle-info.c
View file @
a1ce5ba2
...
@@ -31,8 +31,7 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose)
...
@@ -31,8 +31,7 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose)
if
(
idlestates
==
0
)
{
if
(
idlestates
==
0
)
{
printf
(
_
(
"CPU %u: No idle states
\n
"
),
cpu
);
printf
(
_
(
"CPU %u: No idle states
\n
"
),
cpu
);
return
;
return
;
}
}
else
if
(
idlestates
<=
0
)
{
else
if
(
idlestates
<=
0
)
{
printf
(
_
(
"CPU %u: Can't read idle state info
\n
"
),
cpu
);
printf
(
_
(
"CPU %u: Can't read idle state info
\n
"
),
cpu
);
return
;
return
;
}
}
...
@@ -92,7 +91,7 @@ static void cpuidle_general_output(void)
...
@@ -92,7 +91,7 @@ static void cpuidle_general_output(void)
}
}
printf
(
_
(
"CPUidle driver: %s
\n
"
),
tmp
);
printf
(
_
(
"CPUidle driver: %s
\n
"
),
tmp
);
free
(
tmp
);
free
(
tmp
);
tmp
=
sysfs_get_cpuidle_governor
();
tmp
=
sysfs_get_cpuidle_governor
();
if
(
!
tmp
)
{
if
(
!
tmp
)
{
...
@@ -101,7 +100,7 @@ static void cpuidle_general_output(void)
...
@@ -101,7 +100,7 @@ static void cpuidle_general_output(void)
}
}
printf
(
_
(
"CPUidle governor: %s
\n
"
),
tmp
);
printf
(
_
(
"CPUidle governor: %s
\n
"
),
tmp
);
free
(
tmp
);
free
(
tmp
);
}
}
static
void
proc_cpuidle_cpu_output
(
unsigned
int
cpu
)
static
void
proc_cpuidle_cpu_output
(
unsigned
int
cpu
)
...
@@ -117,8 +116,7 @@ static void proc_cpuidle_cpu_output(unsigned int cpu)
...
@@ -117,8 +116,7 @@ static void proc_cpuidle_cpu_output(unsigned int cpu)
* printf(_("CPU %u: No C-states available\n"), cpu);
* printf(_("CPU %u: No C-states available\n"), cpu);
* return;
* return;
*/
*/
}
}
else
if
(
cstates
<=
0
)
{
else
if
(
cstates
<=
0
)
{
printf
(
_
(
"CPU %u: Can't read C-state info
\n
"
),
cpu
);
printf
(
_
(
"CPU %u: Can't read C-state info
\n
"
),
cpu
);
return
;
return
;
}
}
...
@@ -143,7 +141,8 @@ static void proc_cpuidle_cpu_output(unsigned int cpu)
...
@@ -143,7 +141,8 @@ static void proc_cpuidle_cpu_output(unsigned int cpu)
/* --freq / -f */
/* --freq / -f */
void
idle_info_help
(
void
)
{
void
idle_info_help
(
void
)
{
printf
(
_
(
"Usage: cpupower idleinfo [options]
\n
"
));
printf
(
_
(
"Usage: cpupower idleinfo [options]
\n
"
));
printf
(
_
(
"Options:
\n
"
));
printf
(
_
(
"Options:
\n
"
));
printf
(
_
(
" -s, --silent Only show general C-state information
\n
"
));
printf
(
_
(
" -s, --silent Only show general C-state information
\n
"
));
...
@@ -155,9 +154,9 @@ void idle_info_help(void) {
...
@@ -155,9 +154,9 @@ void idle_info_help(void) {
}
}
static
struct
option
info_opts
[]
=
{
static
struct
option
info_opts
[]
=
{
{
.
name
=
"silent"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
's'
},
{
.
name
=
"silent"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
's'
},
{
.
name
=
"proc"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'o'
},
{
.
name
=
"proc"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'o'
},
{
.
name
=
"help"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'h'
},
{
.
name
=
"help"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'h'
},
{
},
{
},
};
};
...
@@ -202,7 +201,7 @@ int cmd_idle_info(int argc, char **argv)
...
@@ -202,7 +201,7 @@ int cmd_idle_info(int argc, char **argv)
output_param
=
ret
;
output_param
=
ret
;
break
;
break
;
}
}
}
while
(
cont
);
}
while
(
cont
);
switch
(
output_param
)
{
switch
(
output_param
)
{
case
-
1
:
case
-
1
:
...
@@ -241,5 +240,5 @@ int cmd_idle_info(int argc, char **argv)
...
@@ -241,5 +240,5 @@ int cmd_idle_info(int argc, char **argv)
break
;
break
;
}
}
}
}
return
(
EXIT_SUCCESS
)
;
return
EXIT_SUCCESS
;
}
}
tools/power/cpupower/utils/cpupower-info.c
View file @
a1ce5ba2
...
@@ -30,10 +30,10 @@ void info_help(void)
...
@@ -30,10 +30,10 @@ void info_help(void)
}
}
static
struct
option
set_opts
[]
=
{
static
struct
option
set_opts
[]
=
{
{
.
name
=
"perf-bias"
,
.
has_arg
=
optional_argument
,
.
flag
=
NULL
,
.
val
=
'b'
},
{
.
name
=
"perf-bias"
,
.
has_arg
=
optional_argument
,
.
flag
=
NULL
,
.
val
=
'b'
},
{
.
name
=
"sched-mc"
,
.
has_arg
=
optional_argument
,
.
flag
=
NULL
,
.
val
=
'm'
},
{
.
name
=
"sched-mc"
,
.
has_arg
=
optional_argument
,
.
flag
=
NULL
,
.
val
=
'm'
},
{
.
name
=
"sched-smt"
,
.
has_arg
=
optional_argument
,
.
flag
=
NULL
,
.
val
=
's'
},
{
.
name
=
"sched-smt"
,
.
has_arg
=
optional_argument
,
.
flag
=
NULL
,
.
val
=
's'
},
{
.
name
=
"help"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'h'
},
{
.
name
=
"help"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'h'
},
{
},
{
},
};
};
...
@@ -57,12 +57,11 @@ int cmd_info(int argc, char **argv)
...
@@ -57,12 +57,11 @@ int cmd_info(int argc, char **argv)
int
perf_bias
:
1
;
int
perf_bias
:
1
;
};
};
int
params
;
int
params
;
}
params
=
{};
}
params
=
{};
int
ret
=
0
;
int
ret
=
0
;
setlocale
(
LC_ALL
,
""
);
setlocale
(
LC_ALL
,
""
);
textdomain
(
PACKAGE
);
textdomain
(
PACKAGE
);
/* parameter parsing */
/* parameter parsing */
while
((
ret
=
getopt_long
(
argc
,
argv
,
"msbh"
,
set_opts
,
NULL
))
!=
-
1
)
{
while
((
ret
=
getopt_long
(
argc
,
argv
,
"msbh"
,
set_opts
,
NULL
))
!=
-
1
)
{
...
@@ -123,7 +122,7 @@ int cmd_info(int argc, char **argv)
...
@@ -123,7 +122,7 @@ int cmd_info(int argc, char **argv)
if
(
params
.
perf_bias
)
{
if
(
params
.
perf_bias
)
{
if
(
!
run_as_root
)
{
if
(
!
run_as_root
)
{
params
.
perf_bias
=
0
;
params
.
perf_bias
=
0
;
printf
(
_
(
"Intel's performance bias setting needs root privileges
\n
"
));
printf
(
_
(
"Intel's performance bias setting needs root privileges
\n
"
));
}
else
if
(
!
(
cpupower_cpu_info
.
caps
&
CPUPOWER_CAP_PERF_BIAS
))
{
}
else
if
(
!
(
cpupower_cpu_info
.
caps
&
CPUPOWER_CAP_PERF_BIAS
))
{
printf
(
_
(
"System does not support Intel's performance"
printf
(
_
(
"System does not support Intel's performance"
" bias setting
\n
"
));
" bias setting
\n
"
));
...
...
tools/power/cpupower/utils/cpupower-set.c
View file @
a1ce5ba2
...
@@ -30,10 +30,10 @@ void set_help(void)
...
@@ -30,10 +30,10 @@ void set_help(void)
}
}
static
struct
option
set_opts
[]
=
{
static
struct
option
set_opts
[]
=
{
{
.
name
=
"perf-bias"
,
.
has_arg
=
optional_argument
,
.
flag
=
NULL
,
.
val
=
'b'
},
{
.
name
=
"perf-bias"
,
.
has_arg
=
optional_argument
,
.
flag
=
NULL
,
.
val
=
'b'
},
{
.
name
=
"sched-mc"
,
.
has_arg
=
optional_argument
,
.
flag
=
NULL
,
.
val
=
'm'
},
{
.
name
=
"sched-mc"
,
.
has_arg
=
optional_argument
,
.
flag
=
NULL
,
.
val
=
'm'
},
{
.
name
=
"sched-smt"
,
.
has_arg
=
optional_argument
,
.
flag
=
NULL
,
.
val
=
's'
},
{
.
name
=
"sched-smt"
,
.
has_arg
=
optional_argument
,
.
flag
=
NULL
,
.
val
=
's'
},
{
.
name
=
"help"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'h'
},
{
.
name
=
"help"
,
.
has_arg
=
no_argument
,
.
flag
=
NULL
,
.
val
=
'h'
},
{
},
{
},
};
};
...
@@ -57,17 +57,17 @@ int cmd_set(int argc, char **argv)
...
@@ -57,17 +57,17 @@ int cmd_set(int argc, char **argv)
int
perf_bias
:
1
;
int
perf_bias
:
1
;
};
};
int
params
;
int
params
;
}
params
;
}
params
;
int
sched_mc
=
0
,
sched_smt
=
0
,
perf_bias
=
0
;
int
sched_mc
=
0
,
sched_smt
=
0
,
perf_bias
=
0
;
int
ret
=
0
;
int
ret
=
0
;
setlocale
(
LC_ALL
,
""
);
setlocale
(
LC_ALL
,
""
);
textdomain
(
PACKAGE
);
textdomain
(
PACKAGE
);
params
.
params
=
0
;
params
.
params
=
0
;
/* parameter parsing */
/* parameter parsing */
while
((
ret
=
getopt_long
(
argc
,
argv
,
"m:s:b:h"
,
set_opts
,
NULL
))
!=
-
1
)
{
while
((
ret
=
getopt_long
(
argc
,
argv
,
"m:s:b:h"
,
set_opts
,
NULL
))
!=
-
1
)
{
switch
(
ret
)
{
switch
(
ret
)
{
case
'h'
:
case
'h'
:
set_help
();
set_help
();
...
...
tools/power/cpupower/utils/cpupower.c
View file @
a1ce5ba2
...
@@ -51,7 +51,7 @@ static struct cmd_struct commands[] = {
...
@@ -51,7 +51,7 @@ static struct cmd_struct commands[] = {
{
"info"
,
cmd_info
,
info_help
,
0
},
{
"info"
,
cmd_info
,
info_help
,
0
},
{
"monitor"
,
cmd_monitor
,
monitor_help
,
0
},
{
"monitor"
,
cmd_monitor
,
monitor_help
,
0
},
{
"help"
,
cmd_help
,
print_help
,
0
},
{
"help"
,
cmd_help
,
print_help
,
0
},
/
/ { "bench", cmd_bench, NULL, 1 },
/
* { "bench", cmd_bench, NULL, 1 }, */
};
};
int
cmd_help
(
int
argc
,
const
char
**
argv
)
int
cmd_help
(
int
argc
,
const
char
**
argv
)
...
@@ -95,7 +95,8 @@ static void print_help(void)
...
@@ -95,7 +95,8 @@ static void print_help(void)
printf
(
_
(
"
\n
Use cpupower help subcommand for getting help for above subcommands.
\n
"
));
printf
(
_
(
"
\n
Use cpupower help subcommand for getting help for above subcommands.
\n
"
));
}
}
static
void
print_version
(
void
)
{
static
void
print_version
(
void
)
{
printf
(
PACKAGE
" "
VERSION
"
\n
"
);
printf
(
PACKAGE
" "
VERSION
"
\n
"
);
printf
(
_
(
"Report errors and bugs to %s, please.
\n
"
),
PACKAGE_BUGREPORT
);
printf
(
_
(
"Report errors and bugs to %s, please.
\n
"
),
PACKAGE_BUGREPORT
);
}
}
...
@@ -109,10 +110,10 @@ static void handle_options(int *argc, const char ***argv)
...
@@ -109,10 +110,10 @@ static void handle_options(int *argc, const char ***argv)
for
(
x
=
0
;
x
<
*
argc
&&
((
*
argv
)[
x
])[
0
]
==
'-'
;
x
++
)
{
for
(
x
=
0
;
x
<
*
argc
&&
((
*
argv
)[
x
])[
0
]
==
'-'
;
x
++
)
{
const
char
*
param
=
(
*
argv
)[
x
];
const
char
*
param
=
(
*
argv
)[
x
];
if
(
!
strcmp
(
param
,
"-h"
)
||
!
strcmp
(
param
,
"--help"
)){
if
(
!
strcmp
(
param
,
"-h"
)
||
!
strcmp
(
param
,
"--help"
))
{
print_help
();
print_help
();
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
}
else
if
(
!
strcmp
(
param
,
"-c"
)
||
!
strcmp
(
param
,
"--cpu"
)){
}
else
if
(
!
strcmp
(
param
,
"-c"
)
||
!
strcmp
(
param
,
"--cpu"
))
{
if
(
*
argc
<
2
)
{
if
(
*
argc
<
2
)
{
print_help
();
print_help
();
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -132,13 +133,14 @@ static void handle_options(int *argc, const char ***argv)
...
@@ -132,13 +133,14 @@ static void handle_options(int *argc, const char ***argv)
/* Cut out param: cpupower -c 1 info -> cpupower info */
/* Cut out param: cpupower -c 1 info -> cpupower info */
new_argc
+=
2
;
new_argc
+=
2
;
continue
;
continue
;
}
else
if
(
!
strcmp
(
param
,
"-v"
)
||
!
strcmp
(
param
,
"--version"
)){
}
else
if
(
!
strcmp
(
param
,
"-v"
)
||
!
strcmp
(
param
,
"--version"
))
{
print_version
();
print_version
();
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
#ifdef DEBUG
#ifdef DEBUG
}
else
if
(
!
strcmp
(
param
,
"-d"
)
||
!
strcmp
(
param
,
"--debug"
)){
}
else
if
(
!
strcmp
(
param
,
"-d"
)
||
!
strcmp
(
param
,
"--debug"
))
{
be_verbose
=
1
;
be_verbose
=
1
;
new_argc
++
;
new_argc
++
;
continue
;
continue
;
#endif
#endif
}
else
{
}
else
{
...
@@ -171,7 +173,7 @@ int main(int argc, const char *argv[])
...
@@ -171,7 +173,7 @@ int main(int argc, const char *argv[])
}
}
setlocale
(
LC_ALL
,
""
);
setlocale
(
LC_ALL
,
""
);
textdomain
(
PACKAGE
);
textdomain
(
PACKAGE
);
/* Turn "perf cmd --help" into "perf help cmd" */
/* Turn "perf cmd --help" into "perf help cmd" */
if
(
argc
>
1
&&
!
strcmp
(
argv
[
1
],
"--help"
))
{
if
(
argc
>
1
&&
!
strcmp
(
argv
[
1
],
"--help"
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment