linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>, Jiri Olsa <jolsa@kernel.org>
Cc: 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, Will Deacon <will@kernel.org>,
	Waiman Long <longman@redhat.com>,
	Boqun Feng <boqun.feng@gmail.com>,
	Davidlohr Bueso <dave@stgolabs.net>, Song Liu <song@kernel.org>,
	Hao Luo <haoluo@google.com>,
	bpf@vger.kernel.org
Subject: [RFC/PATCH 0/3] perf lock contention: Track lock owner (v2)
Date: Mon,  6 Feb 2023 16:24:00 -0800	[thread overview]
Message-ID: <20230207002403.63590-1-namhyung@kernel.org> (raw)

Hello,

When there're many lock contentions in the system, people sometimes
want to know who caused the contention, IOW who's the owner of the
locks.

This patchset adds -o/--lock-owner option to track the owner info
if it's available.  Right now, it supports mutex and rwsem as they
have the owner fields in themselves.  Please see the patch 2 for the
details.

Changes in v2)
 * fix missing callstacks
 * support old rwsem type with recent clang (>= 15.0)

The patch 1 is a fix for missing callstacks and the patch 2 is the
main change.  The patch 3 adds support for old kernels when compiler
supports a recent builtin to check field type in a struct (Thanks
to Hao).

Example output (for mutex only):

  $ sudo ./perf lock con -abo -Y mutex -- ./perf bench sched pipe
  # Running 'sched/pipe' benchmark:
  # Executed 1000000 pipe operations between two processes

       Total time: 4.910 [sec]

         4.910435 usecs/op
           203647 ops/sec
   contended   total wait     max wait     avg wait          pid   owner

           2     15.50 us      8.29 us      7.75 us      1582852   sched-pipe
           7      7.20 us      2.47 us      1.03 us           -1   Unknown
           1      6.74 us      6.74 us      6.74 us      1582851   sched-pipe

You can get it from 'perf/lock-owner-v2' branch in

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

Thanks,
Namhyung

Namhyung Kim (3):
  perf lock contention: Fix to save callstack for the default modified
  perf lock contention: Add -o/--lock-owner option
  perf lock contention: Support old rw_semaphore type

 tools/perf/Documentation/perf-lock.txt        |  5 +
 tools/perf/builtin-lock.c                     | 52 +++++++++--
 tools/perf/util/bpf_lock_contention.c         |  1 +
 .../perf/util/bpf_skel/lock_contention.bpf.c  | 91 ++++++++++++++++++-
 tools/perf/util/lock-contention.h             |  1 +
 5 files changed, 136 insertions(+), 14 deletions(-)


base-commit: 17f248aa8664ff5b3643491136283e73b5c18166
-- 
2.39.1.519.gcb327c4b5f-goog


             reply	other threads:[~2023-02-07  0:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07  0:24 Namhyung Kim [this message]
2023-02-07  0:24 ` [PATCH 1/3] perf lock contention: Fix to save callstack for the default modified Namhyung Kim
2023-02-07 22:22   ` Namhyung Kim
2023-02-07  0:24 ` [PATCH 2/3] perf lock contention: Add -o/--lock-owner option Namhyung Kim
2023-02-07 15:11   ` Arnaldo Carvalho de Melo
2023-02-07 22:20     ` Namhyung Kim
2023-02-07  0:24 ` [PATCH 3/3] perf lock contention: Support old rw_semaphore type Namhyung Kim
2023-02-08 13:37 ` [RFC/PATCH 0/3] perf lock contention: Track lock owner (v2) Arnaldo Carvalho de Melo

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=20230207002403.63590-1-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=boqun.feng@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=dave@stgolabs.net \
    --cc=haoluo@google.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=song@kernel.org \
    --cc=will@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).