diff options
author | Jason Yeh <jason.yeh@amd.com> | 2009-07-08 07:49:38 -0400 |
---|---|---|
committer | Robert Richter <robert.richter@amd.com> | 2009-07-20 10:33:53 -0400 |
commit | 4d4036e0e7299c6cbb2d2421b4b30b7a409ce61a (patch) | |
tree | c9003cd927ed878412e89a59db0138b6b701b629 /drivers/oprofile/oprofile_files.c | |
parent | 6e63ea4b0b14ff5fb8a3ca704fcda7d28b95f079 (diff) |
oprofile: Implement performance counter multiplexing
The number of hardware counters is limited. The multiplexing feature
enables OProfile to gather more events than counters are provided by
the hardware. This is realized by switching between events at an user
specified time interval.
A new file (/dev/oprofile/time_slice) is added for the user to specify
the timer interval in ms. If the number of events to profile is higher
than the number of hardware counters available, the patch will
schedule a work queue that switches the event counter and re-writes
the different sets of values into it. The switching mechanism needs to
be implemented for each architecture to support multiplexing. This
patch only implements AMD CPU support, but multiplexing can be easily
extended for other models and architectures.
There are follow-on patches that rework parts of this patch.
Signed-off-by: Jason Yeh <jason.yeh@amd.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Diffstat (limited to 'drivers/oprofile/oprofile_files.c')
-rw-r--r-- | drivers/oprofile/oprofile_files.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c index 5d36ffc30dd5..468ec3e4f856 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" |
@@ -22,6 +23,45 @@ unsigned long oprofile_buffer_size; | |||
22 | unsigned long oprofile_cpu_buffer_size; | 23 | unsigned long oprofile_cpu_buffer_size; |
23 | unsigned long oprofile_buffer_watershed; | 24 | unsigned long oprofile_buffer_watershed; |
24 | 25 | ||
26 | #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX | ||
27 | |||
28 | static ssize_t timeout_read(struct file *file, char __user *buf, | ||
29 | size_t count, loff_t *offset) | ||
30 | { | ||
31 | return oprofilefs_ulong_to_user(jiffies_to_msecs(timeout_jiffies), | ||
32 | buf, count, offset); | ||
33 | } | ||
34 | |||
35 | |||
36 | static ssize_t timeout_write(struct file *file, char const __user *buf, | ||
37 | size_t count, loff_t *offset) | ||
38 | { | ||
39 | unsigned long val; | ||
40 | int retval; | ||
41 | |||
42 | if (*offset) | ||
43 | return -EINVAL; | ||
44 | |||
45 | retval = oprofilefs_ulong_from_user(&val, buf, count); | ||
46 | if (retval) | ||
47 | return retval; | ||
48 | |||
49 | retval = oprofile_set_timeout(val); | ||
50 | |||
51 | if (retval) | ||
52 | return retval; | ||
53 | return count; | ||
54 | } | ||
55 | |||
56 | |||
57 | static const struct file_operations timeout_fops = { | ||
58 | .read = timeout_read, | ||
59 | .write = timeout_write, | ||
60 | }; | ||
61 | |||
62 | #endif | ||
63 | |||
64 | |||
25 | static ssize_t depth_read(struct file *file, char __user *buf, size_t count, loff_t *offset) | 65 | static ssize_t depth_read(struct file *file, char __user *buf, size_t count, loff_t *offset) |
26 | { | 66 | { |
27 | return oprofilefs_ulong_to_user(oprofile_backtrace_depth, buf, count, | 67 | return oprofilefs_ulong_to_user(oprofile_backtrace_depth, buf, count, |
@@ -139,6 +179,9 @@ void oprofile_create_files(struct super_block *sb, struct dentry *root) | |||
139 | oprofilefs_create_file(sb, root, "cpu_type", &cpu_type_fops); | 179 | oprofilefs_create_file(sb, root, "cpu_type", &cpu_type_fops); |
140 | oprofilefs_create_file(sb, root, "backtrace_depth", &depth_fops); | 180 | oprofilefs_create_file(sb, root, "backtrace_depth", &depth_fops); |
141 | oprofilefs_create_file(sb, root, "pointer_size", &pointer_size_fops); | 181 | oprofilefs_create_file(sb, root, "pointer_size", &pointer_size_fops); |
182 | #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX | ||
183 | oprofilefs_create_file(sb, root, "time_slice", &timeout_fops); | ||
184 | #endif | ||
142 | oprofile_create_stats_files(sb, root); | 185 | oprofile_create_stats_files(sb, root); |
143 | if (oprofile_ops.create_files) | 186 | if (oprofile_ops.create_files) |
144 | oprofile_ops.create_files(sb, root); | 187 | oprofile_ops.create_files(sb, root); |