RE: [RFC][PATCH v5]trace,x86: add x86 irq vector tracepoints

2012-10-25 Thread Seiji Aguchi
Peter,

I made a patch below making a time penalty zero when not being traced in 
accordance with your comment.
But I'm not sure if it is reasonable to non-tracepoint users.

I agree that a tracepoint should be designed to minimize its impact for 
non-tracepoint users.
But duplicating a function call by using macro makes a code readablity worse.
It has a big impact for all users although a time penalty is zero.

As compared the time penalty to the code readability, I think it is reasonable 
for all users to just add a tracepoint 
to an existing function call because ,as Steven said, a tracepoint is just nops 
when not being traced.

Seiji

> -Original Message-
> From: Seiji Aguchi
> Sent: Thursday, October 18, 2012 2:41 PM
> To: 'H. Peter Anvin'
> Cc: 'Thomas Gleixner (t...@linutronix.de)'; 'linux-kernel@vger.kernel.org'; 
> ''mi...@elte.hu' (mi...@elte.hu)'; 'x...@kernel.org'; 'dle-
> deve...@lists.sourceforge.net'; Satoru Moriya; 'Borislav Petkov'; 
> rost...@goodmis.org
> Subject: RE: [RFC][PATCH v5]trace,x86: add x86 irq vector tracepoints
> 
> Any comment?
> 
> Seiji
> 
> > -Original Message-
> > From: Seiji Aguchi
> > Sent: Thursday, October 11, 2012 1:25 PM
> > To: 'H. Peter Anvin'; 'Steven Rostedt'
> > Cc: 'Thomas Gleixner (t...@linutronix.de)';
> > 'linux-kernel@vger.kernel.org'; ''mi...@elte.hu' (mi...@elte.hu)'; 
> > 'x...@kernel.org'; 'dle- deve...@lists.sourceforge.net'; Satoru
> Moriya; 'Borislav Petkov'
> > Subject: [RFC][PATCH v5]trace,x86: add x86 irq vector tracepoints
> >
> > Change log
> >
> >  v4 -> v5
> >  - Rebased to 3.6.0
> >
> >  - Introduce a logic switching IDT at enabling/disabling TP time
> >so that a time penalty makes a zero when tracepoints are disabled.
> >This IDT is created only when CONFIG_TRACEPOINTS is enabled.
> >
> >  - Remove arch_irq_vector_entry/exit and add followings again
> >so that we can add each tracepoint in a generic way.
> >- error_apic_vector
> >- thermal_apic_vector
> >- threshold_apic_vector
> >- spurious_apic_vector
> >- x86_platform_ipi_vector
> >
> >  - Drop nmi tracepoints to begin with apic interrupts and discuss a logic 
> > switching
> >IDT first.
> >
> >  - Move irq_vectors.h in the directory of arch/x86/include/asm/trace because
> >I'm not sure if a logic switching IDT is sharable with other 
> > architectures.
> >
> >  v3 -> v4
> >  - Add a latency measurement of each tracepoint
> >  - Rebased to 3.6-rc6
> >
> >  v2 -> v3
> >  - Remove an invalidate_tlb_vector event because it was replaced by a call 
> > function vector
> >in a following commit.
> >
> > http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;
> > h=52aec3308db85f4e9f5c8b9f5dc4fbd0138c6fa4
> >
> >  v1 -> v2
> >  - Modify variable name from irq to vector.
> >  - Merge arch-specific tracepoints below to an arch_irq_vector_entry/exit.
> >- error_apic_vector
> >- thermal_apic_vector
> >- threshold_apic_vector
> >- spurious_apic_vector
> >- x86_platform_ipi_vector
> >
> > [Purpose of this patch]
> >
> > As Vaibhav explained in the thread below, tracepoints for irq vectors are 
> > useful.
> >
> > http://www.spinics.net/lists/mm-commits/msg85707.html
> >
> > 
> > The current interrupt traces from irq_handler_entry and
> > irq_handler_exit provide when an interrupt is handled.  They provide good 
> > data about when the system has switched to kernel
> space and how it affects the currently running processes.
> >
> > There are some IRQ vectors which trigger the system into kernel space,
> > which are not handled in generic IRQ handlers.  Tracing such events gives 
> > us the information about IRQ interaction with other system
> events.
> >
> > The trace also tells where the system is spending its time.  We want
> > to know which cores are handling interrupts and how they are affecting
> > other processes in the system.  Also, the trace provides information about 
> > when the cores are idle and which interrupts are
> changing that state.
> > 
> >
> > On the other hand, my usecase is tracing just local timer event and getting 
> > a value of instruction pointer.
> >
> >   I suggested to add an argument local timer event to get instruction 
> > pointer before.
> >   But there is another way to get it with external module like systemtap.
> >   So, I don't need to add any argument to irq vector tracepoints no

