diff options
author | Namhyung Kim <namhyung@kernel.org> | 2022-08-02 22:10:03 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2022-08-03 00:02:59 +0300 |
commit | ceb13bfc01d55388092c00796a5b76aa3dfa483a (patch) | |
tree | f976ddbe504a06bc61688ed7abd532767d4aaef7 /tools/perf/builtin-lock.c | |
parent | 447ec4e5fa339b30537d899447e73a103edef6d8 (diff) | |
download | linux-ceb13bfc01d55388092c00796a5b76aa3dfa483a.tar.xz |
perf lock: Add --map-nr-entries option
The --map-nr-entries option is to control number of max entries in the
perf lock contention BPF maps.
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-2-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, 22 insertions, 1 deletions
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 4bc521adbd60..c6cc6c296419 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -56,6 +56,7 @@ static struct rb_root thread_stats; static bool combine_locks; static bool show_thread_stats; static bool use_bpf; +static unsigned long bpf_map_entries = 10240; static enum { LOCK_AGGR_ADDR, @@ -1598,6 +1599,7 @@ static int __cmd_contention(int argc, const char **argv) struct lock_contention con = { .target = &target, .result = &lockhash_table[0], + .map_nr_entries = bpf_map_entries, }; session = perf_session__new(use_bpf ? NULL : &data, &eops); @@ -1787,6 +1789,24 @@ setup_args: return ret; } +static int parse_map_entry(const struct option *opt, const char *str, + int unset __maybe_unused) +{ + unsigned long *len = (unsigned long *)opt->value; + unsigned long val; + char *endptr; + + errno = 0; + val = strtoul(str, &endptr, 0); + if (*endptr != '\0' || errno != 0) { + pr_err("invalid BPF map length: %s\n", str); + return -1; + } + + *len = val; + return 0; +} + int cmd_lock(int argc, const char **argv) { const struct option lock_options[] = { @@ -1836,9 +1856,10 @@ int cmd_lock(int argc, const char **argv) "List of cpus to monitor"), OPT_STRING('p', "pid", &target.pid, "pid", "Trace on existing process id"), - /* TODO: Add short option -t after -t/--tracer can be removed. */ OPT_STRING(0, "tid", &target.tid, "tid", "Trace on existing thread id (exclusive to --pid)"), + OPT_CALLBACK(0, "map-nr-entries", &bpf_map_entries, "num", + "Max number of BPF map entries", parse_map_entry), OPT_PARENT(lock_options) }; |