Skip to content

Commit bdd9fd0

Browse files
author
CKI KWF Bot
committed
Merge: cpupower: Updates to 6.17
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1567 Description: updates for cpupower The following commits were not applied to this update as they are unnecessary for RHEL10.2: fffadbd cpupower: Make lib versioning scheme more obvio 9c70b77 cpupower: add a systemd service to run cpupower 2a0eaa7 cpupower: do not write DESTDIR to cpupower.serv 4edef85 cpupower: do not call systemctl at install time e517436 cpupower: do not install files to /etc/default/ e044b8a cpupower: split unitdir from libdir in Makefile JIRA: https://issues.redhat.com/browse/RHEL-110832 Build Info: 69077015 Tested: Successful platform test results on Intel (intel-arrowlake-s-02) system. Signed-off-by: Steve Best <sbest@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: Lenny Szubowicz <lszubowi@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents d32c572 + 82aa138 commit bdd9fd0

File tree

5 files changed

+47
-16
lines changed

5 files changed

+47
-16
lines changed

tools/power/cpupower/lib/cpupower.c

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <stdio.h>
1111
#include <errno.h>
1212
#include <stdlib.h>
13+
#include <string.h>
1314

1415
#include "cpupower.h"
1516
#include "cpupower_intern.h"
@@ -150,15 +151,25 @@ static int __compare(const void *t1, const void *t2)
150151
return 0;
151152
}
152153

154+
static int __compare_core_cpu_list(const void *t1, const void *t2)
155+
{
156+
struct cpuid_core_info *top1 = (struct cpuid_core_info *)t1;
157+
struct cpuid_core_info *top2 = (struct cpuid_core_info *)t2;
158+
159+
return strcmp(top1->core_cpu_list, top2->core_cpu_list);
160+
}
161+
153162
/*
154163
* Returns amount of cpus, negative on error, cpu_top must be
155164
* passed to cpu_topology_release to free resources
156165
*
157-
* Array is sorted after ->pkg, ->core, then ->cpu
166+
* Array is sorted after ->cpu_smt_list ->pkg, ->core
158167
*/
159168
int get_cpu_topology(struct cpupower_topology *cpu_top)
160169
{
161170
int cpu, last_pkg, cpus = sysconf(_SC_NPROCESSORS_CONF);
171+
char path[SYSFS_PATH_MAX];
172+
char *last_cpu_list;
162173

163174
cpu_top->core_info = malloc(sizeof(struct cpuid_core_info) * cpus);
164175
if (cpu_top->core_info == NULL)
@@ -183,6 +194,34 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
183194
cpu_top->core_info[cpu].core = -1;
184195
continue;
185196
}
197+
if (cpu_top->core_info[cpu].core == -1) {
198+
strncpy(cpu_top->core_info[cpu].core_cpu_list, "-1", CPULIST_BUFFER);
199+
continue;
200+
}
201+
snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/topology/%s",
202+
cpu, "core_cpus_list");
203+
if (cpupower_read_sysfs(
204+
path,
205+
cpu_top->core_info[cpu].core_cpu_list,
206+
CPULIST_BUFFER) < 1) {
207+
printf("Warning CPU%u has a 0 size core_cpus_list string", cpu);
208+
}
209+
}
210+
211+
/* Count the number of distinct cpu lists to get the physical core
212+
* count.
213+
*/
214+
qsort(cpu_top->core_info, cpus, sizeof(struct cpuid_core_info),
215+
__compare_core_cpu_list);
216+
217+
last_cpu_list = cpu_top->core_info[0].core_cpu_list;
218+
cpu_top->cores = 1;
219+
for (cpu = 1; cpu < cpus; cpu++) {
220+
if (strcmp(cpu_top->core_info[cpu].core_cpu_list, last_cpu_list) != 0 &&
221+
cpu_top->core_info[cpu].pkg != -1) {
222+
last_cpu_list = cpu_top->core_info[cpu].core_cpu_list;
223+
cpu_top->cores++;
224+
}
186225
}
187226

188227
qsort(cpu_top->core_info, cpus, sizeof(struct cpuid_core_info),
@@ -203,13 +242,6 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
203242
if (!(cpu_top->core_info[0].pkg == -1))
204243
cpu_top->pkgs++;
205244

206-
/* Intel's cores count is not consecutively numbered, there may
207-
* be a core_id of 3, but none of 2. Assume there always is 0
208-
* Get amount of cores by counting duplicates in a package
209-
for (cpu = 0; cpu_top->core_info[cpu].pkg = 0 && cpu < cpus; cpu++) {
210-
if (cpu_top->core_info[cpu].core == 0)
211-
cpu_top->cores++;
212-
*/
213245
return cpus;
214246
}
215247

tools/power/cpupower/lib/cpupower.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#ifndef __CPUPOWER_CPUPOWER_H__
33
#define __CPUPOWER_CPUPOWER_H__
44

5+
#define CPULIST_BUFFER 5
6+
57
struct cpupower_topology {
68
/* Amount of CPU cores, packages and threads per core in the system */
79
unsigned int cores;
@@ -16,6 +18,7 @@ struct cpuid_core_info {
1618
int pkg;
1719
int core;
1820
int cpu;
21+
char core_cpu_list[CPULIST_BUFFER];
1922

2023
/* flags */
2124
unsigned int is_online:1;

tools/power/cpupower/utils/cpupower-set.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ int cmd_set(int argc, char **argv)
6363

6464
params.params = 0;
6565
/* parameter parsing */
66-
while ((ret = getopt_long(argc, argv, "b:e:m:",
67-
set_opts, NULL)) != -1) {
66+
while ((ret = getopt_long(argc, argv, "b:e:m:t:",
67+
set_opts, NULL)) != -1) {
6868
switch (ret) {
6969
case 'b':
7070
if (params.perf_bias)

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,8 @@ void print_header(int topology_depth)
121121
switch (topology_depth) {
122122
case TOPOLOGY_DEPTH_PKG:
123123
printf(" PKG|");
124-
break;
125124
case TOPOLOGY_DEPTH_CORE:
126125
printf("CORE|");
127-
break;
128126
case TOPOLOGY_DEPTH_CPU:
129127
printf(" CPU|");
130128
break;
@@ -167,10 +165,8 @@ void print_results(int topology_depth, int cpu)
167165
switch (topology_depth) {
168166
case TOPOLOGY_DEPTH_PKG:
169167
printf("%4d|", cpu_top.core_info[cpu].pkg);
170-
break;
171168
case TOPOLOGY_DEPTH_CORE:
172169
printf("%4d|", cpu_top.core_info[cpu].core);
173-
break;
174170
case TOPOLOGY_DEPTH_CPU:
175171
printf("%4d|", cpu_top.core_info[cpu].cpu);
176172
break;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ static int mperf_stop(void)
240240
int cpu;
241241

242242
for (cpu = 0; cpu < cpu_count; cpu++) {
243-
mperf_measure_stats(cpu);
244-
mperf_get_tsc(&tsc_at_measure_end[cpu]);
245243
clock_gettime(CLOCK_REALTIME, &time_end[cpu]);
244+
mperf_get_tsc(&tsc_at_measure_end[cpu]);
245+
mperf_measure_stats(cpu);
246246
}
247247

248248
return 0;

0 commit comments

Comments
 (0)