All of lore.kernel.org
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: al.grant@arm.com, mathieu.poirier@linaro.org,
	anshuman.khandual@arm.com, coresight@lists.linaro.org,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	leo.yan@linaro.org, mike.leach@linaro.org
Subject: [PATCH 0/3] coresight: etm-perf: Fix pid tracing with VHE
Date: Tue, 10 Nov 2020 18:33:10 +0000	[thread overview]
Message-ID: <20201110183313.1823760-1-suzuki.poulose@arm.com> (raw)

With the Virtualization Host Extensions, the kernel can run at EL2.
In this case the pid is written to CONTEXTIDR_EL2 instead of the
CONTEXTIDR_EL1. Thus the normal coresight tracing will be unable
to detect the PID of the thread generating the trace by looking
at the CONTEXTIDR_EL1. Thus, depending on the kernel EL, we must
switch to tracing the correct CONTEXTIDR register.

With VHE, we must set the TRCCONFIGR.VMID and TRCCONFIGR.VMID_OPT
to include the CONTEXTIDR_EL2 as the VMID in the trace. This
requires the perf tool to detect the changes in the TRCCONFIGR and
use the VMID / CID field for the PID. The challenge here is for
the perf tool to detect the kernel behavior.

Instead of the previously proposed invasive approaches, this set
implements a less intrusive mechanism, by playing with the
perf_event.attribute.config bits.

Some facts:

 - The perf tool requests pid tracing and timestamp in some
   scenarios. (e.g, system wide, task bound (!per-thread).

 - The default pid tracing is via requesting "contextid"
   But this only works for EL1 kernel.

 - "contextid" tracing is useful for tracing VMs (when
   we get to virtualization support). So we don't want
   to move this around.

So this patch series introduces two new format bits: 

- contextid_in_vmid -> Is only supported when the VMID tracing
  and CONTEXTIDR_EL2 both are supported. When requested the perf
  etm4x backend sets (TRCCONFIGR.VMID | TRCCONFIGR.VMID_OPT).
  As per ETMv4.4 TRM, when the core supports VHE, the CONTEXTIDR_EL2
  tracing is mandatory. (See the field TRCID2.VMIDOPT)

- pid -> Is an alias for the correct config to enable PID tracing
  on any kernel.
  i.e, in EL1 kernel -> pid == contextid
          EL2 kernel -> pid == contextid_in_vmid

With this, the perf tool is also updated to request the "pid"
tracing whenever available, falling back to "contextid" if it
is unavailable (to support new tool running on older kernels).

The perf tool will also set the TRCCONFIGR accordingly based
on the config bits, allowing the decoder to output the appropriate
fields.

I have another patch for the perf decoder to set the TID from VMID
when the cid is invalid and and the vmid is valid. But this doesn't
verify if the trcconfigr.vmid_opt was set. I will leave this to
Mike Leach to fix it properly.

Tested on Juno (EL1 kernel) and N1SDP (El2 kernel). Feedback welcome.

A tree with these patches are available here :

 git.gitlab.arm.com:linux-arm/linux-skp.git coresight/el2/pid

Suzuki K Poulose (3):
  coresight: etm-perf: Add support for PID tracing for kernel at EL2
  perf: cs_etm: Use pid tracing explicitly instead of contextid
  rfc: perf: cs_etm: Detect pid in VMID for kernel running at EL2

 .../hwtracing/coresight/coresight-etm-perf.c  | 14 ++++
 .../coresight/coresight-etm4x-core.c          |  9 +++
 include/linux/coresight-pmu.h                 | 11 ++--
 tools/include/linux/coresight-pmu.h           | 11 ++--
 tools/perf/arch/arm/util/cs-etm.c             | 65 ++++++++++++++-----
 .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 28 ++++----
 6 files changed, 101 insertions(+), 37 deletions(-)

-- 
2.24.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2020-11-10 18:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10 18:33 Suzuki K Poulose [this message]
2020-11-10 18:33 ` [PATCH 1/3] coresight: etm-perf: Add support for PID tracing for kernel at EL2 Suzuki K Poulose
2020-11-12 10:27   ` Leo Yan
2020-11-12 12:41     ` Suzuki K Poulose
2020-11-10 18:33 ` [PATCH 2/3] perf: cs_etm: Use pid tracing explicitly instead of contextid Suzuki K Poulose
2020-11-12 10:00   ` Leo Yan
2020-11-12 10:54     ` Suzuki K Poulose
2020-11-12 12:24       ` Leo Yan
2020-11-10 18:33 ` [PATCH 3/3] rfc: perf: cs_etm: Detect pid in VMID for kernel running at EL2 Suzuki K Poulose
2020-11-10 22:57   ` Suzuki K Poulose
2020-11-11 11:03   ` Al Grant
2020-11-11 11:40     ` Suzuki K Poulose
2020-11-13  0:11       ` Leo Yan
2020-11-13  9:47         ` Suzuki K Poulose
2020-11-13 10:42           ` Leo Yan
2020-11-16  9:46           ` Leo Yan
2020-12-18 10:46             ` Daniel Kiss
     [not found]               ` <CADDJ8CVqz8Gdkx42H+TjdBOS-Vjk4MAVV7PhAaeBNq9Ejh=usA@mail.gmail.com>
2020-12-23  8:05                 ` Leo Yan
2021-01-04 17:33                   ` Suzuki K Poulose
2021-01-04 18:06                     ` Mathieu Poirier

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=20201110183313.1823760-1-suzuki.poulose@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=al.grant@arm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=coresight@lists.linaro.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mike.leach@linaro.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.