All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arun Sharma <asharma@fb.com>
To: Roland Dreier <roland@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: perf for analyzing userspace contention
Date: Mon, 17 Oct 2011 16:43:32 -0700	[thread overview]
Message-ID: <20111017234332.GA9745@dev1756.snc6.facebook.com> (raw)
In-Reply-To: <CAG4TOxPowPUbmZBL41MNJjPYKymTNFW3JMAgEf35u1k2BFgbwA@mail.gmail.com>

On Thu, Oct 13, 2011 at 11:36:23PM -0700, Roland Dreier wrote:
> Hi everyone,
> 
> Hope this question from a kernel hacker about profiling userspace
> isn't too dumb...
> 
> Anyway, suppose I have a multithreaded userspace app that uses a bunch of
> pthread_mutexes, and I want to figure out which locks are hot and/or heavily
> contended.  What's the best way to do that?  Is perf the right, or is there
> something better?  (This seems like such an obvious thing to want that there
> must be some good way to get this data, I hope)

Sampling on sys_futex entry/exit is a good start. But it doesn't tell
you if the thread spent 1us or 1ms waiting on the futex. We really need
to add weights to the profile based on sleep times (or other criteria).

You might want to follow further discussion in the thread with the
subject "Profiling sleep times?".

perf record -ag -e cs -- sleep 1

is a more general version of this. It helps in understanding what's
causing the thread to give up CPU voluntarily (you might have to filter
the output a bit).

 -Arun

  parent reply	other threads:[~2011-10-18  0:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-14  6:36 perf for analyzing userspace contention Roland Dreier
2011-10-14  6:58 ` Maucci, Cyrille
2011-10-14  7:21   ` Roland Dreier
2011-10-14  7:33     ` Maucci, Cyrille
2011-10-14  9:42 ` Stefan Hajnoczi
2011-10-14 16:58   ` Roland Dreier
2011-10-14 21:25 ` David Ahern
2011-10-14 22:43   ` Arnaldo Carvalho de Melo
2011-10-17 23:43 ` Arun Sharma [this message]
2011-10-18  0:12   ` David Ahern

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=20111017234332.GA9745@dev1756.snc6.facebook.com \
    --to=asharma@fb.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=roland@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 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.