Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169750
b: refs/heads/master
c: f67218c
h: refs/heads/master
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Nov 23, 2009
1 parent 362128b commit c1add60
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 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: 5e942bb33371254a474653123cd9e13a4c89ee44
refs/heads/master: f67218c3e93abaf0f480bb94b53d234853ffe4de
78 changes: 39 additions & 39 deletions trunk/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,44 @@ static void perf_unpin_context(struct perf_event_context *ctx)
put_ctx(ctx);
}

static inline u64 perf_clock(void)
{
return cpu_clock(smp_processor_id());
}

/*
* Update the record of the current time in a context.
*/
static void update_context_time(struct perf_event_context *ctx)
{
u64 now = perf_clock();

ctx->time += now - ctx->timestamp;
ctx->timestamp = now;
}

/*
* Update the total_time_enabled and total_time_running fields for a event.
*/
static void update_event_times(struct perf_event *event)
{
struct perf_event_context *ctx = event->ctx;
u64 run_end;

if (event->state < PERF_EVENT_STATE_INACTIVE ||
event->group_leader->state < PERF_EVENT_STATE_INACTIVE)
return;

event->total_time_enabled = ctx->time - event->tstamp_enabled;

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

event->total_time_running = run_end - event->tstamp_running;
}

/*
* Add a event from the lists for its context.
* Must be called with ctx->mutex and ctx->lock held.
Expand Down Expand Up @@ -294,6 +332,7 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx)
if (event->group_leader != event)
event->group_leader->nr_siblings--;

update_event_times(event);
event->state = PERF_EVENT_STATE_OFF;

/*
Expand Down Expand Up @@ -454,44 +493,6 @@ static void perf_event_remove_from_context(struct perf_event *event)
spin_unlock_irq(&ctx->lock);
}

static inline u64 perf_clock(void)
{
return cpu_clock(smp_processor_id());
}

/*
* Update the record of the current time in a context.
*/
static void update_context_time(struct perf_event_context *ctx)
{
u64 now = perf_clock();

ctx->time += now - ctx->timestamp;
ctx->timestamp = now;
}

/*
* Update the total_time_enabled and total_time_running fields for a event.
*/
static void update_event_times(struct perf_event *event)
{
struct perf_event_context *ctx = event->ctx;
u64 run_end;

if (event->state < PERF_EVENT_STATE_INACTIVE ||
event->group_leader->state < PERF_EVENT_STATE_INACTIVE)
return;

event->total_time_enabled = ctx->time - event->tstamp_enabled;

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

event->total_time_running = run_end - event->tstamp_running;
}

/*
* Update total_time_enabled and total_time_running for all events in a group.
*/
Expand Down Expand Up @@ -4931,7 +4932,6 @@ __perf_event_exit_task(struct perf_event *child_event,
{
struct perf_event *parent_event;

update_event_times(child_event);
perf_event_remove_from_context(child_event);

parent_event = child_event->parent;
Expand Down

0 comments on commit c1add60

Please sign in to comment.