RE: [RFC][PATCH v5]trace,x86: add x86 irq vector tracepoints

2012-10-25 Thread Seiji Aguchi
Peter,

I made a patch below making a time penalty zero when not being traced in 
accordance with your comment.
But I'm not sure if it is reasonable to non-tracepoint users.

I agree that a tracepoint should be designed to minimize its impact for 
non-tracepoint users.
But duplicating a function call by using macro makes a code readablity worse.
It has a big impact for all users although a time penalty is zero.

As compared the time penalty to the code readability, I think it is reasonable 
for all users to just add a tracepoint 
to an existing function call because ,as Steven said, a tracepoint is just nops 
when not being traced.

Seiji

 -Original Message-
 From: Seiji Aguchi
 Sent: Thursday, October 18, 2012 2:41 PM
 To: 'H. Peter Anvin'
 Cc: 'Thomas Gleixner (t...@linutronix.de)'; 'linux-kernel@vger.kernel.org'; 
 ''mi...@elte.hu' (mi...@elte.hu)'; 'x...@kernel.org'; 'dle-
 deve...@lists.sourceforge.net'; Satoru Moriya; 'Borislav Petkov'; 
 rost...@goodmis.org
 Subject: RE: [RFC][PATCH v5]trace,x86: add x86 irq vector tracepoints
 
 Any comment?
 
 Seiji
 
  -Original Message-
  From: Seiji Aguchi
  Sent: Thursday, October 11, 2012 1:25 PM
  To: 'H. Peter Anvin'; 'Steven Rostedt'
  Cc: 'Thomas Gleixner (t...@linutronix.de)';
  'linux-kernel@vger.kernel.org'; ''mi...@elte.hu' (mi...@elte.hu)'; 
  'x...@kernel.org'; 'dle- deve...@lists.sourceforge.net'; Satoru
 Moriya; 'Borislav Petkov'
  Subject: [RFC][PATCH v5]trace,x86: add x86 irq vector tracepoints
 
  Change log
 
   v4 - v5
   - Rebased to 3.6.0
 
   - Introduce a logic switching IDT at enabling/disabling TP time
 so that a time penalty makes a zero when tracepoints are disabled.
 This IDT is created only when CONFIG_TRACEPOINTS is enabled.
 
   - Remove arch_irq_vector_entry/exit and add followings again
 so that we can add each tracepoint in a generic way.
 - error_apic_vector
 - thermal_apic_vector
 - threshold_apic_vector
 - spurious_apic_vector
 - x86_platform_ipi_vector
 
   - Drop nmi tracepoints to begin with apic interrupts and discuss a logic 
  switching
 IDT first.
 
   - Move irq_vectors.h in the directory of arch/x86/include/asm/trace because
 I'm not sure if a logic switching IDT is sharable with other 
  architectures.
 
   v3 - v4
   - Add a latency measurement of each tracepoint
   - Rebased to 3.6-rc6
 
   v2 - v3
   - Remove an invalidate_tlb_vector event because it was replaced by a call 
  function vector
 in a following commit.
 
  http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;
  h=52aec3308db85f4e9f5c8b9f5dc4fbd0138c6fa4
 
   v1 - v2
   - Modify variable name from irq to vector.
   - Merge arch-specific tracepoints below to an arch_irq_vector_entry/exit.
 - error_apic_vector
 - thermal_apic_vector
 - threshold_apic_vector
 - spurious_apic_vector
 - x86_platform_ipi_vector
 
  [Purpose of this patch]
 
  As Vaibhav explained in the thread below, tracepoints for irq vectors are 
  useful.
 
  http://www.spinics.net/lists/mm-commits/msg85707.html
 
  snip
  The current interrupt traces from irq_handler_entry and
  irq_handler_exit provide when an interrupt is handled.  They provide good 
  data about when the system has switched to kernel
 space and how it affects the currently running processes.
 
  There are some IRQ vectors which trigger the system into kernel space,
  which are not handled in generic IRQ handlers.  Tracing such events gives 
  us the information about IRQ interaction with other system
 events.
 
  The trace also tells where the system is spending its time.  We want
  to know which cores are handling interrupts and how they are affecting
  other processes in the system.  Also, the trace provides information about 
  when the cores are idle and which interrupts are
 changing that state.
  snip
 
  On the other hand, my usecase is tracing just local timer event and getting 
  a value of instruction pointer.
 
