@@ -134,23 +134,6 @@ perf_tmam_data_t perf_tmam_data_t::read_from_perf(int perf_leader_fd) {
134
134
return data;
135
135
}
136
136
137
- unsigned int perf_tmam_handle::get_pmu_type () {
138
- const std::string fname = " /sys/devices/cpu_core/type" ;
139
- unsigned int type;
140
- std::ifstream typefile (fname);
141
-
142
- if (!typefile.is_open ()) {
143
- throw std::system_error (errno, std::generic_category (), " could not open " + fname);
144
- }
145
-
146
- typefile >> type;
147
-
148
- if (0 == type) {
149
- throw std::system_error (EINVAL, std::generic_category (), " perf PMU type must not be zero" );
150
- }
151
-
152
- return type;
153
- }
154
137
155
138
perf_tmam_handle::perf_tmam_handle (bool use_rdpmc, pid_t pid, int cpu) : use_rdpmc(use_rdpmc) {
156
139
// phase 1: open leader
@@ -159,14 +142,15 @@ perf_tmam_handle::perf_tmam_handle(bool use_rdpmc, pid_t pid, int cpu) : use_rdp
159
142
// Note that "config" is using hardcoded values throughout.
160
143
// This is because a) the documentation notes these numbers,
161
144
// so they are assumed to be stable and b) they are hardcoded in the kernel as well.
145
+ // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/Documentation/topdown.txt
162
146
163
147
// Also, the perf_event_attr struct is huged and designed to no be specified for many fields.
164
148
// Therefore the pragma to supress the warnings.
165
149
166
150
#pragma GCC diagnostic push
167
151
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
168
152
struct perf_event_attr leader_perf_attr = {
169
- .type = get_pmu_type () ,
153
+ .type = PERF_TYPE_RAW ,
170
154
.size = sizeof (struct perf_event_attr ),
171
155
.config = 0x400 ,
172
156
.read_format = PERF_FORMAT_GROUP,
@@ -186,7 +170,7 @@ perf_tmam_handle::perf_tmam_handle(bool use_rdpmc, pid_t pid, int cpu) : use_rdp
186
170
#pragma GCC diagnostic push
187
171
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
188
172
struct perf_event_attr perf_attr = {
189
- .type = get_pmu_type () ,
173
+ .type = PERF_TYPE_RAW ,
190
174
.size = sizeof (struct perf_event_attr ),
191
175
.config = config,
192
176
.read_format = PERF_FORMAT_GROUP,
0 commit comments