diff options
author | Heinz Graalfs <graalfs@linux.vnet.ibm.com> | 2011-02-15 13:02:14 -0500 |
---|---|---|
committer | Robert Richter <robert.richter@amd.com> | 2011-03-16 09:05:35 -0400 |
commit | c814d160f61466ea6d4491bb4e8e548856e27a58 (patch) | |
tree | 8cae1f71911a09a61dfdd40a9e346dbc6fcd46ab /arch/s390 | |
parent | 7bb2e269aefe4539313922ab4a89367cd52a51d1 (diff) |
oprofile, s390: Remove hwsampler_files.c and merge it into init.c
Merge the contents of hwsampler_files.c into
arch/s390/oprofile/init.c.
Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/oprofile/Makefile | 2 | ||||
-rw-r--r-- | arch/s390/oprofile/hwsampler_files.c | 162 | ||||
-rw-r--r-- | arch/s390/oprofile/init.c | 161 |
3 files changed, 159 insertions, 166 deletions
diff --git a/arch/s390/oprofile/Makefile b/arch/s390/oprofile/Makefile index 00d8fc8e4429..d698cddcfbdd 100644 --- a/arch/s390/oprofile/Makefile +++ b/arch/s390/oprofile/Makefile | |||
@@ -6,4 +6,4 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ | |||
6 | oprofilefs.o oprofile_stats.o \ | 6 | oprofilefs.o oprofile_stats.o \ |
7 | timer_int.o ) | 7 | timer_int.o ) |
8 | 8 | ||
9 | oprofile-y := $(DRIVER_OBJS) init.o backtrace.o hwsampler.o hwsampler_files.o | 9 | oprofile-y := $(DRIVER_OBJS) init.o backtrace.o hwsampler.o |
diff --git a/arch/s390/oprofile/hwsampler_files.c b/arch/s390/oprofile/hwsampler_files.c deleted file mode 100644 index 2e1da2449ba9..000000000000 --- a/arch/s390/oprofile/hwsampler_files.c +++ /dev/null | |||
@@ -1,162 +0,0 @@ | |||
1 | /** | ||
2 | * arch/s390/oprofile/hwsampler_files.c | ||
3 | * | ||
4 | * Copyright IBM Corp. 2010 | ||
5 | * Author: Mahesh Salgaonkar (mahesh@linux.vnet.ibm.com) | ||
6 | */ | ||
7 | #include <linux/oprofile.h> | ||
8 | #include <linux/errno.h> | ||
9 | #include <linux/fs.h> | ||
10 | |||
11 | #include "../../../drivers/oprofile/oprof.h" | ||
12 | #include "hwsampler.h" | ||
13 | |||
14 | #define DEFAULT_INTERVAL 4096 | ||
15 | |||
16 | #define DEFAULT_SDBT_BLOCKS 1 | ||
17 | #define DEFAULT_SDB_BLOCKS 511 | ||
18 | |||
19 | static unsigned long oprofile_hw_interval = DEFAULT_INTERVAL; | ||
20 | static unsigned long oprofile_min_interval; | ||
21 | static unsigned long oprofile_max_interval; | ||
22 | |||
23 | static unsigned long oprofile_sdbt_blocks = DEFAULT_SDBT_BLOCKS; | ||
24 | static unsigned long oprofile_sdb_blocks = DEFAULT_SDB_BLOCKS; | ||
25 | |||
26 | static int hwsampler_file; | ||
27 | static int hwsampler_running; /* start_mutex must be held to change */ | ||
28 | |||
29 | static struct oprofile_operations timer_ops; | ||
30 | |||
31 | static int oprofile_hwsampler_start(void) | ||
32 | { | ||
33 | int retval; | ||
34 | |||
35 | hwsampler_running = hwsampler_file; | ||
36 | |||
37 | if (!hwsampler_running) | ||
38 | return timer_ops.start(); | ||
39 | |||
40 | retval = hwsampler_allocate(oprofile_sdbt_blocks, oprofile_sdb_blocks); | ||
41 | if (retval) | ||
42 | return retval; | ||
43 | |||
44 | retval = hwsampler_start_all(oprofile_hw_interval); | ||
45 | if (retval) | ||
46 | hwsampler_deallocate(); | ||
47 | |||
48 | return retval; | ||
49 | } | ||
50 | |||
51 | static void oprofile_hwsampler_stop(void) | ||
52 | { | ||
53 | if (!hwsampler_running) { | ||
54 | timer_ops.stop(); | ||
55 | return; | ||
56 | } | ||
57 | |||
58 | hwsampler_stop_all(); | ||
59 | hwsampler_deallocate(); | ||
60 | return; | ||
61 | } | ||
62 | |||
63 | static ssize_t hwsampler_read(struct file *file, char __user *buf, | ||
64 | size_t count, loff_t *offset) | ||
65 | { | ||
66 | return oprofilefs_ulong_to_user(hwsampler_file, buf, count, offset); | ||
67 | } | ||
68 | |||
69 | static ssize_t hwsampler_write(struct file *file, char const __user *buf, | ||
70 | size_t count, loff_t *offset) | ||
71 | { | ||
72 | unsigned long val; | ||
73 | int retval; | ||
74 | |||
75 | if (*offset) | ||
76 | return -EINVAL; | ||
77 | |||
78 | retval = oprofilefs_ulong_from_user(&val, buf, count); | ||
79 | if (retval) | ||
80 | return retval; | ||
81 | |||
82 | if (oprofile_started) | ||
83 | /* | ||
84 | * save to do without locking as we set | ||
85 | * hwsampler_running in start() when start_mutex is | ||
86 | * held | ||
87 | */ | ||
88 | return -EBUSY; | ||
89 | |||
90 | hwsampler_file = val; | ||
91 | |||
92 | return count; | ||
93 | } | ||
94 | |||
95 | static const struct file_operations hwsampler_fops = { | ||
96 | .read = hwsampler_read, | ||
97 | .write = hwsampler_write, | ||
98 | }; | ||
99 | |||
100 | static int oprofile_create_hwsampling_files(struct super_block *sb, | ||
101 | struct dentry *root) | ||
102 | { | ||
103 | struct dentry *hw_dir; | ||
104 | |||
105 | /* reinitialize default values */ | ||
106 | hwsampler_file = 1; | ||
107 | |||
108 | hw_dir = oprofilefs_mkdir(sb, root, "hwsampling"); | ||
109 | if (!hw_dir) | ||
110 | return -EINVAL; | ||
111 | |||
112 | oprofilefs_create_file(sb, hw_dir, "hwsampler", &hwsampler_fops); | ||
113 | oprofilefs_create_ulong(sb, hw_dir, "hw_interval", | ||
114 | &oprofile_hw_interval); | ||
115 | oprofilefs_create_ro_ulong(sb, hw_dir, "hw_min_interval", | ||
116 | &oprofile_min_interval); | ||
117 | oprofilefs_create_ro_ulong(sb, hw_dir, "hw_max_interval", | ||
118 | &oprofile_max_interval); | ||
119 | oprofilefs_create_ulong(sb, hw_dir, "hw_sdbt_blocks", | ||
120 | &oprofile_sdbt_blocks); | ||
121 | |||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | int oprofile_hwsampler_init(struct oprofile_operations* ops) | ||
126 | { | ||
127 | if (hwsampler_setup()) | ||
128 | return -ENODEV; | ||
129 | |||
130 | /* | ||
131 | * create hwsampler files only if hwsampler_setup() succeeds. | ||
132 | */ | ||
133 | oprofile_min_interval = hwsampler_query_min_interval(); | ||
134 | if (oprofile_min_interval < 0) { | ||
135 | oprofile_min_interval = 0; | ||
136 | return -ENODEV; | ||
137 | } | ||
138 | oprofile_max_interval = hwsampler_query_max_interval(); | ||
139 | if (oprofile_max_interval < 0) { | ||
140 | oprofile_max_interval = 0; | ||
141 | return -ENODEV; | ||
142 | } | ||
143 | |||
144 | if (oprofile_timer_init(ops)) | ||
145 | return -ENODEV; | ||
146 | |||
147 | printk(KERN_INFO "oprofile: using hardware sampling\n"); | ||
148 | |||
149 | memcpy(&timer_ops, ops, sizeof(timer_ops)); | ||
150 | |||
151 | ops->start = oprofile_hwsampler_start; | ||
152 | ops->stop = oprofile_hwsampler_stop; | ||
153 | ops->create_files = oprofile_create_hwsampling_files; | ||
154 | |||
155 | return 0; | ||
156 | } | ||
157 | |||
158 | void oprofile_hwsampler_exit(void) | ||
159 | { | ||
160 | oprofile_timer_exit(); | ||
161 | hwsampler_shutdown(); | ||
162 | } | ||
diff --git a/arch/s390/oprofile/init.c b/arch/s390/oprofile/init.c index 059b44b9f171..0e38a5b8793f 100644 --- a/arch/s390/oprofile/init.c +++ b/arch/s390/oprofile/init.c | |||
@@ -4,19 +4,174 @@ | |||
4 | * S390 Version | 4 | * S390 Version |
5 | * Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation | 5 | * Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation |
6 | * Author(s): Thomas Spatzier (tspat@de.ibm.com) | 6 | * Author(s): Thomas Spatzier (tspat@de.ibm.com) |
7 | * Author(s): Mahesh Salgaonkar (mahesh@linux.vnet.ibm.com) | ||
8 | * Author(s): Heinz Graalfs (graalfs@linux.vnet.ibm.com) | ||
7 | * | 9 | * |
8 | * @remark Copyright 2002 OProfile authors | 10 | * @remark Copyright 2002-2011 OProfile authors |
9 | */ | 11 | */ |
10 | 12 | ||
11 | #include <linux/oprofile.h> | 13 | #include <linux/oprofile.h> |
12 | #include <linux/init.h> | 14 | #include <linux/init.h> |
13 | #include <linux/errno.h> | 15 | #include <linux/errno.h> |
16 | #include <linux/oprofile.h> | ||
17 | #include <linux/errno.h> | ||
18 | #include <linux/fs.h> | ||
19 | |||
20 | #include "../../../drivers/oprofile/oprof.h" | ||
21 | #include "hwsampler.h" | ||
22 | |||
23 | #define DEFAULT_INTERVAL 4096 | ||
24 | |||
25 | #define DEFAULT_SDBT_BLOCKS 1 | ||
26 | #define DEFAULT_SDB_BLOCKS 511 | ||
27 | |||
28 | static unsigned long oprofile_hw_interval = DEFAULT_INTERVAL; | ||
29 | static unsigned long oprofile_min_interval; | ||
30 | static unsigned long oprofile_max_interval; | ||
31 | |||
32 | static unsigned long oprofile_sdbt_blocks = DEFAULT_SDBT_BLOCKS; | ||
33 | static unsigned long oprofile_sdb_blocks = DEFAULT_SDB_BLOCKS; | ||
14 | 34 | ||
15 | extern int oprofile_hwsampler_init(struct oprofile_operations* ops); | 35 | static int hwsampler_file; |
16 | extern void oprofile_hwsampler_exit(void); | 36 | static int hwsampler_running; /* start_mutex must be held to change */ |
37 | |||
38 | static struct oprofile_operations timer_ops; | ||
17 | 39 | ||
18 | extern void s390_backtrace(struct pt_regs * const regs, unsigned int depth); | 40 | extern void s390_backtrace(struct pt_regs * const regs, unsigned int depth); |
19 | 41 | ||
42 | static int oprofile_hwsampler_start(void) | ||
43 | { | ||
44 | int retval; | ||
45 | |||
46 | hwsampler_running = hwsampler_file; | ||
47 | |||
48 | if (!hwsampler_running) | ||
49 | return timer_ops.start(); | ||
50 | |||
51 | retval = hwsampler_allocate(oprofile_sdbt_blocks, oprofile_sdb_blocks); | ||
52 | if (retval) | ||
53 | return retval; | ||
54 | |||
55 | retval = hwsampler_start_all(oprofile_hw_interval); | ||
56 | if (retval) | ||
57 | hwsampler_deallocate(); | ||
58 | |||
59 | return retval; | ||
60 | } | ||
61 | |||
62 | static void oprofile_hwsampler_stop(void) | ||
63 | { | ||
64 | if (!hwsampler_running) { | ||
65 | timer_ops.stop(); | ||
66 | return; | ||
67 | } | ||
68 | |||
69 | hwsampler_stop_all(); | ||
70 | hwsampler_deallocate(); | ||
71 | return; | ||
72 | } | ||
73 | |||
74 | static ssize_t hwsampler_read(struct file *file, char __user *buf, | ||
75 | size_t count, loff_t *offset) | ||
76 | { | ||
77 | return oprofilefs_ulong_to_user(hwsampler_file, buf, count, offset); | ||
78 | } | ||
79 | |||
80 | static ssize_t hwsampler_write(struct file *file, char const __user *buf, | ||
81 | size_t count, loff_t *offset) | ||
82 | { | ||
83 | unsigned long val; | ||
84 | int retval; | ||
85 | |||
86 | if (*offset) | ||
87 | return -EINVAL; | ||
88 | |||
89 | retval = oprofilefs_ulong_from_user(&val, buf, count); | ||
90 | if (retval) | ||
91 | return retval; | ||
92 | |||
93 | if (oprofile_started) | ||
94 | /* | ||
95 | * save to do without locking as we set | ||
96 | * hwsampler_running in start() when start_mutex is | ||
97 | * held | ||
98 | */ | ||
99 | return -EBUSY; | ||
100 | |||
101 | hwsampler_file = val; | ||
102 | |||
103 | return count; | ||
104 | } | ||
105 | |||
106 | static const struct file_operations hwsampler_fops = { | ||
107 | .read = hwsampler_read, | ||
108 | .write = hwsampler_write, | ||
109 | }; | ||
110 | |||
111 | static int oprofile_create_hwsampling_files(struct super_block *sb, | ||
112 | struct dentry *root) | ||
113 | { | ||
114 | struct dentry *hw_dir; | ||
115 | |||
116 | /* reinitialize default values */ | ||
117 | hwsampler_file = 1; | ||
118 | |||
119 | hw_dir = oprofilefs_mkdir(sb, root, "hwsampling"); | ||
120 | if (!hw_dir) | ||
121 | return -EINVAL; | ||
122 | |||
123 | oprofilefs_create_file(sb, hw_dir, "hwsampler", &hwsampler_fops); | ||
124 | oprofilefs_create_ulong(sb, hw_dir, "hw_interval", | ||
125 | &oprofile_hw_interval); | ||
126 | oprofilefs_create_ro_ulong(sb, hw_dir, "hw_min_interval", | ||
127 | &oprofile_min_interval); | ||
128 | oprofilefs_create_ro_ulong(sb, hw_dir, "hw_max_interval", | ||
129 | &oprofile_max_interval); | ||
130 | oprofilefs_create_ulong(sb, hw_dir, "hw_sdbt_blocks", | ||
131 | &oprofile_sdbt_blocks); | ||
132 | |||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | int oprofile_hwsampler_init(struct oprofile_operations* ops) | ||
137 | { | ||
138 | if (hwsampler_setup()) | ||
139 | return -ENODEV; | ||
140 | |||
141 | /* | ||
142 | * create hwsampler files only if hwsampler_setup() succeeds. | ||
143 | */ | ||
144 | oprofile_min_interval = hwsampler_query_min_interval(); | ||
145 | if (oprofile_min_interval < 0) { | ||
146 | oprofile_min_interval = 0; | ||
147 | return -ENODEV; | ||
148 | } | ||
149 | oprofile_max_interval = hwsampler_query_max_interval(); | ||
150 | if (oprofile_max_interval < 0) { | ||
151 | oprofile_max_interval = 0; | ||
152 | return -ENODEV; | ||
153 | } | ||
154 | |||
155 | if (oprofile_timer_init(ops)) | ||
156 | return -ENODEV; | ||
157 | |||
158 | printk(KERN_INFO "oprofile: using hardware sampling\n"); | ||
159 | |||
160 | memcpy(&timer_ops, ops, sizeof(timer_ops)); | ||
161 | |||
162 | ops->start = oprofile_hwsampler_start; | ||
163 | ops->stop = oprofile_hwsampler_stop; | ||
164 | ops->create_files = oprofile_create_hwsampling_files; | ||
165 | |||
166 | return 0; | ||
167 | } | ||
168 | |||
169 | void oprofile_hwsampler_exit(void) | ||
170 | { | ||
171 | oprofile_timer_exit(); | ||
172 | hwsampler_shutdown(); | ||
173 | } | ||
174 | |||
20 | int __init oprofile_arch_init(struct oprofile_operations* ops) | 175 | int __init oprofile_arch_init(struct oprofile_operations* ops) |
21 | { | 176 | { |
22 | ops->backtrace = s390_backtrace; | 177 | ops->backtrace = s390_backtrace; |