I suggested to add an argument local timer event to get instruction 
  pointer before.
But there is another way to get it with external module like systemtap.
So, I don't need to add any argument to irq vector tracepoints now.
 
  [Patch Description]
 
  Vaibhav's patch shared a trace point ,irq_vector_entry/irq_vector_exit, in 
  all events.
  But there is an above use case to trace specific irq_vector rather than 
  tracing all events.
  In this case, we are concerned about overhead due to unwanted events.
 
  This patch adds following tracepoints instead of introducing 
  irq_vector_entry/exit.
  so that we can enable them independently.
 - local_timer_vector
 - reschedule_vector
 - call_function_vector
 - call_function_single_vector
 - irq_work_entry_vector
 - error_apic_vector
 - thermal_apic_vector
 - threshold_apic_vector
 - spurious_apic_vector
 - x86_platform_ipi_vector
 
  Also, it introduces a logic switching IDT at enabling/disabling

RE: [RFC][PATCH v5]trace,x86: add x86 irq vector tracepoints

2012-10-18 Thread Seiji Aguchi
Any comment?

Seiji

> -Original Message-
> From: Seiji Aguchi
> Sent: Thursday, October 11, 2012 1:25 PM
> To: 'H. Peter Anvin'; 'Steven Rostedt'
> Cc: 'Thomas Gleixner (t...@linutronix.de)'; 'linux-kernel@vger.kernel.org'; 
> ''mi...@elte.hu' (mi...@elte.hu)'; 'x...@kernel.org'; 'dle-
> deve...@lists.sourceforge.net'; Satoru Moriya; 'Borislav Petkov'
> Subject: [RFC][PATCH v5]trace,x86: add x86 irq vector tracepoints
> 
> Change log
> 
>  v4 -> v5
>  - Rebased to 3.6.0
> 
>  - Introduce a logic switching IDT at enabling/disabling TP time
>so that a time penalty makes a zero when tracepoints are disabled.
>This IDT is created only when CONFIG_TRACEPOINTS is enabled.
> 
>  - Remove arch_irq_vector_entry/exit and add followings again
>so that we can add each tracepoint in a generic way.
>- error_apic_vector
>- thermal_apic_vector
>- threshold_apic_vector
>- spurious_apic_vector
>- x86_platform_ipi_vector
> 
>  - Drop nmi tracepoints to begin with apic interrupts and discuss a logic 
> switching
>IDT first.
> 
>  - Move irq_vectors.h in the directory of arch/x86/include/asm/trace because
>I'm not sure if a logic switching IDT is sharable with other architectures.
> 
>  v3 -> v4
>  - Add a latency measurement of each tracepoint
>  - Rebased to 3.6-rc6
> 
>  v2 -> v3
>  - Remove an invalidate_tlb_vector event because it was replaced by a call 
> function vector
>in a following commit.
>
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=52aec3308db85f4e9f5c8b9f5dc4fbd0138c6fa4
> 
>  v1 -> v2
>  - Modify variable name from irq to vector.
>  - Merge arch-specific tracepoints below to an arch_irq_vector_entry/exit.
>- error_apic_vector
>- thermal_apic_vector
>- threshold_apic_vector
>- spurious_apic_vector
>- x86_platform_ipi_vector
> 
> [Purpose of this patch]
> 
> As Vaibhav explained in the thread below, tracepoints for irq vectors are 
> useful.
> 
> http://www.spinics.net/lists/mm-commits/msg85707.html
> 
> 
> The current interrupt traces from irq_handler_entry and irq_handler_exit 
> provide when an interrupt is handled.  They provide good
> data about when the system has switched to kernel space and how it affects 
> the currently running processes.
> 
> There are some IRQ vectors which trigger the system into kernel space, which 
> are not handled in generic IRQ handlers.  Tracing such
> events gives us the information about IRQ interaction with other system 
> events.
> 
> The trace also tells where the system is spending its time.  We want to know 
> which cores are handling interrupts and how they are
> affecting other processes in the system.  Also, the trace provides 
> information about when the cores are idle and which interrupts are
> changing that state.
> 
> 
> On the other hand, my usecase is tracing just local timer event and getting a 
> value of instruction pointer.
> 
>   I suggested to add an argument local timer event to get instruction pointer 
> before.
>   But there is another way to get it with external module like systemtap.
>   So, I don't need to add any argument to irq vector tracepoints now.
> 
> [Patch Description]
> 
> Vaibhav's patch shared a trace point ,irq_vector_entry/irq_vector_exit, in 
> all events.
> But there is an above use case to trace specific irq_vector rather than 
> tracing all events.
> In this case, we are concerned about overhead due to unwanted events.
> 
> This patch adds following tracepoints instead of introducing 
> irq_vector_entry/exit.
> so that we can enable them independently.
>- local_timer_vector
>- reschedule_vector
>- call_function_vector
>- call_function_single_vector
>- irq_work_entry_vector
>- error_apic_vector
>- thermal_apic_vector
>- threshold_apic_vector
>- spurious_apic_vector
>- x86_platform_ipi_vector
> 
> Also, it introduces a logic switching IDT at enabling/disabling time so that 
> a time penalty makes a complete zero when tracepoints are
> disabled. Detailed explanations are as follows.
>  - Create new irq handlers inserted tracepoints by using macros.
>  - Create a new IDT, trace_idt_table, at boot time by duplicating original 
> IDT, idt table, and
>registering the new handers for tracpoints.
>  - Switch IDT to new one at enabling TP time.
>  - Restore to an original IDT at disabling TP time.
> The new IDT is created only when CONFIG_TRACEPOINTS is enabled to avoid being 
> used for other purposes.
> 
> Signed-off-by: Seiji Aguchi 
> ---
>  arch/x86/include/asm/desc.h  |   27 +
>  arch/x86/inclu

