summaryrefslogtreecommitdiff
path: root/tools/perf/util/bpf_lock_contention.c
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2022-08-02 12:10:02 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-08-02 18:02:10 -0300
commit447ec4e5fa339b30537d899447e73a103edef6d8 (patch)
tree8bc9ecee24e13ec08f0c56077e119dd24b238049 /tools/perf/util/bpf_lock_contention.c
parent4ee3c4da8b1b9c225bd156a7909980e32f3b3153 (diff)
downloadlwn-447ec4e5fa339b30537d899447e73a103edef6d8.tar.gz
lwn-447ec4e5fa339b30537d899447e73a103edef6d8.zip
perf lock: Introduce struct lock_contention
The lock_contention struct is to carry related fields together and to minimize the change when we add new config options. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Blake Jones <blakejones@google.com> Cc: Boqun Feng <boqun.feng@gmail.com> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Song Liu <songliubraving@fb.com> Cc: Waiman Long <longman@redhat.com> Cc: Will Deacon <will@kernel.org> Link: https://lore.kernel.org/r/20220802191004.347740-1-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/bpf_lock_contention.c')
-rw-r--r--tools/perf/util/bpf_lock_contention.c9
1 files changed, 6 insertions, 3 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;
}