From 0b8de3e29deb2b6f80e5882835052bb6f0204ef0 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 23 Feb 2011 07:25:02 -0300 Subject: [PATCH] --- yaml --- r: 234467 b: refs/heads/master c: 6435a5e39d3e01a1a73a925ed53ee18619b0a368 h: refs/heads/master i: 234465: 7f84d64a17fd95f0658c3c1ebdd4e6060f4a203c 234463: 5ffca27beca584a8c45d99b052b8cab445c2ca99 v: v3 --- [refs] | 2 +- trunk/kernel/perf_event.c | 53 ++++++++++--------------- trunk/tools/perf/util/ui/browsers/top.c | 23 +++++++++++ 3 files changed, 45 insertions(+), 33 deletions(-) diff --git a/[refs] b/[refs] index cfdba43b8ff8..d60720db01f2 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 768a06e2ca49cdf72389208cfc056a36cf8bc5e3 +refs/heads/master: 6435a5e39d3e01a1a73a925ed53ee18619b0a368 diff --git a/trunk/kernel/perf_event.c b/trunk/kernel/perf_event.c index 64a018e94fca..a0a6987fabc4 100644 --- a/trunk/kernel/perf_event.c +++ b/trunk/kernel/perf_event.c @@ -201,11 +201,6 @@ __get_cpu_context(struct perf_event_context *ctx) #ifdef CONFIG_CGROUP_PERF -/* - * Must ensure cgroup is pinned (css_get) before calling - * this function. In other words, we cannot call this function - * if there is no cgroup event for the current CPU context. - */ static inline struct perf_cgroup * perf_cgroup_from_task(struct task_struct *task) { @@ -273,41 +268,28 @@ static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx) static inline void update_cgrp_time_from_event(struct perf_event *event) { - struct perf_cgroup *cgrp; - + struct perf_cgroup *cgrp = perf_cgroup_from_task(current); /* - * ensure we access cgroup data only when needed and - * when we know the cgroup is pinned (css_get) + * do not update time when cgroup is not active */ - if (!is_cgroup_event(event)) + if (!event->cgrp || cgrp != event->cgrp) return; - cgrp = perf_cgroup_from_task(current); - /* - * Do not update time when cgroup is not active - */ - if (cgrp == event->cgrp) - __update_cgrp_time(event->cgrp); + __update_cgrp_time(event->cgrp); } static inline void -perf_cgroup_set_timestamp(struct task_struct *task, - struct perf_event_context *ctx) +perf_cgroup_set_timestamp(struct task_struct *task, u64 now) { struct perf_cgroup *cgrp; struct perf_cgroup_info *info; - /* - * ctx->lock held by caller - * ensure we do not access cgroup data - * unless we have the cgroup pinned (css_get) - */ - if (!task || !ctx->nr_cgroups) + if (!task) return; cgrp = perf_cgroup_from_task(task); info = this_cpu_ptr(cgrp->info); - info->timestamp = ctx->timestamp; + info->timestamp = now; } #define PERF_CGROUP_SWOUT 0x1 /* cgroup switch out every event */ @@ -512,8 +494,7 @@ static inline int perf_cgroup_connect(pid_t pid, struct perf_event *event, } static inline void -perf_cgroup_set_timestamp(struct task_struct *task, - struct perf_event_context *ctx) +perf_cgroup_set_timestamp(struct task_struct *task, u64 now) { } @@ -1632,7 +1613,7 @@ static int __perf_event_enable(void *info) /* * set current task's cgroup time reference point */ - perf_cgroup_set_timestamp(current, ctx); + perf_cgroup_set_timestamp(current, perf_clock()); __perf_event_mark_enabled(event, ctx); @@ -2067,7 +2048,7 @@ ctx_sched_in(struct perf_event_context *ctx, now = perf_clock(); ctx->timestamp = now; - perf_cgroup_set_timestamp(task, ctx); + perf_cgroup_set_timestamp(task, now); /* * First go through the list and put on any pinned groups * in order to give them the best chance of going on. @@ -5810,9 +5791,17 @@ static void task_clock_event_del(struct perf_event *event, int flags) static void task_clock_event_read(struct perf_event *event) { - u64 now = perf_clock(); - u64 delta = now - event->ctx->timestamp; - u64 time = event->ctx->time + delta; + u64 time; + + if (!in_nmi()) { + update_context_time(event->ctx); + update_cgrp_time_from_event(event); + time = event->ctx->time; + } else { + u64 now = perf_clock(); + u64 delta = now - event->ctx->timestamp; + time = event->ctx->time + delta; + } task_clock_event_update(event, time); } diff --git a/trunk/tools/perf/util/ui/browsers/top.c b/trunk/tools/perf/util/ui/browsers/top.c index 377ff58c9ae9..2f47224426b6 100644 --- a/trunk/tools/perf/util/ui/browsers/top.c +++ b/trunk/tools/perf/util/ui/browsers/top.c @@ -70,6 +70,7 @@ static void perf_top_browser__write(struct ui_browser *browser, void *entry, int static void perf_top_browser__update_rb_tree(struct perf_top_browser *browser) { struct perf_top *top = browser->b.priv; + u64 top_idx = browser->b.top_idx; browser->root = RB_ROOT; browser->b.top = NULL; @@ -82,7 +83,29 @@ static void perf_top_browser__update_rb_tree(struct perf_top_browser *browser) if (browser->sym_width + browser->dso_width > browser->b.width - 29) browser->sym_width = browser->b.width - browser->dso_width - 29; } + + /* + * Adjust the ui_browser indexes since the entries in the browser->root + * rb_tree may have changed, then seek it from start, so that we get a + * possible new top of the screen. + */ browser->b.nr_entries = top->rb_entries; + + if (top_idx >= browser->b.nr_entries) { + if (browser->b.height >= browser->b.nr_entries) + top_idx = browser->b.nr_entries - browser->b.height; + else + top_idx = 0; + } + + if (browser->b.index >= top_idx + browser->b.height) + browser->b.index = top_idx + browser->b.index - browser->b.top_idx; + + if (browser->b.index >= browser->b.nr_entries) + browser->b.index = browser->b.nr_entries - 1; + + browser->b.top_idx = top_idx; + browser->b.seek(&browser->b, top_idx, SEEK_SET); } static void perf_top_browser__annotate(struct perf_top_browser *browser)