RE: [RFC][PATCH v5]trace,x86: add x86 irq vector tracepoints

2012-10-18 Thread Seiji Aguchi
Any comment?

Seiji

 -Original Message-
 From: Seiji Aguchi
 Sent: Thursday, October 11, 2012 1:25 PM
 To: 'H. Peter Anvin'; 'Steven Rostedt'
 Cc: 'Thomas Gleixner (t...@linutronix.de)'; 'linux-kernel@vger.kernel.org'; 
 ''mi...@elte.hu' (mi...@elte.hu)'; 'x...@kernel.org'; 'dle-
 deve...@lists.sourceforge.net'; Satoru Moriya; 'Borislav Petkov'
 Subject: [RFC][PATCH v5]trace,x86: add x86 irq vector tracepoints
 
 Change log
 
  v4 - v5
  - Rebased to 3.6.0
 
  - Introduce a logic switching IDT at enabling/disabling TP time
so that a time penalty makes a zero when tracepoints are disabled.
This IDT is created only when CONFIG_TRACEPOINTS is enabled.
 
  - Remove arch_irq_vector_entry/exit and add followings again
so that we can add each tracepoint in a generic way.
- error_apic_vector
- thermal_apic_vector
- threshold_apic_vector
- spurious_apic_vector
- x86_platform_ipi_vector
 
  - Drop nmi tracepoints to begin with apic interrupts and discuss a logic 
 switching
IDT first.
 
  - Move irq_vectors.h in the directory of arch/x86/include/asm/trace because
I'm not sure if a logic switching IDT is sharable with other architectures.
 
  v3 - v4
  - Add a latency measurement of each tracepoint
  - Rebased to 3.6-rc6
 
  v2 - v3
  - Remove an invalidate_tlb_vector event because it was replaced by a call 
 function vector
in a following commit.

 http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=52aec3308db85f4e9f5c8b9f5dc4fbd0138c6fa4
 
  v1 - v2
  - Modify variable name from irq to vector.
  - Merge arch-specific tracepoints below to an arch_irq_vector_entry/exit.
