RE: [PATCH v3] Introduce page fault tracepoint

2013-10-16 Thread Seiji Aguchi
Thank you for reviewing.

> > http://marc.info/?l=linux-mm=136807959830182=2
> > http://marc.info/?l=linux-mm=136807959130175=2
> >
> 
> For permanence, please use links of the form:
> 
>   http://lkml.kernel.org/r/message-id
> 
> (Yes, they currently point to marc.info, but can be redirected to point
> to any archive.)

I will fix it.

> This is needlessly confusing, which is apart of why reviewing this patch
> took a lot more time than it should.
> 
> Please break this patch into two: one which sets up the tracing IDT and
> one to create the #PF tracepoint.  The assumption is, I am assuming,
> there will be more.

OK. I will divide the patch into two or more to make the review smooth.

Seiji

> 
>   -hpa



RE: [PATCH v3] Introduce page fault tracepoint

2013-10-16 Thread Seiji Aguchi
Thank you for reviewing.

  http://marc.info/?l=linux-mmm=136807959830182w=2
  http://marc.info/?l=linux-mmm=136807959130175w=2
 
 
 For permanence, please use links of the form:
 
   http://lkml.kernel.org/r/message-id
 
 (Yes, they currently point to marc.info, but can be redirected to point
 to any archive.)

I will fix it.

 This is needlessly confusing, which is apart of why reviewing this patch
 took a lot more time than it should.
 
 Please break this patch into two: one which sets up the tracing IDT and
 one to create the #PF tracepoint.  The assumption is, I am assuming,
 there will be more.

OK. I will divide the patch into two or more to make the review smooth.

Seiji

 
   -hpa



Re: [PATCH v3] Introduce page fault tracepoint

2013-10-15 Thread H. Peter Anvin
On 09/09/2013 02:55 PM, Seiji Aguchi wrote:
> Change from v2
>  - Print entry->ip instead of entry->regs->ip to avoid kernel crash.
>  - Use %pf instead of 0x%lx to print address and ip.
> 
> This patch introduces page fault tracepoints to x86 architecture
> by switching IDT.
> 
> [Use case of page fault events]
> 
>   Two events, for user and kernel spaces, are introduced at the beginning of
>   page fault handler.
> 
>   - User space event
> There is a request of page fault event for user space as below.
> 
> http://marc.info/?l=linux-mm=136807959830182=2
> http://marc.info/?l=linux-mm=136807959130175=2
> 

For permanence, please use links of the form:

http://lkml.kernel.org/r/message-id

(Yes, they currently point to marc.info, but can be redirected to point
to any archive.)

>   - Kernel space event:
> Overhead in kernel space is measurable by enabling it.
> 
> [Creating IDT]
> 
>  A way to create IDT is as below.
> 
>  - Introduce set_intr_gate_raw() to register just non-trace handler to IDT.
>This is used at boot time which tracing is disabled.
>  - Make set_intr_gate() macro so that it can register trace handler to
>trace IDT and non-trace handler to normal IDT.
> 

This is needlessly confusing, which is apart of why reviewing this patch
took a lot more time than it should.

Please break this patch into two: one which sets up the tracing IDT and
one to create the #PF tracepoint.  The assumption is, I am assuming,
there will be more.

-hpa

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


Re: [PATCH v3] Introduce page fault tracepoint

2013-10-15 Thread H. Peter Anvin
On 09/09/2013 02:55 PM, Seiji Aguchi wrote:
 Change from v2
  - Print entry-ip instead of entry-regs-ip to avoid kernel crash.
  - Use %pf instead of 0x%lx to print address and ip.
 
 This patch introduces page fault tracepoints to x86 architecture
 by switching IDT.
 
 [Use case of page fault events]
 
   Two events, for user and kernel spaces, are introduced at the beginning of
   page fault handler.
 
   - User space event
 There is a request of page fault event for user space as below.
 
 http://marc.info/?l=linux-mmm=136807959830182w=2
 http://marc.info/?l=linux-mmm=136807959130175w=2
 

For permanence, please use links of the form:

http://lkml.kernel.org/r/message-id

(Yes, they currently point to marc.info, but can be redirected to point
to any archive.)

   - Kernel space event:
 Overhead in kernel space is measurable by enabling it.
 
 [Creating IDT]
 
  A way to create IDT is as below.
 
  - Introduce set_intr_gate_raw() to register just non-trace handler to IDT.
This is used at boot time which tracing is disabled.
  - Make set_intr_gate() macro so that it can register trace handler to
trace IDT and non-trace handler to normal IDT.
 

This is needlessly confusing, which is apart of why reviewing this patch
took a lot more time than it should.

Please break this patch into two: one which sets up the tracing IDT and
one to create the #PF tracepoint.  The assumption is, I am assuming,
there will be more.

-hpa

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


RE: [PATCH v3] Introduce page fault tracepoint

2013-10-11 Thread Seiji Aguchi
Peter,

Any comment?

Seiji

