From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>, Thomas Gleixner <tglx@linutronix.de>
Cc: Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Clark Williams <williams@redhat.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Adrian Hunter <adrian.hunter@intel.com>,
Jiri Olsa <jolsa@redhat.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 40/41] perf intel-pt: Improve sync_switch by processing PERF_RECORD_SWITCH* in events
Date: Wed, 29 May 2019 10:36:04 -0300 [thread overview]
Message-ID: <20190529133605.21118-41-acme@kernel.org> (raw)
In-Reply-To: <20190529133605.21118-1-acme@kernel.org>
From: Adrian Hunter <adrian.hunter@intel.com>
sync_switch is a facility to synchronize decoding more closely with the
point in the kernel when the context actually switched.
Improve it by processing "context switch in" events.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190412113830.4126-8-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/intel-pt.c | 40 +++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 03b1da6d1da4..6aaba1146fc8 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1914,6 +1914,44 @@ static int intel_pt_process_switch(struct intel_pt *pt,
return machine__set_current_tid(pt->machine, cpu, -1, tid);
}
+static int intel_pt_context_switch_in(struct intel_pt *pt,
+ struct perf_sample *sample)
+{
+ pid_t pid = sample->pid;
+ pid_t tid = sample->tid;
+ int cpu = sample->cpu;
+
+ if (pt->sync_switch) {
+ struct intel_pt_queue *ptq;
+
+ ptq = intel_pt_cpu_to_ptq(pt, cpu);
+ if (ptq && ptq->sync_switch) {
+ ptq->next_tid = -1;
+ switch (ptq->switch_state) {
+ case INTEL_PT_SS_NOT_TRACING:
+ case INTEL_PT_SS_UNKNOWN:
+ case INTEL_PT_SS_TRACING:
+ break;
+ case INTEL_PT_SS_EXPECTING_SWITCH_EVENT:
+ case INTEL_PT_SS_EXPECTING_SWITCH_IP:
+ ptq->switch_state = INTEL_PT_SS_TRACING;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ /*
+ * If the current tid has not been updated yet, ensure it is now that
+ * a "switch in" event has occurred.
+ */
+ if (machine__get_current_tid(pt->machine, cpu) == tid)
+ return 0;
+
+ return machine__set_current_tid(pt->machine, cpu, pid, tid);
+}
+
static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event,
struct perf_sample *sample)
{
@@ -1925,7 +1963,7 @@ static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event,
if (pt->have_sched_switch == 3) {
if (!out)
- return 0;
+ return intel_pt_context_switch_in(pt, sample);
if (event->header.type != PERF_RECORD_SWITCH_CPU_WIDE) {
pr_err("Expecting CPU-wide context switch event\n");
return -EINVAL;
--
2.20.1
next prev parent reply other threads:[~2019-05-29 13:36 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-29 13:35 [GIT PULL] perf/core improvements and fixes for 5.3 Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 01/41] perf-with-kcore.sh: Always allow fix_buildid_cache_permissions Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 02/41] perf intel-pt: Fix itrace defaults for perf script Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 03/41] perf auxtrace: " Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 04/41] perf intel-pt: Fix itrace defaults for perf script intel-pt documentation Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 05/41] perf machine: Keep zero in pgoff BPF map Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 06/41] perf tools: Preserve eBPF maps when loading kcore Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 07/41] perf augmented_raw_syscalls: Fix up comment Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 08/41] perf beauty: Add generator for 'move_mount' flags argument Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 09/41] perf trace: Beautify 'move_mount' arguments Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 10/41] perf beauty: Add generator for fspick's 'flags' arg values Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 11/41] perf trace: Beautify 'fspick' arguments Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 12/41] perf beauty: Add generator for fsconfig's 'cmd' arg values Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 13/41] perf trace: Beautify 'fsconfig' arguments Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 14/41] perf beauty: Add generator for fsmount's 'attr_flags' arg values Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 15/41] perf trace: Introduce syscall_arg__scnprintf_strarray_flags Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 16/41] perf trace: Beautify 'fsmount' arguments Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 17/41] perf trace beauty clone: Handle CLONE_PIDFD Arnaldo Carvalho de Melo
2019-05-29 14:49 ` Christian Brauner
2019-05-29 13:35 ` [PATCH 18/41] perf beauty: Add generator for sync_file_range's 'flags' arg values Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 19/41] perf trace: Beautify 'sync_file_range' arguments Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 20/41] perf top: Add --namespaces option Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 21/41] perf tools: Remove const from thread read accessors Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 22/41] perf dso: Separate generic code in dso__data_file_size() Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 23/41] perf dso: Separate generic code in dso_cache__read Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 24/41] perf dso: Simplify dso_cache__read function Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 25/41] perf dso: Add BPF DSO read and size hooks Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 26/41] perf script: Pad DSO name for --call-trace Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 27/41] perf tests: Add map_groups__merge_in test Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 28/41] perf script: Add --show-bpf-events to show eBPF related events Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 29/41] perf script: Remove superfluous BPF event titles Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 30/41] perf version: Append 12 git SHA chars to the version string Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 31/41] perf machine: Return NULL instead of null-terminating /proc/version array Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 32/41] perf annotate TUI browser: Do not use member from variable within its own initialization Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 33/41] perf python: Remove -fstack-protector-strong if clang doesn't have it Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 34/41] perf top: Lower message level for failure on synthesizing events for pre-existing BPF programs Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 35/41] perf scripts python: exported-sql-viewer.py: Change python2 to python Arnaldo Carvalho de Melo
2019-05-29 13:36 ` [PATCH 36/41] perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing Arnaldo Carvalho de Melo
2019-05-29 13:36 ` [PATCH 37/41] perf scripts python: exported-sql-viewer.py: Add support for pyside2 Arnaldo Carvalho de Melo
2019-05-29 13:36 ` [PATCH 38/41] perf scripts python: export-to-sqlite.py: " Arnaldo Carvalho de Melo
2019-05-29 13:36 ` [PATCH 39/41] perf scripts python: export-to-postgresql.py: " Arnaldo Carvalho de Melo
2019-05-29 13:36 ` Arnaldo Carvalho de Melo [this message]
2019-05-29 13:36 ` [PATCH 41/41] perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid Arnaldo Carvalho de Melo
2019-05-30 7:50 ` [GIT PULL] perf/core improvements and fixes for 5.3 Ingo Molnar
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=20190529133605.21118-41-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.com \
/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).