- error_apic_vector
- thermal_apic_vector
- threshold_apic_vector
- spurious_apic_vector
- x86_platform_ipi_vector
 
 [Purpose of this patch]
 
 As Vaibhav explained in the thread below, tracepoints for irq vectors are 
 useful.
 
 http://www.spinics.net/lists/mm-commits/msg85707.html
 
 snip
 The current interrupt traces from irq_handler_entry and irq_handler_exit 
 provide when an interrupt is handled.  They provide good
 data about when the system has switched to kernel space and how it affects 
 the currently running processes.
 
 There are some IRQ vectors which trigger the system into kernel space, which 
 are not handled in generic IRQ handlers.  Tracing such
 events gives us the information about IRQ interaction with other system 
 events.
 
 The trace also tells where the system is spending its time.  We want to know 
 which cores are handling interrupts and how they are
 affecting other processes in the system.  Also, the trace provides 
 information about when the cores are idle and which interrupts are
 changing that state.
 snip
 
 On the other hand, my usecase is tracing just local timer event and getting a 
 value of instruction pointer.
 
   I suggested to add an argument local timer event to get instruction pointer 
 before.
   But there is another way to get it with external module like systemtap.
   So, I don't need to add any argument to irq vector tracepoints now.
 
 [Patch Description]
 
 Vaibhav's patch shared a trace point ,irq_vector_entry/irq_vector_exit, in 
 all events.
 But there is an above use case to trace specific irq_vector rather than 
 tracing all events.
 In this case, we are concerned about overhead due to unwanted events.
 
 This patch adds following tracepoints instead of introducing 
 irq_vector_entry/exit.
 so that we can enable them independently.
- local_timer_vector
- reschedule_vector
- call_function_vector
- call_function_single_vector
- irq_work_entry_vector
- error_apic_vector
- thermal_apic_vector
- threshold_apic_vector
- spurious_apic_vector
- x86_platform_ipi_vector
 
 Also, it introduces a logic switching IDT at enabling/disabling time so that 
 a time penalty makes a complete zero when tracepoints are
 disabled. Detailed explanations are as follows.
  - Create new irq handlers inserted tracepoints by using macros.
  - Create a new IDT, trace_idt_table, at boot time by duplicating original 
 IDT, idt table, and
registering the new handers for tracpoints.
  - Switch IDT to new one at enabling TP time.
  - Restore to an original IDT at disabling TP time.
 The new IDT is created only when CONFIG_TRACEPOINTS is enabled to avoid being 
 used for other purposes.
 
 Signed-off-by: Seiji Aguchi seiji.agu...@hds.com
 ---
  arch/x86/include/asm/desc.h  |   27 +
  arch/x86/include/asm/entry_arch.h|   32 +
  arch/x86/include/asm/hw_irq.h|   14 +++
  arch/x86/include/asm/trace/irq_vectors.h |  153 
  arch/x86/kernel/Makefile |1 +
  arch/x86/kernel/apic/apic.c  |  186 
 +-
  arch/x86/kernel/cpu/mcheck/therm_throt.c |   26 +++--
  arch/x86/kernel/cpu/mcheck/threshold.c   |   27 +++--
  arch/x86/kernel/entry_64.S   |   33 ++
  arch/x86

[RFC][PATCH v5]trace,x86: add x86 irq vector tracepoints

2012-10-11 Thread Seiji Aguchi
Change log 

 v4 -> v5
 - Rebased to 3.6.0

 - Introduce a logic switching IDT at enabling/disabling TP time 
   so that a time penalty makes a zero when tracepoints are disabled.
   This IDT is created only when CONFIG_TRACEPOINTS is enabled.

 - Remove arch_irq_vector_entry/exit and add followings again
   so that we can add each tracepoint in a generic way.
   - error_apic_vector
   - thermal_apic_vector
   - threshold_apic_vector
   - spurious_apic_vector
   - x86_platform_ipi_vector

 - Drop nmi tracepoints to begin with apic interrupts and discuss a logic 
switching
   IDT first.

 - Move irq_vectors.h in the directory of arch/x86/include/asm/trace because
   I'm not sure if a logic switching IDT is sharable with other architectures.

 v3 -> v4
 - Add a latency measurement of each tracepoint
 - Rebased to 3.6-rc6

 v2 -> v3
 - Remove an invalidate_tlb_vector event because it was replaced by a call 
function vector
   in a following commit.
   
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=52aec3308db85f4e9f5c8b9f5dc4fbd0138c6fa4

 v1 -> v2
 - Modify variable name from irq to vector.
 - Merge arch-specific tracepoints below to an arch_irq_vector_entry/exit.
   - error_apic_vector
   - thermal_apic_vector
   - threshold_apic_vector
   - spurious_apic_vector
   - x86_platform_ipi_vector

