cpqarray: switch to seq_file
[safe/jmp/linux-2.6] / drivers / oprofile / cpu_buffer.c
index f0e99d4..a7aae24 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <linux/sched.h>
 #include <linux/oprofile.h>
-#include <linux/vmalloc.h>
 #include <linux/errno.h>
 
 #include "event_buffer.h"
@@ -78,16 +77,20 @@ void free_cpu_buffers(void)
        op_ring_buffer_write = NULL;
 }
 
+#define RB_EVENT_HDR_SIZE 4
+
 int alloc_cpu_buffers(void)
 {
        int i;
 
        unsigned long buffer_size = oprofile_cpu_buffer_size;
+       unsigned long byte_size = buffer_size * (sizeof(struct op_sample) +
+                                                RB_EVENT_HDR_SIZE);
 
-       op_ring_buffer_read = ring_buffer_alloc(buffer_size, OP_BUFFER_FLAGS);
+       op_ring_buffer_read = ring_buffer_alloc(byte_size, OP_BUFFER_FLAGS);
        if (!op_ring_buffer_read)
                goto fail;
-       op_ring_buffer_write = ring_buffer_alloc(buffer_size, OP_BUFFER_FLAGS);
+       op_ring_buffer_write = ring_buffer_alloc(byte_size, OP_BUFFER_FLAGS);
        if (!op_ring_buffer_write)
                goto fail;
 
@@ -403,6 +406,21 @@ int oprofile_add_data(struct op_entry *entry, unsigned long val)
        return op_cpu_buffer_add_data(entry, val);
 }
 
+int oprofile_add_data64(struct op_entry *entry, u64 val)
+{
+       if (!entry->event)
+               return 0;
+       if (op_cpu_buffer_get_size(entry) < 2)
+               /*
+                * the function returns 0 to indicate a too small
+                * buffer, even if there is some space left
+                */
+               return 0;
+       if (!op_cpu_buffer_add_data(entry, (u32)val))
+               return 0;
+       return op_cpu_buffer_add_data(entry, (u32)(val >> 32));
+}
+
 int oprofile_write_commit(struct op_entry *entry)
 {
        if (!entry->event)