Skip to content

Commit d4affd6

Browse files
committed
Merge tag 'perf-tools-fixes-for-v5.14-2021-08-01' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
Pull perf tools fixes from Arnaldo Carvalho de Melo: - Revert "perf map: Fix dso->nsinfo refcounting", this makes 'perf top' abort, uncovering a design flaw on how namespace information is kept. The fix for that is more than we can do right now, leave it for the next merge window. - Split --dump-raw-trace by AUX records for ARM's CoreSight, fixing up the decoding of some records. - Fix PMU alias matching. Thanks to James Clark and John Garry for these fixes. * tag 'perf-tools-fixes-for-v5.14-2021-08-01' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: Revert "perf map: Fix dso->nsinfo refcounting" perf pmu: Fix alias matching perf cs-etm: Split --dump-raw-trace by AUX records
2 parents c82357a + 9bac1bd commit d4affd6

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed

tools/perf/util/cs-etm.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,6 +2434,22 @@ static int cs_etm__process_event(struct perf_session *session,
24342434
return 0;
24352435
}
24362436

2437+
static void dump_queued_data(struct cs_etm_auxtrace *etm,
2438+
struct perf_record_auxtrace *event)
2439+
{
2440+
struct auxtrace_buffer *buf;
2441+
unsigned int i;
2442+
/*
2443+
* Find all buffers with same reference in the queues and dump them.
2444+
* This is because the queues can contain multiple entries of the same
2445+
* buffer that were split on aux records.
2446+
*/
2447+
for (i = 0; i < etm->queues.nr_queues; ++i)
2448+
list_for_each_entry(buf, &etm->queues.queue_array[i].head, list)
2449+
if (buf->reference == event->reference)
2450+
cs_etm__dump_event(etm, buf);
2451+
}
2452+
24372453
static int cs_etm__process_auxtrace_event(struct perf_session *session,
24382454
union perf_event *event,
24392455
struct perf_tool *tool __maybe_unused)
@@ -2466,7 +2482,8 @@ static int cs_etm__process_auxtrace_event(struct perf_session *session,
24662482
cs_etm__dump_event(etm, buffer);
24672483
auxtrace_buffer__put_data(buffer);
24682484
}
2469-
}
2485+
} else if (dump_trace)
2486+
dump_queued_data(etm, &event->auxtrace);
24702487

24712488
return 0;
24722489
}
@@ -3042,7 +3059,6 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
30423059

30433060
if (dump_trace) {
30443061
cs_etm__print_auxtrace_info(auxtrace_info->priv, num_cpu);
3045-
return 0;
30463062
}
30473063

30483064
err = cs_etm__synth_events(etm, session);

tools/perf/util/map.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
192192
if (!(prot & PROT_EXEC))
193193
dso__set_loaded(dso);
194194
}
195-
196-
nsinfo__put(dso->nsinfo);
197195
dso->nsinfo = nsi;
198196

199197
if (build_id__is_defined(bid))

tools/perf/util/pmu.c

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -742,9 +742,13 @@ struct pmu_events_map *__weak pmu_events_map__find(void)
742742
return perf_pmu__find_map(NULL);
743743
}
744744

745-
static bool perf_pmu__valid_suffix(char *pmu_name, char *tok)
745+
/*
746+
* Suffix must be in form tok_{digits}, or tok{digits}, or same as pmu_name
747+
* to be valid.
748+
*/
749+
static bool perf_pmu__valid_suffix(const char *pmu_name, char *tok)
746750
{
747-
char *p;
751+
const char *p;
748752

749753
if (strncmp(pmu_name, tok, strlen(tok)))
750754
return false;
@@ -753,12 +757,16 @@ static bool perf_pmu__valid_suffix(char *pmu_name, char *tok)
753757
if (*p == 0)
754758
return true;
755759

756-
if (*p != '_')
757-
return false;
760+
if (*p == '_')
761+
++p;
758762

759-
++p;
760-
if (*p == 0 || !isdigit(*p))
761-
return false;
763+
/* Ensure we end in a number */
764+
while (1) {
765+
if (!isdigit(*p))
766+
return false;
767+
if (*(++p) == 0)
768+
break;
769+
}
762770

763771
return true;
764772
}
@@ -789,12 +797,19 @@ bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
789797
* match "socket" in "socketX_pmunameY" and then "pmuname" in
790798
* "pmunameY".
791799
*/
792-
for (; tok; name += strlen(tok), tok = strtok_r(NULL, ",", &tmp)) {
800+
while (1) {
801+
char *next_tok = strtok_r(NULL, ",", &tmp);
802+
793803
name = strstr(name, tok);
794-
if (!name || !perf_pmu__valid_suffix((char *)name, tok)) {
804+
if (!name ||
805+
(!next_tok && !perf_pmu__valid_suffix(name, tok))) {
795806
res = false;
796807
goto out;
797808
}
809+
if (!next_tok)
810+
break;
811+
tok = next_tok;
812+
name += strlen(tok);
798813
}
799814

800815
res = true;

0 commit comments

Comments
 (0)