From: Milian Wolff <milian.wolff@kdab.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: Tracing sched_switch events for client application when process is switched back in
Date: Wed, 16 Nov 2016 12:17:40 +0100 [thread overview]
Message-ID: <3673091.Y7H8VIyPtY@milian-kdab2> (raw)
In-Reply-To: <20161115011703.GL26543@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 2862 bytes --]
On Monday, November 14, 2016 10:17:03 PM CET Arnaldo Carvalho de Melo wrote:
> Em Mon, Nov 14, 2016 at 07:17:01PM +0100, Milian Wolff escreveu:
> > On Monday, November 14, 2016 12:36:11 PM CET Arnaldo Carvalho de Melo
wrote:
> > > Em Mon, Nov 14, 2016 at 03:10:26PM +0100, Milian Wolff escreveu:
> > > > features:
> > > >
> > > > - sample CPU events for a given application with backtraces
> > > >
> > > > perf record --call-graph dwarf ./foo
> > > >
> > > > - record switch-out events with backtraces (`-e
> > > > sched:sched_switch/fp=dwarf/`) - somehow record the switch-in events,
> > > > which are associated with a different process and thus currently
> > > > discarded
> > >
> > > You want the backtraces with that, and since this is a meta-event...
> > > Humm,
> > > for the switch in would the above be sufficient? What value would be in
> > > knowing the backtrace in that case?
> >
> > Knowing the backtrace would ensure I get the real location that triggered
> > a
> > switch, i.e. often times that comes from a syscall like futex or the like.
> > Or
> Sure, sure, a backtrace for a sched switch _out_ of a thread is useful,
> and that you get from the sched:sched_switch tracepoint, what I'm
> alluding to is the lack of a backtrace with the PERF_RECORD_SWITCH _IN_,
> meta-event i.e. when the kernel switchs back to the thread being
> monitored.
I think my previous mail was confusing: Your approach works really well,
thanks again. I do not need a backtrace for the switch-in in the general case.
> > would I always get a CPU event (e.g. cycles) with a backtrace before the
>
> Is there a need for that? With sched:sched_switch + backtrace you get a
> backtrace right at the moment of the sched_switch _out_, then, with
> PERF_RECORD_SWITCH (--switch-events) you'll get the missing piece, the
> sched switch _in_, that gets a CPU back to your thread. You'll not know
> from where it came (the thread using the CPU right before this switch),
> unless you're root, then PERF_RECORD_SWITCH _will_ have that info.
Right, as said above - that is not too crucial. I simply need to know I'm
getting switched in again, and at what time that happens.
Thanks again!
<snip>
> > That gives me all information. With some post-processing one could then
> > turn this into a really useful profiling tool, as one will only need a
> > single perf record step to allow both, on-CPU as well as off-CPU
> > profiling for application developers.
>
> right, off-cpu info in a 'perf trace' session is something we should
> have, for instance. It should appear like a syscall, i.e. another way
> out of the thread that will take some time to complete (sched_out ...
> sched_in).
Good idea, yes.
--
Milian Wolff | milian.wolff@kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5903 bytes --]
prev parent reply other threads:[~2016-11-16 11:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-06 15:52 Tracing sched_switch events for client application when process is switched back in Milian Wolff
2016-10-06 16:21 ` Arnaldo Carvalho de Melo
2016-10-06 16:38 ` Milian Wolff
2016-10-11 0:36 ` Arnaldo Carvalho de Melo
2016-11-14 14:10 ` Milian Wolff
2016-11-14 15:36 ` Arnaldo Carvalho de Melo
2016-11-14 18:17 ` Milian Wolff
2016-11-15 1:17 ` Arnaldo Carvalho de Melo
2016-11-16 11:17 ` Milian Wolff [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=3673091.Y7H8VIyPtY@milian-kdab2 \
--to=milian.wolff@kdab.com \
--cc=acme@kernel.org \
--cc=linux-perf-users@vger.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).