From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>, Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 1/3] perf lock: Add -E/--entries option
Date: Mon, 26 Sep 2022 20:45:48 +0100 [thread overview]
Message-ID: <YzIBbErRhxzk5ppd@kernel.org> (raw)
In-Reply-To: <20220924004221.841024-1-namhyung@kernel.org>
Em Fri, Sep 23, 2022 at 05:42:19PM -0700, Namhyung Kim escreveu:
> Like perf top, the -E option can limit number of entries to print.
> It can be useful when users want to see top N contended locks only.
Thanks, applied.
- Arnaldo
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/Documentation/perf-lock.txt | 10 ++++++++++
> tools/perf/builtin-lock.c | 20 +++++++++++++++-----
> 2 files changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/Documentation/perf-lock.txt b/tools/perf/Documentation/perf-lock.txt
> index 5f2dc634258e..b23e76200ac2 100644
> --- a/tools/perf/Documentation/perf-lock.txt
> +++ b/tools/perf/Documentation/perf-lock.txt
> @@ -94,6 +94,11 @@ REPORT OPTIONS
> EventManager_De 1845 1 636
> futex-default-S 1609 0 0
>
> +-E::
> +--entries=<value>::
> + Display this many entries.
> +
> +
> INFO OPTIONS
> ------------
>
> @@ -105,6 +110,7 @@ INFO OPTIONS
> --map::
> dump map of lock instances (address:name table)
>
> +
> CONTENTION OPTIONS
> --------------
>
> @@ -154,6 +160,10 @@ CONTENTION OPTIONS
> --stack-skip
> Number of stack depth to skip when finding a lock caller (default: 3).
>
> +-E::
> +--entries=<value>::
> + Display this many entries.
> +
>
> SEE ALSO
> --------
> diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
> index 25d75fa09b90..1c0d52384d9e 100644
> --- a/tools/perf/builtin-lock.c
> +++ b/tools/perf/builtin-lock.c
> @@ -58,6 +58,7 @@ static bool use_bpf;
> static unsigned long bpf_map_entries = 10240;
> static int max_stack_depth = CONTENTION_STACK_DEPTH;
> static int stack_skip = CONTENTION_STACK_SKIP;
> +static int print_nr_entries = INT_MAX / 2;
>
> static enum {
> LOCK_AGGR_ADDR,
> @@ -1266,14 +1267,14 @@ static void print_result(void)
> struct lock_stat *st;
> struct lock_key *key;
> char cut_name[20];
> - int bad, total;
> + int bad, total, printed;
>
> pr_info("%20s ", "Name");
> list_for_each_entry(key, &lock_keys, list)
> pr_info("%*s ", key->len, key->header);
> pr_info("\n\n");
>
> - bad = total = 0;
> + bad = total = printed = 0;
> while ((st = pop_from_result())) {
> total++;
> if (st->broken)
> @@ -1311,6 +1312,9 @@ static void print_result(void)
> pr_info(" ");
> }
> pr_info("\n");
> +
> + if (++printed >= print_nr_entries)
> + break;
> }
>
> print_bad_events(bad, total);
> @@ -1476,7 +1480,7 @@ static void print_contention_result(struct lock_contention *con)
> {
> struct lock_stat *st;
> struct lock_key *key;
> - int bad, total;
> + int bad, total, printed;
>
> list_for_each_entry(key, &lock_keys, list)
> pr_info("%*s ", key->len, key->header);
> @@ -1486,7 +1490,7 @@ static void print_contention_result(struct lock_contention *con)
> else
> pr_info(" %10s %s\n\n", "type", "caller");
>
> - bad = total = 0;
> + bad = total = printed = 0;
> if (use_bpf)
> bad = bad_hist[BROKEN_CONTENDED];
>
> @@ -1507,7 +1511,7 @@ static void print_contention_result(struct lock_contention *con)
> /* st->addr contains tid of thread */
> t = perf_session__findnew(session, pid);
> pr_info(" %10d %s\n", pid, thread__comm_str(t));
> - continue;
> + goto next;
> }
>
> pr_info(" %10s %s\n", get_type_str(st), st->name);
> @@ -1527,6 +1531,10 @@ static void print_contention_result(struct lock_contention *con)
> pr_info("\t\t\t%#lx %s\n", (unsigned long)ip, buf);
> }
> }
> +
> +next:
> + if (++printed >= print_nr_entries)
> + break;
> }
>
> print_bad_events(bad, total);
> @@ -1878,6 +1886,7 @@ int cmd_lock(int argc, const char **argv)
> "combine locks in the same class"),
> OPT_BOOLEAN('t', "threads", &show_thread_stats,
> "show per-thread lock stats"),
> + OPT_INTEGER('E', "entries", &print_nr_entries, "display this many functions"),
> OPT_PARENT(lock_options)
> };
>
> @@ -1905,6 +1914,7 @@ int cmd_lock(int argc, const char **argv)
> OPT_INTEGER(0, "stack-skip", &stack_skip,
> "Set the number of stack depth to skip when finding a lock caller, "
> "Default: " __stringify(CONTENTION_STACK_SKIP)),
> + OPT_INTEGER('E', "entries", &print_nr_entries, "display this many functions"),
> OPT_PARENT(lock_options)
> };
>
> --
> 2.37.3.998.g577e59143f-goog
--
- Arnaldo
prev parent reply other threads:[~2022-09-26 19:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-24 0:42 [PATCH 1/3] perf lock: Add -E/--entries option Namhyung Kim
2022-09-24 0:42 ` [PATCH 2/3] perf lock: Add -q/--quiet option Namhyung Kim
2022-09-24 2:49 ` Ian Rogers
2022-09-24 0:42 ` [PATCH 3/3] perf test: Add kernel lock contention test Namhyung Kim
2022-09-24 2:50 ` Ian Rogers
2022-09-24 8:09 ` Adrian Hunter
2022-09-24 16:50 ` Namhyung Kim
2022-09-24 2:49 ` [PATCH 1/3] perf lock: Add -E/--entries option Ian Rogers
2022-09-26 19:45 ` Arnaldo Carvalho de Melo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YzIBbErRhxzk5ppd@kernel.org \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.