diff options
author | Namhyung Kim <namhyung@kernel.org> | 2022-08-02 21:10:02 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2022-08-02 23:02:10 +0200 |
commit | 447ec4e5fa339b30537d899447e73a103edef6d8 (patch) | |
tree | 8bc9ecee24e13ec08f0c56077e119dd24b238049 /tools/perf/builtin-lock.c | |
parent | perf scripting python: Do not build fail on deprecation warnings (diff) | |
download | linux-447ec4e5fa339b30537d899447e73a103edef6d8.tar.xz linux-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/builtin-lock.c')
-rw-r--r-- | tools/perf/builtin-lock.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 2a09f369a59c..4bc521adbd60 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -1595,7 +1595,10 @@ static int __cmd_contention(int argc, const char **argv) .mode = PERF_DATA_MODE_READ, .force = force, }; - struct evlist *evlist = NULL; + struct lock_contention con = { + .target = &target, + .result = &lockhash_table[0], + }; session = perf_session__new(use_bpf ? NULL : &data, &eops); if (IS_ERR(session)) { @@ -1621,24 +1624,26 @@ static int __cmd_contention(int argc, const char **argv) signal(SIGCHLD, sighandler); signal(SIGTERM, sighandler); - evlist = evlist__new(); - if (evlist == NULL) { + con.machine = &session->machines.host; + + con.evlist = evlist__new(); + if (con.evlist == NULL) { err = -ENOMEM; goto out_delete; } - err = evlist__create_maps(evlist, &target); + err = evlist__create_maps(con.evlist, &target); if (err < 0) goto out_delete; if (argc) { - err = evlist__prepare_workload(evlist, &target, + err = evlist__prepare_workload(con.evlist, &target, argv, false, NULL); if (err < 0) goto out_delete; } - if (lock_contention_prepare(evlist, &target) < 0) { + if (lock_contention_prepare(&con) < 0) { pr_err("lock contention BPF setup failed\n"); goto out_delete; } @@ -1673,13 +1678,13 @@ static int __cmd_contention(int argc, const char **argv) if (use_bpf) { lock_contention_start(); if (argc) - evlist__start_workload(evlist); + evlist__start_workload(con.evlist); /* wait for signal */ pause(); lock_contention_stop(); - lock_contention_read(&session->machines.host, &lockhash_table[0]); + lock_contention_read(&con); } else { err = perf_session__process_events(session); if (err) @@ -1692,7 +1697,7 @@ static int __cmd_contention(int argc, const char **argv) print_contention_result(); out_delete: - evlist__delete(evlist); + evlist__delete(con.evlist); lock_contention_finish(); perf_session__delete(session); return err; |