All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf_event: fix broken calc_timer_values()
@ 2011-08-29 12:41 Stephane Eranian
  2011-08-29 12:53 ` Peter Zijlstra
  2011-08-29 13:04 ` Peter Zijlstra
  0 siblings, 2 replies; 3+ messages in thread
From: Stephane Eranian @ 2011-08-29 12:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: peterz, mingo, emunson, vweaver1


We detected a serious issue with PERF_SAMPLE_READ and
timing information when events were being multiplexing.

Samples would have time_running > time_enabled. That
was easy to reproduce with a libpfm4 example (ran 3
times to cause multiplexing on Core 2):

$ syst_smpl -e uops_retired:freq=1 &
$ syst_smpl -e uops_retired:freq=1 &
$ syst_smpl -e uops_retired:freq=1 &
IIP:0x0000000040062d ... PERIOD:2355332948 ENA=40144625315 RUN=60014875184
syst_smpl: WARNING: time_running > time_enabled
	63277537998 uops_retired:freq=1 , scaled

The bug was not present in kernel up to 3.0. It turns
out the bug was introduced by the following commit:

commit c4794295917ebeda8013b6cb9c8d71ab4f74a1fa
Author: Eric B Munson <emunson@mgebm.net>
Date:   Thu Jun 23 16:34:38 2011 -0400

    events: Move lockless timer calculation into helper function
    
The parameters of the function got reversed yet the call sites
were not updated to reflect the change. That lead to time_running
and time_enabled being swapped. That had no effect when there was
no multiplexing because in that case time_running = time_enabled
but it would show up in any other scenario.

Signed-off-by: Stephane Eranian <eranian@google.com>
---

diff --git a/kernel/events/core.c b/kernel/events/core.c
index adc3ef3..6bacaee 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3354,8 +3354,8 @@ static int perf_event_index(struct perf_event *event)
 }
 
 static void calc_timer_values(struct perf_event *event,
-				u64 *running,
-				u64 *enabled)
+				u64 *enabled,
+				u64 *running)
 {
 	u64 now, ctx_time;
 

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

* Re: [PATCH] perf_event: fix broken calc_timer_values()
  2011-08-29 12:41 [PATCH] perf_event: fix broken calc_timer_values() Stephane Eranian
@ 2011-08-29 12:53 ` Peter Zijlstra
  2011-08-29 13:04 ` Peter Zijlstra
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2011-08-29 12:53 UTC (permalink / raw)
  To: Stephane Eranian; +Cc: linux-kernel, mingo, emunson, vweaver1

On Mon, 2011-08-29 at 14:41 +0200, Stephane Eranian wrote:

> @@ -3354,8 +3354,8 @@ static int perf_event_index(struct perf_event *event)
>  }
>  
>  static void calc_timer_values(struct perf_event *event,
> -				u64 *running,
> -				u64 *enabled)
> +				u64 *enabled,
> +				u64 *running)
>  {
>  	u64 now, ctx_time;
>  

Urgh, nice catch.. I'll queue it for perf/urgent and Cc stable for 3.0.x

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

* Re: [PATCH] perf_event: fix broken calc_timer_values()
  2011-08-29 12:41 [PATCH] perf_event: fix broken calc_timer_values() Stephane Eranian
  2011-08-29 12:53 ` Peter Zijlstra
@ 2011-08-29 13:04 ` Peter Zijlstra
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2011-08-29 13:04 UTC (permalink / raw)
  To: Stephane Eranian; +Cc: linux-kernel, mingo, emunson, vweaver1

On Mon, 2011-08-29 at 14:41 +0200, Stephane Eranian wrote:
> The bug was not present in kernel up to 3.0. It turns
> out the bug was introduced by the following commit:
> 
> commit c4794295917ebeda8013b6cb9c8d71ab4f74a1fa 

Ah, up to /and including/ 3.0, since:

git describe --contains c4794295917ebeda8013b6cb9c8d71ab4f74a1fa --match "v*"
v3.1-rc1~299^2~32

So only perf/urgent is needed.

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

end of thread, other threads:[~2011-08-29 13:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-29 12:41 [PATCH] perf_event: fix broken calc_timer_values() Stephane Eranian
2011-08-29 12:53 ` Peter Zijlstra
2011-08-29 13:04 ` Peter Zijlstra

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.