Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147301
b: refs/heads/master
c: 53cfbf5
h: refs/heads/master
i:
  147299: f70f5dc
v: v3
  • Loading branch information
Paul Mackerras authored and Ingo Molnar committed Apr 6, 2009
1 parent 4a27de8 commit ad68d9d
Show file tree
Hide file tree
Showing 4 changed files with 192 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: 7730d8655880f41f2ea519aca2ca6a1413dfd2c9
refs/heads/master: 53cfbf593758916aac41db728f029986a62f1254
2 changes: 2 additions & 0 deletions trunk/arch/powerpc/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ static void counter_sched_in(struct perf_counter *counter, int cpu)
{
counter->state = PERF_COUNTER_STATE_ACTIVE;
counter->oncpu = cpu;
counter->tstamp_running += counter->ctx->time_now -
counter->tstamp_stopped;
if (is_software_counter(counter))
counter->hw_ops->enable(counter);
}
Expand Down
53 changes: 53 additions & 0 deletions trunk/include/linux/perf_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ enum perf_counter_record_type {
#define PERF_COUNTER_EVENT_SHIFT 0
#define PERF_COUNTER_EVENT_MASK __PERF_COUNTER_MASK(EVENT)

/*
* Bits that can be set in hw_event.read_format to request that
* reads on the counter should return the indicated quantities,
* in increasing order of bit value, after the counter value.
*/
enum perf_counter_read_format {
PERF_FORMAT_TOTAL_TIME_ENABLED = 1,
PERF_FORMAT_TOTAL_TIME_RUNNING = 2,
};

/*
* Hardware event to monitor via a performance monitoring counter:
*/
Expand Down Expand Up @@ -281,6 +291,32 @@ struct perf_counter {
enum perf_counter_active_state prev_state;
atomic64_t count;

/*
* These are the total time in nanoseconds that the counter
* has been enabled (i.e. eligible to run, and the task has
* been scheduled in, if this is a per-task counter)
* and running (scheduled onto the CPU), respectively.
*
* They are computed from tstamp_enabled, tstamp_running and
* tstamp_stopped when the counter is in INACTIVE or ACTIVE state.
*/
u64 total_time_enabled;
u64 total_time_running;

/*
* These are timestamps used for computing total_time_enabled
* and total_time_running when the counter is in INACTIVE or
* ACTIVE state, measured in nanoseconds from an arbitrary point
* in time.
* tstamp_enabled: the notional time when the counter was enabled
* tstamp_running: the notional time when the counter was scheduled on
* tstamp_stopped: in INACTIVE state, the notional time when the
* counter was scheduled off.
*/
u64 tstamp_enabled;
u64 tstamp_running;
u64 tstamp_stopped;

struct perf_counter_hw_event hw_event;
struct hw_perf_counter hw;

Expand All @@ -291,6 +327,13 @@ struct perf_counter {
struct perf_counter *parent;
struct list_head child_list;

/*
* These accumulate total time (in nanoseconds) that children
* counters have been enabled and running, respectively.
*/
atomic64_t child_total_time_enabled;
atomic64_t child_total_time_running;

/*
* Protect attach/detach and child_list:
*/
Expand Down Expand Up @@ -339,6 +382,16 @@ struct perf_counter_context {
int nr_active;
int is_active;
struct task_struct *task;

/*
* time_now is the current time in nanoseconds since an arbitrary
* point in the past. For per-task counters, this is based on the
* task clock, and for per-cpu counters it is based on the cpu clock.
* time_lost is an offset from the task/cpu clock, used to make it
* appear that time only passes while the context is scheduled in.
*/
u64 time_now;
u64 time_lost;
#endif
};

Expand Down
Loading

0 comments on commit ad68d9d

Please sign in to comment.