diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2010-10-19 08:37:23 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-10-22 08:18:25 -0400 |
commit | 65af94baca56beb3514d6cfce782634db9cf676d (patch) | |
tree | caeba23895f0948bfcef58ec1a27a86b1ff8d6d7 /arch/x86 | |
parent | 5ee25c87318fa3722026fd77089fa7ba0db8d447 (diff) |
perf, x86: Extract DS alloc/free functions
Again, mostly a cleanup to unclutter the reserve_ds_buffer() code.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Stephane Eranian <eranian@google.com>
LKML-Reference: <20101019134808.304495776@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/cpu/perf_event_intel_ds.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c index 14d98bd52055..3c86f4d2f02d 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_ds.c +++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c | |||
@@ -148,6 +148,30 @@ static void release_bts_buffer(int cpu) | |||
148 | ds->bts_buffer_base = 0; | 148 | ds->bts_buffer_base = 0; |
149 | } | 149 | } |
150 | 150 | ||
151 | static int alloc_ds_buffer(int cpu) | ||
152 | { | ||
153 | struct debug_store *ds; | ||
154 | |||
155 | ds = kzalloc(sizeof(*ds), GFP_KERNEL); | ||
156 | if (unlikely(!ds)) | ||
157 | return -ENOMEM; | ||
158 | |||
159 | per_cpu(cpu_hw_events, cpu).ds = ds; | ||
160 | |||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static void release_ds_buffer(int cpu) | ||
165 | { | ||
166 | struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds; | ||
167 | |||
168 | if (!ds) | ||
169 | return; | ||
170 | |||
171 | per_cpu(cpu_hw_events, cpu).ds = NULL; | ||
172 | kfree(ds); | ||
173 | } | ||
174 | |||
151 | static void release_ds_buffers(void) | 175 | static void release_ds_buffers(void) |
152 | { | 176 | { |
153 | int cpu; | 177 | int cpu; |
@@ -160,16 +184,9 @@ static void release_ds_buffers(void) | |||
160 | fini_debug_store_on_cpu(cpu); | 184 | fini_debug_store_on_cpu(cpu); |
161 | 185 | ||
162 | for_each_possible_cpu(cpu) { | 186 | for_each_possible_cpu(cpu) { |
163 | struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds; | ||
164 | |||
165 | if (!ds) | ||
166 | continue; | ||
167 | |||
168 | release_pebs_buffer(cpu); | 187 | release_pebs_buffer(cpu); |
169 | release_bts_buffer(cpu); | 188 | release_bts_buffer(cpu); |
170 | 189 | release_ds_buffer(cpu); | |
171 | per_cpu(cpu_hw_events, cpu).ds = NULL; | ||
172 | kfree(ds); | ||
173 | } | 190 | } |
174 | put_online_cpus(); | 191 | put_online_cpus(); |
175 | } | 192 | } |
@@ -184,13 +201,8 @@ static int reserve_ds_buffers(void) | |||
184 | get_online_cpus(); | 201 | get_online_cpus(); |
185 | 202 | ||
186 | for_each_possible_cpu(cpu) { | 203 | for_each_possible_cpu(cpu) { |
187 | struct debug_store *ds; | 204 | if (alloc_ds_buffer(cpu)) |
188 | |||
189 | err = -ENOMEM; | ||
190 | ds = kzalloc(sizeof(*ds), GFP_KERNEL); | ||
191 | if (unlikely(!ds)) | ||
192 | break; | 205 | break; |
193 | per_cpu(cpu_hw_events, cpu).ds = ds; | ||
194 | 206 | ||
195 | if (alloc_bts_buffer(cpu)) | 207 | if (alloc_bts_buffer(cpu)) |
196 | break; | 208 | break; |