2023-06-28 20:11:36

by Namhyung Kim

[permalink] [raw]
Subject: [PATCHSET 0/4] perf lock contention: Add CSV style output support (v2)

Hello,

This is v2 of perf lock contention CSV output change.
I've added --output option and a test case according to Ian's feedback.

Sometimes we want to process the output by external programs. Let's add
the -x option to specify the field separator like perf stat.

$ sudo ./perf lock con -ab -x, sleep 1
# output: contended, total wait, max wait, avg wait, type, caller
19, 194232, 21415, 10222, spinlock, process_one_work+0x1f0
15, 162748, 23843, 10849, rwsem:R, do_user_addr_fault+0x40e
4, 86740, 23415, 21685, rwlock:R, ep_poll_callback+0x2d
1, 84281, 84281, 84281, mutex, iwl_mvm_async_handlers_wk+0x135
8, 67608, 27404, 8451, spinlock, __queue_work+0x174
3, 58616, 31125, 19538, rwsem:W, do_mprotect_pkey+0xff
3, 52953, 21172, 17651, rwlock:W, do_epoll_wait+0x248
2, 30324, 19704, 15162, rwsem:R, do_madvise+0x3ad
1, 24619, 24619, 24619, spinlock, rcu_core+0xd4

The first line is a comment that shows the output format. Each line is
separated by the given string ("," in this case). The time is printed
in nsec without the unit so that it can be parsed easily.

The code is available at 'perf/lock-con-csv-v2' branch in

git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Thanks,
Namhyung


Namhyung Kim (4):
perf lock: Remove stale comments
perf lock contention: Add -x option for CSV style output
perf lock contention: Add --output option
perf test: Test perf lock contention CSV output

tools/perf/Documentation/perf-lock.txt | 5 +
tools/perf/builtin-lock.c | 383 ++++++++++++++++------
tools/perf/tests/shell/lock_contention.sh | 36 ++
3 files changed, 328 insertions(+), 96 deletions(-)

--
2.41.0.255.g8b1d071c50-goog



2023-06-28 20:11:42

by Namhyung Kim

[permalink] [raw]
Subject: [PATCH 1/4] perf lock: Remove stale comments

The comment was for symbol_conf.sort_by_name which was deleted already.
Let's get rid of the stale comments as well.

Signed-off-by: Namhyung Kim <[email protected]>
---
tools/perf/builtin-lock.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index da36ace66d68..187efb651436 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -1773,7 +1773,6 @@ static int __cmd_report(bool display_info)
return PTR_ERR(session);
}

- /* for lock function check */
symbol_conf.allow_aliases = true;
symbol__init(&session->header.env);

@@ -1902,7 +1901,6 @@ static int __cmd_contention(int argc, const char **argv)
if (con.aggr_mode == LOCK_AGGR_CALLER)
con.save_callstack = true;

- /* for lock function check */
symbol_conf.allow_aliases = true;
symbol__init(&session->header.env);

--
2.41.0.255.g8b1d071c50-goog


2023-06-30 16:31:29

by Ian Rogers

[permalink] [raw]
Subject: Re: [PATCH 1/4] perf lock: Remove stale comments

On Wed, Jun 28, 2023 at 1:01 PM Namhyung Kim <[email protected]> wrote:
>
> The comment was for symbol_conf.sort_by_name which was deleted already.
> Let's get rid of the stale comments as well.
>
> Signed-off-by: Namhyung Kim <[email protected]>

Acked-by: Ian Rogers <[email protected]>

Thanks,
Ian

> ---
> tools/perf/builtin-lock.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
> index da36ace66d68..187efb651436 100644
> --- a/tools/perf/builtin-lock.c
> +++ b/tools/perf/builtin-lock.c
> @@ -1773,7 +1773,6 @@ static int __cmd_report(bool display_info)
> return PTR_ERR(session);
> }
>
> - /* for lock function check */
> symbol_conf.allow_aliases = true;
> symbol__init(&session->header.env);
>
> @@ -1902,7 +1901,6 @@ static int __cmd_contention(int argc, const char **argv)
> if (con.aggr_mode == LOCK_AGGR_CALLER)
> con.save_callstack = true;
>
> - /* for lock function check */
> symbol_conf.allow_aliases = true;
> symbol__init(&session->header.env);
>
> --
> 2.41.0.255.g8b1d071c50-goog
>

2023-07-02 01:09:12

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCHSET 0/4] perf lock contention: Add CSV style output support (v2)

On Wed, Jun 28, 2023 at 1:01 PM Namhyung Kim <[email protected]> wrote:
>
> Hello,
>
> This is v2 of perf lock contention CSV output change.
> I've added --output option and a test case according to Ian's feedback.
>
> Sometimes we want to process the output by external programs. Let's add
> the -x option to specify the field separator like perf stat.
>
> $ sudo ./perf lock con -ab -x, sleep 1
> # output: contended, total wait, max wait, avg wait, type, caller
> 19, 194232, 21415, 10222, spinlock, process_one_work+0x1f0
> 15, 162748, 23843, 10849, rwsem:R, do_user_addr_fault+0x40e
> 4, 86740, 23415, 21685, rwlock:R, ep_poll_callback+0x2d
> 1, 84281, 84281, 84281, mutex, iwl_mvm_async_handlers_wk+0x135
> 8, 67608, 27404, 8451, spinlock, __queue_work+0x174
> 3, 58616, 31125, 19538, rwsem:W, do_mprotect_pkey+0xff
> 3, 52953, 21172, 17651, rwlock:W, do_epoll_wait+0x248
> 2, 30324, 19704, 15162, rwsem:R, do_madvise+0x3ad
> 1, 24619, 24619, 24619, spinlock, rcu_core+0xd4
>
> The first line is a comment that shows the output format. Each line is
> separated by the given string ("," in this case). The time is printed
> in nsec without the unit so that it can be parsed easily.
>
> The code is available at 'perf/lock-con-csv-v2' branch in
>
> git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
>
> Thanks,
> Namhyung
>
>
> Namhyung Kim (4):
> perf lock: Remove stale comments
> perf lock contention: Add -x option for CSV style output
> perf lock contention: Add --output option
> perf test: Test perf lock contention CSV output

Applied to perf-tools-next, thanks!