summaryrefslogtreecommitdiff
path: root/tools/perf/util
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/bpf_lock_contention.c9
-rw-r--r--tools/perf/util/lock-contention.h17
2 files changed, 17 insertions, 9 deletions
diff --git a/tools/perf/util/bpf_lock_contention.c b/tools/perf/util/bpf_lock_contention.c
index 16b7451b4b09..f5e2b4f19a72 100644
--- a/tools/perf/util/bpf_lock_contention.c
+++ b/tools/perf/util/bpf_lock_contention.c
@@ -27,10 +27,12 @@ struct lock_contention_data {
u32 flags;
};
-int lock_contention_prepare(struct evlist *evlist, struct target *target)
+int lock_contention_prepare(struct lock_contention *con)
{
int i, fd;
int ncpus = 1, ntasks = 1;
+ struct evlist *evlist = con->evlist;
+ struct target *target = con->target;
skel = lock_contention_bpf__open();
if (!skel) {
@@ -102,12 +104,13 @@ int lock_contention_stop(void)
return 0;
}
-int lock_contention_read(struct machine *machine, struct hlist_head *head)
+int lock_contention_read(struct lock_contention *con)
{
int fd, stack;
u32 prev_key, key;
struct lock_contention_data data;
struct lock_stat *st;
+ struct machine *machine = con->machine;
u64 stack_trace[CONTENTION_STACK_DEPTH];
fd = bpf_map__fd(skel->maps.lock_stat);
@@ -163,7 +166,7 @@ int lock_contention_read(struct machine *machine, struct hlist_head *head)
return -1;
}
- hlist_add_head(&st->hash_entry, head);
+ hlist_add_head(&st->hash_entry, con->result);
prev_key = key;
}
diff --git a/tools/perf/util/lock-contention.h b/tools/perf/util/lock-contention.h
index 092c84441f9f..a0df5308cca4 100644
--- a/tools/perf/util/lock-contention.h
+++ b/tools/perf/util/lock-contention.h
@@ -107,18 +107,24 @@ struct evlist;
struct machine;
struct target;
+struct lock_contention {
+ struct evlist *evlist;
+ struct target *target;
+ struct machine *machine;
+ struct hlist_head *result;
+};
+
#ifdef HAVE_BPF_SKEL
-int lock_contention_prepare(struct evlist *evlist, struct target *target);
+int lock_contention_prepare(struct lock_contention *con);
int lock_contention_start(void);
int lock_contention_stop(void);
-int lock_contention_read(struct machine *machine, struct hlist_head *head);
+int lock_contention_read(struct lock_contention *con);
int lock_contention_finish(void);
#else /* !HAVE_BPF_SKEL */
-static inline int lock_contention_prepare(struct evlist *evlist __maybe_unused,
- struct target *target __maybe_unused)
+static inline int lock_contention_prepare(struct lock_contention *con __maybe_unused)
{
return 0;
}
@@ -127,8 +133,7 @@ static inline int lock_contention_start(void) { return 0; }
static inline int lock_contention_stop(void) { return 0; }
static inline int lock_contention_finish(void) { return 0; }
-static inline int lock_contention_read(struct machine *machine __maybe_unused,
- struct hlist_head *head __maybe_unused)
+static inline int lock_contention_read(struct lock_contention *con __maybe_unused)
{
return 0;
}