oprofile: adding cpu_buffer_write_commit()
authorRobert Richter <robert.richter@amd.com>
Thu, 27 Nov 2008 17:36:08 +0000 (18:36 +0100)
committerRobert Richter <robert.richter@amd.com>
Wed, 10 Dec 2008 13:20:14 +0000 (14:20 +0100)
This is in preparation for changes in the cpu buffer implementation.

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

index 7e5e650e409f926f2bf85eaf018fd16632af50ac..d6f5de686363559c51660ef7af1c9c0a9429a223 100644 (file)
@@ -148,22 +148,6 @@ static unsigned long nr_available_slots(struct oprofile_cpu_buffer const *b)
        return tail + (b->buffer_size - head) - 1;
 }
 
-static void increment_head(struct oprofile_cpu_buffer *b)
-{
-       unsigned long new_head = b->head_pos + 1;
-
-       /*
-        * Ensure anything written to the slot before we increment is
-        * visible
-        */
-       wmb();
-
-       if (new_head < b->buffer_size)
-               b->head_pos = new_head;
-       else
-               b->head_pos = 0;
-}
-
 static inline void
 add_sample(struct oprofile_cpu_buffer *cpu_buf,
           unsigned long pc, unsigned long event)
@@ -171,7 +155,7 @@ add_sample(struct oprofile_cpu_buffer *cpu_buf,
        struct op_sample *entry = cpu_buffer_write_entry(cpu_buf);
        entry->eip = pc;
        entry->event = event;
-       increment_head(cpu_buf);
+       cpu_buffer_write_commit(cpu_buf);
 }
 
 static inline void
index 08706991fdd2254854b36bcfec1d6f7b36ee09dd..e6089768ae6658dce3a471205a34d08643928da8 100644 (file)
@@ -58,6 +58,23 @@ struct op_sample *cpu_buffer_write_entry(struct oprofile_cpu_buffer *cpu_buf)
        return &cpu_buf->buffer[cpu_buf->head_pos];
 }
 
+static inline
+void cpu_buffer_write_commit(struct oprofile_cpu_buffer *b)
+{
+       unsigned long new_head = b->head_pos + 1;
+
+       /*
+        * Ensure anything written to the slot before we increment is
+        * visible
+        */
+       wmb();
+
+       if (new_head < b->buffer_size)
+               b->head_pos = new_head;
+       else
+               b->head_pos = 0;
+}
+
 static inline
 struct op_sample *cpu_buffer_read_entry(struct oprofile_cpu_buffer *cpu_buf)
 {