diff options
| author | Ingo Molnar <mingo@elte.hu> | 2010-10-16 14:17:25 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2010-10-16 14:17:25 -0400 |
| commit | f92f6e6ee35d2779aa62e70f78ad8e1cd417eb52 (patch) | |
| tree | 1e8e2ee34678a43d416c4bab58f9ca91673d4444 /drivers | |
| parent | 66af86e2c630908b21cec018cb612576cf5f516e (diff) | |
| parent | cd254f295248c98b62ea824f361e10d80a081fe7 (diff) | |
Merge branch 'core' of git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile into perf/core
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/oprofile/oprof.c | 32 | ||||
| -rw-r--r-- | drivers/oprofile/oprof.h | 2 | ||||
| -rw-r--r-- | drivers/oprofile/oprofile_files.c | 7 | ||||
| -rw-r--r-- | drivers/oprofile/oprofile_perf.c | 328 | ||||
| -rw-r--r-- | drivers/oprofile/oprofilefs.c | 54 |
5 files changed, 362 insertions, 61 deletions
diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c index b336cd9ee7a1..f9bda64fcd1b 100644 --- a/drivers/oprofile/oprof.c +++ b/drivers/oprofile/oprof.c | |||
| @@ -225,26 +225,17 @@ post_sync: | |||
| 225 | mutex_unlock(&start_mutex); | 225 | mutex_unlock(&start_mutex); |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | int oprofile_set_backtrace(unsigned long val) | 228 | int oprofile_set_ulong(unsigned long *addr, unsigned long val) |
| 229 | { | 229 | { |
| 230 | int err = 0; | 230 | int err = -EBUSY; |
| 231 | 231 | ||
| 232 | mutex_lock(&start_mutex); | 232 | mutex_lock(&start_mutex); |
| 233 | 233 | if (!oprofile_started) { | |
| 234 | if (oprofile_started) { | 234 | *addr = val; |
| 235 | err = -EBUSY; | 235 | err = 0; |
| 236 | goto out; | ||
| 237 | } | ||
| 238 | |||
| 239 | if (!oprofile_ops.backtrace) { | ||
| 240 | err = -EINVAL; | ||
| 241 | goto out; | ||
| 242 | } | 236 | } |
| 243 | |||
| 244 | oprofile_backtrace_depth = val; | ||
| 245 | |||
| 246 | out: | ||
| 247 | mutex_unlock(&start_mutex); | 237 | mutex_unlock(&start_mutex); |
| 238 | |||
| 248 | return err; | 239 | return err; |
| 249 | } | 240 | } |
| 250 | 241 | ||
| @@ -257,16 +248,9 @@ static int __init oprofile_init(void) | |||
| 257 | printk(KERN_INFO "oprofile: using timer interrupt.\n"); | 248 | printk(KERN_INFO "oprofile: using timer interrupt.\n"); |
| 258 | err = oprofile_timer_init(&oprofile_ops); | 249 | err = oprofile_timer_init(&oprofile_ops); |
| 259 | if (err) | 250 | if (err) |
| 260 | goto out_arch; | 251 | return err; |
| 261 | } | 252 | } |
| 262 | err = oprofilefs_register(); | 253 | return oprofilefs_register(); |
| 263 | if (err) | ||
| 264 | goto out_arch; | ||
| 265 | return 0; | ||
| 266 | |||
| 267 | out_arch: | ||
| 268 | oprofile_arch_exit(); | ||
| 269 | return err; | ||
| 270 | } | 254 | } |
| 271 | 255 | ||
| 272 | 256 | ||
diff --git a/drivers/oprofile/oprof.h b/drivers/oprofile/oprof.h index 47e12cb4ee8b..177b73de5e5f 100644 --- a/drivers/oprofile/oprof.h +++ b/drivers/oprofile/oprof.h | |||
| @@ -37,7 +37,7 @@ void oprofile_create_files(struct super_block *sb, struct dentry *root); | |||
| 37 | int oprofile_timer_init(struct oprofile_operations *ops); | 37 | int oprofile_timer_init(struct oprofile_operations *ops); |
| 38 | void oprofile_timer_exit(void); | 38 | void oprofile_timer_exit(void); |
| 39 | 39 | ||
| 40 | int oprofile_set_backtrace(unsigned long depth); | 40 | int oprofile_set_ulong(unsigned long *addr, unsigned long val); |
| 41 | int oprofile_set_timeout(unsigned long time); | 41 | int oprofile_set_timeout(unsigned long time); |
| 42 | 42 | ||
| 43 | #endif /* OPROF_H */ | 43 | #endif /* OPROF_H */ |
diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c index bbd7516e0869..ccf099e684a4 100644 --- a/drivers/oprofile/oprofile_files.c +++ b/drivers/oprofile/oprofile_files.c | |||
| @@ -79,14 +79,17 @@ static ssize_t depth_write(struct file *file, char const __user *buf, size_t cou | |||
| 79 | if (*offset) | 79 | if (*offset) |
| 80 | return -EINVAL; | 80 | return -EINVAL; |
| 81 | 81 | ||
| 82 | if (!oprofile_ops.backtrace) | ||
| 83 | return -EINVAL; | ||
| 84 | |||
| 82 | retval = oprofilefs_ulong_from_user(&val, buf, count); | 85 | retval = oprofilefs_ulong_from_user(&val, buf, count); |
| 83 | if (retval) | 86 | if (retval) |
| 84 | return retval; | 87 | return retval; |
| 85 | 88 | ||
| 86 | retval = oprofile_set_backtrace(val); | 89 | retval = oprofile_set_ulong(&oprofile_backtrace_depth, val); |
| 87 | |||
| 88 | if (retval) | 90 | if (retval) |
| 89 | return retval; | 91 | return retval; |
| 92 | |||
| 90 | return count; | 93 | return count; |
| 91 | } | 94 | } |
| 92 | 95 | ||
diff --git a/drivers/oprofile/oprofile_perf.c b/drivers/oprofile/oprofile_perf.c new file mode 100644 index 000000000000..9046f7b2ed79 --- /dev/null +++ b/drivers/oprofile/oprofile_perf.c | |||
| @@ -0,0 +1,328 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2010 ARM Ltd. | ||
| 3 | * | ||
| 4 | * Perf-events backend for OProfile. | ||
| 5 | */ | ||
| 6 | #include <linux/perf_event.h> | ||
| 7 | #include <linux/platform_device.h> | ||
| 8 | #include <linux/oprofile.h> | ||
| 9 | #include <linux/slab.h> | ||
| 10 | |||
| 11 | /* | ||
| 12 | * Per performance monitor configuration as set via oprofilefs. | ||
| 13 | */ | ||
| 14 | struct op_counter_config { | ||
| 15 | unsigned long count; | ||
| 16 | unsigned long enabled; | ||
| 17 | unsigned long event; | ||
| 18 | unsigned long unit_mask; | ||
| 19 | unsigned long kernel; | ||
| 20 | unsigned long user; | ||
| 21 | struct perf_event_attr attr; | ||
| 22 | }; | ||
| 23 | |||
| 24 | static int oprofile_perf_enabled; | ||
| 25 | static DEFINE_MUTEX(oprofile_perf_mutex); | ||
| 26 | |||
| 27 | static struct op_counter_config *counter_config; | ||
| 28 | static struct perf_event **perf_events[nr_cpumask_bits]; | ||
| 29 | static int num_counters; | ||
| 30 | |||
| 31 | /* | ||
| 32 | * Overflow callback for oprofile. | ||
| 33 | */ | ||
| 34 | static void op_overflow_handler(struct perf_event *event, int unused, | ||
| 35 | struct perf_sample_data *data, struct pt_regs *regs) | ||
| 36 | { | ||
| 37 | int id; | ||
| 38 | u32 cpu = smp_processor_id(); | ||
| 39 | |||
| 40 | for (id = 0; id < num_counters; ++id) | ||
| 41 | if (perf_events[cpu][id] == event) | ||
| 42 | break; | ||
| 43 | |||
| 44 | if (id != num_counters) | ||
| 45 | oprofile_add_sample(regs, id); | ||
| 46 | else | ||
| 47 | pr_warning("oprofile: ignoring spurious overflow " | ||
| 48 | "on cpu %u\n", cpu); | ||
| 49 | } | ||
| 50 | |||
| 51 | /* | ||
| 52 | * Called by oprofile_perf_setup to create perf attributes to mirror the oprofile | ||
| 53 | * settings in counter_config. Attributes are created as `pinned' events and | ||
| 54 | * so are permanently scheduled on the PMU. | ||
| 55 | */ | ||
| 56 | static void op_perf_setup(void) | ||
| 57 | { | ||
| 58 | int i; | ||
| 59 | u32 size = sizeof(struct perf_event_attr); | ||
| 60 | struct perf_event_attr *attr; | ||
| 61 | |||
| 62 | for (i = 0; i < num_counters; ++i) { | ||
| 63 | attr = &counter_config[i].attr; | ||
| 64 | memset(attr, 0, size); | ||
| 65 | attr->type = PERF_TYPE_RAW; | ||
| 66 | attr->size = size; | ||
| 67 | attr->config = counter_config[i].event; | ||
| 68 | attr->sample_period = counter_config[i].count; | ||
| 69 | attr->pinned = 1; | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | static int op_create_counter(int cpu, int event) | ||
| 74 | { | ||
| 75 | struct perf_event *pevent; | ||
| 76 | |||
| 77 | if (!counter_config[event].enabled || perf_events[cpu][event]) | ||
| 78 | return 0; | ||
| 79 | |||
| 80 | pevent = perf_event_create_kernel_counter(&counter_config[event].attr, | ||
| 81 | cpu, NULL, | ||
| 82 | op_overflow_handler); | ||
| 83 | |||
| 84 | if (IS_ERR(pevent)) | ||
| 85 | return PTR_ERR(pevent); | ||
| 86 | |||
| 87 | if (pevent->state != PERF_EVENT_STATE_ACTIVE) { | ||
| 88 | perf_event_release_kernel(pevent); | ||
| 89 | pr_warning("oprofile: failed to enable event %d " | ||
| 90 | "on CPU %d\n", event, cpu); | ||
| 91 | return -EBUSY; | ||
| 92 | } | ||
| 93 | |||
| 94 | perf_events[cpu][event] = pevent; | ||
| 95 | |||
| 96 | return 0; | ||
| 97 | } | ||
| 98 | |||
| 99 | static void op_destroy_counter(int cpu, int event) | ||
| 100 | { | ||
| 101 | struct perf_event *pevent = perf_events[cpu][event]; | ||
| 102 | |||
| 103 | if (pevent) { | ||
| 104 | perf_event_release_kernel(pevent); | ||
| 105 | perf_events[cpu][event] = NULL; | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | /* | ||
| 110 | * Called by oprofile_perf_start to create active perf events based on the | ||
| 111 | * perviously configured attributes. | ||
| 112 | */ | ||
| 113 | static int op_perf_start(void) | ||
| 114 | { | ||
| 115 | int cpu, event, ret = 0; | ||
| 116 | |||
| 117 | for_each_online_cpu(cpu) { | ||
| 118 | for (event = 0; event < num_counters; ++event) { | ||
| 119 | ret = op_create_counter(cpu, event); | ||
| 120 | if (ret) | ||
| 121 | return ret; | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 125 | return ret; | ||
| 126 | } | ||
| 127 | |||
| 128 | /* | ||
| 129 | * Called by oprofile_perf_stop at the end of a profiling run. | ||
| 130 | */ | ||
| 131 | static void op_perf_stop(void) | ||
| 132 | { | ||
| 133 | int cpu, event; | ||
| 134 | |||
| 135 | for_each_online_cpu(cpu) | ||
| 136 | for (event = 0; event < num_counters; ++event) | ||
| 137 | op_destroy_counter(cpu, event); | ||
| 138 | } | ||
| 139 | |||
| 140 | static int oprofile_perf_create_files(struct super_block *sb, struct dentry *root) | ||
| 141 | { | ||
| 142 | unsigned int i; | ||
| 143 | |||
| 144 | for (i = 0; i < num_counters; i++) { | ||
| 145 | struct dentry *dir; | ||
| 146 | char buf[4]; | ||
| 147 | |||
| 148 | snprintf(buf, sizeof buf, "%d", i); | ||
| 149 | dir = oprofilefs_mkdir(sb, root, buf); | ||
| 150 | oprofilefs_create_ulong(sb, dir, "enabled", &counter_config[i].enabled); | ||
| 151 | oprofilefs_create_ulong(sb, dir, "event", &counter_config[i].event); | ||
| 152 | oprofilefs_create_ulong(sb, dir, "count", &counter_config[i].count); | ||
| 153 | oprofilefs_create_ulong(sb, dir, "unit_mask", &counter_config[i].unit_mask); | ||
| 154 | oprofilefs_create_ulong(sb, dir, "kernel", &counter_config[i].kernel); | ||
| 155 | oprofilefs_create_ulong(sb, dir, "user", &counter_config[i].user); | ||
| 156 | } | ||
| 157 | |||
| 158 | return 0; | ||
| 159 | } | ||
| 160 | |||
| 161 | static int oprofile_perf_setup(void) | ||
| 162 | { | ||
| 163 | spin_lock(&oprofilefs_lock); | ||
| 164 | op_perf_setup(); | ||
| 165 | spin_unlock(&oprofilefs_lock); | ||
| 166 | return 0; | ||
| 167 | } | ||
| 168 | |||
| 169 | static int oprofile_perf_start(void) | ||
| 170 | { | ||
| 171 | int ret = -EBUSY; | ||
| 172 | |||
| 173 | mutex_lock(&oprofile_perf_mutex); | ||
| 174 | if (!oprofile_perf_enabled) { | ||
| 175 | ret = 0; | ||
| 176 | op_perf_start(); | ||
| 177 | oprofile_perf_enabled = 1; | ||
| 178 | } | ||
| 179 | mutex_unlock(&oprofile_perf_mutex); | ||
| 180 | return ret; | ||
| 181 | } | ||
| 182 | |||
| 183 | static void oprofile_perf_stop(void) | ||
| 184 | { | ||
| 185 | mutex_lock(&oprofile_perf_mutex); | ||
| 186 | if (oprofile_perf_enabled) | ||
| 187 | op_perf_stop(); | ||
| 188 | oprofile_perf_enabled = 0; | ||
| 189 | mutex_unlock(&oprofile_perf_mutex); | ||
| 190 | } | ||
| 191 | |||
| 192 | #ifdef CONFIG_PM | ||
| 193 | |||
| 194 | static int oprofile_perf_suspend(struct platform_device *dev, pm_message_t state) | ||
| 195 | { | ||
| 196 | mutex_lock(&oprofile_perf_mutex); | ||
| 197 | if (oprofile_perf_enabled) | ||
| 198 | op_perf_stop(); | ||
| 199 | mutex_unlock(&oprofile_perf_mutex); | ||
| 200 | return 0; | ||
| 201 | } | ||
| 202 | |||
| 203 | static int oprofile_perf_resume(struct platform_device *dev) | ||
| 204 | { | ||
| 205 | mutex_lock(&oprofile_perf_mutex); | ||
| 206 | if (oprofile_perf_enabled && op_perf_start()) | ||
| 207 | oprofile_perf_enabled = 0; | ||
| 208 | mutex_unlock(&oprofile_perf_mutex); | ||
| 209 | return 0; | ||
| 210 | } | ||
| 211 | |||
| 212 | static struct platform_driver oprofile_driver = { | ||
| 213 | .driver = { | ||
| 214 | .name = "oprofile-perf", | ||
| 215 | }, | ||
| 216 | .resume = oprofile_perf_resume, | ||
| 217 | .suspend = oprofile_perf_suspend, | ||
| 218 | }; | ||
| 219 | |||
| 220 | static struct platform_device *oprofile_pdev; | ||
| 221 | |||
| 222 | static int __init init_driverfs(void) | ||
| 223 | { | ||
| 224 | int ret; | ||
| 225 | |||
| 226 | ret = platform_driver_register(&oprofile_driver); | ||
| 227 | if (ret) | ||
| 228 | return ret; | ||
| 229 | |||
| 230 | oprofile_pdev = platform_device_register_simple( | ||
| 231 | oprofile_driver.driver.name, 0, NULL, 0); | ||
| 232 | if (IS_ERR(oprofile_pdev)) { | ||
| 233 | ret = PTR_ERR(oprofile_pdev); | ||
| 234 | platform_driver_unregister(&oprofile_driver); | ||
| 235 | } | ||
| 236 | |||
| 237 | return ret; | ||
| 238 | } | ||
| 239 | |||
| 240 | static void exit_driverfs(void) | ||
| 241 | { | ||
| 242 | platform_device_unregister(oprofile_pdev); | ||
| 243 | platform_driver_unregister(&oprofile_driver); | ||
| 244 | } | ||
| 245 | |||
| 246 | #else | ||
| 247 | |||
| 248 | static inline int init_driverfs(void) { return 0; } | ||
| 249 | static inline void exit_driverfs(void) { } | ||
| 250 | |||
| 251 | #endif /* CONFIG_PM */ | ||
| 252 | |||
| 253 | void oprofile_perf_exit(void) | ||
| 254 | { | ||
| 255 | int cpu, id; | ||
| 256 | struct perf_event *event; | ||
| 257 | |||
| 258 | for_each_possible_cpu(cpu) { | ||
| 259 | for (id = 0; id < num_counters; ++id) { | ||
| 260 | event = perf_events[cpu][id]; | ||
| 261 | if (event) | ||
| 262 | perf_event_release_kernel(event); | ||
| 263 | } | ||
| 264 | |||
| 265 | kfree(perf_events[cpu]); | ||
| 266 | } | ||
| 267 | |||
| 268 | kfree(counter_config); | ||
| 269 | exit_driverfs(); | ||
| 270 | } | ||
| 271 | |||
| 272 | int __init oprofile_perf_init(struct oprofile_operations *ops) | ||
| 273 | { | ||
| 274 | int cpu, ret = 0; | ||
| 275 | |||
| 276 | ret = init_driverfs(); | ||
| 277 | if (ret) | ||
| 278 | return ret; | ||
| 279 | |||
| 280 | memset(&perf_events, 0, sizeof(perf_events)); | ||
| 281 | |||
| 282 | num_counters = perf_num_counters(); | ||
| 283 | if (num_counters <= 0) { | ||
| 284 | pr_info("oprofile: no performance counters\n"); | ||
| 285 | ret = -ENODEV; | ||
| 286 | goto out; | ||
| 287 | } | ||
| 288 | |||
| 289 | counter_config = kcalloc(num_counters, | ||
| 290 | sizeof(struct op_counter_config), GFP_KERNEL); | ||
| 291 | |||
| 292 | if (!counter_config) { | ||
| 293 | pr_info("oprofile: failed to allocate %d " | ||
| 294 | "counters\n", num_counters); | ||
| 295 | ret = -ENOMEM; | ||
| 296 | num_counters = 0; | ||
| 297 | goto out; | ||
| 298 | } | ||
| 299 | |||
| 300 | for_each_possible_cpu(cpu) { | ||
| 301 | perf_events[cpu] = kcalloc(num_counters, | ||
| 302 | sizeof(struct perf_event *), GFP_KERNEL); | ||
| 303 | if (!perf_events[cpu]) { | ||
| 304 | pr_info("oprofile: failed to allocate %d perf events " | ||
| 305 | "for cpu %d\n", num_counters, cpu); | ||
| 306 | ret = -ENOMEM; | ||
| 307 | goto out; | ||
| 308 | } | ||
| 309 | } | ||
| 310 | |||
| 311 | ops->create_files = oprofile_perf_create_files; | ||
| 312 | ops->setup = oprofile_perf_setup; | ||
| 313 | ops->start = oprofile_perf_start; | ||
| 314 | ops->stop = oprofile_perf_stop; | ||
| 315 | ops->shutdown = oprofile_perf_stop; | ||
| 316 | ops->cpu_type = op_name_from_perf_id(); | ||
| 317 | |||
| 318 | if (!ops->cpu_type) | ||
| 319 | ret = -ENODEV; | ||
| 320 | else | ||
| 321 | pr_info("oprofile: using %s\n", ops->cpu_type); | ||
| 322 | |||
| 323 | out: | ||
| 324 | if (ret) | ||
| 325 | oprofile_perf_exit(); | ||
| 326 | |||
| 327 | return ret; | ||
| 328 | } | ||
diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c index 2766a6d3c2e9..1944621930d9 100644 --- a/drivers/oprofile/oprofilefs.c +++ b/drivers/oprofile/oprofilefs.c | |||
| @@ -91,16 +91,20 @@ static ssize_t ulong_read_file(struct file *file, char __user *buf, size_t count | |||
| 91 | 91 | ||
| 92 | static ssize_t ulong_write_file(struct file *file, char const __user *buf, size_t count, loff_t *offset) | 92 | static ssize_t ulong_write_file(struct file *file, char const __user *buf, size_t count, loff_t *offset) |
| 93 | { | 93 | { |
| 94 | unsigned long *value = file->private_data; | 94 | unsigned long value; |
| 95 | int retval; | 95 | int retval; |
| 96 | 96 | ||
| 97 | if (*offset) | 97 | if (*offset) |
| 98 | return -EINVAL; | 98 | return -EINVAL; |
| 99 | 99 | ||
| 100 | retval = oprofilefs_ulong_from_user(value, buf, count); | 100 | retval = oprofilefs_ulong_from_user(&value, buf, count); |
| 101 | if (retval) | ||
| 102 | return retval; | ||
| 101 | 103 | ||
| 104 | retval = oprofile_set_ulong(file->private_data, value); | ||
| 102 | if (retval) | 105 | if (retval) |
| 103 | return retval; | 106 | return retval; |
| 107 | |||
| 104 | return count; | 108 | return count; |
| 105 | } | 109 | } |
| 106 | 110 | ||
| @@ -126,50 +130,41 @@ static const struct file_operations ulong_ro_fops = { | |||
| 126 | }; | 130 | }; |
| 127 | 131 | ||
| 128 | 132 | ||
| 129 | static struct dentry *__oprofilefs_create_file(struct super_block *sb, | 133 | static int __oprofilefs_create_file(struct super_block *sb, |
| 130 | struct dentry *root, char const *name, const struct file_operations *fops, | 134 | struct dentry *root, char const *name, const struct file_operations *fops, |
| 131 | int perm) | 135 | int perm, void *priv) |
| 132 | { | 136 | { |
| 133 | struct dentry *dentry; | 137 | struct dentry *dentry; |
| 134 | struct inode *inode; | 138 | struct inode *inode; |
| 135 | 139 | ||
| 136 | dentry = d_alloc_name(root, name); | 140 | dentry = d_alloc_name(root, name); |
| 137 | if (!dentry) | 141 | if (!dentry) |
| 138 | return NULL; | 142 | return -ENOMEM; |
| 139 | inode = oprofilefs_get_inode(sb, S_IFREG | perm); | 143 | inode = oprofilefs_get_inode(sb, S_IFREG | perm); |
| 140 | if (!inode) { | 144 | if (!inode) { |
| 141 | dput(dentry); | 145 | dput(dentry); |
| 142 | return NULL; | 146 | return -ENOMEM; |
| 143 | } | 147 | } |
| 144 | inode->i_fop = fops; | 148 | inode->i_fop = fops; |
| 145 | d_add(dentry, inode); | 149 | d_add(dentry, inode); |
| 146 | return dentry; | 150 | dentry->d_inode->i_private = priv; |
| 151 | return 0; | ||
| 147 | } | 152 | } |
| 148 | 153 | ||
| 149 | 154 | ||
| 150 | int oprofilefs_create_ulong(struct super_block *sb, struct dentry *root, | 155 | int oprofilefs_create_ulong(struct super_block *sb, struct dentry *root, |
| 151 | char const *name, unsigned long *val) | 156 | char const *name, unsigned long *val) |
| 152 | { | 157 | { |
| 153 | struct dentry *d = __oprofilefs_create_file(sb, root, name, | 158 | return __oprofilefs_create_file(sb, root, name, |
| 154 | &ulong_fops, 0644); | 159 | &ulong_fops, 0644, val); |
| 155 | if (!d) | ||
| 156 | return -EFAULT; | ||
| 157 | |||
| 158 | d->d_inode->i_private = val; | ||
| 159 | return 0; | ||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | 162 | ||
| 163 | int oprofilefs_create_ro_ulong(struct super_block *sb, struct dentry *root, | 163 | int oprofilefs_create_ro_ulong(struct super_block *sb, struct dentry *root, |
| 164 | char const *name, unsigned long *val) | 164 | char const *name, unsigned long *val) |
| 165 | { | 165 | { |
| 166 | struct dentry *d = __oprofilefs_create_file(sb, root, name, | 166 | return __oprofilefs_create_file(sb, root, name, |
| 167 | &ulong_ro_fops, 0444); | 167 | &ulong_ro_fops, 0444, val); |
| 168 | if (!d) | ||
| 169 | return -EFAULT; | ||
| 170 | |||
| 171 | d->d_inode->i_private = val; | ||
| 172 | return 0; | ||
| 173 | } | 168 | } |
| 174 | 169 | ||
| 175 | 170 | ||
| @@ -189,31 +184,22 @@ static const struct file_operations atomic_ro_fops = { | |||
| 189 | int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root, | 184 | int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root, |
| 190 | char const *name, atomic_t *val) | 185 | char const *name, atomic_t *val) |
| 191 | { | 186 | { |
| 192 | struct dentry *d = __oprofilefs_create_file(sb, root, name, | 187 | return __oprofilefs_create_file(sb, root, name, |
| 193 | &atomic_ro_fops, 0444); | 188 | &atomic_ro_fops, 0444, val); |
| 194 | if (!d) | ||
| 195 | return -EFAULT; | ||
| 196 | |||
| 197 | d->d_inode->i_private = val; | ||
| 198 | return 0; | ||
| 199 | } | 189 | } |
| 200 | 190 | ||
| 201 | 191 | ||
| 202 | int oprofilefs_create_file(struct super_block *sb, struct dentry *root, | 192 | int oprofilefs_create_file(struct super_block *sb, struct dentry *root, |
| 203 | char const *name, const struct file_operations *fops) | 193 | char const *name, const struct file_operations *fops) |
| 204 | { | 194 | { |
| 205 | if (!__oprofilefs_create_file(sb, root, name, fops, 0644)) | 195 | return __oprofilefs_create_file(sb, root, name, fops, 0644, NULL); |
| 206 | return -EFAULT; | ||
| 207 | return 0; | ||
| 208 | } | 196 | } |
| 209 | 197 | ||
| 210 | 198 | ||
| 211 | int oprofilefs_create_file_perm(struct super_block *sb, struct dentry *root, | 199 | int oprofilefs_create_file_perm(struct super_block *sb, struct dentry *root, |
| 212 | char const *name, const struct file_operations *fops, int perm) | 200 | char const *name, const struct file_operations *fops, int perm) |
| 213 | { | 201 | { |
| 214 | if (!__oprofilefs_create_file(sb, root, name, fops, perm)) | 202 | return __oprofilefs_create_file(sb, root, name, fops, perm, NULL); |
| 215 | return -EFAULT; | ||
| 216 | return 0; | ||
| 217 | } | 203 | } |
| 218 | 204 | ||
| 219 | 205 | ||
