public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [DRAFT PATCH 0/3] perf: Add Intel Nehalem uncore pmu support
@ 2010-11-02  7:27 Lin Ming
  2010-11-02 12:29 ` Peter Zijlstra
  0 siblings, 1 reply; 4+ messages in thread
From: Lin Ming @ 2010-11-02  7:27 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: Frederic Weisbecker, Arjan van de Ven, Stephane Eranian,
	robert.richter, Cyrill Gorcunov, paulus, Thomas Gleixner,
	H. Peter Anvin, CoreyAshford, lkml

Hi, all

Here is the draft patch to add Intel Nehalem uncore pmu support.
It's not fully functional, but I threw it out early to get comments.

For the background of Nehalem uncore pmu, see Intel SDM Volume 3B
"30.6.2 Performance Monitoring Facility in the Uncore"

1. data structure

struct node_hw_events {
        struct perf_event *events[UNCORE_NUM_COUNTERS];
        int n_events;
        struct spinlock lock;
        int enabled;
};

struct node_hw_events is the per node structure.
"lock" protects add/delete events to uncore pmu.

struct uncore_cpu_hw_events {
        unsigned long active_mask[BITS_TO_LONGS(UNCORE_NUM_COUNTERS)];
};

struct uncore_cpu_hw_events is the per logical cpu structure.
"active_mask" represents the counters used by the cpu.
For example, if bit 3, 6 are set for cpuX, then it means uncore counter
3 and 6 are used by cpuX.

2. Uncore pmu NMI handling

Every core in the socket can be programmed to receive uncore counter
overflow interrupt.

In this draft implementation, each core handles the overflow interrupt
caused by the counters with bit set in "active_mask".

3. perf tool update

In this draft, the uncore events are monitored with raw events with "ru"
prefix("u" for uncore).

./perf stat -e ru0101 -- ls

Performance counter stats for 'ls':

             795920  raw 0x101               

        0.002110130  seconds time elapsed

4. Issues

How to eliminate the duplicate counter values accumulated by multi child
processes on the same socket?

perf stat -e ru0101 -- make -j4

Assume the 4 "make" child processes are running on the same socket and
counting uncore raw event "0101", and the counter value read by them are
val0, val1, val2, val3.

Then the final counter result given by "perf stat" will be "val0 + val1
+ val2 + val3".

But this is obvious wrong, because the uncore counter is shared by all
cores in the socket, so the final result should not be accumulated.

Any comment is very appreciated.

 arch/x86/include/asm/msr-index.h              |    1 +
 arch/x86/kernel/cpu/perf_event.c              |   30 ++-
 arch/x86/kernel/cpu/perf_event_intel.c        |    4 +-
 arch/x86/kernel/cpu/perf_event_intel_uncore.c |  280 +++++++++++++++++++++++++
 arch/x86/kernel/cpu/perf_event_intel_uncore.h |   80 +++++++
 arch/x86/kernel/cpu/perf_event_p4.c           |    2 +-
 include/linux/perf_event.h                    |    1 +
 tools/perf/util/parse-events.c                |   14 +-
 8 files changed, 394 insertions(+), 18 deletions(-)


Thanks,
Lin Ming




^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: [DRAFT PATCH 0/3] perf: Add Intel Nehalem uncore pmu support
@ 2010-11-07 22:07 Cyrill Gorcunov
  0 siblings, 0 replies; 4+ messages in thread
From: Cyrill Gorcunov @ 2010-11-07 22:07 UTC (permalink / raw)
  To: Lin Ming
  Cc: Peter Zijlstra, Ingo Molnar, Frederic Weisbecker,
	Arjan van de Ven, Stephane Eranian, robert.richter, paulus,
	Thomas Gleixner, H. Peter Anvin, CoreyAshford, lkml

On Tue, Nov 02, 2010 at 03:27:38PM +0800, Lin Ming wrote:
> Hi, all
> 
> Here is the draft patch to add Intel Nehalem uncore pmu support.
> It's not fully functional, but I threw it out early to get comments.
> 

 Hi Ming, sorry for late response, though there are already a lot
of comments anyway :) Great job!

 Cyrill

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-11-07 22:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-02  7:27 [DRAFT PATCH 0/3] perf: Add Intel Nehalem uncore pmu support Lin Ming
2010-11-02 12:29 ` Peter Zijlstra
2010-11-02 13:58   ` Lin Ming
  -- strict thread matches above, loose matches on Subject: below --
2010-11-07 22:07 Cyrill Gorcunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox