Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH 0/8] More perf patches

1 view
Skip to first unread message

Peter Zijlstra

unread,
Nov 23, 2009, 5:42:17 AM11/23/09
to Ingo Molnar, Paul Mackerras, linux-...@vger.kernel.org, Peter Zijlstra
--

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Peter Zijlstra

unread,
Nov 23, 2009, 5:42:35 AM11/23/09
to Ingo Molnar, Paul Mackerras, linux-...@vger.kernel.org, Peter Zijlstra
perf-foo-4.patch

Peter Zijlstra

unread,
Nov 23, 2009, 5:42:45 AM11/23/09
to Ingo Molnar, Paul Mackerras, linux-...@vger.kernel.org, Peter Zijlstra
perf-foo-5.patch

Ingo Molnar

unread,
Nov 23, 2009, 5:52:18 AM11/23/09
to Peter Zijlstra, Paul Mackerras, linux-...@vger.kernel.org

* Peter Zijlstra <a.p.zi...@chello.nl> wrote:

> Normally we flatten the inherited hierarchy by attaching all childs to
> the top parent, therefore a child's child_total_time_* should never
> get incremented, add it anyway?
>
> Signed-off-by: Peter Zijlstra <a.p.zi...@chello.nl>
> ---
> kernel/perf_event.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> Index: linux-2.6/kernel/perf_event.c
> ===================================================================
> --- linux-2.6.orig/kernel/perf_event.c
> +++ linux-2.6/kernel/perf_event.c
> @@ -1780,8 +1780,10 @@ u64 perf_event_read_value(struct perf_ev
>
> list_for_each_entry(child, &event->child_list, child_list) {
> total += perf_event_read(child);
> - *enabled += child->total_time_enabled;
> - *running += child->total_time_running;
> + *enabled += child->total_time_enabled +
> + atomic64_read(&child->child_total_time_enabled);
> + *running += child->total_time_running +
> + atomic64_read(&child->child_total_time_running);

Stick in a WARN_ON_ONCE() instead?

Ingo

tip-bot for Peter Zijlstra

unread,
Nov 23, 2009, 6:55:42 AM11/23/09
to linux-ti...@vger.kernel.org, linux-...@vger.kernel.org, pau...@samba.org, h...@zytor.com, mi...@redhat.com, fwei...@gmail.com, a.p.zi...@chello.nl, tg...@linutronix.de, mi...@elte.hu
Commit-ID: 2e2af50b1fab3c40636839a7f439c167ae559533
Gitweb: http://git.kernel.org/tip/2e2af50b1fab3c40636839a7f439c167ae559533
Author: Peter Zijlstra <a.p.zi...@chello.nl>
AuthorDate: Mon, 23 Nov 2009 11:37:25 +0100
Committer: Ingo Molnar <mi...@elte.hu>
CommitDate: Mon, 23 Nov 2009 11:49:56 +0100

perf_events: Disable events when we detach them

If we leave the event in STATE_INACTIVE, any read of the event
after the detach will increase the running count but not the
enabled count and cause funny scaling artefacts.

Signed-off-by: Peter Zijlstra <a.p.zi...@chello.nl>
Cc: Paul Mackerras <pau...@samba.org>
Cc: Frederic Weisbecker <fwei...@gmail.com>
LKML-Reference: <200911231038...@chello.nl>
Signed-off-by: Ingo Molnar <mi...@elte.hu>
---
kernel/perf_event.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 1f14481..fb851ec 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -294,6 +294,8 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx)
if (event->group_leader != event)
event->group_leader->nr_siblings--;

+ event->state = PERF_EVENT_STATE_OFF;
+
/*
* If this was a group event with sibling events then
* upgrade the siblings to singleton events by adding them

Peter Zijlstra

unread,
Nov 23, 2009, 9:00:52 AM11/23/09
to Ingo Molnar, Paul Mackerras, linux-...@vger.kernel.org
It is quite possible to call update_event_times() on a context that
isn't actually running and thereby confuse the thing.

perf stat was reporting !100% scale values for software counters
(2e2af50b perf_events: Disable events when we detach them, solved the
worst of that, but there was still some left).

The thing that happens is that because we are not self-reaping (we have
a caring parent) there is a time between the last schedule (out) and
having do_exit() called which will detach the events.

This period would be accounted as enabled,!running because the
event->state==INACTIVE, even though !event->ctx->is_active.

Similar issues could have been observed by calling read() on a event
while the attached task was not scheduled in.

Solve this by teaching update_event_times() about ctx->is_active.

Signed-off-by: Peter Zijlstra <a.p.zi...@chello.nl>
---

kernel/perf_event.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 0b0d5f7..0aafe85 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -274,7 +274,12 @@ static void update_event_times(struct perf_event *event)
event->group_leader->state < PERF_EVENT_STATE_INACTIVE)
return;

- event->total_time_enabled = ctx->time - event->tstamp_enabled;
+ if (ctx->is_active)
+ run_end = ctx->time;
+ else
+ run_end = event->tstamp_stopped;
+
+ event->total_time_enabled = run_end - event->tstamp_enabled;

if (event->state == PERF_EVENT_STATE_INACTIVE)
run_end = event->tstamp_stopped;

tip-bot for Peter Zijlstra

unread,
Nov 23, 2009, 12:43:55 PM11/23/09
to linux-ti...@vger.kernel.org, linux-...@vger.kernel.org, ac...@redhat.com, pau...@samba.org, h...@zytor.com, mi...@redhat.com, a.p.zi...@chello.nl, efa...@gmx.de, pet...@infradead.org, fwei...@gmail.com, tg...@linutronix.de, mi...@elte.hu
Commit-ID: acd1d7c1f8f3d848a3c5327dc09f8c1efb971678
Gitweb: http://git.kernel.org/tip/acd1d7c1f8f3d848a3c5327dc09f8c1efb971678
Author: Peter Zijlstra <pet...@infradead.org>
AuthorDate: Mon, 23 Nov 2009 15:00:36 +0100
Committer: Ingo Molnar <mi...@elte.hu>
CommitDate: Mon, 23 Nov 2009 15:22:19 +0100

perf_events: Restore sanity to scaling land

It is quite possible to call update_event_times() on a context
that isn't actually running and thereby confuse the thing.

perf stat was reporting !100% scale values for software counters
(2e2af50b perf_events: Disable events when we detach them,
solved the worst of that, but there was still some left).

The thing that happens is that because we are not self-reaping
(we have a caring parent) there is a time between the last
schedule (out) and having do_exit() called which will detach the
events.

This period would be accounted as enabled,!running because the
event->state==INACTIVE, even though !event->ctx->is_active.

Similar issues could have been observed by calling read() on a
event while the attached task was not scheduled in.

Solve this by teaching update_event_times() about
ctx->is_active.

Signed-off-by: Peter Zijlstra <a.p.zi...@chello.nl>
Cc: Paul Mackerras <pau...@samba.org>
Cc: Mike Galbraith <efa...@gmx.de>
Cc: Arnaldo Carvalho de Melo <ac...@redhat.com>
Cc: Frederic Weisbecker <fwei...@gmail.com>
LKML-Reference: <1258984836.4531.480.camel@laptop>
Signed-off-by: Ingo Molnar <mi...@elte.hu>

0 new messages