X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Foprofile%2Foprof.c;h=b82a7b5aaa740520932ade8d84110be5495c13ea;hb=16c70f8c1b54b61c3b951b6fb220df250fe09b32;hp=76bac8dfe8a823764c273b9033cd24bb57122d9d;hpb=4e76c8a9fa413ccc09d3f7f664183dcce3555d57;p=linux-2.6.git diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c index 76bac8dfe..b82a7b5aa 100644 --- a/drivers/oprofile/oprof.c +++ b/drivers/oprofile/oprof.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include "oprof.h" #include "event_buffer.h" @@ -29,7 +29,7 @@ struct oprofile_operations oprofile_ops; unsigned long oprofile_started; unsigned long backtrace_depth; static unsigned long is_setup; -static DECLARE_MUTEX(start_sem); +static DEFINE_MUTEX(start_mutex); /* timer 0 - use performance monitoring hardware if available @@ -37,7 +37,6 @@ static DECLARE_MUTEX(start_sem); */ static int timer = 0; -#ifdef CONFIG_XEN int oprofile_set_active(int active_domains[], unsigned int adomains) { int err; @@ -45,9 +44,9 @@ int oprofile_set_active(int active_domains[], unsigned int adomains) if (!oprofile_ops.set_active) return -EINVAL; - down(&start_sem); + mutex_lock(&start_mutex); err = oprofile_ops.set_active(active_domains, adomains); - up(&start_sem); + mutex_unlock(&start_mutex); return err; } @@ -58,18 +57,17 @@ int oprofile_set_passive(int passive_domains[], unsigned int pdomains) if (!oprofile_ops.set_passive) return -EINVAL; - down(&start_sem); + mutex_lock(&start_mutex); err = oprofile_ops.set_passive(passive_domains, pdomains); - up(&start_sem); + mutex_unlock(&start_mutex); return err; } -#endif int oprofile_setup(void) { int err; - down(&start_sem); + mutex_lock(&start_mutex); if ((err = alloc_cpu_buffers())) goto out; @@ -89,7 +87,7 @@ int oprofile_setup(void) goto out3; is_setup = 1; - up(&start_sem); + mutex_unlock(&start_mutex); return 0; out3: @@ -100,7 +98,7 @@ out2: out1: free_cpu_buffers(); out: - up(&start_sem); + mutex_unlock(&start_mutex); return err; } @@ -110,7 +108,7 @@ int oprofile_start(void) { int err = -EINVAL; - down(&start_sem); + mutex_lock(&start_mutex); if (!is_setup) goto out; @@ -127,7 +125,7 @@ int oprofile_start(void) oprofile_started = 1; out: - up(&start_sem); + mutex_unlock(&start_mutex); return err; } @@ -135,7 +133,7 @@ out: /* echo 0>/dev/oprofile/enable */ void oprofile_stop(void) { - down(&start_sem); + mutex_lock(&start_mutex); if (!oprofile_started) goto out; oprofile_ops.stop(); @@ -143,20 +141,20 @@ void oprofile_stop(void) /* wake up the daemon to read what remains */ wake_up_buffer_waiter(); out: - up(&start_sem); + mutex_unlock(&start_mutex); } void oprofile_shutdown(void) { - down(&start_sem); + mutex_lock(&start_mutex); sync_stop(); if (oprofile_ops.shutdown) oprofile_ops.shutdown(); is_setup = 0; free_event_buffer(); free_cpu_buffers(); - up(&start_sem); + mutex_unlock(&start_mutex); } @@ -164,7 +162,7 @@ int oprofile_set_backtrace(unsigned long val) { int err = 0; - down(&start_sem); + mutex_lock(&start_mutex); if (oprofile_started) { err = -EBUSY; @@ -179,7 +177,7 @@ int oprofile_set_backtrace(unsigned long val) backtrace_depth = val; out: - up(&start_sem); + mutex_unlock(&start_mutex); return err; }