> -Original Message-
> From: linux-kernel-ow...@vger.kernel.org 
> [mailto:linux-kernel-ow...@vger.kernel.org] On Behalf Of Seiji Aguchi
> Sent: Monday, September 09, 2013 5:56 PM
> To: linux-kernel@vger.kernel.org; x...@kernel.org
> Cc: h...@zytor.com; rost...@goodmis.org; mi...@elte.hu; b...@alien8.de; 
> t...@linutronix.de; fdesl...@gmail.com;
> raphael.beamo...@gmail.com; dle-deve...@lists.sourceforge.net; Tomoki Sekiyama
> Subject: [PATCH v3] Introduce page fault tracepoint
> 
> Change from v2
>  - Print entry->ip instead of entry->regs->ip to avoid kernel crash.
>  - Use %pf instead of 0x%lx to print address and ip.
> 
> This patch introduces page fault tracepoints to x86 architecture
> by switching IDT.
> 
> [Use case of page fault events]
> 
>   Two events, for user and kernel spaces, are introduced at the beginning of
>   page fault handler.
> 
>   - User space event
> There is a request of page fault event for user space as below.
> 
> http://marc.info/?l=linux-mm=136807959830182=2
> http://marc.info/?l=linux-mm=136807959130175=2
> 
>   - Kernel space event:
> Overhead in kernel space is measurable by enabling it.
> 
> [Creating IDT]
> 
>  A way to create IDT is as below.
> 
>  - Introduce set_intr_gate_raw() to register just non-trace handler to IDT.
>This is used at boot time which tracing is disabled.
>  - Make set_intr_gate() macro so that it can register trace handler to
>trace IDT and non-trace handler to normal IDT.
> 
> Signed-off-by: Seiji Aguchi 
> ---
>  arch/x86/include/asm/desc.h | 33 +
>  arch/x86/include/asm/hw_irq.h   | 14 -
>  arch/x86/include/asm/trace/exceptions.h | 52 
> +
>  arch/x86/include/asm/traps.h| 22 ++
>  arch/x86/kernel/entry_32.S  | 10 +++
>  arch/x86/kernel/entry_64.S  | 13 -
>  arch/x86/kernel/head64.c|  2 +-
>  arch/x86/kernel/irqinit.c   |  2 +-
>  arch/x86/kernel/kvm.c   |  2 +-
>  arch/x86/kernel/traps.c | 28 +-
>  arch/x86/mm/Makefile|  2 ++
>  arch/x86/mm/fault.c | 22 ++
>  12 files changed, 178 insertions(+), 24 deletions(-)
>  create mode 100644 arch/x86/include/asm/trace/exceptions.h
> 
> diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
> index b90e5df..c04302b 100644
> --- a/arch/x86/include/asm/desc.h
> +++ b/arch/x86/include/asm/desc.h
> @@ -327,10 +327,28 @@ static inline void write_trace_idt_entry(int entry, 
> const gate_desc *gate)
>  {
>   write_idt_entry(trace_idt_table, entry, gate);
>  }
> +
> +static inline void _trace_set_gate(int gate, unsigned type, void *addr,
> +unsigned dpl, unsigned ist, unsigned seg)
> +{
> + gate_desc s;
> +
> + pack_gate(, type, (unsigned long)addr, dpl, ist, seg);
> + /*
> +  * does not need to be atomic because it is only done once at
> +  * setup time
> +  */
> + write_trace_idt_entry(gate, );
> +}
>  #else
>  static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
>  {
>  }
> +
> +static inline void _trace_set_gate(int gate, unsigned type, void *addr,
> +unsigned dpl, unsigned ist, unsigned seg)
> +{
> +}
>  #endif
> 
>  static inline void _set_gate(int gate, unsigned type, void *addr,
> @@ -353,12 +371,20 @@ static inline void _set_gate(int gate, unsigned type, 
> void *addr,
>   * Pentium F0 0F bugfix can have resulted in the mapped
>   * IDT being write-protected.
>   */
> -static inline void set_intr_gate(unsigned int n, void *addr)
> +static inline void set_intr_gate_raw(unsigned int n, void *addr)
>  {
>   BUG_ON((unsigned)n > 0xFF);
>   _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
>  }
> 
> +#define set_intr_gate(n, addr)   
> \
> + do {\
> + BUG_ON((unsigned)n > 0xFF); \
> + _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);  \
> + _trace_set_gate(n, GATE_INTERRUPT, trace_##addr, 0, 0,  \
> + __KERNEL_CS);   \
> + } while (0)
> +
>  extern int first_system_vector;
>  /* used_vectors is BITMAP for irq is not managed by percpu vector_irq */
>  extern unsigned long used_vectors[];
> @@ -395,10 +421,7 @@ static inline void trace_set_intr_gate(unsigned int 
> gate, void *addr)
>  #define __trace_alloc_intr_gate(n, addr)
>  #endif
> 
> -static inline void __alloc_intr_gate(unsigned int n, void *addr)
> -{
> - set_intr_gate(n, addr);
> -}
> +#define __alloc_intr_gate(n, addr) set_intr_gate(n, addr)
> 
>  #define alloc_intr_gate(n, addr) \
>   do {

RE: [PATCH v3] Introduce page fault tracepoint

2013-10-11 Thread Seiji Aguchi
Peter,

Any comment?

Seiji

 -Original Message-
 From: linux-kernel-ow...@vger.kernel.org 
 [mailto:linux-kernel-ow...@vger.kernel.org] On Behalf Of Seiji Aguchi
 Sent: Monday, September 09, 2013 5:56 PM
 To: linux-kernel@vger.kernel.org; x...@kernel.org
 Cc: h...@zytor.com; rost...@goodmis.org; mi...@elte.hu; b...@alien8.de; 
 t...@linutronix.de; fdesl...@gmail.com;
 raphael.beamo...@gmail.com; dle-deve...@lists.sourceforge.net; Tomoki Sekiyama
 Subject: [PATCH v3] Introduce page fault tracepoint
 
 Change from v2
  - Print entry-ip instead of entry-regs-ip to avoid kernel crash.
  - Use %pf instead of 0x%lx to print address and ip.
 
 This patch introduces page fault tracepoints to x86 architecture
 by switching IDT.
 
 [Use case of page fault events]
 
   Two events, for user and kernel spaces, are introduced at the beginning of
   page fault handler.
 
   - User space event
 There is a request of page fault event for user space as below.
 
 http://marc.info/?l=linux-mmm=136807959830182w=2
 http://marc.info/?l=linux-mmm=136807959130175w=2
 
   - Kernel space event:
 Overhead in kernel space is measurable by enabling it.
 
 [Creating IDT]
 
  A way to create IDT is as below.
 
  - Introduce set_intr_gate_raw() to register just non-trace handler to IDT.
This is used at boot time which tracing is disabled.
  - Make set_intr_gate() macro so that it can register trace handler to
trace IDT and non-trace handler to normal IDT.
 
 Signed-off-by: Seiji Aguchi seiji.agu...@hds.com
 ---
  arch/x86/include/asm/desc.h | 33 +
  arch/x86/include/asm/hw_irq.h   | 14 -
  arch/x86/include/asm/trace/exceptions.h | 52 
 +
  arch/x86/include/asm/traps.h| 22 ++
  arch/x86/kernel/entry_32.S  | 10 +++
  arch/x86/kernel/entry_64.S  | 13 -
  arch/x86/kernel/head64.c|  2 +-
  arch/x86/kernel/irqinit.c   |  2 +-
  arch/x86/kernel/kvm.c   |  2 +-
  arch/x86/kernel/traps.c | 28 +-
  arch/x86/mm/Makefile|  2 ++
  arch/x86/mm/fault.c | 22 ++
  12 files changed, 178 insertions(+), 24 deletions(-)
  create mode 100644 arch/x86/include/asm/trace/exceptions.h
 
 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
 index b90e5df..c04302b 100644
 --- a/arch/x86/include/asm/desc.h
 +++ b/arch/x86/include/asm/desc.h
 @@ -327,10 +327,28 @@ static inline void write_trace_idt_entry(int entry, 
 const gate_desc *gate)
  {
   write_idt_entry(trace_idt_table, entry, gate);
  }
 +
 +static inline void _trace_set_gate(int gate, unsigned type, void *addr,
 +unsigned dpl, unsigned ist, unsigned seg)
 +{
 + gate_desc s;
 +
 + pack_gate(s, type, (unsigned long)addr, dpl, ist, seg);
 + /*
 +  * does not need to be atomic because it is only done once at
 +  * setup time
 +  */
 + write_trace_idt_entry(gate, s);
 +}
  #else
  static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
  {
  }
 +
 +static inline void _trace_set_gate(int gate, unsigned type, void *addr,
 +unsigned dpl, unsigned ist, unsigned seg)
 +{
 +}
  #endif
 
  static inline void _set_gate(int gate, unsigned type, void *addr,
 @@ -353,12 +371,20 @@ static inline void _set_gate(int gate, unsigned type, 
 void *addr,
   * Pentium F0 0F bugfix can have resulted in the mapped
   * IDT being write-protected.
   */
 -static inline void set_intr_gate(unsigned int n, void *addr)
 +static inline void set_intr_gate_raw(unsigned int n, void *addr)
  {
   BUG_ON((unsigned)n  0xFF);
   _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
  }
 
 +#define set_intr_gate(n, addr)   
 \
 + do {\
 + BUG_ON((unsigned)n  0xFF); \
 + _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);  \
 + _trace_set_gate(n, GATE_INTERRUPT, trace_##addr, 0, 0,  \
 + __KERNEL_CS);   \
 + } while (0)
 +
  extern int first_system_vector;
  /* used_vectors is BITMAP for irq is not managed by percpu vector_irq */
  extern unsigned long used_vectors[];
 @@ -395,10 +421,7 @@ static inline void trace_set_intr_gate(unsigned int 
 gate, void *addr)
  #define __trace_alloc_intr_gate(n, addr)
  #endif
 
 -static inline void __alloc_intr_gate(unsigned int n, void *addr)
 -{
 - set_intr_gate(n, addr);
 -}
 +#define __alloc_intr_gate(n, addr) set_intr_gate(n, addr)
 
  #define alloc_intr_gate(n, addr) \
   do {\
 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h