Skip to content

Commit 5202e32

Browse files
committed
Merge tag 'linux-cpupower-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux
Pull cpupower updates for v4.18-rc1 from Shuah Khan: "This cpupower update for 4.18-rc1 consists of two minor fixes." * tag 'linux-cpupower-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux: cpupower : Fix header name to read idle state name cpupower: fix spelling mistake: "logilename" -> "logfilename"
2 parents 3c89adb + f9652d5 commit 5202e32

File tree

4 files changed

+45
-16
lines changed

4 files changed

+45
-16
lines changed

tools/power/cpupower/bench/parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ FILE *prepare_output(const char *dirname)
104104
dirname, time(NULL));
105105
}
106106

107-
dprintf("logilename: %s\n", filename);
107+
dprintf("logfilename: %s\n", filename);
108108

109109
output = fopen(filename, "w+");
110110
if (output == NULL) {

tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,20 @@ void fix_up_intel_idle_driver_name(char *tmp, int num)
126126
}
127127
}
128128

129+
#ifdef __powerpc__
130+
void map_power_idle_state_name(char *tmp)
131+
{
132+
if (!strncmp(tmp, "stop0_lite", CSTATE_NAME_LEN))
133+
strcpy(tmp, "stop0L");
134+
else if (!strncmp(tmp, "stop1_lite", CSTATE_NAME_LEN))
135+
strcpy(tmp, "stop1L");
136+
else if (!strncmp(tmp, "stop2_lite", CSTATE_NAME_LEN))
137+
strcpy(tmp, "stop2L");
138+
}
139+
#else
140+
void map_power_idle_state_name(char *tmp) { }
141+
#endif
142+
129143
static struct cpuidle_monitor *cpuidle_register(void)
130144
{
131145
int num;
@@ -145,6 +159,7 @@ static struct cpuidle_monitor *cpuidle_register(void)
145159
if (tmp == NULL)
146160
continue;
147161

162+
map_power_idle_state_name(tmp);
148163
fix_up_intel_idle_driver_name(tmp, num);
149164
strncpy(cpuidle_cstates[num].name, tmp, CSTATE_NAME_LEN - 1);
150165
free(tmp);

tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,60 +70,65 @@ void print_n_spaces(int n)
7070
printf(" ");
7171
}
7272

73-
/* size of s must be at least n + 1 */
73+
/*s is filled with left and right spaces
74+
*to make its length atleast n+1
75+
*/
7476
int fill_string_with_spaces(char *s, int n)
7577
{
78+
char *temp;
7679
int len = strlen(s);
77-
if (len > n)
80+
81+
if (len >= n)
7882
return -1;
83+
84+
temp = malloc(sizeof(char) * (n+1));
7985
for (; len < n; len++)
8086
s[len] = ' ';
8187
s[len] = '\0';
88+
snprintf(temp, n+1, " %s", s);
89+
strcpy(s, temp);
90+
free(temp);
8291
return 0;
8392
}
8493

94+
#define MAX_COL_WIDTH 6
8595
void print_header(int topology_depth)
8696
{
8797
int unsigned mon;
8898
int state, need_len;
8999
cstate_t s;
90100
char buf[128] = "";
91-
int percent_width = 4;
92101

93102
fill_string_with_spaces(buf, topology_depth * 5 - 1);
94103
printf("%s|", buf);
95104

96105
for (mon = 0; mon < avail_monitors; mon++) {
97-
need_len = monitors[mon]->hw_states_num * (percent_width + 3)
106+
need_len = monitors[mon]->hw_states_num * (MAX_COL_WIDTH + 1)
98107
- 1;
99-
if (mon != 0) {
100-
printf("|| ");
101-
need_len--;
102-
}
108+
if (mon != 0)
109+
printf("||");
103110
sprintf(buf, "%s", monitors[mon]->name);
104111
fill_string_with_spaces(buf, need_len);
105112
printf("%s", buf);
106113
}
107114
printf("\n");
108115

109116
if (topology_depth > 2)
110-
printf("PKG |");
117+
printf(" PKG|");
111118
if (topology_depth > 1)
112119
printf("CORE|");
113120
if (topology_depth > 0)
114-
printf("CPU |");
121+
printf(" CPU|");
115122

116123
for (mon = 0; mon < avail_monitors; mon++) {
117124
if (mon != 0)
118-
printf("|| ");
119-
else
120-
printf(" ");
125+
printf("||");
121126
for (state = 0; state < monitors[mon]->hw_states_num; state++) {
122127
if (state != 0)
123-
printf(" | ");
128+
printf("|");
124129
s = monitors[mon]->hw_states[state];
125130
sprintf(buf, "%s", s.name);
126-
fill_string_with_spaces(buf, percent_width);
131+
fill_string_with_spaces(buf, MAX_COL_WIDTH);
127132
printf("%s", buf);
128133
}
129134
printf(" ");

tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@
1515

1616
#define MONITORS_MAX 20
1717
#define MONITOR_NAME_LEN 20
18+
19+
/* CSTATE_NAME_LEN is limited by header field width defined
20+
* in cpupower-monitor.c. Header field width is defined to be
21+
* sum of percent width and two spaces for padding.
22+
*/
23+
#ifdef __powerpc__
24+
#define CSTATE_NAME_LEN 7
25+
#else
1826
#define CSTATE_NAME_LEN 5
27+
#endif
1928
#define CSTATE_DESC_LEN 60
2029

2130
int cpu_count;

0 commit comments

Comments
 (0)