aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/oprofile/cpu_buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/oprofile/cpu_buffer.h')
-rw-r--r--drivers/oprofile/cpu_buffer.h50
1 files changed, 4 insertions, 46 deletions
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h
index 83d491e273fe..cd28abc06960 100644
--- a/drivers/oprofile/cpu_buffer.h
+++ b/drivers/oprofile/cpu_buffer.h
@@ -54,8 +54,6 @@ struct oprofile_cpu_buffer {
54 struct delayed_work work; 54 struct delayed_work work;
55}; 55};
56 56
57extern struct ring_buffer *op_ring_buffer_read;
58extern struct ring_buffer *op_ring_buffer_write;
59DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer); 57DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer);
60 58
61/* 59/*
@@ -72,50 +70,10 @@ static inline void op_cpu_buffer_reset(int cpu)
72 cpu_buf->last_task = NULL; 70 cpu_buf->last_task = NULL;
73} 71}
74 72
75static inline int op_cpu_buffer_write_entry(struct op_entry *entry) 73int op_cpu_buffer_write_entry(struct op_entry *entry);
76{ 74int op_cpu_buffer_write_commit(struct op_entry *entry);
77 entry->event = ring_buffer_lock_reserve(op_ring_buffer_write, 75struct op_sample *op_cpu_buffer_read_entry(int cpu);
78 sizeof(struct op_sample), 76unsigned long op_cpu_buffer_entries(int cpu);
79 &entry->irq_flags);
80 if (entry->event)
81 entry->sample = ring_buffer_event_data(entry->event);
82 else
83 entry->sample = NULL;
84
85 if (!entry->sample)
86 return -ENOMEM;
87
88 return 0;
89}
90
91static inline int op_cpu_buffer_write_commit(struct op_entry *entry)
92{
93 return ring_buffer_unlock_commit(op_ring_buffer_write, entry->event,
94 entry->irq_flags);
95}
96
97static inline struct op_sample *op_cpu_buffer_read_entry(int cpu)
98{
99 struct ring_buffer_event *e;
100 e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL);
101 if (e)
102 return ring_buffer_event_data(e);
103 if (ring_buffer_swap_cpu(op_ring_buffer_read,
104 op_ring_buffer_write,
105 cpu))
106 return NULL;
107 e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL);
108 if (e)
109 return ring_buffer_event_data(e);
110 return NULL;
111}
112
113/* "acquire" as many cpu buffer slots as we can */
114static inline unsigned long op_cpu_buffer_entries(int cpu)
115{
116 return ring_buffer_entries_cpu(op_ring_buffer_read, cpu)
117 + ring_buffer_entries_cpu(op_ring_buffer_write, cpu);
118}
119 77
120/* transient events for the CPU buffer -> event buffer */ 78/* transient events for the CPU buffer -> event buffer */
121#define CPU_IS_KERNEL 1 79#define CPU_IS_KERNEL 1