x86, bts: add _noirq variants to the debug store interface
PATCH 7/21 x86, bts: add _noirq variants to the debug store interface
The hw-branch-tracer uses debug store functions from an on_each_cpu() context, which is simply wrong since the functions may sleep.
Add _noirq variants for most functions that may be called with interrupts disabled.
Separate per-cpu and per-task tracing and allow per-cpu tracing to be controlled from any cpu.
---
arch/x86/include/asm/ds.h +45 -12
@@ -15,8 +15,8 @@* - buffer allocation (memory accounting) * * -* Copyright (C) 2007-2008 Intel Corporation. -* Markus Metzger <[email protected]>, 2007-2008 +* Copyright (C) 2007-2009 Intel Corporation. +* Markus Metzger <[email protected]>, 2007-2009 */ #ifndef _ASM_X86_DS_H
@@ -83,8 +83,10 @@ enum ds_feature {* The interrupt threshold is independent from the overflow callback * to allow users to use their own overflow interrupt handling mechanism. * -* task: the task to request recording for; -* NULL for per-cpu recording on the current cpu +* The function might sleep. +* +* task: the task to request recording for +* cpu: the cpu to request recording for * base: the base pointer for the (non-pageable) buffer; * size: the size of the provided buffer in bytes * ovfl: pointer to a function to be called on buffer overflow;
@@ -93,19 +95,28 @@ enum ds_feature {* -1 if no interrupt threshold is requested. * flags: a bit-mask of the above flags */ -extern struct bts_tracer *ds_request_bts (struct task_struct *task, -void *base,size_t size, -bts_ovfl_callback_t ovfl, -size_t th,unsigned int flags); -extern struct pebs_tracer *ds_request_pebs (struct task_struct *task, -void *base,size_t size, -pebs_ovfl_callback_t ovfl, -size_t th,unsigned int flags); +extern struct bts_tracer *ds_request_bts_task (struct task_struct *task, +void *base,size_t size, +bts_ovfl_callback_t ovfl, +size_t th,unsigned int flags); +extern struct bts_tracer *ds_request_bts_cpu (int cpu,void *base,size_t size, +bts_ovfl_callback_t ovfl, +size_t th,unsigned int flags); +extern struct pebs_tracer *ds_request_pebs_task (struct task_struct *task, +void *base,size_t size, +pebs_ovfl_callback_t ovfl, +size_t th,unsigned int flags); +extern struct pebs_tracer *ds_request_pebs_cpu (int cpu, +void *base,size_t size, +pebs_ovfl_callback_t ovfl, +size_t th,unsigned int flags);/* * Release BTS or PEBS resources * Suspend and resume BTS or PEBS tracing * +* Must be called with irq's enabled. +* * tracer: the tracer handle returned from ds_request_~() */ extern void ds_release_bts (struct bts_tracer *tracer);
@@ -115,6 +126,28 @@ extern void ds_release_pebs(struct pebs_extern void ds_suspend_pebs (struct pebs_tracer *tracer);extern void ds_resume_pebs (struct pebs_tracer *tracer); +/* +* Release BTS or PEBS resources +* Suspend and resume BTS or PEBS tracing +* +* Cpu tracers must call this on the traced cpu. +* Task tracers must call ds_release_~_noirq() for themselves. +* +* May be called with irq's disabled. +* +* Returns 0 if successful; +* -EPERM if the cpu tracer does not trace the current cpu. +* -EPERM if the task tracer does not trace itself. +* +* tracer: the tracer handle returned from ds_request_~() +*/ +extern int ds_release_bts_noirq (struct bts_tracer *tracer); +extern int ds_suspend_bts_noirq (struct bts_tracer *tracer); +extern int ds_resume_bts_noirq (struct bts_tracer *tracer); +extern int ds_release_pebs_noirq (struct pebs_tracer *tracer); +extern int ds_suspend_pebs_noirq (struct pebs_tracer *tracer); +extern int ds_resume_pebs_noirq (struct pebs_tracer *tracer); +/* * The raw DS buffer state as it is used for BTS and PEBS recording.
arch/x86/kernel/ds.c +339 -84
650 lines not on this page · raw message
---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.