linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Matt Fleming <matt@console-pimps.org>
Cc: Will Deacon <will.deacon@arm.com>, paulus <paulus@samba.org>,
	stephane eranian <eranian@googlemail.com>,
	Robert Richter <robert.richter@amd.com>,
	Paul Mundt <lethal@linux-sh.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Cyrill Gorcunov <gorcunov@gmail.com>,
	Lin Ming <ming.m.lin@intel.com>,
	Yanmin <yanmin_zhang@linux.intel.com>,
	Deng-Cheng Zhu <dengcheng.zhu@gmail.com>,
	David Miller <davem@davemloft.net>,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 00/11] perf pmu interface -v2
Date: Thu, 08 Jul 2010 13:13:42 +0200	[thread overview]
Message-ID: <1278587622.1900.79.camel@laptop> (raw)
In-Reply-To: <1277998793.1917.212.camel@laptop>

On Thu, 2010-07-01 at 17:39 +0200, Peter Zijlstra wrote:
> 
> Ah, for sampling for sure, simply group a software perf event and a
> hardware perf event together and use PERF_SAMPLE_READ. 

So the idea is to sample using a software event (periodic timer of
sorts, maybe randomize it) and weight its samples by the hardware event
deltas.

Suppose you have a workload consisting of two main parts:

  my_important_work()
  {
     load_my_data();
     compute_me_silly();
  }

Now, lets assume that both these functions take the same time to
complete for each part of work. In that case a periodic timer generate
samples that are about 50/50 distributed between these two functions.

Now, let us further assume that load_my_data() is so slow because its
missing all the caches and compute_me_silly() is slow because its
defeating the branch predictor.

So what we want to end up with, is that when we sample for cache-misses
we get load_my_data() as the predominant function, not a nice 50/50
relation. Idem for branch misses and compute_me_silly().

By weighting the samples by the hw counter delta we get this, if we
assume that the sampling frequency is not a harmonic of the runtime of
these functions, then statistics will dtrt.

It basically generates a massive skid on the sample, but as long as most
of the samples end up hitting the right function we're good. For a
periodic workload like: 
  while (lots) { my_important_work() }
that is even true for period > function_runtime with the exception of
that harmonic thing. For less neat workloads like:
  while (lots) { my_important_work(); other_random_things(); }
This doesn't need to work unless period < function_runtime.

Clearly we cannot attribute anything to the actual instruction hit due
to the massive skid, but we can (possibly) say something about the
function based on these statistical rules.



  parent reply	other threads:[~2010-07-08 11:13 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-24 14:28 [RFC][PATCH 00/11] perf pmu interface -v2 Peter Zijlstra
2010-06-24 14:28 ` [PATCH 01/11] perf, x86: Fix Nehalem PMU quirk Peter Zijlstra
2010-06-24 14:28 ` [PATCH 02/11] perf: Fix argument of perf_arch_fetch_caller_regs Peter Zijlstra
2010-06-24 14:28 ` [PATCH 03/11] perf, sparc64: Fix maybe_change_configuration() PCR setting Peter Zijlstra
2010-06-24 14:28 ` [RFC][PATCH 04/11] perf: deconstify struct pmu Peter Zijlstra
2010-06-24 14:28 ` [RFC][PATCH 05/11] perf: register pmu implementations Peter Zijlstra
2010-06-28 13:21   ` Frederic Weisbecker
2010-06-28 15:16     ` Peter Zijlstra
2010-06-28 15:29       ` Frederic Weisbecker
2010-07-09  3:08   ` Paul Mackerras
2010-07-09  8:14     ` Peter Zijlstra
2010-06-24 14:28 ` [RFC][PATCH 06/11] perf: Unindent labels Peter Zijlstra
2010-06-24 14:28 ` [RFC][PATCH 07/11] perf: Reduce perf_disable() usage Peter Zijlstra
2010-06-24 14:28 ` [RFC][PATCH 08/11] perf: Per PMU disable Peter Zijlstra
2010-07-09  7:31   ` Paul Mackerras
2010-07-09  8:36     ` Peter Zijlstra
2010-06-24 14:28 ` [RFC][PATCH 09/11] perf: Default PMU ops Peter Zijlstra
2010-06-29 14:49   ` Frederic Weisbecker
2010-06-29 14:57     ` Peter Zijlstra
2010-06-29 15:00       ` Frederic Weisbecker
2010-06-29 14:58   ` Frederic Weisbecker
2010-06-29 14:59     ` Peter Zijlstra
2010-06-29 15:03       ` Frederic Weisbecker
2010-06-29 16:34         ` Peter Zijlstra
2010-06-29 18:07           ` Frederic Weisbecker
2010-06-29 18:09             ` Peter Zijlstra
2010-06-29 18:11               ` Frederic Weisbecker
2010-06-29 18:19                 ` Peter Zijlstra
2010-06-29 18:21                   ` Frederic Weisbecker
2010-06-24 14:28 ` [RFC][PATCH 10/11] perf: Shrink hw_perf_event Peter Zijlstra
2010-06-29 15:06   ` Frederic Weisbecker
2010-06-24 14:28 ` [RFC][PATCH 11/11] perf: Rework the PMU methods Peter Zijlstra
2010-06-29 15:37   ` Frederic Weisbecker
2010-06-29 16:40     ` Peter Zijlstra
2010-06-29 18:09       ` Frederic Weisbecker
2010-06-25 11:11 ` [RFC][PATCH 00/11] perf pmu interface -v2 Will Deacon
2010-06-25 11:16   ` Peter Zijlstra
2010-06-25 14:36     ` Will Deacon
2010-06-25 14:50       ` Peter Zijlstra
2010-07-01 14:36         ` Peter Zijlstra
2010-07-01 15:02           ` Peter Zijlstra
2010-07-01 15:31             ` MattFleming
2010-07-01 15:39               ` Peter Zijlstra
2010-07-01 16:04                 ` Matt Fleming
2010-07-02  2:57                 ` Paul Mundt
2010-07-02  9:52                   ` Peter Zijlstra
2010-07-05 11:14                     ` Paul Mundt
2010-07-08 11:13                 ` Peter Zijlstra [this message]
2010-07-08 11:19                   ` Ingo Molnar
2010-07-18 19:37                     ` Matt Fleming
2010-07-02 12:55           ` Will Deacon
2010-06-26 11:22 ` Matt Fleming
2010-06-26 16:22 ` Corey Ashford
2010-06-28 15:13   ` Peter Zijlstra
2010-06-30 17:19     ` Corey Ashford
2010-06-30 18:11       ` 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=1278587622.1900.79.camel@laptop \
    --to=peterz@infradead.org \
    --cc=davem@davemloft.net \
    --cc=dengcheng.zhu@gmail.com \
    --cc=eranian@googlemail.com \
    --cc=fweisbec@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@console-pimps.org \
    --cc=ming.m.lin@intel.com \
    --cc=paulus@samba.org \
    --cc=robert.richter@amd.com \
    --cc=will.deacon@arm.com \
    --cc=yanmin_zhang@linux.intel.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).