All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Thierry <julien.thierry@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: mark.rutland@arm.com, Julien Thierry <julien.thierry@arm.com>,
	peterz@infradead.org, will.deacon@arm.com, acme@kernel.org,
	alexander.shishkin@linux.intel.com, mingo@redhat.com,
	namhyung@kernel.org, jolsa@redhat.com
Subject: [PATCH v2 0/9] arm_pmu: Use NMI for perf interrupt
Date: Fri, 22 Mar 2019 16:23:55 +0000	[thread overview]
Message-ID: <1553271844-49003-1-git-send-email-julien.thierry@arm.com> (raw)

Hi,

On arm64, perf reports that counter overflow very often (too often)
happen in function that potentially enabled interrutps:

$ perf record -a -- sleep 60; perf report -F overhead,symbol
[...]
# Overhead  Symbol
# ........  ..........................................
#
     6.58%  [k] _raw_spin_unlock_irq
     6.10%  [k] _raw_spin_unlock_irqrestore
     5.52%  [k] ___bpf_prog_run
     4.37%  [k] el0_svc_common
     2.58%  [k] arch_cpu_idle
     2.39%  [k] kmem_cache_alloc
     2.06%  [k] __seccomp_filter
     [...]

The root issue is, if an overflow happens while executing with
interrupts disabled, the perf event will only be handled when interrupts
are reenabled (i.e. when the PMU interrupt is taken). The result being
the event being reported at the interrupt enabling location rather than
where the overflow actually happened.

Now that we have support for pseudo-NMI on arm64 with GICv3, we can use
it to improve the profiling done using the PMU interrupt.

With these changes, on the same machine, we get:
# Overhead  Symbol
# ........  ..................................
#
     7.06%  [k] ___bpf_prog_run
     4.08%  [k] __update_load_avg_se
     4.02%  [k] ktime_get_ts64
     3.77%  [k] __ll_sc_arch_atomic_add_return
     3.71%  [k] file_ra_state_init
     3.62%  [k] __ll_sc_arch_atomic64_sub
     3.53%  [k] __ll_sc___cmpxchg_case_acq_32
     [...]

_raw_spin_unlock_irq/irqrestore don't event appear anymore in the
perf trace.

* Patches 1 to 4 remove the need to use spinlocks for the Arm PMU
  driver for Armv7 and Armv8 (aarch64).
* Patches 5 moves the locking to Armv6 specific code which is the sole
  user
* Patches 6 and 7 make the PMU interrupt handler NMI-safe
* Patches 8 and 9 enable using pseudo-NMI for the PMU interrupt when
  the feature is available

Changes since v1[1]:
- Rebased on v5.1-rc1
- Pseudo-NMI has changed a lot since then, use the (now merged) NMI API
- Remove locking from armv7 perf_event
- Use locking only in armv6 perf_event
- Use direct counter/type registers insted of selector register for armv8

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2018-January/554611.html

Cheers,

Julien

-->

Julien Thierry (8):
  arm64: perf: Remove PMU locking
  arm: perf: save/resore pmsel
  arm: perf: Remove Remove PMU locking
  perf/arm_pmu: Move PMU lock to ARMv6 events
  arm64: perf: Do not call irq_work_run in NMI context
  arm/arm64: kvm: pmu: Make overflow handler NMI safe
  arm_pmu: Introduce pmu_irq_ops
  arm_pmu: Use NMIs for PMU

Mark Rutland (1):
  arm64: perf: avoid PMXEV* indirection

 arch/arm/kernel/perf_event_v6.c |  26 +++++---
 arch/arm/kernel/perf_event_v7.c |  77 +++++++---------------
 arch/arm64/kernel/perf_event.c  | 122 ++++++++++++++++++++++------------
 drivers/perf/arm_pmu.c          | 143 ++++++++++++++++++++++++++++++++++------
 include/kvm/arm_pmu.h           |   1 +
 include/linux/perf/arm_pmu.h    |   5 --
 virt/kvm/arm/pmu.c              |  37 +++++++++--
 7 files changed, 277 insertions(+), 134 deletions(-)

--
1.9.1

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

             reply	other threads:[~2019-03-22 16:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-22 16:23 Julien Thierry [this message]
2019-03-22 16:23 ` [PATCH v2 1/9] arm64: perf: avoid PMXEV* indirection Julien Thierry
2019-03-25 12:36   ` liwei (GF)
2019-03-25 13:59     ` Julien Thierry
2019-03-25 12:37   ` liwei (GF)
2019-03-25 13:59     ` Julien Thierry
2019-03-26  2:10       ` liwei (GF)
2019-03-28  9:48         ` Julien Thierry
2019-03-25 13:01   ` Marc Gonzalez
2019-07-08 11:40     ` Julien Thierry
2019-03-22 16:23 ` [PATCH v2 2/9] arm64: perf: Remove PMU locking Julien Thierry
2019-03-22 16:23 ` [PATCH v2 3/9] arm: perf: save/resore pmsel Julien Thierry
2019-03-22 16:23 ` [PATCH v2 4/9] arm: perf: Remove Remove PMU locking Julien Thierry
2019-03-22 16:24 ` [PATCH v2 5/9] perf/arm_pmu: Move PMU lock to ARMv6 events Julien Thierry
2019-03-22 16:24 ` [PATCH v2 6/9] arm64: perf: Do not call irq_work_run in NMI context Julien Thierry
2019-03-22 16:24 ` [PATCH v2 7/9] arm/arm64: kvm: pmu: Make overflow handler NMI safe Julien Thierry
2019-03-22 16:24   ` Julien Thierry
2019-03-22 16:24 ` [PATCH v2 8/9] arm_pmu: Introduce pmu_irq_ops Julien Thierry
2019-03-22 16:24 ` [PATCH v2 9/9] arm_pmu: Use NMIs for PMU Julien Thierry
2019-03-22 16:49 ` [PATCH v2 0/9] arm_pmu: Use NMI for perf interrupt Peter Zijlstra

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=1553271844-49003-1-git-send-email-julien.thierry@arm.com \
    --to=julien.thierry@arm.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.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 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.