lkml.org 
[lkml]   [2021]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH V2 09/10] perf dlfilter: Add attr() to perf_dlfilter_fns
Date
Add a function, for use by dlfilters, to return the perf_event_attr
structure.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/Documentation/perf-dlfilter.txt | 5 ++++-
tools/perf/util/dlfilter.c | 11 +++++++++++
tools/perf/util/perf_dlfilter.h | 4 +++-
3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-dlfilter.txt b/tools/perf/Documentation/perf-dlfilter.txt
index df118ddcd7f4..6b1d9da16feb 100644
--- a/tools/perf/Documentation/perf-dlfilter.txt
+++ b/tools/perf/Documentation/perf-dlfilter.txt
@@ -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 *);
};
----

@@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

diff --git a/tools/perf/util/dlfilter.c b/tools/perf/util/dlfilter.c
index f4ce1a80bddc..e50d524906d6 100644
--- a/tools/perf/util/dlfilter.c
+++ b/tools/perf/util/dlfilter.c
@@ -235,6 +235,16 @@ 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,
@@ -242,6 +252,7 @@ static const struct perf_dlfilter_fns perf_dlfilter_fns = {
.resolve_address = dlfilter__resolve_address,
.insn = dlfilter__insn,
.srcline = dlfilter__srcline,
+ .attr = dlfilter__attr,
};

static char *find_dlfilter(const char *file)
diff --git a/tools/perf/util/perf_dlfilter.h b/tools/perf/util/perf_dlfilter.h
index b989918056e2..f3fc92fcb3c0 100644
--- a/tools/perf/util/perf_dlfilter.h
+++ b/tools/perf/util/perf_dlfilter.h
@@ -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 *);
};

/*
--
2.17.1
\
 
 \ /
  Last update: 2021-06-27 15:18    [W:0.093 / U:0.600 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site