diff options
author | Jason Yeh <jason.yeh@amd.com> | 2008-07-23 17:05:53 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-26 05:48:16 -0400 |
commit | 1a960b402a51d80abf54e3f8e4972374ffe5f22d (patch) | |
tree | 108222afe94df145e7a71f44bb077067c35f0131 /drivers/oprofile/oprofile_files.c | |
parent | 6852fd9b86d05063c6ef49d2e12e061cc7f6a105 (diff) |
Oprofile Multiplexing Patch
This patch introduces multiplexing support for the Oprofile kernel
module. It basically adds a new function pointer in oprofile_operator
allowing each architecture to supply its callback to switch between
different sets of event when the timer expires. Userspace tools can
modify the time slice through /dev/oprofile/time_slice.
It also modifies the number of counters exposed to the userspace through
/dev/oprofile. For example, the number of counters for AMD CPUs are
changed to 32 and multiplexed in the sets of 4.
Signed-off-by: Jason Yeh <jason.yeh@amd.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/oprofile/oprofile_files.c')
-rw-r--r-- | drivers/oprofile/oprofile_files.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c index ef953ba5ab6b..cc4f5a1f8ef2 100644 --- a/drivers/oprofile/oprofile_files.c +++ b/drivers/oprofile/oprofile_files.c | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
11 | #include <linux/oprofile.h> | 11 | #include <linux/oprofile.h> |
12 | #include <linux/jiffies.h> | ||
12 | 13 | ||
13 | #include "event_buffer.h" | 14 | #include "event_buffer.h" |
14 | #include "oprofile_stats.h" | 15 | #include "oprofile_stats.h" |
@@ -18,6 +19,40 @@ unsigned long fs_buffer_size = 131072; | |||
18 | unsigned long fs_cpu_buffer_size = 8192; | 19 | unsigned long fs_cpu_buffer_size = 8192; |
19 | unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */ | 20 | unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */ |
20 | 21 | ||
22 | static ssize_t timeout_read(struct file *file, char __user *buf, | ||
23 | size_t count, loff_t *offset) | ||
24 | { | ||
25 | return oprofilefs_ulong_to_user(jiffies_to_msecs(timeout_jiffies), | ||
26 | buf, count, offset); | ||
27 | } | ||
28 | |||
29 | |||
30 | static ssize_t timeout_write(struct file *file, char const __user *buf, | ||
31 | size_t count, loff_t *offset) | ||
32 | { | ||
33 | unsigned long val; | ||
34 | int retval; | ||
35 | |||
36 | if (*offset) | ||
37 | return -EINVAL; | ||
38 | |||
39 | retval = oprofilefs_ulong_from_user(&val, buf, count); | ||
40 | if (retval) | ||
41 | return retval; | ||
42 | |||
43 | retval = oprofile_set_timeout(val); | ||
44 | |||
45 | if (retval) | ||
46 | return retval; | ||
47 | return count; | ||
48 | } | ||
49 | |||
50 | static const struct file_operations timeout_fops = { | ||
51 | .read = timeout_read, | ||
52 | .write = timeout_write, | ||
53 | }; | ||
54 | |||
55 | |||
21 | static ssize_t depth_read(struct file * file, char __user * buf, size_t count, loff_t * offset) | 56 | static ssize_t depth_read(struct file * file, char __user * buf, size_t count, loff_t * offset) |
22 | { | 57 | { |
23 | return oprofilefs_ulong_to_user(backtrace_depth, buf, count, offset); | 58 | return oprofilefs_ulong_to_user(backtrace_depth, buf, count, offset); |
@@ -85,11 +120,10 @@ static ssize_t enable_write(struct file * file, char const __user * buf, size_t | |||
85 | 120 | ||
86 | if (*offset) | 121 | if (*offset) |
87 | return -EINVAL; | 122 | return -EINVAL; |
88 | |||
89 | retval = oprofilefs_ulong_from_user(&val, buf, count); | 123 | retval = oprofilefs_ulong_from_user(&val, buf, count); |
90 | if (retval) | 124 | if (retval) |
91 | return retval; | 125 | return retval; |
92 | 126 | ||
93 | if (val) | 127 | if (val) |
94 | retval = oprofile_start(); | 128 | retval = oprofile_start(); |
95 | else | 129 | else |
@@ -129,6 +163,7 @@ void oprofile_create_files(struct super_block * sb, struct dentry * root) | |||
129 | oprofilefs_create_file(sb, root, "cpu_type", &cpu_type_fops); | 163 | oprofilefs_create_file(sb, root, "cpu_type", &cpu_type_fops); |
130 | oprofilefs_create_file(sb, root, "backtrace_depth", &depth_fops); | 164 | oprofilefs_create_file(sb, root, "backtrace_depth", &depth_fops); |
131 | oprofilefs_create_file(sb, root, "pointer_size", &pointer_size_fops); | 165 | oprofilefs_create_file(sb, root, "pointer_size", &pointer_size_fops); |
166 | oprofilefs_create_file(sb, root, "timeout_ms", &timeout_fops); | ||
132 | oprofile_create_stats_files(sb, root); | 167 | oprofile_create_stats_files(sb, root); |
133 | if (oprofile_ops.create_files) | 168 | if (oprofile_ops.create_files) |
134 | oprofile_ops.create_files(sb, root); | 169 | oprofile_ops.create_files(sb, root); |