aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/oprofile
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2006-06-25 08:47:33 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:01:04 -0400
commit59cc185ada89245204c658ebcf64422968736672 (patch)
tree042e46cfe90c2ad5b711e2791b05f73ab1fe7725 /drivers/oprofile
parenta2926b1449bcc3d348e2228114b04869dc2f3986 (diff)
[PATCH] oprofile: convert from semaphores to mutexes
Signed-off-by: Markus Armbruster <armbru@redhat.com> Cc: Philippe Elie <phil.el@wanadoo.fr> Cc: John Levon <levon@movementarian.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/oprofile')
-rw-r--r--drivers/oprofile/buffer_sync.c8
-rw-r--r--drivers/oprofile/event_buffer.c12
-rw-r--r--drivers/oprofile/event_buffer.h4
-rw-r--r--drivers/oprofile/oprof.c26
4 files changed, 25 insertions, 25 deletions
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index b2e8e49c8659..43e521e99126 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -108,10 +108,10 @@ static int module_load_notify(struct notifier_block * self, unsigned long val, v
108 return 0; 108 return 0;
109 109
110 /* FIXME: should we process all CPU buffers ? */ 110 /* FIXME: should we process all CPU buffers ? */
111 down(&buffer_sem); 111 mutex_lock(&buffer_mutex);
112 add_event_entry(ESCAPE_CODE); 112 add_event_entry(ESCAPE_CODE);
113 add_event_entry(MODULE_LOADED_CODE); 113 add_event_entry(MODULE_LOADED_CODE);
114 up(&buffer_sem); 114 mutex_unlock(&buffer_mutex);
115#endif 115#endif
116 return 0; 116 return 0;
117} 117}
@@ -501,7 +501,7 @@ void sync_buffer(int cpu)
501 sync_buffer_state state = sb_buffer_start; 501 sync_buffer_state state = sb_buffer_start;
502 unsigned long available; 502 unsigned long available;
503 503
504 down(&buffer_sem); 504 mutex_lock(&buffer_mutex);
505 505
506 add_cpu_switch(cpu); 506 add_cpu_switch(cpu);
507 507
@@ -550,5 +550,5 @@ void sync_buffer(int cpu)
550 550
551 mark_done(cpu); 551 mark_done(cpu);
552 552
553 up(&buffer_sem); 553 mutex_unlock(&buffer_mutex);
554} 554}
diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
index b80318f03420..04d641714d34 100644
--- a/drivers/oprofile/event_buffer.c
+++ b/drivers/oprofile/event_buffer.c
@@ -24,7 +24,7 @@
24#include "event_buffer.h" 24#include "event_buffer.h"
25#include "oprofile_stats.h" 25#include "oprofile_stats.h"
26 26
27DECLARE_MUTEX(buffer_sem); 27DEFINE_MUTEX(buffer_mutex);
28 28
29static unsigned long buffer_opened; 29static unsigned long buffer_opened;
30static DECLARE_WAIT_QUEUE_HEAD(buffer_wait); 30static DECLARE_WAIT_QUEUE_HEAD(buffer_wait);
@@ -32,7 +32,7 @@ static unsigned long * event_buffer;
32static unsigned long buffer_size; 32static unsigned long buffer_size;
33static unsigned long buffer_watershed; 33static unsigned long buffer_watershed;
34static size_t buffer_pos; 34static size_t buffer_pos;
35/* atomic_t because wait_event checks it outside of buffer_sem */ 35/* atomic_t because wait_event checks it outside of buffer_mutex */
36static atomic_t buffer_ready = ATOMIC_INIT(0); 36static atomic_t buffer_ready = ATOMIC_INIT(0);
37 37
38/* Add an entry to the event buffer. When we 38/* Add an entry to the event buffer. When we
@@ -60,10 +60,10 @@ void add_event_entry(unsigned long value)
60 */ 60 */
61void wake_up_buffer_waiter(void) 61void wake_up_buffer_waiter(void)
62{ 62{
63 down(&buffer_sem); 63 mutex_lock(&buffer_mutex);
64 atomic_set(&buffer_ready, 1); 64 atomic_set(&buffer_ready, 1);
65 wake_up(&buffer_wait); 65 wake_up(&buffer_wait);
66 up(&buffer_sem); 66 mutex_unlock(&buffer_mutex);
67} 67}
68 68
69 69
@@ -162,7 +162,7 @@ static ssize_t event_buffer_read(struct file * file, char __user * buf,
162 if (!atomic_read(&buffer_ready)) 162 if (!atomic_read(&buffer_ready))
163 return -EAGAIN; 163 return -EAGAIN;
164 164
165 down(&buffer_sem); 165 mutex_lock(&buffer_mutex);
166 166
167 atomic_set(&buffer_ready, 0); 167 atomic_set(&buffer_ready, 0);
168 168
@@ -177,7 +177,7 @@ static ssize_t event_buffer_read(struct file * file, char __user * buf,
177 buffer_pos = 0; 177 buffer_pos = 0;
178 178
179out: 179out:
180 up(&buffer_sem); 180 mutex_unlock(&buffer_mutex);
181 return retval; 181 return retval;
182} 182}
183 183
diff --git a/drivers/oprofile/event_buffer.h b/drivers/oprofile/event_buffer.h
index 018023630599..92416276e577 100644
--- a/drivers/oprofile/event_buffer.h
+++ b/drivers/oprofile/event_buffer.h
@@ -11,7 +11,7 @@
11#define EVENT_BUFFER_H 11#define EVENT_BUFFER_H
12 12
13#include <linux/types.h> 13#include <linux/types.h>
14#include <asm/semaphore.h> 14#include <asm/mutex.h>
15 15
16int alloc_event_buffer(void); 16int alloc_event_buffer(void);
17 17
@@ -46,6 +46,6 @@ extern struct file_operations event_buffer_fops;
46/* mutex between sync_cpu_buffers() and the 46/* mutex between sync_cpu_buffers() and the
47 * file reading code. 47 * file reading code.
48 */ 48 */
49extern struct semaphore buffer_sem; 49extern struct mutex buffer_mutex;
50 50
51#endif /* EVENT_BUFFER_H */ 51#endif /* EVENT_BUFFER_H */
diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
index b3f1cd6a24c1..e5162a64018b 100644
--- a/drivers/oprofile/oprof.c
+++ b/drivers/oprofile/oprof.c
@@ -12,7 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/oprofile.h> 13#include <linux/oprofile.h>
14#include <linux/moduleparam.h> 14#include <linux/moduleparam.h>
15#include <asm/semaphore.h> 15#include <asm/mutex.h>
16 16
17#include "oprof.h" 17#include "oprof.h"
18#include "event_buffer.h" 18#include "event_buffer.h"
@@ -25,7 +25,7 @@ struct oprofile_operations oprofile_ops;
25unsigned long oprofile_started; 25unsigned long oprofile_started;
26unsigned long backtrace_depth; 26unsigned long backtrace_depth;
27static unsigned long is_setup; 27static unsigned long is_setup;
28static DECLARE_MUTEX(start_sem); 28static DEFINE_MUTEX(start_mutex);
29 29
30/* timer 30/* timer
31 0 - use performance monitoring hardware if available 31 0 - use performance monitoring hardware if available
@@ -37,7 +37,7 @@ int oprofile_setup(void)
37{ 37{
38 int err; 38 int err;
39 39
40 down(&start_sem); 40 mutex_lock(&start_mutex);
41 41
42 if ((err = alloc_cpu_buffers())) 42 if ((err = alloc_cpu_buffers()))
43 goto out; 43 goto out;
@@ -57,7 +57,7 @@ int oprofile_setup(void)
57 goto out3; 57 goto out3;
58 58
59 is_setup = 1; 59 is_setup = 1;
60 up(&start_sem); 60 mutex_unlock(&start_mutex);
61 return 0; 61 return 0;
62 62
63out3: 63out3:
@@ -68,7 +68,7 @@ out2:
68out1: 68out1:
69 free_cpu_buffers(); 69 free_cpu_buffers();
70out: 70out:
71 up(&start_sem); 71 mutex_unlock(&start_mutex);
72 return err; 72 return err;
73} 73}
74 74
@@ -78,7 +78,7 @@ int oprofile_start(void)
78{ 78{
79 int err = -EINVAL; 79 int err = -EINVAL;
80 80
81 down(&start_sem); 81 mutex_lock(&start_mutex);
82 82
83 if (!is_setup) 83 if (!is_setup)
84 goto out; 84 goto out;
@@ -95,7 +95,7 @@ int oprofile_start(void)
95 95
96 oprofile_started = 1; 96 oprofile_started = 1;
97out: 97out:
98 up(&start_sem); 98 mutex_unlock(&start_mutex);
99 return err; 99 return err;
100} 100}
101 101
@@ -103,7 +103,7 @@ out:
103/* echo 0>/dev/oprofile/enable */ 103/* echo 0>/dev/oprofile/enable */
104void oprofile_stop(void) 104void oprofile_stop(void)
105{ 105{
106 down(&start_sem); 106 mutex_lock(&start_mutex);
107 if (!oprofile_started) 107 if (!oprofile_started)
108 goto out; 108 goto out;
109 oprofile_ops.stop(); 109 oprofile_ops.stop();
@@ -111,20 +111,20 @@ void oprofile_stop(void)
111 /* wake up the daemon to read what remains */ 111 /* wake up the daemon to read what remains */
112 wake_up_buffer_waiter(); 112 wake_up_buffer_waiter();
113out: 113out:
114 up(&start_sem); 114 mutex_unlock(&start_mutex);
115} 115}
116 116
117 117
118void oprofile_shutdown(void) 118void oprofile_shutdown(void)
119{ 119{
120 down(&start_sem); 120 mutex_lock(&start_mutex);
121 sync_stop(); 121 sync_stop();
122 if (oprofile_ops.shutdown) 122 if (oprofile_ops.shutdown)
123 oprofile_ops.shutdown(); 123 oprofile_ops.shutdown();
124 is_setup = 0; 124 is_setup = 0;
125 free_event_buffer(); 125 free_event_buffer();
126 free_cpu_buffers(); 126 free_cpu_buffers();
127 up(&start_sem); 127 mutex_unlock(&start_mutex);
128} 128}
129 129
130 130
@@ -132,7 +132,7 @@ int oprofile_set_backtrace(unsigned long val)
132{ 132{
133 int err = 0; 133 int err = 0;
134 134
135 down(&start_sem); 135 mutex_lock(&start_mutex);
136 136
137 if (oprofile_started) { 137 if (oprofile_started) {
138 err = -EBUSY; 138 err = -EBUSY;
@@ -147,7 +147,7 @@ int oprofile_set_backtrace(unsigned long val)
147 backtrace_depth = val; 147 backtrace_depth = val;
148 148
149out: 149out:
150 up(&start_sem); 150 mutex_unlock(&start_mutex);
151 return err; 151 return err;
152} 152}
153 153