x86, ds: add _noirq variants for ds_ functions
Subsystems (3)
PATCH 6/14 x86, ds: add _noirq variants for ds_ functions
Add functions to the Debug Store interface that may be called (with some restrictions) with irq's disabled.
Undo the GFP_ATOMIC changes from an earlier patch. Memory is allocated using GFP_KERNEL.
Split ds_request into _cpu and _task variants. Change all users to use the correct ds_request variant.
Allow the non-_noirq variants to be called from different cpus for cpu tracing.
Remove the unnecessary lock in the hw-branch-tracer. Use get/put_online_cpus() to synchronize with hotplug cpu events.
---
arch/x86/include/asm/ds.h +48 -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 may 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,31 @@ 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 or ensure +* that tracing is inactive before calling ds_release_~_noirq(). +* +* 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 and tracing has not +* been suspended. +* +* 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 +347 -102
684 lines not on this page · raw message
kernel/trace/trace_hw_branches.c +63 -118
284 lines not on this page · raw message
arch/x86/kernel/ptrace.c +3 -3
@@ -708,9 +708,9 @@ static int ptrace_bts_config(struct taskif (cfg.flags &PTRACE_BTS_O_SCHED ) flags |=BTS_TIMESTAMPS ; - child->bts =ds_request_bts (child, child->bts_buffer, child->bts_size, -/* ovfl = */ NULL ,/* th = */ (size_t )-1 , - flags); + child->bts =ds_request_bts_task (child, child->bts_buffer, + child->bts_size, +NULL , (size_t )-1 , flags);if (IS_ERR (child->bts)) {int error =PTR_ERR (child->bts);
arch/x86/kernel/ds_selftest.c +4 -2
@@ -10,6 +10,7 @@#include <linux/kernel.h> #include <linux/string.h> +#include <linux/smp.h> #include <asm/ds.h>
@@ -129,8 +130,9 @@ int ds_selftest_bts(void)printk (KERN_INFO "[ds] bts selftest..." ); - tracer =ds_request_bts (NULL , buffer,DS_SELFTEST_BUFFER_SIZE , -NULL , (size_t )-1 ,BTS_KERNEL ); + tracer =ds_request_bts_cpu (smp_processor_id (), buffer, +DS_SELFTEST_BUFFER_SIZE ,NULL , (size_t )-1 , +BTS_KERNEL );if (IS_ERR (tracer)) { error =PTR_ERR (tracer); tracer =NULL ;
---------------------------------------------------------------------
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.