Commit 27c14ce8 authored by John Levon's avatar John Levon Committed by Linus Torvalds

[PATCH] OProfile update

Clear up the code around  start_sem so it's more obvious, and remove a pointless
down/up pair on buffer_sem (shutdown is already synchronised in sync_stop()).
parent 72e8f923
...@@ -28,6 +28,8 @@ int oprofile_setup(void) ...@@ -28,6 +28,8 @@ int oprofile_setup(void)
{ {
int err; int err;
down(&start_sem);
if ((err = alloc_cpu_buffers())) if ((err = alloc_cpu_buffers()))
goto out; goto out;
...@@ -45,7 +47,6 @@ int oprofile_setup(void) ...@@ -45,7 +47,6 @@ int oprofile_setup(void)
if ((err = sync_start())) if ((err = sync_start()))
goto out3; goto out3;
down(&start_sem);
is_setup = 1; is_setup = 1;
up(&start_sem); up(&start_sem);
return 0; return 0;
...@@ -58,6 +59,7 @@ int oprofile_setup(void) ...@@ -58,6 +59,7 @@ int oprofile_setup(void)
out1: out1:
free_cpu_buffers(); free_cpu_buffers();
out: out:
up(&start_sem);
return err; return err;
} }
...@@ -106,16 +108,14 @@ void oprofile_stop(void) ...@@ -106,16 +108,14 @@ void oprofile_stop(void)
void oprofile_shutdown(void) void oprofile_shutdown(void)
{ {
down(&start_sem);
sync_stop(); sync_stop();
if (oprofile_ops->shutdown) if (oprofile_ops->shutdown)
oprofile_ops->shutdown(); oprofile_ops->shutdown();
/* down() is also necessary to synchronise all pending events
* before freeing */
down(&buffer_sem);
is_setup = 0; is_setup = 0;
up(&buffer_sem);
free_event_buffer(); free_event_buffer();
free_cpu_buffers(); free_cpu_buffers();
up(&start_sem);
} }
......
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