Commit 8c977c50 authored by John Levon's avatar John Levon Committed by James Bottomley

[PATCH] oprofile update

This makes the following changes :
 o headers cleanup
 o remove deprecated kernel_only
 o mention minimum oprofile version
 o correct initialise stats
 o remove racy debug check (wli saw this oops)
 o remove pointless simple_open
 o add dump functionality
 o remove pessimising FASTCALL

It fixes a critical race.
parent 75fb58ee
...@@ -61,6 +61,7 @@ o pcmcia-cs 3.1.21 # cardmgr -V ...@@ -61,6 +61,7 @@ o pcmcia-cs 3.1.21 # cardmgr -V
o PPP 2.4.0 # pppd --version o PPP 2.4.0 # pppd --version
o isdn4k-utils 3.1pre1 # isdnctrl 2>&1|grep version o isdn4k-utils 3.1pre1 # isdnctrl 2>&1|grep version
o procps 2.0.9 # ps --version o procps 2.0.9 # ps --version
o oprofile 0.5 # oprofiled --version
Kernel compilation Kernel compilation
================== ==================
...@@ -368,6 +369,10 @@ Ip-route2 ...@@ -368,6 +369,10 @@ Ip-route2
--------- ---------
o <ftp://ftp.inr.ac.ru/ip-routing/iproute2-2.2.4-now-ss991023.tar.gz> o <ftp://ftp.inr.ac.ru/ip-routing/iproute2-2.2.4-now-ss991023.tar.gz>
OProfile
--------
o <http://oprofile.sf.net/download.php3>
Suggestions and corrections Suggestions and corrections
=========================== ===========================
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* @author John Levon <levon@movementarian.org> * @author John Levon <levon@movementarian.org>
*/ */
#include <linux/kernel.h>
#include <linux/oprofile.h> #include <linux/oprofile.h>
#include <linux/init.h> #include <linux/init.h>
......
...@@ -7,19 +7,13 @@ ...@@ -7,19 +7,13 @@
* @author John Levon <levon@movementarian.org> * @author John Levon <levon@movementarian.org>
*/ */
#include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/oprofile.h> #include <linux/oprofile.h>
#include <linux/pm.h>
#include <linux/thread_info.h>
#include <asm/nmi.h> #include <asm/nmi.h>
#include <asm/ptrace.h>
#include <asm/msr.h> #include <asm/msr.h>
#include <asm/apic.h> #include <asm/apic.h>
#include <asm/bitops.h>
#include <asm/processor.h>
#include "op_counter.h" #include "op_counter.h"
#include "op_x86_model.h" #include "op_x86_model.h"
...@@ -27,7 +21,6 @@ ...@@ -27,7 +21,6 @@
static struct op_x86_model_spec const * model; static struct op_x86_model_spec const * model;
static struct op_msrs cpu_msrs[NR_CPUS]; static struct op_msrs cpu_msrs[NR_CPUS];
static unsigned long saved_lvtpc[NR_CPUS]; static unsigned long saved_lvtpc[NR_CPUS];
static unsigned long kernel_only;
static int nmi_start(void); static int nmi_start(void);
static void nmi_stop(void); static void nmi_stop(void);
...@@ -53,10 +46,9 @@ static int oprofile_pm_callback(struct pm_dev * dev, ...@@ -53,10 +46,9 @@ static int oprofile_pm_callback(struct pm_dev * dev,
} }
// FIXME: kernel_only
static int nmi_callback(struct pt_regs * regs, int cpu) static int nmi_callback(struct pt_regs * regs, int cpu)
{ {
return (model->check_ctrs(cpu, &cpu_msrs[cpu], regs)); return model->check_ctrs(cpu, &cpu_msrs[cpu], regs);
} }
...@@ -210,7 +202,6 @@ static int nmi_create_files(struct super_block * sb, struct dentry * root) ...@@ -210,7 +202,6 @@ static int nmi_create_files(struct super_block * sb, struct dentry * root)
oprofilefs_create_ulong(sb, dir, "user", &counter_config[i].user); oprofilefs_create_ulong(sb, dir, "user", &counter_config[i].user);
} }
oprofilefs_create_ulong(sb, root, "kernel_only", &kernel_only);
return 0; return 0;
} }
......
...@@ -19,17 +19,17 @@ ...@@ -19,17 +19,17 @@
* objects. * objects.
*/ */
#include <linux/fs.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/timer.h> #include <linux/workqueue.h>
#include <linux/dcookies.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/dcookies.h>
#include <linux/profile.h> #include <linux/profile.h>
#include <linux/workqueue.h> #include <linux/fs.h>
#include "oprofile_stats.h"
#include "event_buffer.h" #include "event_buffer.h"
#include "cpu_buffer.h" #include "cpu_buffer.h"
#include "oprofile_stats.h" #include "buffer_sync.h"
#define DEFAULT_EXPIRE (HZ / 4) #define DEFAULT_EXPIRE (HZ / 4)
......
...@@ -19,13 +19,10 @@ ...@@ -19,13 +19,10 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/smp.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/cache.h>
#include "cpu_buffer.h" #include "cpu_buffer.h"
#include "oprof.h" #include "oprof.h"
#include "oprofile_stats.h"
struct oprofile_cpu_buffer cpu_buffer[NR_CPUS] __cacheline_aligned; struct oprofile_cpu_buffer cpu_buffer[NR_CPUS] __cacheline_aligned;
...@@ -68,6 +65,7 @@ int alloc_cpu_buffers(void) ...@@ -68,6 +65,7 @@ int alloc_cpu_buffers(void)
b->sample_received = 0; b->sample_received = 0;
b->sample_lost_locked = 0; b->sample_lost_locked = 0;
b->sample_lost_overflow = 0; b->sample_lost_overflow = 0;
b->sample_lost_task_exit = 0;
} }
return 0; return 0;
fail: fail:
...@@ -92,9 +90,6 @@ void oprofile_add_sample(unsigned long eip, unsigned long event, int cpu) ...@@ -92,9 +90,6 @@ void oprofile_add_sample(unsigned long eip, unsigned long event, int cpu)
struct oprofile_cpu_buffer * cpu_buf = &cpu_buffer[cpu]; struct oprofile_cpu_buffer * cpu_buf = &cpu_buffer[cpu];
struct task_struct * task; struct task_struct * task;
/* temporary ? */
BUG_ON(!oprofile_started);
cpu_buf->sample_received++; cpu_buf->sample_received++;
if (!spin_trylock(&cpu_buf->int_lock)) { if (!spin_trylock(&cpu_buf->int_lock)) {
......
...@@ -12,19 +12,15 @@ ...@@ -12,19 +12,15 @@
* escape value ESCAPE_CODE followed by an identifying code. * escape value ESCAPE_CODE followed by an identifying code.
*/ */
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/smp.h>
#include <linux/dcookies.h>
#include <linux/oprofile.h> #include <linux/oprofile.h>
#include <linux/sched.h>
#include <linux/dcookies.h>
#include <linux/fs.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/atomic.h>
#include "event_buffer.h"
#include "cpu_buffer.h"
#include "oprof.h" #include "oprof.h"
#include "event_buffer.h"
#include "oprofile_stats.h" #include "oprofile_stats.h"
DECLARE_MUTEX(buffer_sem); DECLARE_MUTEX(buffer_sem);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#define EVENT_BUFFER_H #define EVENT_BUFFER_H
#include <linux/types.h> #include <linux/types.h>
#include <linux/sem.h> #include <asm/semaphore.h>
int alloc_event_buffer(void); int alloc_event_buffer(void);
......
...@@ -10,12 +10,8 @@ ...@@ -10,12 +10,8 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/notifier.h>
#include <linux/profile.h>
#include <linux/oprofile.h> #include <linux/oprofile.h>
#include <asm/semaphore.h>
#include "oprof.h" #include "oprof.h"
#include "event_buffer.h" #include "event_buffer.h"
...@@ -82,11 +78,12 @@ int oprofile_start(void) ...@@ -82,11 +78,12 @@ int oprofile_start(void)
if (oprofile_started) if (oprofile_started)
goto out; goto out;
oprofile_reset_stats();
if ((err = oprofile_ops->start())) if ((err = oprofile_ops->start()))
goto out; goto out;
oprofile_started = 1; oprofile_started = 1;
oprofile_reset_stats();
out: out:
up(&start_sem); up(&start_sem);
return err; return err;
...@@ -148,6 +145,10 @@ static void __exit oprofile_exit(void) ...@@ -148,6 +145,10 @@ static void __exit oprofile_exit(void)
oprofilefs_unregister(); oprofilefs_unregister();
} }
MODULE_LICENSE("GPL");
module_init(oprofile_init); module_init(oprofile_init);
module_exit(oprofile_exit); module_exit(oprofile_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("John Levon <levon@movementarian.org>");
MODULE_DESCRIPTION("OProfile system profiler");
...@@ -10,9 +10,6 @@ ...@@ -10,9 +10,6 @@
#ifndef OPROF_H #ifndef OPROF_H
#define OPROF_H #define OPROF_H
#include <linux/spinlock.h>
#include <linux/oprofile.h>
int oprofile_setup(void); int oprofile_setup(void);
void oprofile_shutdown(void); void oprofile_shutdown(void);
...@@ -22,6 +19,8 @@ void oprofilefs_unregister(void); ...@@ -22,6 +19,8 @@ void oprofilefs_unregister(void);
int oprofile_start(void); int oprofile_start(void);
void oprofile_stop(void); void oprofile_stop(void);
struct oprofile_operations;
extern unsigned long fs_buffer_size; extern unsigned long fs_buffer_size;
extern unsigned long fs_cpu_buffer_size; extern unsigned long fs_cpu_buffer_size;
extern unsigned long fs_buffer_watershed; extern unsigned long fs_buffer_watershed;
...@@ -29,6 +28,9 @@ extern enum oprofile_cpu oprofile_cpu_type; ...@@ -29,6 +28,9 @@ extern enum oprofile_cpu oprofile_cpu_type;
extern struct oprofile_operations * oprofile_ops; extern struct oprofile_operations * oprofile_ops;
extern unsigned long oprofile_started; extern unsigned long oprofile_started;
struct super_block;
struct dentry;
void oprofile_create_files(struct super_block * sb, struct dentry * root); void oprofile_create_files(struct super_block * sb, struct dentry * root);
#endif /* OPROF_H */ #endif /* OPROF_H */
...@@ -7,26 +7,18 @@ ...@@ -7,26 +7,18 @@
* @author John Levon <levon@movementarian.org> * @author John Levon <levon@movementarian.org>
*/ */
#include <linux/oprofile.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/slab.h> #include <linux/oprofile.h>
#include <asm/uaccess.h>
#include "oprof.h"
#include "event_buffer.h" #include "event_buffer.h"
#include "oprofile_stats.h" #include "oprofile_stats.h"
#include "oprof.h"
unsigned long fs_buffer_size = 131072; unsigned long fs_buffer_size = 131072;
unsigned long fs_cpu_buffer_size = 8192; unsigned long fs_cpu_buffer_size = 8192;
unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */ unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */
static int simple_open(struct inode * inode, struct file * filp)
{
return 0;
}
static ssize_t cpu_type_read(struct file * file, char * buf, size_t count, loff_t * offset) static ssize_t cpu_type_read(struct file * file, char * buf, size_t count, loff_t * offset)
{ {
unsigned long cpu_type = oprofile_cpu_type; unsigned long cpu_type = oprofile_cpu_type;
...@@ -36,7 +28,6 @@ static ssize_t cpu_type_read(struct file * file, char * buf, size_t count, loff_ ...@@ -36,7 +28,6 @@ static ssize_t cpu_type_read(struct file * file, char * buf, size_t count, loff_
static struct file_operations cpu_type_fops = { static struct file_operations cpu_type_fops = {
.open = simple_open,
.read = cpu_type_read, .read = cpu_type_read,
}; };
...@@ -71,15 +62,26 @@ static ssize_t enable_write(struct file *file, char const * buf, size_t count, l ...@@ -71,15 +62,26 @@ static ssize_t enable_write(struct file *file, char const * buf, size_t count, l
static struct file_operations enable_fops = { static struct file_operations enable_fops = {
.open = simple_open,
.read = enable_read, .read = enable_read,
.write = enable_write, .write = enable_write,
}; };
static ssize_t dump_write(struct file *file, char const * buf, size_t count, loff_t * offset)
{
wake_up_buffer_waiter();
return count;
}
static struct file_operations dump_fops = {
.write = dump_write,
};
void oprofile_create_files(struct super_block * sb, struct dentry * root) void oprofile_create_files(struct super_block * sb, struct dentry * root)
{ {
oprofilefs_create_file(sb, root, "enable", &enable_fops); oprofilefs_create_file(sb, root, "enable", &enable_fops);
oprofilefs_create_file(sb, root, "dump", &dump_fops);
oprofilefs_create_file(sb, root, "buffer", &event_buffer_fops); oprofilefs_create_file(sb, root, "buffer", &event_buffer_fops);
oprofilefs_create_ulong(sb, root, "buffer_size", &fs_buffer_size); oprofilefs_create_ulong(sb, root, "buffer_size", &fs_buffer_size);
oprofilefs_create_ulong(sb, root, "buffer_watershed", &fs_buffer_watershed); oprofilefs_create_ulong(sb, root, "buffer_watershed", &fs_buffer_watershed);
......
...@@ -12,12 +12,9 @@ ...@@ -12,12 +12,9 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pagemap.h>
#include <linux/fs.h>
#include <linux/dcache.h>
#include <linux/file.h>
#include <linux/namei.h>
#include <linux/oprofile.h> #include <linux/oprofile.h>
#include <linux/fs.h>
#include <linux/pagemap.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "oprof.h" #include "oprof.h"
......
...@@ -55,7 +55,7 @@ int oprofile_arch_init(struct oprofile_operations ** ops, enum oprofile_cpu * cp ...@@ -55,7 +55,7 @@ int oprofile_arch_init(struct oprofile_operations ** ops, enum oprofile_cpu * cp
* Add a sample. This may be called from any context. Pass * Add a sample. This may be called from any context. Pass
* smp_processor_id() as cpu. * smp_processor_id() as cpu.
*/ */
extern void FASTCALL(oprofile_add_sample(unsigned long eip, unsigned long event, int cpu)); extern void oprofile_add_sample(unsigned long eip, unsigned long event, int cpu);
/** /**
* Create a file of the given name as a child of the given root, with * Create a file of the given name as a child of the given root, with
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment