Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf s390 s390_cpumcfdg_dump: Don't scan all PMUs

Rather than scanning all PMUs for a counter name, scan the PMU
associated with the evsel of the sample. This is done to remove a
dependence on pmu-events.h.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230824041330.266337-7-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
c4ac7f75 9d31cb93

+26 -24
+26 -24
tools/perf/util/s390-sample-raw.c
··· 27 27 #include "color.h" 28 28 #include "sample-raw.h" 29 29 #include "s390-cpumcf-kernel.h" 30 - #include "pmu-events/pmu-events.h" 30 + #include "util/pmu.h" 31 31 #include "util/sample.h" 32 32 33 33 static size_t ctrset_size(struct cf_ctrset_entry *set) ··· 132 132 133 133 struct get_counter_name_data { 134 134 int wanted; 135 - const char *result; 135 + char *result; 136 136 }; 137 137 138 - static int get_counter_name_callback(const struct pmu_event *evp, 139 - const struct pmu_events_table *table __maybe_unused, 140 - void *vdata) 138 + static int get_counter_name_callback(void *vdata, struct pmu_event_info *info) 141 139 { 142 140 struct get_counter_name_data *data = vdata; 143 141 int rc, event_nr; 142 + const char *event_str; 144 143 145 - if (evp->name == NULL || evp->event == NULL) 144 + if (info->str == NULL) 146 145 return 0; 147 - rc = sscanf(evp->event, "event=%x", &event_nr); 146 + 147 + event_str = strstr(info->str, "event="); 148 + if (!event_str) 149 + return 0; 150 + 151 + rc = sscanf(event_str, "event=%x", &event_nr); 148 152 if (rc == 1 && event_nr == data->wanted) { 149 - data->result = evp->name; 153 + data->result = strdup(info->name); 150 154 return 1; /* Terminate the search. */ 151 155 } 152 156 return 0; 153 157 } 154 158 155 - /* Scan the PMU table and extract the logical name of a counter from the 156 - * PMU events table. Input is the counter set and counter number with in the 157 - * set. Construct the event number and use this as key. If they match return 158 - * the name of this counter. 159 + /* Scan the PMU and extract the logical name of a counter from the event. Input 160 + * is the counter set and counter number with in the set. Construct the event 161 + * number and use this as key. If they match return the name of this counter. 159 162 * If no match is found a NULL pointer is returned. 160 163 */ 161 - static const char *get_counter_name(int set, int nr, const struct pmu_events_table *table) 164 + static char *get_counter_name(int set, int nr, struct perf_pmu *pmu) 162 165 { 163 166 struct get_counter_name_data data = { 164 167 .wanted = get_counterset_start(set) + nr, 165 168 .result = NULL, 166 169 }; 167 170 168 - if (!table) 171 + if (!pmu) 169 172 return NULL; 170 173 171 - pmu_events_table__for_each_event(table, get_counter_name_callback, &data); 174 + perf_pmu__for_each_event(pmu, &data, get_counter_name_callback); 172 175 return data.result; 173 176 } 174 177 175 - static void s390_cpumcfdg_dump(struct perf_sample *sample) 178 + static void s390_cpumcfdg_dump(struct perf_pmu *pmu, struct perf_sample *sample) 176 179 { 177 180 size_t i, len = sample->raw_size, offset = 0; 178 181 unsigned char *buf = sample->raw_data; 179 182 const char *color = PERF_COLOR_BLUE; 180 183 struct cf_ctrset_entry *cep, ce; 181 - const struct pmu_events_table *table; 182 184 u64 *p; 183 185 184 - table = pmu_events_table__find(); 185 186 while (offset < len) { 186 187 cep = (struct cf_ctrset_entry *)(buf + offset); 187 188 ··· 200 199 color_fprintf(stdout, color, " [%#08zx] Counterset:%d" 201 200 " Counters:%d\n", offset, ce.set, ce.ctr); 202 201 for (i = 0, p = (u64 *)(cep + 1); i < ce.ctr; ++i, ++p) { 203 - const char *ev_name = get_counter_name(ce.set, i, table); 202 + char *ev_name = get_counter_name(ce.set, i, pmu); 204 203 205 204 color_fprintf(stdout, color, 206 205 "\tCounter:%03d %s Value:%#018lx\n", i, 207 206 ev_name ?: "<unknown>", be64_to_cpu(*p)); 207 + free(ev_name); 208 208 } 209 209 offset += ctrset_size(&ce); 210 210 } ··· 218 216 */ 219 217 void evlist__s390_sample_raw(struct evlist *evlist, union perf_event *event, struct perf_sample *sample) 220 218 { 221 - struct evsel *ev_bc000; 219 + struct evsel *evsel; 222 220 223 221 if (event->header.type != PERF_RECORD_SAMPLE) 224 222 return; 225 223 226 - ev_bc000 = evlist__event2evsel(evlist, event); 227 - if (ev_bc000 == NULL || 228 - ev_bc000->core.attr.config != PERF_EVENT_CPUM_CF_DIAG) 224 + evsel = evlist__event2evsel(evlist, event); 225 + if (evsel == NULL || 226 + evsel->core.attr.config != PERF_EVENT_CPUM_CF_DIAG) 229 227 return; 230 228 231 229 /* Display raw data on screen */ ··· 233 231 pr_err("Invalid counter set data encountered\n"); 234 232 return; 235 233 } 236 - s390_cpumcfdg_dump(sample); 234 + s390_cpumcfdg_dump(evsel->pmu, sample); 237 235 }