[Purpose of this patch]

As Vaibhav explained in the thread below, tracepoints for irq vectors
are useful.

http://www.spinics.net/lists/mm-commits/msg85707.html


The current interrupt traces from irq_handler_entry and irq_handler_exit
provide when an interrupt is handled.  They provide good data about when
the system has switched to kernel space and how it affects the currently
running processes.

There are some IRQ vectors which trigger the system into kernel space,
which are not handled in generic IRQ handlers.  Tracing such events gives
us the information about IRQ interaction with other system events.

The trace also tells where the system is spending its time.  We want to
know which cores are handling interrupts and how they are affecting other
processes in the system.  Also, the trace provides information about when
the cores are idle and which interrupts are changing that state.


On the other hand, my usecase is tracing just local timer event and 
getting a value of instruction pointer.

  I suggested to add an argument local timer event to get instruction pointer 
before.
  But there is another way to get it with external module like systemtap.
  So, I don't need to add any argument to irq vector tracepoints now.

[Patch Description]

Vaibhav's patch shared a trace point ,irq_vector_entry/irq_vector_exit, in all 
events.
But there is an above use case to trace specific irq_vector rather than tracing 
all events.
In this case, we are concerned about overhead due to unwanted events.

This patch adds following tracepoints instead of introducing 
irq_vector_entry/exit.
so that we can enable them independently.
   - local_timer_vector
   - reschedule_vector
   - call_function_vector
   - call_function_single_vector 
   - irq_work_entry_vector
   - error_apic_vector
   - thermal_apic_vector
   - threshold_apic_vector
   - spurious_apic_vector
   - x86_platform_ipi_vector

Also, it introduces a logic switching IDT at enabling/disabling time so that a 
time penalty makes 
a complete zero when tracepoints are disabled. Detailed explanations are as 
follows.
 - Create new irq handlers inserted tracepoints by using macros.
 - Create a new IDT, trace_idt_table, at boot time by duplicating original IDT, 
idt table, and 
   registering the new handers for tracpoints.
 - Switch IDT to new one at enabling TP time.
 - Restore to an original IDT at disabling TP time.
The new IDT is created only when CONFIG_TRACEPOINTS is enabled to avoid being 
used for other purposes.

Signed-off-by: Seiji Aguchi 
---
 arch/x86/include/asm/desc.h  |   27 +
 arch/x86/include/asm/entry_arch.h|   32 +
 arch/x86/include/asm/hw_irq.h|   14 +++
 arch/x86/include/asm/trace/irq_vectors.h |  153 
 arch/x86/kernel/Makefile |1 +
 arch/x86/kernel/apic/apic.c  |  186 +-
 arch/x86/kernel/cpu/mcheck/therm_throt.c |   26 +++--
 arch/x86/kernel/cpu/mcheck/threshold.c   |   27 +++--
 arch/x86/kernel/entry_64.S   |   33 ++
 arch/x86/kernel/head_64.S|6 +
 arch/x86/kernel/irq.c|   44 ---
 arch/x86/kernel/irq_work.c   |   22 +++-
 arch/x86/kernel/irqinit.c|2 +
 arch/x86/kernel/smp.c|   68 
 arch/x86/kernel/tracepoint.c |  102 
 15 files changed, 600 insertions(+), 143 deletions(-)
 create mode 100644 arch/x86/include/asm/trace/irq_vectors.h
 create mode 100644 arch/x86/kernel/tracepoint.c

diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
index 

[RFC][PATCH v5]trace,x86: add x86 irq vector tracepoints

2012-10-11 Thread Seiji Aguchi
Change log 

 v4 - v5
 - Rebased to 3.6.0

 - Introduce a logic switching IDT at enabling/disabling TP time 
   so that a time penalty makes a zero when tracepoints are disabled.
   This IDT is created only when CONFIG_TRACEPOINTS is enabled.

 - Remove arch_irq_vector_entry/exit and add followings again
   so that we can add each tracepoint in a generic way.
   - error_apic_vector
   - thermal_apic_vector
   - threshold_apic_vector
   - spurious_apic_vector
   - x86_platform_ipi_vector

 - Drop nmi tracepoints to begin with apic interrupts and discuss a logic 
