OProfile updates for v2.6.29
Subsystems (3)
Linus,
Please pull the latest oprofile-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git oprofile-for-linus
[ it merges without conflicts with the x86 tree and with the tracing tree. ]
Thanks,
Ingo
------------------>
Ingo Molnar (1):
oprofile: select RING_BUFFER
Robert Richter (19):
oprofile: comment cleanup
oprofile: update comment for oprofile_add_sample()
oprofile: whitspace changes only
oprofile: fix typo
x86/oprofile: reordering IBS code in op_model_amd.c x86/oprofile: cleanup IBS init/exit functions in op_model_amd.c
oprofile: implement switch/case in buffer_sync.c
oprofile: set values to default when creating oprofilefs
ring_buffer: update description for ring_buffer_alloc()
ftrace: remove unused function arg in trace_iterator_increment()
oprofile: adding cpu buffer r/w access functions
oprofile: adding cpu_buffer_write_commit()
oprofile: adding cpu_buffer_entries()
oprofile: moving cpu_buffer_reset() to cpu_buffer.h
ring_buffer: add remaining cpu functions to ring_buffer.h
oprofile: port to the new ring_buffer
oprofile: remove nr_available_slots()
oprofile: fix lost sample counter
ring_buffer: adding EXPORT_SYMBOLs
arch/Kconfig | 2 + arch/x86/oprofile/op_model_amd.c | 89 +++++++++-------- drivers/oprofile/buffer_sync.c | 117 ++++++++-------------- drivers/oprofile/cpu_buffer.c | 197 +++++++++++++++++++------------------ drivers/oprofile/cpu_buffer.h | 69 +++++++++++++- drivers/oprofile/oprofile_files.c | 15 +++- include/linux/oprofile.h | 3 +- include/linux/ring_buffer.h | 2 + kernel/trace/ring_buffer.c | 36 +++++++- kernel/trace/trace.c | 4 +- 10 files changed, 306 insertions(+), 228 deletions(-)
arch/Kconfig +2 -0
@@ -6,6 +6,8 @@ config OPROFILE tristate "OProfile system profiling (EXPERIMENTAL)" depends on PROFILING depends on HAVE_OPROFILE + select TRACING + select RING_BUFFER help OProfile is a profiling system capable of profiling the whole system, include the kernel, kernel modules, libraries,
arch/x86/oprofile/op_model_amd.c +46 -43
170 lines not on this page · raw message
drivers/oprofile/buffer_sync.c +40 -77
206 lines not on this page · raw message
drivers/oprofile/cpu_buffer.c +99 -98
303 lines not on this page · raw message
drivers/oprofile/cpu_buffer.h +67 -2
95 lines not on this page · raw message
drivers/oprofile/oprofile_files.c +12 -3
@@ -14,9 +14,13 @@#include "oprofile_stats.h" #include "oprof.h" -unsigned long fs_buffer_size =131072 ; -unsigned long fs_cpu_buffer_size =8192 ; -unsigned long fs_buffer_watershed =32768 ;/* FIXME: tune */ +#define FS_BUFFER_SIZE_DEFAULT 131072 +#define FS_CPU_BUFFER_SIZE_DEFAULT 8192 +#define FS_BUFFER_WATERSHED_DEFAULT 32768/* FIXME: tune */ + +unsigned long fs_buffer_size; +unsigned long fs_cpu_buffer_size; +unsigned long fs_buffer_watershed;static ssize_t depth_read (struct file *file,char __user *buf,size_t count,loff_t *offset) {
@@ -120,6 +124,11 @@ static const struct file_operations dump_fops = {void oprofile_create_files (struct super_block *sb,struct dentry *root) { +/* reinitialize default values */ + fs_buffer_size =FS_BUFFER_SIZE_DEFAULT ; + fs_cpu_buffer_size =FS_CPU_BUFFER_SIZE_DEFAULT ; + fs_buffer_watershed =FS_BUFFER_WATERSHED_DEFAULT ; +oprofilefs_create_file (sb, root,"enable" , &enable_fops);oprofilefs_create_file_perm (sb, root,"dump" , &dump_fops,0666 );oprofilefs_create_file (sb, root,"buffer" , &event_buffer_fops);
include/linux/oprofile.h +1 -2
@@ -86,8 +86,7 @@ int oprofile_arch_init(struct oprofile_operations * ops);void oprofile_arch_exit (void );/** -* Add a sample. This may be called from any context. Pass -* smp_processor_id() as cpu. +* Add a sample. This may be called from any context. */ void oprofile_add_sample (struct pt_regs *const regs,unsigned long event);
include/linux/ring_buffer.h +2 -0
@@ -116,6 +116,8 @@ void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu);unsigned long ring_buffer_entries (struct ring_buffer *buffer);unsigned long ring_buffer_overruns (struct ring_buffer *buffer); +unsigned long ring_buffer_entries_cpu (struct ring_buffer *buffer,int cpu); +unsigned long ring_buffer_overrun_cpu (struct ring_buffer *buffer,int cpu);u64 ring_buffer_time_stamp (int cpu);void ring_buffer_normalize_time_stamp (int cpu,u64 *ts);
kernel/trace/ring_buffer.c +35 -1
@@ -31,6 +31,7 @@ void tracing_on(void) { ring_buffers_off =0 ; } +EXPORT_SYMBOL_GPL (tracing_on);/** * tracing_off - turn off all tracing buffers
@@ -44,6 +45,7 @@ void tracing_off(void) { ring_buffers_off =1 ; } +EXPORT_SYMBOL_GPL (tracing_off);/* Up this if you want to test the TIME_EXTENTS and normalization */ #define DEBUG_SHIFT 0
@@ -60,12 +62,14 @@ u64 ring_buffer_time_stamp(int cpu)return time; } +EXPORT_SYMBOL_GPL (ring_buffer_time_stamp);void ring_buffer_normalize_time_stamp (int cpu,u64 *ts) {/* Just stupid testing the normalize function and deltas */ *ts >>=DEBUG_SHIFT ; } +EXPORT_SYMBOL_GPL (ring_buffer_normalize_time_stamp);#define RB_EVNT_HDR_SIZE (sizeof(struct ring_buffer_event))#define RB_ALIGNMENT_SHIFT 2
@@ -115,6 +119,7 @@ unsigned ring_buffer_event_length(struct ring_buffer_event *event) {return rb_event_length (event); } +EXPORT_SYMBOL_GPL (ring_buffer_event_length);/* inline for ring buffer fast paths */ static inline void *
@@ -136,6 +141,7 @@ void *ring_buffer_event_data(struct ring_buffer_event *event) {return rb_event_data (event); } +EXPORT_SYMBOL_GPL (ring_buffer_event_data);#define for_each_buffer_cpu (buffer, cpu) \ for_each_cpu_mask(cpu, buffer->cpumask)
@@ -381,7 +387,7 @@ extern int ring_buffer_page_too_big(void);/** * ring_buffer_alloc - allocate a new ring_buffer -* @size: the size in bytes that is needed. +* @size: the size in bytes per cpu that is needed. * @flags: attributes to set for the ring buffer. * * Currently the only flag that is available is the RB_FL_OVERWRITE
@@ -444,6 +450,7 @@ struct ring_buffer *ring_buffer_alloc(unsigned long size, unsigned flags)kfree (buffer);return NULL ; } +EXPORT_SYMBOL_GPL (ring_buffer_alloc);/** * ring_buffer_free - free a ring buffer.
@@ -459,6 +466,7 @@ ring_buffer_free(struct ring_buffer *buffer)kfree (buffer); } +EXPORT_SYMBOL_GPL (ring_buffer_free);static void rb_reset_cpu (struct ring_buffer_per_cpu *cpu_buffer);
@@ -620,6 +628,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)mutex_unlock (&buffer->mutex);return -ENOMEM ; } +EXPORT_SYMBOL_GPL (ring_buffer_resize);static inline int rb_null_event (struct ring_buffer_event *event) {
@@ -1220,6 +1229,7 @@ ring_buffer_lock_reserve(struct ring_buffer *buffer,preempt_enable_notrace ();return NULL ; } +EXPORT_SYMBOL_GPL (ring_buffer_lock_reserve);static void rb_commit (struct ring_buffer_per_cpu *cpu_buffer,struct ring_buffer_event *event)
@@ -1269,6 +1279,7 @@ int ring_buffer_unlock_commit(struct ring_buffer *buffer,return 0 ; } +EXPORT_SYMBOL_GPL (ring_buffer_unlock_commit);/** * ring_buffer_write - write data to the buffer without reserving
@@ -1334,6 +1345,7 @@ int ring_buffer_write(struct ring_buffer *buffer,return ret; } +EXPORT_SYMBOL_GPL (ring_buffer_write);static inline int rb_per_cpu_empty (struct ring_buffer_per_cpu *cpu_buffer) {
@@ -1360,6 +1372,7 @@ void ring_buffer_record_disable(struct ring_buffer *buffer) {atomic_inc (&buffer->record_disabled); } +EXPORT_SYMBOL_GPL (ring_buffer_record_disable);/** * ring_buffer_record_enable - enable writes to the buffer
@@ -1372,6 +1385,7 @@ void ring_buffer_record_enable(struct ring_buffer *buffer) {atomic_dec (&buffer->record_disabled); } +EXPORT_SYMBOL_GPL (ring_buffer_record_enable);/** * ring_buffer_record_disable_cpu - stop all writes into the cpu_buffer
@@ -1393,6 +1407,7 @@ void ring_buffer_record_disable_cpu(struct ring_buffer *buffer, int cpu) cpu_buffer = buffer->buffers[cpu];atomic_inc (&cpu_buffer->record_disabled); } +EXPORT_SYMBOL_GPL (ring_buffer_record_disable_cpu);/** * ring_buffer_record_enable_cpu - enable writes to the buffer
@@ -1412,6 +1427,7 @@ void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu) cpu_buffer = buffer->buffers[cpu];atomic_dec (&cpu_buffer->record_disabled); } +EXPORT_SYMBOL_GPL (ring_buffer_record_enable_cpu);/** * ring_buffer_entries_cpu - get the number of entries in a cpu buffer
@@ -1428,6 +1444,7 @@ unsigned long ring_buffer_entries_cpu(struct ring_buffer *buffer, int cpu) cpu_buffer = buffer->buffers[cpu];return cpu_buffer->entries; } +EXPORT_SYMBOL_GPL (ring_buffer_entries_cpu);/** * ring_buffer_overrun_cpu - get the number of overruns in a cpu_buffer
@@ -1444,6 +1461,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu) cpu_buffer = buffer->buffers[cpu];return cpu_buffer->overrun; } +EXPORT_SYMBOL_GPL (ring_buffer_overrun_cpu);/** * ring_buffer_entries - get the number of entries in a buffer
@@ -1466,6 +1484,7 @@ unsigned long ring_buffer_entries(struct ring_buffer *buffer)return entries; } +EXPORT_SYMBOL_GPL (ring_buffer_entries);/** * ring_buffer_overrun_cpu - get the number of overruns in buffer
@@ -1488,6 +1507,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)return overruns; } +EXPORT_SYMBOL_GPL (ring_buffer_overruns);/** * ring_buffer_iter_reset - reset an iterator
@@ -1513,6 +1533,7 @@ void ring_buffer_iter_reset(struct ring_buffer_iter *iter)else iter->read_stamp = iter->head_page->time_stamp; } +EXPORT_SYMBOL_GPL (ring_buffer_iter_reset);/** * ring_buffer_iter_empty - check if an iterator has no more to read
@@ -1527,6 +1548,7 @@ int ring_buffer_iter_empty(struct ring_buffer_iter *iter)return iter->head_page == cpu_buffer->commit_page && iter->head ==rb_commit_index (cpu_buffer); } +EXPORT_SYMBOL_GPL (ring_buffer_iter_empty); static void rb_update_read_stamp(struct ring_buffer_per_cpu *cpu_buffer,
@@ -1797,6 +1819,7 @@ ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)return NULL ; } +EXPORT_SYMBOL_GPL (ring_buffer_peek);/** * ring_buffer_iter_peek - peek at the next event to be read
@@ -1867,6 +1890,7 @@ ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts)return NULL ; } +EXPORT_SYMBOL_GPL (ring_buffer_iter_peek);/** * ring_buffer_consume - return an event and consume it
@@ -1894,6 +1918,7 @@ ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts)return event; } +EXPORT_SYMBOL_GPL (ring_buffer_consume);/** * ring_buffer_read_start - start a non consuming read of the buffer
@@ -1934,6 +1959,7 @@ ring_buffer_read_start(struct ring_buffer *buffer, int cpu)return iter; } +EXPORT_SYMBOL_GPL (ring_buffer_read_start);/** * ring_buffer_finish - finish reading the iterator of the buffer
@@ -1950,6 +1976,7 @@ ring_buffer_read_finish(struct ring_buffer_iter *iter)atomic_dec (&cpu_buffer->record_disabled);kfree (iter); } +EXPORT_SYMBOL_GPL (ring_buffer_read_finish);/** * ring_buffer_read - read the next item in the ring buffer by the iterator
@@ -1971,6 +1998,7 @@ ring_buffer_read(struct ring_buffer_iter *iter, u64 *ts)return event; } +EXPORT_SYMBOL_GPL (ring_buffer_read);/** * ring_buffer_size - return the size of the ring buffer (in bytes)
@@ -1980,6 +2008,7 @@ unsigned long ring_buffer_size(struct ring_buffer *buffer) {return BUF_PAGE_SIZE * buffer->pages; } +EXPORT_SYMBOL_GPL (ring_buffer_size);static void rb_reset_cpu (struct ring_buffer_per_cpu *cpu_buffer)
@@ -2022,6 +2051,7 @@ void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu)spin_unlock_irqrestore (&cpu_buffer->lock, flags); } +EXPORT_SYMBOL_GPL (ring_buffer_reset_cpu);/** * ring_buffer_reset - reset a ring buffer
@@ -2034,6 +2064,7 @@ void ring_buffer_reset(struct ring_buffer *buffer)for_each_buffer_cpu (buffer, cpu)ring_buffer_reset_cpu (buffer, cpu); } +EXPORT_SYMBOL_GPL (ring_buffer_reset);/** * rind_buffer_empty - is the ring buffer empty?
@@ -2052,6 +2083,7 @@ int ring_buffer_empty(struct ring_buffer *buffer) }return 1 ; } +EXPORT_SYMBOL_GPL (ring_buffer_empty);/** * ring_buffer_empty_cpu - is a cpu buffer of a ring buffer empty?
@@ -2068,6 +2100,7 @@ int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu) cpu_buffer = buffer->buffers[cpu];return rb_per_cpu_empty (cpu_buffer); } +EXPORT_SYMBOL_GPL (ring_buffer_empty_cpu);/** * ring_buffer_swap_cpu - swap a CPU buffer between two ring buffers
@@ -2117,6 +2150,7 @@ int ring_buffer_swap_cpu(struct ring_buffer *buffer_a,return 0 ; } +EXPORT_SYMBOL_GPL (ring_buffer_swap_cpu); static ssize_t rb_simple_read(struct file *filp, char __user *ubuf,
kernel/trace/trace.c +2 -2
@@ -914,7 +914,7 @@ enum trace_file_type { TRACE_FILE_LAT_FMT = 1, }; -static void trace_iterator_increment (struct trace_iterator *iter,int cpu) +static void trace_iterator_increment (struct trace_iterator *iter) {/* Don't allow ftrace to trace into the ring buffers */ ftrace_disable_cpu ();
@@ -993,7 +993,7 @@ static void *find_next_entry_inc(struct trace_iterator *iter) iter->ent =__find_next_entry (iter, &iter->cpu, &iter->ts);if (iter->ent) -trace_iterator_increment (iter, iter->cpu); +trace_iterator_increment (iter);return iter->ent ? iter :NULL ; }