Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234469
b: refs/heads/master
c: 9848caf
h: refs/heads/master
i:
  234467: 0b8de3e
v: v3
  • Loading branch information
Ingo Molnar committed Feb 23, 2011
1 parent a47db12 commit ff959ef
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9826e8329bc160e4cc58b83019f3f056965e42d0
refs/heads/master: 9848caf26dafefcec7881f0e3c35fc81c454ba59
53 changes: 32 additions & 21 deletions trunk/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ __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)
{
Expand Down Expand Up @@ -268,28 +273,41 @@ 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 = perf_cgroup_from_task(current);
struct perf_cgroup *cgrp;

/*
* do not update time when cgroup is not active
* ensure we access cgroup data only when needed and
* when we know the cgroup is pinned (css_get)
*/
if (!event->cgrp || cgrp != event->cgrp)
if (!is_cgroup_event(event))
return;

__update_cgrp_time(event->cgrp);
cgrp = perf_cgroup_from_task(current);
/*
* Do not update time when cgroup is not active
*/
if (cgrp == event->cgrp)
__update_cgrp_time(event->cgrp);
}

static inline void
perf_cgroup_set_timestamp(struct task_struct *task, u64 now)
perf_cgroup_set_timestamp(struct task_struct *task,
struct perf_event_context *ctx)
{
struct perf_cgroup *cgrp;
struct perf_cgroup_info *info;

if (!task)
/*
* 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)
return;

cgrp = perf_cgroup_from_task(task);
info = this_cpu_ptr(cgrp->info);
info->timestamp = now;
info->timestamp = ctx->timestamp;
}

#define PERF_CGROUP_SWOUT 0x1 /* cgroup switch out every event */
Expand Down Expand Up @@ -494,7 +512,8 @@ static inline int perf_cgroup_connect(pid_t pid, struct perf_event *event,
}

static inline void
perf_cgroup_set_timestamp(struct task_struct *task, u64 now)
perf_cgroup_set_timestamp(struct task_struct *task,
struct perf_event_context *ctx)
{
}

Expand Down Expand Up @@ -1613,7 +1632,7 @@ static int __perf_event_enable(void *info)
/*
* set current task's cgroup time reference point
*/
perf_cgroup_set_timestamp(current, perf_clock());
perf_cgroup_set_timestamp(current, ctx);

__perf_event_mark_enabled(event, ctx);

Expand Down Expand Up @@ -2048,7 +2067,7 @@ ctx_sched_in(struct perf_event_context *ctx,

now = perf_clock();
ctx->timestamp = now;
perf_cgroup_set_timestamp(task, now);
perf_cgroup_set_timestamp(task, ctx);
/*
* First go through the list and put on any pinned groups
* in order to give them the best chance of going on.
Expand Down Expand Up @@ -5791,17 +5810,9 @@ static void task_clock_event_del(struct perf_event *event, int flags)

static void task_clock_event_read(struct perf_event *event)
{
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;
}
u64 now = perf_clock();
u64 delta = now - event->ctx->timestamp;
u64 time = event->ctx->time + delta;

task_clock_event_update(event, time);
}
Expand Down

0 comments on commit ff959ef

Please sign in to comment.