Re: [PATCH 7/7] perf: Add load latency monitoring on Intel Nehalem/Westmere v2

Previous thread: [PATCH] i7core_edac: fix misuse of logical operation in place of bitop by David Sterba on Monday, December 27, 2010 - 8:39 am. (1 message)

Next thread: [PATCH] [TRIVIAL] i7core_edac: fix typos in comments by David Sterba on Monday, December 27, 2010 - 8:51 am. (2 messages)
From: Lin Ming
Date: Monday, December 27, 2010 - 8:39 am

v2 change logs:
- generic load latency data source encoding
- sample more load latency data(data address/latency value/data source)
- remove the hw_perf_event::extra_flags 
- increment MAX_EXTRA_REGS to 3


This patch adds load latency monitoring on Intel Nehalem/Westmere.
It's applied on top of tip/master(1f7107c8) and Andi's offcore
patchsets are needed(see PATCH 0-3).

The load latency on Intel Nehalem/Westmere is monitored by event
MEM_INST_RETIRED.LATENCY_ABOVE_THRESHOLD(0x100b). It measures latency
from micro-operation (uop) dispatch to when data is globally observable
(GO).

To monitor load latency, both the PEBS_EN_CTRx and LL_EN_CTRx bits must
be set in IA32_PEBS_ENABLE register. And an extra MSR
MSR_PEBS_LD_LAT_THRESHOLD must be programmed with the desired latency
threshold in core clock cycles. Loads with latencies greater than this
value are counted.

The latency threshold is encoded in the upper 32 bits of
perf_event_attr::config and 'p' modifier must be used to enabel PEBS.

The default latency threshold is 3, as Intel manual says, "The minimum
value that may be programmed in this register is 3 (the minimum
detectable load latency is 4 core clock cycles)."

Usage:

# perf top -e r100b:p

#Monitor load latency > 51 cycles
# perf top -e r510000100b:p

Any comment is appropriated.

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
---
 arch/x86/include/asm/msr-index.h          |    2 +
 arch/x86/include/asm/perf_event.h         |   26 ++++++++++++++++
 arch/x86/kernel/cpu/perf_event.c          |    7 ++++
 arch/x86/kernel/cpu/perf_event_intel.c    |    6 +++-
 arch/x86/kernel/cpu/perf_event_intel_ds.c |   47 +++++++++++++++++++++++++----
 include/linux/perf_event.h                |    8 ++++-
 6 files changed, 87 insertions(+), 9 deletions(-)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index c3c42b1..174127d 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -54,6 +54,8 @@
 ...
From: Peter Zijlstra
Date: Tuesday, January 4, 2011 - 4:59 am

Hmm, why is that RESREVED? From what I can see that ends up being:
  RAM-remote-invalid

Which brings us to the NOT_USED thing, from what I can see its the value
that toggles between {L1, L2, L3, RAM} and {unknown, IO, uncached},
that's not NOT_USED.

There's still room for a {reserved} value in that alternative set,
making it: {unknown, IO, uncached, reserved}

Which would make


I'm not really sure about this, should we silently fix up or bail on



So you cast to the biggest and make sure you don't peek past the end of

This is what stops us from peeking past the end of the pebs record,

Right, so I think I want this in 3 patches, one adding the load-latency
extra reg thing and PERF_SAMPLE_ADDR usage, one adding
PERF_SAMPLE_LATENCY and one adding PERF_SAMPLE_EXTRA, I really dislike
the LATENCY_DATA name since that ties the extra data to the latency
thing, which isn't at all true for other platforms.


--

From: Peter Zijlstra
Date: Tuesday, January 4, 2011 - 7:03 am

Also, this wants a 4th patch to be fully mergable, we want to have
tools/perf/ support for these things..
--

Previous thread: [PATCH] i7core_edac: fix misuse of logical operation in place of bitop by David Sterba on Monday, December 27, 2010 - 8:39 am. (1 message)

Next thread: [PATCH] [TRIVIAL] i7core_edac: fix typos in comments by David Sterba on Monday, December 27, 2010 - 8:51 am. (2 messages)