Skip to content

Commit 09ff607

Browse files
ahunter6acmel
authored andcommitted
perf tools: Add perf_pmu__format_bits()
Add perf_pmu__format_bits() to get the format bits for a PMU config term. Intel PT will use this to validate terms and to record format bits to enable later interpreting the config from the attribute stored in the perf.data file. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/1437150840-31811-15-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 8bd1b2d commit 09ff607

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

tools/perf/util/pmu.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ struct perf_pmu *perf_pmu__find(const char *name)
542542
}
543543

544544
static struct perf_pmu_format *
545-
pmu_find_format(struct list_head *formats, char *name)
545+
pmu_find_format(struct list_head *formats, const char *name)
546546
{
547547
struct perf_pmu_format *format;
548548

@@ -553,6 +553,21 @@ pmu_find_format(struct list_head *formats, char *name)
553553
return NULL;
554554
}
555555

556+
__u64 perf_pmu__format_bits(struct list_head *formats, const char *name)
557+
{
558+
struct perf_pmu_format *format = pmu_find_format(formats, name);
559+
__u64 bits = 0;
560+
int fbit;
561+
562+
if (!format)
563+
return 0;
564+
565+
for_each_set_bit(fbit, format->bits, PERF_PMU_FORMAT_BITS)
566+
bits |= 1ULL << fbit;
567+
568+
return bits;
569+
}
570+
556571
/*
557572
* Sets value based on the format definition (format parameter)
558573
* and unformated value (value parameter).

tools/perf/util/pmu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ int perf_pmu__config_terms(struct list_head *formats,
5454
struct perf_event_attr *attr,
5555
struct list_head *head_terms,
5656
bool zero, struct parse_events_error *error);
57+
__u64 perf_pmu__format_bits(struct list_head *formats, const char *name);
5758
int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
5859
struct perf_pmu_info *info);
5960
struct list_head *perf_pmu__alias(struct perf_pmu *pmu,

0 commit comments

Comments
 (0)