Skip to content

Commit a5015d9

Browse files
committed
tools/power turbostat: delete GET_PKG()
pkg_base[pkg_id] is a simple array of structure pointers, let the compiler treat it that way. Signed-off-by: Len Brown <[email protected]>
1 parent 5f961fb commit a5015d9

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

tools/power/x86/turbostat/turbostat.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,8 +2080,6 @@ struct pkg_data {
20802080
((node_no) * topo.cores_per_node) + \
20812081
(core_no))
20822082

2083-
#define GET_PKG(pkg_base, pkg_no) (pkg_base + pkg_no)
2084-
20852083
/*
20862084
* The accumulated sum of MSR is defined as a monotonic
20872085
* increasing MSR, it will be accumulated periodically,
@@ -2345,16 +2343,15 @@ int for_all_cpus(int (func) (struct thread_data *, struct core_data *, struct pk
23452343
for (thread_no = 0; thread_no < topo.threads_per_core; ++thread_no) {
23462344
struct thread_data *t;
23472345
struct core_data *c;
2348-
struct pkg_data *p;
2346+
23492347
t = GET_THREAD(thread_base, thread_no, core_no, node_no, pkg_no);
23502348

23512349
if (cpu_is_not_allowed(t->cpu_id))
23522350
continue;
23532351

23542352
c = GET_CORE(core_base, core_no, node_no, pkg_no);
2355-
p = GET_PKG(pkg_base, pkg_no);
23562353

2357-
retval |= func(t, c, p);
2354+
retval |= func(t, c, &pkg_base[pkg_no]);
23582355
}
23592356
}
23602357
}
@@ -6119,7 +6116,6 @@ int for_all_cpus_2(int (func) (struct thread_data *, struct core_data *,
61196116
for (thread_no = 0; thread_no < topo.threads_per_core; ++thread_no) {
61206117
struct thread_data *t, *t2;
61216118
struct core_data *c, *c2;
6122-
struct pkg_data *p, *p2;
61236119

61246120
t = GET_THREAD(thread_base, thread_no, core_no, node_no, pkg_no);
61256121

@@ -6131,10 +6127,7 @@ int for_all_cpus_2(int (func) (struct thread_data *, struct core_data *,
61316127
c = GET_CORE(core_base, core_no, node_no, pkg_no);
61326128
c2 = GET_CORE(core_base2, core_no, node_no, pkg_no);
61336129

6134-
p = GET_PKG(pkg_base, pkg_no);
6135-
p2 = GET_PKG(pkg_base2, pkg_no);
6136-
6137-
retval |= func(t, c, p, t2, c2, p2);
6130+
retval |= func(t, c, &pkg_base[pkg_no], t2, c2, &pkg_base2[pkg_no]);
61386131
}
61396132
}
61406133
}
@@ -9342,7 +9335,6 @@ void init_counter(struct thread_data *thread_base, struct core_data *core_base,
93429335
int thread_id = cpus[cpu_id].thread_id;
93439336
struct thread_data *t;
93449337
struct core_data *c;
9345-
struct pkg_data *p;
93469338

93479339
/* Workaround for systems where physical_node_id==-1
93489340
* and logical_node_id==(-1 - topo.num_cpus)
@@ -9352,18 +9344,17 @@ void init_counter(struct thread_data *thread_base, struct core_data *core_base,
93529344

93539345
t = GET_THREAD(thread_base, thread_id, core_id, node_id, pkg_id);
93549346
c = GET_CORE(core_base, core_id, node_id, pkg_id);
9355-
p = GET_PKG(pkg_base, pkg_id);
93569347

93579348
t->cpu_id = cpu_id;
93589349
if (!cpu_is_not_allowed(cpu_id)) {
93599350
if (c->base_cpu < 0)
93609351
c->base_cpu = t->cpu_id;
9361-
if (p->base_cpu < 0)
9362-
p->base_cpu = t->cpu_id;
9352+
if (pkg_base[pkg_id].base_cpu < 0)
9353+
pkg_base[pkg_id].base_cpu = t->cpu_id;
93639354
}
93649355

93659356
c->core_id = core_id;
9366-
p->package_id = pkg_id;
9357+
pkg_base[pkg_id].package_id = pkg_id;
93679358
}
93689359

93699360
int initialize_counters(int cpu_id)

0 commit comments

Comments
 (0)