mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-10 23:20:05 +00:00
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>
This commit is contained in:
parent
5ee25c8731
commit
65af94baca
@ -148,6 +148,30 @@ static void release_bts_buffer(int cpu)
|
|||||||
ds->bts_buffer_base = 0;
|
ds->bts_buffer_base = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int alloc_ds_buffer(int cpu)
|
||||||
|
{
|
||||||
|
struct debug_store *ds;
|
||||||
|
|
||||||
|
ds = kzalloc(sizeof(*ds), GFP_KERNEL);
|
||||||
|
if (unlikely(!ds))
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
per_cpu(cpu_hw_events, cpu).ds = ds;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void release_ds_buffer(int cpu)
|
||||||
|
{
|
||||||
|
struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
|
||||||
|
|
||||||
|
if (!ds)
|
||||||
|
return;
|
||||||
|
|
||||||
|
per_cpu(cpu_hw_events, cpu).ds = NULL;
|
||||||
|
kfree(ds);
|
||||||
|
}
|
||||||
|
|
||||||
static void release_ds_buffers(void)
|
static void release_ds_buffers(void)
|
||||||
{
|
{
|
||||||
int cpu;
|
int cpu;
|
||||||
@ -160,16 +184,9 @@ static void release_ds_buffers(void)
|
|||||||
fini_debug_store_on_cpu(cpu);
|
fini_debug_store_on_cpu(cpu);
|
||||||
|
|
||||||
for_each_possible_cpu(cpu) {
|
for_each_possible_cpu(cpu) {
|
||||||
struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
|
|
||||||
|
|
||||||
if (!ds)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
release_pebs_buffer(cpu);
|
release_pebs_buffer(cpu);
|
||||||
release_bts_buffer(cpu);
|
release_bts_buffer(cpu);
|
||||||
|
release_ds_buffer(cpu);
|
||||||
per_cpu(cpu_hw_events, cpu).ds = NULL;
|
|
||||||
kfree(ds);
|
|
||||||
}
|
}
|
||||||
put_online_cpus();
|
put_online_cpus();
|
||||||
}
|
}
|
||||||
@ -184,13 +201,8 @@ static int reserve_ds_buffers(void)
|
|||||||
get_online_cpus();
|
get_online_cpus();
|
||||||
|
|
||||||
for_each_possible_cpu(cpu) {
|
for_each_possible_cpu(cpu) {
|
||||||
struct debug_store *ds;
|
if (alloc_ds_buffer(cpu))
|
||||||
|
|
||||||
err = -ENOMEM;
|
|
||||||
ds = kzalloc(sizeof(*ds), GFP_KERNEL);
|
|
||||||
if (unlikely(!ds))
|
|
||||||
break;
|
break;
|
||||||
per_cpu(cpu_hw_events, cpu).ds = ds;
|
|
||||||
|
|
||||||
if (alloc_bts_buffer(cpu))
|
if (alloc_bts_buffer(cpu))
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user