From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>,
Andi Kleen <ak@linux.intel.com>, Ingo Molnar <mingo@kernel.org>,
linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
Stephane Eranian <eranian@google.com>,
mathieu.poirier@linaro.org, Pawel Moll <pawel.moll@arm.com>
Subject: Re: [PATCH V4 1/5] perf: Add PERF_RECORD_SWITCH to indicate context switches
Date: Tue, 21 Jul 2015 14:54:54 -0300 [thread overview]
Message-ID: <20150721175454.GC16921@kernel.org> (raw)
In-Reply-To: <20150721102955.GM19282@twins.programming.kicks-ass.net>
Em Tue, Jul 21, 2015 at 12:29:55PM +0200, Peter Zijlstra escreveu:
> On Tue, Jul 21, 2015 at 12:44:02PM +0300, Adrian Hunter wrote:
> > There are already two events for context switches, namely
> > the tracepoint sched:sched_switch and the software event
> > context_switches. Unfortunately neither are suitable for
> > use by non-privileged users for the purpose of synchronizing
> > hardware trace data (e.g. Intel PT) to the context switch.
> >
> > Tracepoints are no good at all for non-privileged users
> > because they need either CAP_SYS_ADMIN or
> > /proc/sys/kernel/perf_event_paranoid <= -1.
> >
> > On the other hand, kernel software events need either
> > CAP_SYS_ADMIN or /proc/sys/kernel/perf_event_paranoid <= 1.
> >
> > Now many distributions do default perf_event_paranoid to 1
> > making context_switches a contender, except it has another
> > problem (which is also shared with sched:sched_switch)
> > which is that it happens before perf schedules events out
> > instead of after perf schedules events in. Whereas a
> > privileged user can see all the events anyway, a
> > non-privileged user only sees events for their own processes,
> > in other words they see when their process was scheduled out
> > not when it was scheduled in. That presents two problems to
> > use the event: 1. the information comes too late, so tools
> > have to look ahead in the event stream to find out what the
> > current state is 2. if they are unlucky tracing might have
> > stopped before the context-switches event is recorded.
> >
> > This new PERF_RECORD_SWITCH event does not have those problems
> > and it also has a couple of other small advantages. It is
> > easier to use because it is an auxiliary event (like mmap,
> > comm and task events) which can be enabled by setting a single
> > bit. It is smaller than sched:sched_switch and easier to parse.
> >
> > To make the event useful for privileged users also, if the
> > context is cpu-wide then the event record will be
> > PERF_RECORD_SWITCH_CPU_WIDE which is the same as
> > PERF_RECORD_SWITCH except it also provides the next or
> > previous pid/tid.
> >
> > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
>
> Acme, if you agree with the tools part, feel free to take the lot.
Looking at it, if all is well, I'll do it
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
next prev parent reply other threads:[~2015-07-21 17:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-21 9:44 [PATCH V4 0/5] perf: Add PERF_RECORD_SWITCH to indicate context switches Adrian Hunter
2015-07-21 9:44 ` [PATCH V4 1/5] " Adrian Hunter
2015-07-21 10:29 ` Peter Zijlstra
2015-07-21 17:54 ` Arnaldo Carvalho de Melo [this message]
2015-07-21 18:15 ` Arnaldo Carvalho de Melo
2015-07-22 9:53 ` Jiri Olsa
2015-07-29 8:14 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-07-21 9:44 ` [PATCH V4 2/5] perf tools: Add new PERF_RECORD_SWITCH event Adrian Hunter
2015-07-29 8:14 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-07-21 9:44 ` [PATCH V4 3/5] perf record: Add option --switch-events to select PERF_RECORD_SWITCH events Adrian Hunter
2015-07-29 8:15 ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-07-21 9:44 ` [PATCH V4 4/5] perf script: Don't assume evsel position of tracking events Adrian Hunter
2015-07-29 8:15 ` [tip:perf/core] perf script: Don' t " tip-bot for Adrian Hunter
2015-07-21 9:44 ` [PATCH V4 5/5] perf script: Add option --show-switch-events Adrian Hunter
2015-07-29 8:15 ` [tip:perf/core] " tip-bot for Adrian Hunter
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=20150721175454.GC16921@kernel.org \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=mingo@kernel.org \
--cc=pawel.moll@arm.com \
--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.