switching
   IDT first.

 - Move irq_vectors.h in the directory of arch/x86/include/asm/trace because
   I'm not sure if a logic switching IDT is sharable with other architectures.

 v3 - v4
 - Add a latency measurement of each tracepoint
 - Rebased to 3.6-rc6

 v2 - v3
 - Remove an invalidate_tlb_vector event because it was replaced by a call 
function vector
   in a following commit.
   
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=52aec3308db85f4e9f5c8b9f5dc4fbd0138c6fa4

 v1 - v2
 - Modify variable name from irq to vector.
 - Merge arch-specific tracepoints below to an arch_irq_vector_entry/exit.
   - error_apic_vector
   - thermal_apic_vector
   - threshold_apic_vector
   - spurious_apic_vector
   - x86_platform_ipi_vector

[Purpose of this patch]

As Vaibhav explained in the thread below, tracepoints for irq vectors
are useful.

http://www.spinics.net/lists/mm-commits/msg85707.html

snip
The current interrupt traces from irq_handler_entry and irq_handler_exit
provide when an interrupt is handled.  They provide good data about when
the system has switched to kernel space and how it affects the currently
running processes.

There are some IRQ vectors which trigger the system into kernel space,
which are not handled in generic IRQ handlers.  Tracing such events gives
us the information about IRQ interaction with other system events.

The trace also tells where the system is spending its time.  We want to
know which cores are handling interrupts and how they are affecting other
processes in the system.  Also, the trace provides information about when
the cores are idle and which interrupts are changing that state.
snip

On the other hand, my usecase is tracing just local timer event and 
getting a value of instruction pointer.

  I suggested to add an argument local timer event to get instruction pointer 
before.
  But there is another way to get it with external module like systemtap.
  So, I don't need to add any argument to irq vector tracepoints now.

[Patch Description]

Vaibhav's patch shared a trace point ,irq_vector_entry/irq_vector_exit, in all 
events.
But there is an above use case to trace specific irq_vector rather than tracing 
all events.
In this case, we are concerned about overhead due to unwanted events.

This patch adds following tracepoints instead of introducing 
irq_vector_entry/exit.
so that we can enable them independently.
   - local_timer_vector
   - reschedule_vector
   - call_function_vector
   - call_function_single_vector 
   - irq_work_entry_vector
   - error_apic_vector
   - thermal_apic_vector
   - threshold_apic_vector
   - spurious_apic_vector
   - x86_platform_ipi_vector

Also, it introduces a logic switching IDT at enabling/disabling time so that a 
time penalty makes 
a complete zero when tracepoints are disabled. Detailed explanations are as 
follows.
 - Create new irq handlers inserted tracepoints by using macros.
 - Create a new IDT, trace_idt_table, at boot time by duplicating original IDT, 
idt table, and 
   registering the new handers for tracpoints.
 - Switch IDT to new one at enabling TP time.
 - Restore to an original IDT at disabling TP time.
The new IDT is created only when CONFIG_TRACEPOINTS is enabled to avoid being 
used for other purposes.

Signed-off-by: Seiji Aguchi seiji.agu...@hds.com
---
 arch/x86/include/asm/desc.h  |   27 +
 arch/x86/include/asm/entry_arch.h|   32 +
 arch/x86/include/asm/hw_irq.h|   14 +++
 arch/x86/include/asm/trace/irq_vectors.h |  153 
 arch/x86/kernel/Makefile |1 +
 arch/x86/kernel/apic/apic.c  |  186 +-
 arch/x86/kernel/cpu/mcheck/therm_throt.c |   26 +++--
 arch/x86/kernel/cpu/mcheck/threshold.c   |   27 +++--
 arch/x86/kernel/entry_64.S   |   33 ++
 arch/x86/kernel/head_64.S|6 +
 arch/x86/kernel/irq.c|   44 ---
 arch/x86/kernel/irq_work.c   |   22 +++-
 arch/x86/kernel/irqinit.c|2 +
 arch/x86/kernel/smp.c|   68 
 arch/x86/kernel/tracepoint.c |  102 
 15 files changed, 600 insertions(+), 143 deletions(-)
 create mode 100644 arch/x86/include/asm/trace/irq_vectors.h
 create mode 100644 arch/x86/kernel/tracepoint.c

diff --git a/arch/x86/include/asm/desc.h