oprofile: add op_cpu_buffer_add_data()
authorRobert Richter <robert.richter@amd.com>
Thu, 25 Dec 2008 16:26:07 +0000 (17:26 +0100)
committerRobert Richter <robert.richter@amd.com>
Wed, 7 Jan 2009 21:41:47 +0000 (22:41 +0100)
This function can be used to attach data to a sample. It returns the
remaining free buffer size that has been reserved with
op_cpu_buffer_write_reserve().

Signed-off-by: Robert Richter <robert.richter@amd.com>
drivers/oprofile/cpu_buffer.c
drivers/oprofile/cpu_buffer.h

index e859d23cfc5736a1cf8d38dfc7b5173962180da1..1b6590746be4d0334685cf2b940263bfd12e5f96 100644 (file)
@@ -258,7 +258,7 @@ op_add_code(struct oprofile_cpu_buffer *cpu_buf, unsigned long backtrace,
        sample->event = flags;
 
        if (size)
-               sample->data[0] = (unsigned long)task;
+               op_cpu_buffer_add_data(&entry, (unsigned long)task);
 
        op_cpu_buffer_write_commit(&entry);
 
index e634dcf2f26f16476b455aff11fb1faeb94aed35..e178dd2799c4f387f9fbff31805cbc34301792c6 100644 (file)
@@ -78,6 +78,18 @@ int op_cpu_buffer_write_commit(struct op_entry *entry);
 struct op_sample *op_cpu_buffer_read_entry(struct op_entry *entry, int cpu);
 unsigned long op_cpu_buffer_entries(int cpu);
 
+/* returns the remaining free size of data in the entry */
+static inline
+int op_cpu_buffer_add_data(struct op_entry *entry, unsigned long val)
+{
+       if (!entry->size)
+               return 0;
+       *entry->data = val;
+       entry->size--;
+       entry->data++;
+       return entry->size;
+}
+
 /* extra data flags */
 #define KERNEL_CTX_SWITCH      (1UL << 0)
 #define IS_KERNEL              (1UL << 1)