2 * @file oprofile_files.c
4 * @remark Copyright 2002 OProfile authors
5 * @remark Read the file COPYING
7 * @author John Levon <levon@movementarian.org>
11 #include <linux/oprofile.h>
13 #include "event_buffer.h"
14 #include "oprofile_stats.h"
17 unsigned long fs_buffer_size
= 131072;
18 unsigned long fs_cpu_buffer_size
= 8192;
19 unsigned long fs_buffer_watershed
= 32768; /* FIXME: tune */
22 static ssize_t
pointer_size_read(struct file
* file
, char __user
* buf
, size_t count
, loff_t
* offset
)
24 return oprofilefs_ulong_to_user(sizeof(void *), buf
, count
, offset
);
28 static struct file_operations pointer_size_fops
= {
29 .read
= pointer_size_read
,
33 static ssize_t
cpu_type_read(struct file
* file
, char __user
* buf
, size_t count
, loff_t
* offset
)
35 return oprofilefs_str_to_user(oprofile_ops
->cpu_type
, buf
, count
, offset
);
39 static struct file_operations cpu_type_fops
= {
40 .read
= cpu_type_read
,
44 static ssize_t
enable_read(struct file
* file
, char __user
* buf
, size_t count
, loff_t
* offset
)
46 return oprofilefs_ulong_to_user(oprofile_started
, buf
, count
, offset
);
50 static ssize_t
enable_write(struct file
*file
, char const __user
* buf
, size_t count
, loff_t
* offset
)
58 retval
= oprofilefs_ulong_from_user(&val
, buf
, count
);
63 retval
= oprofile_start();
73 static struct file_operations enable_fops
= {
75 .write
= enable_write
,
79 static ssize_t
dump_write(struct file
*file
, char const __user
* buf
, size_t count
, loff_t
* offset
)
81 wake_up_buffer_waiter();
86 static struct file_operations dump_fops
= {
90 void oprofile_create_files(struct super_block
* sb
, struct dentry
* root
)
92 oprofilefs_create_file(sb
, root
, "enable", &enable_fops
);
93 oprofilefs_create_file_perm(sb
, root
, "dump", &dump_fops
, 0666);
94 oprofilefs_create_file(sb
, root
, "buffer", &event_buffer_fops
);
95 oprofilefs_create_ulong(sb
, root
, "buffer_size", &fs_buffer_size
);
96 oprofilefs_create_ulong(sb
, root
, "buffer_watershed", &fs_buffer_watershed
);
97 oprofilefs_create_ulong(sb
, root
, "cpu_buffer_size", &fs_cpu_buffer_size
);
98 oprofilefs_create_file(sb
, root
, "cpu_type", &cpu_type_fops
);
99 oprofilefs_create_file(sb
, root
, "pointer_size", &pointer_size_fops
);
100 oprofile_create_stats_files(sb
, root
);
101 if (oprofile_ops
->create_files
)
102 oprofile_ops
->create_files(sb
, root
);