diff options
Diffstat (limited to 'drivers/oprofile/oprofile_files.c')
-rw-r--r-- | drivers/oprofile/oprofile_files.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c index 5d36ffc30dd5..bbd7516e0869 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" |
@@ -17,10 +18,51 @@ | |||
17 | #define BUFFER_SIZE_DEFAULT 131072 | 18 | #define BUFFER_SIZE_DEFAULT 131072 |
18 | #define CPU_BUFFER_SIZE_DEFAULT 8192 | 19 | #define CPU_BUFFER_SIZE_DEFAULT 8192 |
19 | #define BUFFER_WATERSHED_DEFAULT 32768 /* FIXME: tune */ | 20 | #define BUFFER_WATERSHED_DEFAULT 32768 /* FIXME: tune */ |
21 | #define TIME_SLICE_DEFAULT 1 | ||
20 | 22 | ||
21 | unsigned long oprofile_buffer_size; | 23 | unsigned long oprofile_buffer_size; |
22 | unsigned long oprofile_cpu_buffer_size; | 24 | unsigned long oprofile_cpu_buffer_size; |
23 | unsigned long oprofile_buffer_watershed; | 25 | unsigned long oprofile_buffer_watershed; |
26 | unsigned long oprofile_time_slice; | ||
27 | |||
28 | #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX | ||
29 | |||
30 | static ssize_t timeout_read(struct file *file, char __user *buf, | ||
31 | size_t count, loff_t *offset) | ||
32 | { | ||
33 | return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice), | ||
34 | buf, count, offset); | ||
35 | } | ||
36 | |||
37 | |||
38 | static ssize_t timeout_write(struct file *file, char const __user *buf, | ||
39 | size_t count, loff_t *offset) | ||
40 | { | ||
41 | unsigned long val; | ||
42 | int retval; | ||
43 | |||
44 | if (*offset) | ||
45 | return -EINVAL; | ||
46 | |||
47 | retval = oprofilefs_ulong_from_user(&val, buf, count); | ||
48 | if (retval) | ||
49 | return retval; | ||
50 | |||
51 | retval = oprofile_set_timeout(val); | ||
52 | |||
53 | if (retval) | ||
54 | return retval; | ||
55 | return count; | ||
56 | } | ||
57 | |||
58 | |||
59 | static const struct file_operations timeout_fops = { | ||
60 | .read = timeout_read, | ||
61 | .write = timeout_write, | ||
62 | }; | ||
63 | |||
64 | #endif | ||
65 | |||
24 | 66 | ||
25 | static ssize_t depth_read(struct file *file, char __user *buf, size_t count, loff_t *offset) | 67 | static ssize_t depth_read(struct file *file, char __user *buf, size_t count, loff_t *offset) |
26 | { | 68 | { |
@@ -129,6 +171,7 @@ void oprofile_create_files(struct super_block *sb, struct dentry *root) | |||
129 | oprofile_buffer_size = BUFFER_SIZE_DEFAULT; | 171 | oprofile_buffer_size = BUFFER_SIZE_DEFAULT; |
130 | oprofile_cpu_buffer_size = CPU_BUFFER_SIZE_DEFAULT; | 172 | oprofile_cpu_buffer_size = CPU_BUFFER_SIZE_DEFAULT; |
131 | oprofile_buffer_watershed = BUFFER_WATERSHED_DEFAULT; | 173 | oprofile_buffer_watershed = BUFFER_WATERSHED_DEFAULT; |
174 | oprofile_time_slice = msecs_to_jiffies(TIME_SLICE_DEFAULT); | ||
132 | 175 | ||
133 | oprofilefs_create_file(sb, root, "enable", &enable_fops); | 176 | oprofilefs_create_file(sb, root, "enable", &enable_fops); |
134 | oprofilefs_create_file_perm(sb, root, "dump", &dump_fops, 0666); | 177 | oprofilefs_create_file_perm(sb, root, "dump", &dump_fops, 0666); |
@@ -139,6 +182,9 @@ void oprofile_create_files(struct super_block *sb, struct dentry *root) | |||
139 | oprofilefs_create_file(sb, root, "cpu_type", &cpu_type_fops); | 182 | oprofilefs_create_file(sb, root, "cpu_type", &cpu_type_fops); |
140 | oprofilefs_create_file(sb, root, "backtrace_depth", &depth_fops); | 183 | oprofilefs_create_file(sb, root, "backtrace_depth", &depth_fops); |
141 | oprofilefs_create_file(sb, root, "pointer_size", &pointer_size_fops); | 184 | oprofilefs_create_file(sb, root, "pointer_size", &pointer_size_fops); |
185 | #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX | ||
186 | oprofilefs_create_file(sb, root, "time_slice", &timeout_fops); | ||
187 | #endif | ||
142 | oprofile_create_stats_files(sb, root); | 188 | oprofile_create_stats_files(sb, root); |
143 | if (oprofile_ops.create_files) | 189 | if (oprofile_ops.create_files) |
144 | oprofile_ops.create_files(sb, root); | 190 | oprofile_ops.create_files(sb, root); |