diff options
author | Robert Richter <robert.richter@amd.com> | 2008-11-27 04:57:09 -0500 |
---|---|---|
committer | Robert Richter <robert.richter@amd.com> | 2008-12-10 08:20:13 -0500 |
commit | 7d468abee0f1a7e918b5e2f23120436a54ba9f33 (patch) | |
tree | 397e40ca95ef2dcf70ed308cd1032c0f63f0508c | |
parent | e2ac8ef576e45d9db7264abc51383e68d26067bb (diff) |
oprofile: adding cpu buffer r/w access functions
This is in preparation for changes in the cpu buffer implementation.
Signed-off-by: Robert Richter <robert.richter@amd.com>
-rw-r--r-- | drivers/oprofile/buffer_sync.c | 20 | ||||
-rw-r--r-- | drivers/oprofile/cpu_buffer.c | 2 | ||||
-rw-r--r-- | drivers/oprofile/cpu_buffer.h | 12 |
3 files changed, 22 insertions, 12 deletions
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c index 7d61ae8ee8cf..44f676c8a51d 100644 --- a/drivers/oprofile/buffer_sync.c +++ b/drivers/oprofile/buffer_sync.c | |||
@@ -331,10 +331,8 @@ static void add_trace_begin(void) | |||
331 | 331 | ||
332 | #define IBS_FETCH_CODE_SIZE 2 | 332 | #define IBS_FETCH_CODE_SIZE 2 |
333 | #define IBS_OP_CODE_SIZE 5 | 333 | #define IBS_OP_CODE_SIZE 5 |
334 | #define IBS_EIP(offset) \ | 334 | #define IBS_EIP(cpu_buf) ((cpu_buffer_read_entry(cpu_buf))->eip) |
335 | (((struct op_sample *)&cpu_buf->buffer[(offset)])->eip) | 335 | #define IBS_EVENT(cpu_buf) ((cpu_buffer_read_entry(cpu_buf))->event) |
336 | #define IBS_EVENT(offset) \ | ||
337 | (((struct op_sample *)&cpu_buf->buffer[(offset)])->event) | ||
338 | 336 | ||
339 | /* | 337 | /* |
340 | * Add IBS fetch and op entries to event buffer | 338 | * Add IBS fetch and op entries to event buffer |
@@ -349,10 +347,10 @@ static void add_ibs_begin(struct oprofile_cpu_buffer *cpu_buf, int code, | |||
349 | 347 | ||
350 | increment_tail(cpu_buf); /* move to RIP entry */ | 348 | increment_tail(cpu_buf); /* move to RIP entry */ |
351 | 349 | ||
352 | rip = IBS_EIP(cpu_buf->tail_pos); | 350 | rip = IBS_EIP(cpu_buf); |
353 | 351 | ||
354 | #ifdef __LP64__ | 352 | #ifdef __LP64__ |
355 | rip += IBS_EVENT(cpu_buf->tail_pos) << 32; | 353 | rip += IBS_EVENT(cpu_buf) << 32; |
356 | #endif | 354 | #endif |
357 | 355 | ||
358 | if (mm) { | 356 | if (mm) { |
@@ -376,8 +374,8 @@ static void add_ibs_begin(struct oprofile_cpu_buffer *cpu_buf, int code, | |||
376 | add_event_entry(offset); /* Offset from Dcookie */ | 374 | add_event_entry(offset); /* Offset from Dcookie */ |
377 | 375 | ||
378 | /* we send the Dcookie offset, but send the raw Linear Add also*/ | 376 | /* we send the Dcookie offset, but send the raw Linear Add also*/ |
379 | add_event_entry(IBS_EIP(cpu_buf->tail_pos)); | 377 | add_event_entry(IBS_EIP(cpu_buf)); |
380 | add_event_entry(IBS_EVENT(cpu_buf->tail_pos)); | 378 | add_event_entry(IBS_EVENT(cpu_buf)); |
381 | 379 | ||
382 | if (code == IBS_FETCH_CODE) | 380 | if (code == IBS_FETCH_CODE) |
383 | count = IBS_FETCH_CODE_SIZE; /*IBS FETCH is 2 int64s*/ | 381 | count = IBS_FETCH_CODE_SIZE; /*IBS FETCH is 2 int64s*/ |
@@ -386,8 +384,8 @@ static void add_ibs_begin(struct oprofile_cpu_buffer *cpu_buf, int code, | |||
386 | 384 | ||
387 | for (i = 0; i < count; i++) { | 385 | for (i = 0; i < count; i++) { |
388 | increment_tail(cpu_buf); | 386 | increment_tail(cpu_buf); |
389 | add_event_entry(IBS_EIP(cpu_buf->tail_pos)); | 387 | add_event_entry(IBS_EIP(cpu_buf)); |
390 | add_event_entry(IBS_EVENT(cpu_buf->tail_pos)); | 388 | add_event_entry(IBS_EVENT(cpu_buf)); |
391 | } | 389 | } |
392 | } | 390 | } |
393 | 391 | ||
@@ -584,7 +582,7 @@ void sync_buffer(int cpu) | |||
584 | #else | 582 | #else |
585 | while (get_slots(cpu_buf)) { | 583 | while (get_slots(cpu_buf)) { |
586 | #endif | 584 | #endif |
587 | struct op_sample *s = &cpu_buf->buffer[cpu_buf->tail_pos]; | 585 | struct op_sample *s = cpu_buffer_read_entry(cpu_buf); |
588 | 586 | ||
589 | if (is_code(s->eip)) { | 587 | if (is_code(s->eip)) { |
590 | switch (s->event) { | 588 | switch (s->event) { |
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c index 2c4d54187b90..7e5e650e409f 100644 --- a/drivers/oprofile/cpu_buffer.c +++ b/drivers/oprofile/cpu_buffer.c | |||
@@ -168,7 +168,7 @@ static inline void | |||
168 | add_sample(struct oprofile_cpu_buffer *cpu_buf, | 168 | add_sample(struct oprofile_cpu_buffer *cpu_buf, |
169 | unsigned long pc, unsigned long event) | 169 | unsigned long pc, unsigned long event) |
170 | { | 170 | { |
171 | struct op_sample *entry = &cpu_buf->buffer[cpu_buf->head_pos]; | 171 | struct op_sample *entry = cpu_buffer_write_entry(cpu_buf); |
172 | entry->eip = pc; | 172 | entry->eip = pc; |
173 | entry->event = event; | 173 | entry->event = event; |
174 | increment_head(cpu_buf); | 174 | increment_head(cpu_buf); |
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h index d3cc26264db5..08706991fdd2 100644 --- a/drivers/oprofile/cpu_buffer.h +++ b/drivers/oprofile/cpu_buffer.h | |||
@@ -52,6 +52,18 @@ DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer); | |||
52 | 52 | ||
53 | void cpu_buffer_reset(struct oprofile_cpu_buffer *cpu_buf); | 53 | void cpu_buffer_reset(struct oprofile_cpu_buffer *cpu_buf); |
54 | 54 | ||
55 | static inline | ||
56 | struct op_sample *cpu_buffer_write_entry(struct oprofile_cpu_buffer *cpu_buf) | ||
57 | { | ||
58 | return &cpu_buf->buffer[cpu_buf->head_pos]; | ||
59 | } | ||
60 | |||
61 | static inline | ||
62 | struct op_sample *cpu_buffer_read_entry(struct oprofile_cpu_buffer *cpu_buf) | ||
63 | { | ||
64 | return &cpu_buf->buffer[cpu_buf->tail_pos]; | ||
65 | } | ||
66 | |||
55 | /* transient events for the CPU buffer -> event buffer */ | 67 | /* transient events for the CPU buffer -> event buffer */ |
56 | #define CPU_IS_KERNEL 1 | 68 | #define CPU_IS_KERNEL 1 |
57 | #define CPU_TRACE_BEGIN 2 | 69 | #define CPU_TRACE_BEGIN 2 |