Skip to content

Commit

Permalink
perf dlfilter: Add attr() to perf_dlfilter_fns
Browse files Browse the repository at this point in the history
Add a function, for use by dlfilters, to return the perf_event_attr
structure.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210627131818.810-10-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Adrian Hunter authored and Arnaldo Carvalho de Melo committed Jul 1, 2021
1 parent 244afc0 commit 6495e76
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tools/perf/Documentation/perf-dlfilter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ struct perf_dlfilter_fns {
__s32 (*resolve_address)(void *ctx, __u64 address, struct perf_dlfilter_al *al);
const __u8 *(*insn)(void *ctx, __u32 *length);
const char *(*srcline)(void *ctx, __u32 *line_number);
void *(*reserved[122])(void *);
struct perf_event_attr *(*attr)(void *ctx);
void *(*reserved[121])(void *);
};
----

Expand All @@ -143,6 +144,8 @@ before calling. Returns 0 on success, -1 otherwise.

'srcline' return source file name and line number.

'attr' returns perf_event_attr, refer <linux/perf_event.h>.

The perf_dlfilter_al structure
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
11 changes: 11 additions & 0 deletions tools/perf/util/dlfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,24 @@ static const char *dlfilter__srcline(void *ctx, __u32 *line_no)
return srcfile;
}

static struct perf_event_attr *dlfilter__attr(void *ctx)
{
struct dlfilter *d = (struct dlfilter *)ctx;

if (!d->ctx_valid)
return NULL;

return &d->evsel->core.attr;
}

static const struct perf_dlfilter_fns perf_dlfilter_fns = {
.resolve_ip = dlfilter__resolve_ip,
.resolve_addr = dlfilter__resolve_addr,
.args = dlfilter__args,
.resolve_address = dlfilter__resolve_address,
.insn = dlfilter__insn,
.srcline = dlfilter__srcline,
.attr = dlfilter__attr,
};

static char *find_dlfilter(const char *file)
Expand Down
4 changes: 3 additions & 1 deletion tools/perf/util/perf_dlfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ struct perf_dlfilter_fns {
const __u8 *(*insn)(void *ctx, __u32 *length);
/* Return source file name and line number */
const char *(*srcline)(void *ctx, __u32 *line_number);
/* Return perf_event_attr, refer <linux/perf_event.h> */
struct perf_event_attr *(*attr)(void *ctx);
/* Reserved */
void *(*reserved[122])(void *);
void *(*reserved[121])(void *);
};

/*
Expand Down

0 comments on commit 6495e76

Please sign in to comment.