linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH tracing/kprobes 0/3] tracing/kprobes: kprobe-tracer updates
@ 2009-09-25 18:19 Masami Hiramatsu
  2009-09-25 18:20 ` [PATCH tracing/kprobes 1/3] tracing/kprobes: Use global event profile buffer in kprobe tracer Masami Hiramatsu
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Masami Hiramatsu @ 2009-09-25 18:19 UTC (permalink / raw)
  To: Frederic Weisbecker, Steven Rostedt, Ingo Molnar, lkml
  Cc: Ananth N Mavinakayanahalli, Andi Kleen, Christoph Hellwig,
	Frank Ch. Eigler, H. Peter Anvin, Jason Baron, Jim Keniston,
	K.Prasad, Lai Jiangshan, Li Zefan, Peter Zijlstra,
	Srikar Dronamraju, Tom Zanussi, systemtap, DLE

Hi Frederic,

Here is a few updates for kprobe-tracer which fix reported bugs and
is for catching up the latest ftrace.

 - Use dynamic percpu profiling buffer patch is for catching up
   the latest ftrace change.
 - Checking the result of create_event_dir() patch improves ftrace
   code pointed by Li Zefan (thanks!).
 - Add VIA instructions to x86 insn decoder patch fixes decoding
   bug reported by Ingo Molnar (thanks!).

Soon after this series, I'll send perf-kprobe patch series.

Thank you,

---

Masami Hiramatsu (3):
      tracing/ftrace: Fix to check create_event_dir() when adding new events
      x86: Add VIA processor instructions
      tracing/kprobes: Use global event profile buffer in kprobe tracer


 arch/x86/lib/x86-opcode-map.txt |    8 ++-
 kernel/trace/trace_events.c     |   29 +++++++---
 kernel/trace/trace_kprobe.c     |  115 +++++++++++++++++++++++++--------------
 3 files changed, 101 insertions(+), 51 deletions(-)

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH tracing/kprobes 1/3] tracing/kprobes: Use global event profile buffer in kprobe tracer
  2009-09-25 18:19 [PATCH tracing/kprobes 0/3] tracing/kprobes: kprobe-tracer updates Masami Hiramatsu
@ 2009-09-25 18:20 ` Masami Hiramatsu
  2009-10-17 10:02   ` [tip:perf/probes] tracing/kprobes: Use global event perf buffers " tip-bot for Masami Hiramatsu
  2009-09-25 18:20 ` [PATCH tracing/kprobes 2/3] x86: Add VIA processor instructions Masami Hiramatsu
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Masami Hiramatsu @ 2009-09-25 18:20 UTC (permalink / raw)
  To: Frederic Weisbecker, Steven Rostedt, Ingo Molnar, lkml
  Cc: systemtap, DLE, Masami Hiramatsu, Steven Rostedt, Jim Keniston,
	Ananth N Mavinakayanahalli, Andi Kleen, Christoph Hellwig,
	Frank Ch. Eigler, Frederic Weisbecker, H. Peter Anvin,
	Ingo Molnar, Jason Baron, K.Prasad, Lai Jiangshan, Li Zefan,
	Peter Zijlstra, Srikar Dronamraju, Tom Zanussi

