Re: [RFC][PATCH v8 2/3] trace,x86: add x86 irq vector tracepoints

From: Steven Rostedt
Date: Fri Feb 01 2013 - 16:03:42 EST


On Mon, 2013-01-21 at 22:14 +0000, Seiji Aguchi wrote:

> --- /dev/null
> +++ b/arch/x86/kernel/tracepoint.c
> @@ -0,0 +1,61 @@
> +/*
> + * Code for supporting irq vector tracepoints.
> + *
> + * Copyright (C) 2013 Seiji Aguchi <seiji.aguchi@xxxxxxx>
> + *
> + */
> +#include <asm/hw_irq.h>
> +#include <asm/desc.h>
> +
> +static struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
> + (unsigned long) trace_idt_table };
> +
> +#ifndef CONFIG_X86_64
> +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_data
> + = { { { { 0, 0 } } }, };
> +#endif
> +
> +static struct desc_ptr orig_idt_descr[NR_CPUS];

BTW, this should be:

static DEFINE_PER_CPU(struct desc_ptr, orig_idt_descr);

And look at the patch I made about the NMI/DEBUG trap handling to see
how to use it.

Thanks,

-- Steve

> +static int trace_irq_vector_refcount;
> +
> +static void switch_to_trace_idt(void *arg)
> +{
> + store_idt(&orig_idt_descr[smp_processor_id()]);
> + load_idt(&trace_idt_descr);
> +
> + return;
> +}
> +
> +static void restore_original_idt(void *arg)
> +{
> + if (orig_idt_descr[smp_processor_id()].address) {
> + load_idt(&orig_idt_descr[smp_processor_id()]);
> + memset(&orig_idt_descr[smp_processor_id()], 0,
> + sizeof(struct desc_ptr));
> + }
> +
> + return;
> +}
> +
> +void trace_irq_vector_regfunc(void)
> +{
> + if (!trace_irq_vector_refcount) {
> + smp_call_function(switch_to_trace_idt, NULL, 0);
> + local_irq_disable();
> + switch_to_trace_idt(NULL);
> + local_irq_enable();
> + }
> + trace_irq_vector_refcount++;
> +}
> +
> +void trace_irq_vector_unregfunc(void)
> +{
> + trace_irq_vector_refcount--;
> + if (!trace_irq_vector_refcount) {
> + smp_call_function(restore_original_idt, NULL, 0);
> + local_irq_disable();
> + restore_original_idt(NULL);
> + local_irq_enable();
> + }
> +}
> +
> diff --git a/include/xen/events.h b/include/xen/events.h
> index c6bfe01..9216d07 100644
> --- a/include/xen/events.h
> +++ b/include/xen/events.h
> @@ -76,6 +76,9 @@ unsigned irq_from_evtchn(unsigned int evtchn);
>
> /* Xen HVM evtchn vector callback */
> void xen_hvm_callback_vector(void);
> +#ifdef CONFIG_TRACING
> +#define trace_xen_hvm_callback_vector xen_hvm_callback_vector
> +#endif
> extern int xen_have_vector_callback;
> int xen_set_callback_via(uint64_t via);
> void xen_evtchn_do_upcall(struct pt_regs *regs);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/