* @remark Read the file COPYING
*
* @author John Levon <levon@movementarian.org>
+ *
+ * Modified by Aravind Menon for Xen
+ * These modifications are:
+ * Copyright (C) 2005 Hewlett-Packard Co.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/oprofile.h>
#include <linux/moduleparam.h>
-#include <asm/semaphore.h>
+#include <asm/mutex.h>
#include "oprof.h"
#include "event_buffer.h"
#include "cpu_buffer.h"
#include "buffer_sync.h"
#include "oprofile_stats.h"
-
+
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
*/
static int timer = 0;
+int oprofile_set_active(int active_domains[], unsigned int adomains)
+{
+ int err;
+
+ if (!oprofile_ops.set_active)
+ return -EINVAL;
+
+ mutex_lock(&start_mutex);
+ err = oprofile_ops.set_active(active_domains, adomains);
+ mutex_unlock(&start_mutex);
+ return err;
+}
+
+int oprofile_set_passive(int passive_domains[], unsigned int pdomains)
+{
+ int err;
+
+ if (!oprofile_ops.set_passive)
+ return -EINVAL;
+
+ mutex_lock(&start_mutex);
+ err = oprofile_ops.set_passive(passive_domains, pdomains);
+ mutex_unlock(&start_mutex);
+ return err;
+}
+
int oprofile_setup(void)
{
int err;
- down(&start_sem);
+ mutex_lock(&start_mutex);
if ((err = alloc_cpu_buffers()))
goto out;
goto out3;
is_setup = 1;
- up(&start_sem);
+ mutex_unlock(&start_mutex);
return 0;
out3:
out1:
free_cpu_buffers();
out:
- up(&start_sem);
+ mutex_unlock(&start_mutex);
return err;
}
{
int err = -EINVAL;
- down(&start_sem);
+ mutex_lock(&start_mutex);
if (!is_setup)
goto out;
oprofile_started = 1;
out:
- up(&start_sem);
+ mutex_unlock(&start_mutex);
return err;
}
/* echo 0>/dev/oprofile/enable */
void oprofile_stop(void)
{
- down(&start_sem);
+ mutex_lock(&start_mutex);
if (!oprofile_started)
goto out;
oprofile_ops.stop();
/* 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);
}
{
int err = 0;
- down(&start_sem);
+ mutex_lock(&start_mutex);
if (oprofile_started) {
err = -EBUSY;
backtrace_depth = val;
out:
- up(&start_sem);
+ mutex_unlock(&start_mutex);
return err;
}