Use new percpu global event profile buffer instead of stack in kprobe
tracer.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
---

 kernel/trace/trace_kprobe.c |  115 +++++++++++++++++++++++++++----------------
 1 files changed, 73 insertions(+), 42 deletions(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 09cba27..97309d4 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1149,35 +1149,49 @@ static __kprobes int kprobe_profile_func(struct kprobe *kp,
 	struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);
 	struct ftrace_event_call *call = &tp->call;
 	struct kprobe_trace_entry *entry;
-	int size, __size, i, pc;
+	struct trace_entry *ent;
+	int size, __size, i, pc, __cpu;
 	unsigned long irq_flags;
+	char *raw_data;
 
-	local_save_flags(irq_flags);
 	pc = preempt_count();
-
 	__size = SIZEOF_KPROBE_TRACE_ENTRY(tp->nr_args);
 	size = ALIGN(__size + sizeof(u32), sizeof(u64));
 	size -= sizeof(u32);
+	if (WARN_ONCE(size > FTRACE_MAX_PROFILE_SIZE,
+		     "profile buffer not large enough"))
+		return 0;
 
-	do {
-		char raw_data[size];
-		struct trace_entry *ent;
-		/*
-		 * Zero dead bytes from alignment to avoid stack leak
-		 * to userspace
-		 */
-		*(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
-		entry = (struct kprobe_trace_entry *)raw_data;
-		ent = &entry->ent;
-
-		tracing_generic_entry_update(ent, irq_flags, pc);
-		ent->type = call->id;
-		entry->nargs = tp->nr_args;
-		entry->ip = (unsigned long)kp->addr;
-		for (i = 0; i < tp->nr_args; i++)
-			entry->args[i] = call_fetch(&tp->args[i].fetch, regs);
-		perf_tp_event(call->id, entry->ip, 1, entry, size);
-	} while (0);
+	/*
+	 * Protect the non nmi buffer
+	 * This also protects the rcu read side
+	 */
+	local_irq_save(irq_flags);
+	__cpu = smp_processor_id();
+
+	if (in_nmi())
+		raw_data = rcu_dereference(trace_profile_buf_nmi);
+	else
+		raw_data = rcu_dereference(trace_profile_buf);
+
+	if (!raw_data)
+		goto end;
+
+	raw_data = per_cpu_ptr(raw_data, __cpu);
+	/* Zero dead bytes from alignment to avoid buffer leak to userspace */
+	*(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
+	entry = (struct kprobe_trace_entry *)raw_data;
+	ent = &entry->ent;
+
+	tracing_generic_entry_update(ent, irq_flags, pc);
+	ent->type = call->id;
+	entry->nargs = tp->nr_args;
+	entry->ip = (unsigned long)kp->addr;
+	for (i = 0; i < tp->nr_args; i++)
+		entry->args[i] = call_fetch(&tp->args[i].fetch, regs);
+	perf_tp_event(call->id, entry->ip, 1, entry, size);
+end:
+	local_irq_restore(irq_flags);
 	return 0;
 }
 
@@ -1188,33 +1202,50 @@ static __kprobes int kretprobe_profile_func(struct kretprobe_instance *ri,
 	struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
 	struct ftrace_event_call *call = &tp->call;
 	struct kretprobe_trace_entry *entry;
-	int size, __size, i, pc;
+	struct trace_entry *ent;
+	int size, __size, i, pc, __cpu;
 	unsigned long irq_flags;
+	char *raw_data;
 
-	local_save_flags(irq_flags);
 	pc = preempt_count();
-
 	__size = SIZEOF_KRETPROBE_TRACE_ENTRY(tp->nr_args);
 	size = ALIGN(__size + sizeof(u32), sizeof(u64));
 	size -= sizeof(u32);
+	if (WARN_ONCE(size > FTRACE_MAX_PROFILE_SIZE,
+		     "profile buffer not large enough"))
+		return 0;
+
+	/*
+	 * Protect the non nmi buffer
+	 * This also protects the rcu read side
+	 */
+	local_irq_save(irq_flags);
+	__cpu = smp_processor_id();
+
+	if (in_nmi())
+		raw_data = rcu_dereference(trace_profile_buf_nmi);
+	else
+		raw_data = rcu_dereference(trace_profile_buf);
+
+	if (!raw_data)
+		goto end;
+
+	raw_data = per_cpu_ptr(raw_data, __cpu);
+	/* Zero dead bytes from alignment to avoid buffer leak to userspace */
+	*(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
+	entry = (struct kretprobe_trace_entry *)raw_data;
+	ent = &entry->ent;
 
-	do {
-		char raw_data[size];
-		struct trace_entry *ent;
-
-		*(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
-		entry = (struct kretprobe_trace_entry *)raw_data;
-		ent = &entry->ent;
-
-		tracing_generic_entry_update(ent, irq_flags, pc);
-		ent->type = call->id;
-		entry->nargs = tp->nr_args;
-		entry->func = (unsigned long)tp->rp.kp.addr;
-		entry->ret_ip = (unsigned long)ri->ret_addr;
-		for (i = 0; i < tp->nr_args; i++)
-			entry->args[i] = call_fetch(&tp->args[i].fetch, regs);
-		perf_tp_event(call->id, entry->ret_ip, 1, entry, size);
-	} while (0);
+	tracing_generic_entry_update(ent, irq_flags, pc);
+	ent->type = call->id;
+	entry->nargs = tp->nr_args;
+	entry->func = (unsigned long)tp->rp.kp.addr;
+	entry->ret_ip = (unsigned long)ri->ret_addr;
+	for (i = 0; i < tp->nr_args; i++)
+		entry->args[i] = call_fetch(&tp->args[i].fetch, regs);
+	perf_tp_event(call->id, entry->ret_ip, 1, entry, size);
+end:
+	local_irq_restore(irq_flags);
 	return 0;
 }
 


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH tracing/kprobes 2/3] x86: Add VIA processor instructions
  2009-09-25 18:19 [PATCH tracing/kprobes 0/3] tracing/kprobes: kprobe-tracer updates Masami Hiramatsu
  2009-09-25 18:20 ` [PATCH tracing/kprobes 1/3] tracing/kprobes: Use global event profile buffer in kprobe tracer Masami Hiramatsu
@ 2009-09-25 18:20 ` Masami Hiramatsu
  2009-10-17 10:02   ` [tip:perf/probes] x86: Add VIA processor instructions in opcodes decoder tip-bot for Masami Hiramatsu
  2009-09-25 18:20 ` [PATCH tracing/kprobes 3/3] tracing/ftrace: Fix to check create_event_dir() when adding new events Masami Hiramatsu
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Masami Hiramatsu @ 2009-09-25 18:20 UTC (permalink / raw)
  To: Frederic Weisbecker, Steven Rostedt, Ingo Molnar, lkml
  Cc: systemtap, DLE, Masami Hiramatsu, Steven Rostedt, Jim Keniston,
	Ananth N Mavinakayanahalli, Andi Kleen, Christoph Hellwig,
	Frank Ch. Eigler, Frederic Weisbecker, H. Peter Anvin,
	Jason Baron, K.Prasad, Lai Jiangshan, Li Zefan, Peter Zijlstra,
	Srikar Dronamraju, Tom Zanussi

Add VIA processor's Padlock instructions(MONTMUL, XSHA1, XSHA256).

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Reported-by: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
---

 arch/x86/lib/x86-opcode-map.txt |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/arch/x86/lib/x86-opcode-map.txt b/arch/x86/lib/x86-opcode-map.txt
index 59e20d5..78a0daf 100644
--- a/arch/x86/lib/x86-opcode-map.txt
+++ b/arch/x86/lib/x86-opcode-map.txt
@@ -469,7 +469,7 @@ a2: CPUID
 a3: BT Ev,Gv
 a4: SHLD Ev,Gv,Ib
 a5: SHLD Ev,Gv,CL
-a6:
+a6: GrpPDLK
 a7: GrpRNG
 a8: PUSH GS (d64)
 a9: POP GS (d64)
@@ -803,6 +803,12 @@ GrpTable: Grp16
 3: prefetch T2
 EndTable
 
+GrpTable: GrpPDLK
+0: MONTMUL
+1: XSHA1
+2: XSHA2
+EndTable
+
 GrpTable: GrpRNG
 0: xstore-rng
 1: xcrypt-ecb


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH tracing/kprobes 3/3] tracing/ftrace: Fix to check create_event_dir() when adding new events
  2009-09-25 18:19 [PATCH tracing/kprobes 0/3] tracing/kprobes: kprobe-tracer updates Masami Hiramatsu
  2009-09-25 18:20 ` [PATCH tracing/kprobes 1/3] tracing/kprobes: Use global event profile buffer in kprobe tracer Masami Hiramatsu
  2009-09-25 18:20 ` [PATCH tracing/kprobes 2/3] x86: Add VIA processor instructions Masami Hiramatsu
@ 2009-09-25 18:20 ` Masami Hiramatsu
  2009-10-03  0:56   ` Frederic Weisbecker
  2009-10-17 10:02   ` [tip:perf/probes] " tip-bot for Masami Hiramatsu
  2009-09-26  9:08 ` [PATCH tracing/kprobes 0/3] tracing/kprobes: kprobe-tracer updates Steven Rostedt
  2009-10-03  0:57 ` Frederic Weisbecker
  4 siblings, 2 replies; 10+ messages in thread
From: Masami Hiramatsu @ 2009-09-25 18:20 UTC (permalink / raw)
  To: Frederic Weisbecker, Steven Rostedt, Ingo Molnar, lkml
  Cc: systemtap, DLE, Masami Hiramatsu, Steven Rostedt, Jim Keniston,
	Ananth N Mavinakayanahalli, Andi Kleen, Christoph Hellwig,
	Frank Ch. Eigler, Frederic Weisbecker, H. Peter Anvin,
	Ingo Molnar, Jason Baron, K.Prasad, Lai Jiangshan, Li Zefan,
	Peter Zijlstra, Srikar Dronamraju, Tom Zanussi

Check result of create_event_dir() and add ftrace_event_call to
ftrace_events list only if it is succeeded. Thanks Li for pointing it out.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
---

 kernel/trace/trace_events.c |   29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index a4b7c9a..f03cda3 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -957,12 +957,14 @@ static int __trace_add_event_call(struct ftrace_event_call *call)
 	if (!d_events)
 		return -ENOENT;
 
-	list_add(&call->list, &ftrace_events);
 	ret = event_create_dir(call, d_events, &ftrace_event_id_fops,
 				&ftrace_enable_fops, &ftrace_event_filter_fops,
 				&ftrace_event_format_fops);
 	if (ret < 0)
-		list_del(&call->list);
+		pr_warning("Could not create directory of trace events/%s\n",
+			   call->name);
+	else
+		list_add(&call->list, &ftrace_events);
 	return ret;
 }
 
@@ -1124,10 +1126,15 @@ static void trace_module_add_events(struct module *mod)
 				return;
 		}
 		call->mod = mod;
+		ret = event_create_dir(call, d_events,
+				       &file_ops->id, &file_ops->enable,
+				       &file_ops->filter, &file_ops->format);
+		if (ret < 0) {
+			pr_warning("Could not create directory of trace "
+				   "point events/%s\n", call->name);
+			continue;
+		}
 		list_add(&call->list, &ftrace_events);
-		event_create_dir(call, d_events,
-				 &file_ops->id, &file_ops->enable,
-				 &file_ops->filter, &file_ops->format);
 	}
 }
 
@@ -1267,10 +1274,16 @@ static __init int event_trace_init(void)
 				continue;
 			}
 		}
+		ret = event_create_dir(call, d_events, &ftrace_event_id_fops,
+				       &ftrace_enable_fops,
+				       &ftrace_event_filter_fops,
+				       &ftrace_event_format_fops);
+		if (ret < 0) {
+			pr_warning("Could not create directory of trace "
+				   "point events/%s\n", call->name);
+			continue;
+		}
 		list_add(&call->list, &ftrace_events);
-		event_create_dir(call, d_events, &ftrace_event_id_fops,
-				 &ftrace_enable_fops, &ftrace_event_filter_fops,
-				 &ftrace_event_format_fops);
 	}
 
 	while (true) {


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH tracing/kprobes 0/3] tracing/kprobes: kprobe-tracer updates
  2009-09-25 18:19 [PATCH tracing/kprobes 0/3] tracing/kprobes: kprobe-tracer updates Masami Hiramatsu
                   ` (2 preceding siblings ...)
  2009-09-25 18:20 ` [PATCH tracing/kprobes 3/3] tracing/ftrace: Fix to check create_event_dir() when adding new events Masami Hiramatsu
@ 2009-09-26  9:08 ` Steven Rostedt
  2009-10-03  0:57 ` Frederic Weisbecker
  4 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2009-09-26  9:08 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Frederic Weisbecker, Ingo Molnar, lkml,
	Ananth N Mavinakayanahalli, Andi Kleen, Christoph Hellwig,
	Frank Ch. Eigler, H. Peter Anvin, Jason Baron, Jim Keniston,
	K.Prasad, Lai Jiangshan, Li Zefan, Peter Zijlstra,
	Srikar Dronamraju, Tom Zanussi, systemtap, DLE

On Fri, 2009-09-25 at 11:19 -0700, Masami Hiramatsu wrote:
> Hi Frederic,
> 
> Here is a few updates for kprobe-tracer which fix reported bugs and
> is for catching up the latest ftrace.
> 
>  - Use dynamic percpu profiling buffer patch is for catching up
>    the latest ftrace change.
>  - Checking the result of create_event_dir() patch improves ftrace
>    code pointed by Li Zefan (thanks!).
>  - Add VIA instructions to x86 insn decoder patch fixes decoding
>    bug reported by Ingo Molnar (thanks!).
> 
> Soon after this series, I'll send perf-kprobe patch series.

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH tracing/kprobes 3/3] tracing/ftrace: Fix to check create_event_dir() when adding new events
  2009-09-25 18:20 ` [PATCH tracing/kprobes 3/3] tracing/ftrace: Fix to check create_event_dir() when adding new events Masami Hiramatsu
@ 2009-10-03  0:56   ` Frederic Weisbecker
  2009-10-17 10:02   ` [tip:perf/probes] " tip-bot for Masami Hiramatsu
  1 sibling, 0 replies; 10+ messages in thread
From: Frederic Weisbecker @ 2009-10-03  0:56 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Steven Rostedt, Ingo Molnar, lkml, systemtap, DLE, Jim Keniston,
	Ananth N Mavinakayanahalli, Andi Kleen, Christoph Hellwig,
	Frank Ch. Eigler, H. Peter Anvin, Jason Baron, K.Prasad,
	Lai Jiangshan, Li Zefan, Peter Zijlstra, Srikar Dronamraju,
	Tom Zanussi

On Fri, Sep 25, 2009 at 11:20:54AM -0700, Masami Hiramatsu wrote:
> Check result of create_event_dir() and add ftrace_event_call to
> ftrace_events list only if it is succeeded. Thanks Li for pointing it out.
> 
> Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Jim Keniston <jkenisto@us.ibm.com>
> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
> Cc: Andi Kleen <ak@linux.intel.com>
> Cc: Christoph Hellwig <hch@infradead.org>
> Cc: Frank Ch. Eigler <fche@redhat.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Jason Baron <jbaron@redhat.com>
> Cc: K.Prasad <prasad@linux.vnet.ibm.com>
> Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
> Cc: Li Zefan <lizf@cn.fujitsu.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> Cc: Tom Zanussi <tzanussi@gmail.com>
> ---
> 
>  kernel/trace/trace_events.c |   29 +++++++++++++++++++++--------
>  1 files changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index a4b7c9a..f03cda3 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -957,12 +957,14 @@ static int __trace_add_event_call(struct ftrace_event_call *call)
>  	if (!d_events)
>  		return -ENOENT;
>  
> -	list_add(&call->list, &ftrace_events);
>  	ret = event_create_dir(call, d_events, &ftrace_event_id_fops,
>  				&ftrace_enable_fops, &ftrace_event_filter_fops,
>  				&ftrace_event_format_fops);
>  	if (ret < 0)
> -		list_del(&call->list);
> +		pr_warning("Could not create directory of trace events/%s\n",
> +			   call->name);




We already have such warnings in event_create_dir, with even more granularity
against the failure reason. The patch is fine, but I'll just remove the warning
introduced inside while applying it.

Thanks.


PS: Also I guess we could add the event in the list right from
event_create_dir()...


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH tracing/kprobes 0/3] tracing/kprobes: kprobe-tracer updates
  2009-09-25 18:19 [PATCH tracing/kprobes 0/3] tracing/kprobes: kprobe-tracer updates Masami Hiramatsu
                   ` (3 preceding siblings ...)
  2009-09-26  9:08 ` [PATCH tracing/kprobes 0/3] tracing/kprobes: kprobe-tracer updates Steven Rostedt
@ 2009-10-03  0:57 ` Frederic Weisbecker
  4 siblings, 0 replies; 10+ messages in thread
From: Frederic Weisbecker @ 2009-10-03  0:57 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Steven Rostedt, Ingo Molnar, lkml, Ananth N Mavinakayanahalli,
	Andi Kleen, Christoph Hellwig, Frank Ch. Eigler, H. Peter Anvin,
	Jason Baron, Jim Keniston, K.Prasad, Lai Jiangshan, Li Zefan,
	Peter Zijlstra, Srikar Dronamraju, Tom Zanussi, systemtap, DLE

On Fri, Sep 25, 2009 at 11:19:52AM -0700, Masami Hiramatsu wrote:
> Hi Frederic,
> 
> Here is a few updates for kprobe-tracer which fix reported bugs and
> is for catching up the latest ftrace.
> 
>  - Use dynamic percpu profiling buffer patch is for catching up
>    the latest ftrace change.
>  - Checking the result of create_event_dir() patch improves ftrace
>    code pointed by Li Zefan (thanks!).
>  - Add VIA instructions to x86 insn decoder patch fixes decoding
>    bug reported by Ingo Molnar (thanks!).
> 
> Soon after this series, I'll send perf-kprobe patch series.
> 
> Thank you,


Applied, thanks Masami!


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [tip:perf/probes] tracing/kprobes: Use global event perf buffers in kprobe tracer
  2009-09-25 18:20 ` [PATCH tracing/kprobes 1/3] tracing/kprobes: Use global event profile buffer in kprobe tracer Masami Hiramatsu
@ 2009-10-17 10:02   ` tip-bot for Masami Hiramatsu
  0 siblings, 0 replies; 10+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2009-10-17 10:02 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, peterz, fweisbec, rostedt, ak, jbaron, tglx, laijs,
	mhiramat, linux-kernel, hpa, fche, jkenisto, tzanussi, lizf, hch,
	ananth, srikar, mingo, prasad

Commit-ID:  a1a138d05fa060ac4238c19a1e890aacc25ed3ba
Gitweb:     http://git.kernel.org/tip/a1a138d05fa060ac4238c19a1e890aacc25ed3ba
Author:     Masami Hiramatsu <mhiramat@redhat.com>
AuthorDate: Fri, 25 Sep 2009 11:20:12 -0700
Committer:  Frederic Weisbecker <fweisbec@gmail.com>
CommitDate: Sat, 3 Oct 2009 02:21:39 +0200

tracing/kprobes: Use global event perf buffers in kprobe tracer

Use new percpu global event buffer instead of stack in kprobe
tracer while tracing through perf.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <20090925182011.10157.60140.stgit@omoto>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 kernel/trace/trace_kprobe.c |  115 +++++++++++++++++++++++++++----------------
 1 files changed, 73 insertions(+), 42 deletions(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 09cba27..97309d4 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1149,35 +1149,49 @@ static __kprobes int kprobe_profile_func(struct kprobe *kp,
 	struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);
 	struct ftrace_event_call *call = &tp->call;
 	struct kprobe_trace_entry *entry;
-	int size, __size, i, pc;
+	struct trace_entry *ent;
+	int size, __size, i, pc, __cpu;
 	unsigned long irq_flags;
+	char *raw_data;
 
-	local_save_flags(irq_flags);
 	pc = preempt_count();
-
 	__size = SIZEOF_KPROBE_TRACE_ENTRY(tp->nr_args);
 	size = ALIGN(__size + sizeof(u32), sizeof(u64));
 	size -= sizeof(u32);
+	if (WARN_ONCE(size > FTRACE_MAX_PROFILE_SIZE,
+		     "profile buffer not large enough"))
+		return 0;
 
-	do {
-		char raw_data[size];
-		struct trace_entry *ent;
-		/*
-		 * Zero dead bytes from alignment to avoid stack leak
-		 * to userspace
-		 */
-		*(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
-		entry = (struct kprobe_trace_entry *)raw_data;
-		ent = &entry->ent;
-
-		tracing_generic_entry_update(ent, irq_flags, pc);
-		ent->type = call->id;
-		entry->nargs = tp->nr_args;
-		entry->ip = (unsigned long)kp->addr;
-		for (i = 0; i < tp->nr_args; i++)
-			entry->args[i] = call_fetch(&tp->args[i].fetch, regs);
-		perf_tp_event(call->id, entry->ip, 1, entry, size);
-	} while (0);
+	/*
+	 * Protect the non nmi buffer
+	 * This also protects the rcu read side
+	 */
+	local_irq_save(irq_flags);
+	__cpu = smp_processor_id();
+
+	if (in_nmi())
+		raw_data = rcu_dereference(trace_profile_buf_nmi);
+	else
+		raw_data = rcu_dereference(trace_profile_buf);
+
+	if (!raw_data)
+		goto end;
+
+	raw_data = per_cpu_ptr(raw_data, __cpu);
+	/* Zero dead bytes from alignment to avoid buffer leak to userspace */
+	*(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
+	entry = (struct kprobe_trace_entry *)raw_data;
+	ent = &entry->ent;
+
+	tracing_generic_entry_update(ent, irq_flags, pc);
+	ent->type = call->id;
+	entry->nargs = tp->nr_args;
+	entry->ip = (unsigned long)kp->addr;
+	for (i = 0; i < tp->nr_args; i++)
+		entry->args[i] = call_fetch(&tp->args[i].fetch, regs);
+	perf_tp_event(call->id, entry->ip, 1, entry, size);
+end:
+	local_irq_restore(irq_flags);
 	return 0;
 }
 
@@ -1188,33 +1202,50 @@ static __kprobes int kretprobe_profile_func(struct kretprobe_instance *ri,
 	struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
 	struct ftrace_event_call *call = &tp->call;
 	struct kretprobe_trace_entry *entry;
-	int size, __size, i, pc;
+	struct trace_entry *ent;
+	int size, __size, i, pc, __cpu;
 	unsigned long irq_flags;
+	char *raw_data;
 
-	local_save_flags(irq_flags);
 	pc = preempt_count();
-
 	__size = SIZEOF_KRETPROBE_TRACE_ENTRY(tp->nr_args);
 	size = ALIGN(__size + sizeof(u32), sizeof(u64));
 	size -= sizeof(u32);
+	if (WARN_ONCE(size > FTRACE_MAX_PROFILE_SIZE,
+		     "profile buffer not large enough"))
+		return 0;
+
+	/*
+	 * Protect the non nmi buffer
+	 * This also protects the rcu read side
+	 */
+	local_irq_save(irq_flags);
+	__cpu = smp_processor_id();
+
+	if (in_nmi())
+		raw_data = rcu_dereference(trace_profile_buf_nmi);
+	else
+		raw_data = rcu_dereference(trace_profile_buf);
+
+	if (!raw_data)
+		goto end;
+
+	raw_data = per_cpu_ptr(raw_data, __cpu);
+	/* Zero dead bytes from alignment to avoid buffer leak to userspace */
+	*(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
+	entry = (struct kretprobe_trace_entry *)raw_data;
+	ent = &entry->ent;
 
-	do {
-		char raw_data[size];
-		struct trace_entry *ent;
-
-		*(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
-		entry = (struct kretprobe_trace_entry *)raw_data;
-		ent = &entry->ent;
-
-		tracing_generic_entry_update(ent, irq_flags, pc);
-		ent->type = call->id;
-		entry->nargs = tp->nr_args;
-		entry->func = (unsigned long)tp->rp.kp.addr;
-		entry->ret_ip = (unsigned long)ri->ret_addr;
-		for (i = 0; i < tp->nr_args; i++)
-			entry->args[i] = call_fetch(&tp->args[i].fetch, regs);
-		perf_tp_event(call->id, entry->ret_ip, 1, entry, size);
-	} while (0);
+	tracing_generic_entry_update(ent, irq_flags, pc);
+	ent->type = call->id;
+	entry->nargs = tp->nr_args;
+	entry->func = (unsigned long)tp->rp.kp.addr;
+	entry->ret_ip = (unsigned long)ri->ret_addr;
+	for (i = 0; i < tp->nr_args; i++)
+		entry->args[i] = call_fetch(&tp->args[i].fetch, regs);
+	perf_tp_event(call->id, entry->ret_ip, 1, entry, size);
+end:
+	local_irq_restore(irq_flags);
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [tip:perf/probes] x86: Add VIA processor instructions in opcodes decoder
  2009-09-25 18:20 ` [PATCH tracing/kprobes 2/3] x86: Add VIA processor instructions Masami Hiramatsu
@ 2009-10-17 10:02   ` tip-bot for Masami Hiramatsu
  0 siblings, 0 replies; 10+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2009-10-17 10:02 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, peterz, fweisbec, rostedt, ak, jbaron, tglx, laijs,
	mhiramat, linux-kernel, hpa, fche, jkenisto, tzanussi, lizf, hch,
	ananth, srikar, mingo, prasad

Commit-ID:  c0b11d3af164947c71e2491912c5b8418900dafb
Gitweb:     http://git.kernel.org/tip/c0b11d3af164947c71e2491912c5b8418900dafb
Author:     Masami Hiramatsu <mhiramat@redhat.com>
AuthorDate: Fri, 25 Sep 2009 11:20:38 -0700
Committer:  Frederic Weisbecker <fweisbec@gmail.com>
CommitDate: Sat, 3 Oct 2009 02:43:00 +0200

x86: Add VIA processor instructions in opcodes decoder

Add VIA processor's Padlock instructions(MONTMUL, XSHA1, XSHA256)
as parts of the kernel may use them.

This fixes the following crash in opcodes decoder selftests:

 make[2]: `scripts/unifdef' is up to date.
   TEST    posttest
 Error: c145cf71:        f3 0f a6 d0             repz xsha256
 Error: objdump says 4 bytes, but insn_get_length() says 3 (attr:0)
 make[1]: *** [posttest] Error 2
 make: *** [bzImage] Error 2

Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <20090925182037.10157.3180.stgit@omoto>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 arch/x86/lib/x86-opcode-map.txt |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/arch/x86/lib/x86-opcode-map.txt b/arch/x86/lib/x86-opcode-map.txt
index 59e20d5..78a0daf 100644
--- a/arch/x86/lib/x86-opcode-map.txt
+++ b/arch/x86/lib/x86-opcode-map.txt
@@ -469,7 +469,7 @@ a2: CPUID
 a3: BT Ev,Gv
 a4: SHLD Ev,Gv,Ib
 a5: SHLD Ev,Gv,CL
-a6:
+a6: GrpPDLK
 a7: GrpRNG
 a8: PUSH GS (d64)
 a9: POP GS (d64)
@@ -803,6 +803,12 @@ GrpTable: Grp16
 3: prefetch T2
 EndTable
 
+GrpTable: GrpPDLK
+0: MONTMUL
+1: XSHA1
+2: XSHA2
+EndTable
+
 GrpTable: GrpRNG
 0: xstore-rng
 1: xcrypt-ecb

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [tip:perf/probes] tracing/ftrace: Fix to check create_event_dir() when adding new events
  2009-09-25 18:20 ` [PATCH tracing/kprobes 3/3] tracing/ftrace: Fix to check create_event_dir() when adding new events Masami Hiramatsu
  2009-10-03  0:56   ` Frederic Weisbecker
@ 2009-10-17 10:02   ` tip-bot for Masami Hiramatsu
  1 sibling, 0 replies; 10+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2009-10-17 10:02 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, peterz, fweisbec, rostedt, ak, jbaron, tglx, laijs,
	mhiramat, linux-kernel, hpa, fche, jkenisto, tzanussi, lizf, hch,
	ananth, srikar, mingo, prasad

Commit-ID:  88f70d7590538e427c8405a2e02ac2624847386c
Gitweb:     http://git.kernel.org/tip/88f70d7590538e427c8405a2e02ac2624847386c
Author:     Masami Hiramatsu <mhiramat@redhat.com>
AuthorDate: Fri, 25 Sep 2009 11:20:54 -0700
Committer:  Frederic Weisbecker <fweisbec@gmail.com>
CommitDate: Sat, 3 Oct 2009 03:04:58 +0200

tracing/ftrace: Fix to check create_event_dir() when adding new events

Check result of event_create_dir() and add ftrace_event_call to
ftrace_events list only if it is succeeded. Thanks to Li for pointing
it out.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <20090925182054.10157.55219.stgit@omoto>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 kernel/trace/trace_events.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index a4b7c9a..155b5d5 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -957,12 +957,12 @@ static int __trace_add_event_call(struct ftrace_event_call *call)
 	if (!d_events)
 		return -ENOENT;
 
-	list_add(&call->list, &ftrace_events);
 	ret = event_create_dir(call, d_events, &ftrace_event_id_fops,
 				&ftrace_enable_fops, &ftrace_event_filter_fops,
 				&ftrace_event_format_fops);
-	if (ret < 0)
-		list_del(&call->list);
+	if (!ret)
+		list_add(&call->list, &ftrace_events);
+
 	return ret;
 }
 
@@ -1124,10 +1124,11 @@ static void trace_module_add_events(struct module *mod)
 				return;
 		}
 		call->mod = mod;
-		list_add(&call->list, &ftrace_events);
-		event_create_dir(call, d_events,
-				 &file_ops->id, &file_ops->enable,
-				 &file_ops->filter, &file_ops->format);
+		ret = event_create_dir(call, d_events,
+				       &file_ops->id, &file_ops->enable,
+				       &file_ops->filter, &file_ops->format);
+		if (!ret)
+			list_add(&call->list, &ftrace_events);
 	}
 }
 
@@ -1267,10 +1268,12 @@ static __init int event_trace_init(void)
 				continue;
 			}
 		}
-		list_add(&call->list, &ftrace_events);
-		event_create_dir(call, d_events, &ftrace_event_id_fops,
-				 &ftrace_enable_fops, &ftrace_event_filter_fops,
-				 &ftrace_event_format_fops);
+		ret = event_create_dir(call, d_events, &ftrace_event_id_fops,
+				       &ftrace_enable_fops,
+				       &ftrace_event_filter_fops,
+				       &ftrace_event_format_fops);
+		if (!ret)
+			list_add(&call->list, &ftrace_events);
 	}
 
 	while (true) {

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-10-17 10:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-25 18:19 [PATCH tracing/kprobes 0/3] tracing/kprobes: kprobe-tracer updates Masami Hiramatsu
2009-09-25 18:20 ` [PATCH tracing/kprobes 1/3] tracing/kprobes: Use global event profile buffer in kprobe tracer Masami Hiramatsu
2009-10-17 10:02   ` [tip:perf/probes] tracing/kprobes: Use global event perf buffers " tip-bot for Masami Hiramatsu
2009-09-25 18:20 ` [PATCH tracing/kprobes 2/3] x86: Add VIA processor instructions Masami Hiramatsu
2009-10-17 10:02   ` [tip:perf/probes] x86: Add VIA processor instructions in opcodes decoder tip-bot for Masami Hiramatsu
2009-09-25 18:20 ` [PATCH tracing/kprobes 3/3] tracing/ftrace: Fix to check create_event_dir() when adding new events Masami Hiramatsu
2009-10-03  0:56   ` Frederic Weisbecker
2009-10-17 10:02   ` [tip:perf/probes] " tip-bot for Masami Hiramatsu
2009-09-26  9:08 ` [PATCH tracing/kprobes 0/3] tracing/kprobes: kprobe-tracer updates Steven Rostedt
2009-10-03  0:57 ` Frederic Weisbecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).