aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2009-05-07 11:28:59 -0400
committerRobert Richter <robert.richter@amd.com>2009-05-07 11:28:59 -0400
commit54f2c841fa0007e5fee3b7d01a911c774f0a6cda (patch)
tree058b9a96ed4fa2c963d18d0a66c2d3a5af38d881
parent091438dd5668396328a3419abcbc6591159eb8d1 (diff)
oprofile: fix cpu buffer size
The unit of oprofile_cpu_buffer_size is in samples, but was allocated in bytes. This led to the allocation of too small cpu buffers. This patch recalculates the buffer size in bytes taking also the ring_buffer_event header size into account. Reported-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by: Robert Richter <robert.richter@amd.com>
-rw-r--r--drivers/oprofile/cpu_buffer.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index f0e99d4c066b..242257b19441 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -78,16 +78,20 @@ void free_cpu_buffers(void)
78 op_ring_buffer_write = NULL; 78 op_ring_buffer_write = NULL;
79} 79}
80 80
81#define RB_EVENT_HDR_SIZE 4
82
81int alloc_cpu_buffers(void) 83int alloc_cpu_buffers(void)
82{ 84{
83 int i; 85 int i;
84 86
85 unsigned long buffer_size = oprofile_cpu_buffer_size; 87 unsigned long buffer_size = oprofile_cpu_buffer_size;
88 unsigned long byte_size = buffer_size * (sizeof(struct op_sample) +
89 RB_EVENT_HDR_SIZE);
86 90
87 op_ring_buffer_read = ring_buffer_alloc(buffer_size, OP_BUFFER_FLAGS); 91 op_ring_buffer_read = ring_buffer_alloc(byte_size, OP_BUFFER_FLAGS);
88 if (!op_ring_buffer_read) 92 if (!op_ring_buffer_read)
89 goto fail; 93 goto fail;
90 op_ring_buffer_write = ring_buffer_alloc(buffer_size, OP_BUFFER_FLAGS); 94 op_ring_buffer_write = ring_buffer_alloc(byte_size, OP_BUFFER_FLAGS);
91 if (!op_ring_buffer_write) 95 if (!op_ring_buffer_write)
92 goto fail; 96 goto fail;
93 97