linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] [GIT PULL][v3.7] tracing: Updates and fixes (for 3.7 queue)
@ 2012-09-08 11:55 Steven Rostedt
  2012-09-08 11:55 ` [PATCH 1/7] perf: Enable function tracing for perf core Steven Rostedt
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-09-08 11:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 1274 bytes --]


Ingo,

Please pull the latest tip/perf/core tree, which can be found at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
tip/perf/core

Head SHA1: d73177789872d52ab916c749357b883d56208e21


Andi Kleen (1):
      perf: Enable function tracing for perf core

Josh Triplett (1):
      trace: Stop compiling in trace_clock unconditionally

Masami Hiramatsu (3):
      ftrace/x86: Adjust x86 regs.ip as like as x86-64
      kprobes/x86: Fix kprobes to collectly handle IP on ftrace
      kprobes/x86: Fix to support jprobes on ftrace-based kprobe

Steven Rostedt (1):
      ftrace/x86-64: Allow to change RIP in handlers

Yuanhan Liu (1):
      tracing: Skip printing "OK" if failed to disable event

----
 arch/x86/kernel/cpu/Makefile |    1 -
 arch/x86/kernel/entry_32.S   |    3 +--
 arch/x86/kernel/entry_64.S   |    4 ++++
 arch/x86/kernel/kprobes.c    |   43 ++++++++++++++++++++++++++++++------------
 kernel/Makefile              |    2 +-
 kernel/events/Makefile       |    4 ----
 kernel/kprobes.c             |    3 ---
 kernel/trace/Kconfig         |    5 +++++
 kernel/trace/Makefile        |    6 +-----
 kernel/trace/trace_events.c  |    4 +++-
 10 files changed, 46 insertions(+), 29 deletions(-)

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [PATCH 1/7] perf: Enable function tracing for perf core
  2012-09-08 11:55 [PATCH 0/7] [GIT PULL][v3.7] tracing: Updates and fixes (for 3.7 queue) Steven Rostedt
@ 2012-09-08 11:55 ` Steven Rostedt
  2012-09-08 13:06   ` Frederic Weisbecker
  2012-09-08 14:15   ` Namhyung Kim
  2012-09-08 11:55 ` [PATCH 2/7] tracing: Skip printing "OK" if failed to disable event Steven Rostedt
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-09-08 11:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Andi Kleen

[-- Attachment #1: Type: text/plain, Size: 1279 bytes --]

According to Steven R. there is no reason left to not support
function tracing for the perf core. This makes it easier to debug
perf.

Don't remove -pg for the x86 and generic perf core.

Link: http://lkml.kernel.org/r/1345306530-25665-2-git-send-email-andi@firstfloor.org

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 arch/x86/kernel/cpu/Makefile |    1 -
 kernel/events/Makefile       |    4 ----
 2 files changed, 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index d30a6a9..6a16725 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -5,7 +5,6 @@
 # Don't trace early stages of a secondary CPU boot
 ifdef CONFIG_FUNCTION_TRACER
 CFLAGS_REMOVE_common.o = -pg
-CFLAGS_REMOVE_perf_event.o = -pg
 endif
 
 # Make sure load_percpu_segment has no stackprotector
diff --git a/kernel/events/Makefile b/kernel/events/Makefile
index 103f5d1..a630994 100644
--- a/kernel/events/Makefile
+++ b/kernel/events/Makefile
@@ -1,7 +1,3 @@
-ifdef CONFIG_FUNCTION_TRACER
-CFLAGS_REMOVE_core.o = -pg
-endif
-
 obj-y := core.o ring_buffer.o callchain.o
 
 obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [PATCH 2/7] tracing: Skip printing "OK" if failed to disable event
  2012-09-08 11:55 [PATCH 0/7] [GIT PULL][v3.7] tracing: Updates and fixes (for 3.7 queue) Steven Rostedt
  2012-09-08 11:55 ` [PATCH 1/7] perf: Enable function tracing for perf core Steven Rostedt
@ 2012-09-08 11:55 ` Steven Rostedt
  2012-09-08 11:55 ` [PATCH 3/7] trace: Stop compiling in trace_clock unconditionally Steven Rostedt
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-09-08 11:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Yuanhan Liu

[-- Attachment #1: Type: text/plain, Size: 920 bytes --]

No acutal case found. But logically, we should skip "OK" in case any
error met.

Link: http://lkml.kernel.org/r/1346051625-25231-1-git-send-email-yuanhan.liu@linux.intel.com

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_events.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 6825d83..bbb0e63 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1646,9 +1646,11 @@ static __init void event_trace_self_tests(void)
 		event_test_stuff();
 
 		ret = __ftrace_set_clr_event(NULL, system->name, NULL, 0);
-		if (WARN_ON_ONCE(ret))
+		if (WARN_ON_ONCE(ret)) {
 			pr_warning("error disabling system %s\n",
 				   system->name);
+			continue;
+		}
 
 		pr_cont("OK\n");
 	}
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [PATCH 3/7] trace: Stop compiling in trace_clock unconditionally
  2012-09-08 11:55 [PATCH 0/7] [GIT PULL][v3.7] tracing: Updates and fixes (for 3.7 queue) Steven Rostedt
  2012-09-08 11:55 ` [PATCH 1/7] perf: Enable function tracing for perf core Steven Rostedt
  2012-09-08 11:55 ` [PATCH 2/7] tracing: Skip printing "OK" if failed to disable event Steven Rostedt
@ 2012-09-08 11:55 ` Steven Rostedt
  2012-09-08 11:55 ` [PATCH 4/7] ftrace/x86: Adjust x86 regs.ip as like as x86-64 Steven Rostedt
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-09-08 11:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Ingo Molnar,
	Peter Zijlstra, Eric W. Biederman, Al Viro, Josh Triplett

[-- Attachment #1: Type: text/plain, Size: 2620 bytes --]

Commit 56449f437 "tracing: make the trace clocks available generally",
in April 2009, made trace_clock available unconditionally, since
CONFIG_X86_DS used it too.

Commit faa4602e47 "x86, perf, bts, mm: Delete the never used BTS-ptrace code",
in March 2010, removed CONFIG_X86_DS, and now only CONFIG_RING_BUFFER (split
out from CONFIG_TRACING for general use) has a dependency on trace_clock. So,
only compile in trace_clock with CONFIG_RING_BUFFER or CONFIG_TRACING
enabled.

Link: http://lkml.kernel.org/r/20120903024513.GA19583@leaf

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/Makefile       |    2 +-
 kernel/trace/Kconfig  |    5 +++++
 kernel/trace/Makefile |    6 +-----
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/Makefile b/kernel/Makefile
index c0cc67a..29d993b 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -98,7 +98,7 @@ obj-$(CONFIG_COMPAT_BINFMT_ELF) += elfcore.o
 obj-$(CONFIG_BINFMT_ELF_FDPIC) += elfcore.o
 obj-$(CONFIG_FUNCTION_TRACER) += trace/
 obj-$(CONFIG_TRACING) += trace/
-obj-$(CONFIG_X86_DS) += trace/
+obj-$(CONFIG_TRACE_CLOCK) += trace/
 obj-$(CONFIG_RING_BUFFER) += trace/
 obj-$(CONFIG_TRACEPOINTS) += trace/
 obj-$(CONFIG_IRQ_WORK) += irq_work.o
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 9301a0e..4cea4f4 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -62,8 +62,12 @@ config HAVE_C_RECORDMCOUNT
 config TRACER_MAX_TRACE
 	bool
 
+config TRACE_CLOCK
+	bool
+
 config RING_BUFFER
 	bool
+	select TRACE_CLOCK
 
 config FTRACE_NMI_ENTER
        bool
@@ -114,6 +118,7 @@ config TRACING
 	select NOP_TRACER
 	select BINARY_PRINTF
 	select EVENT_TRACING
+	select TRACE_CLOCK
 
 config GENERIC_TRACER
 	bool
diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
index 8370908..d7e2068 100644
--- a/kernel/trace/Makefile
+++ b/kernel/trace/Makefile
@@ -19,11 +19,7 @@ endif
 
 CFLAGS_trace_events_filter.o := -I$(src)
 
-#
-# Make the trace clocks available generally: it's infrastructure
-# relied on by ptrace for example:
-#
-obj-y += trace_clock.o
+obj-$(CONFIG_TRACE_CLOCK) += trace_clock.o
 
 obj-$(CONFIG_FUNCTION_TRACER) += libftrace.o
 obj-$(CONFIG_RING_BUFFER) += ring_buffer.o
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [PATCH 4/7] ftrace/x86: Adjust x86 regs.ip as like as x86-64
  2012-09-08 11:55 [PATCH 0/7] [GIT PULL][v3.7] tracing: Updates and fixes (for 3.7 queue) Steven Rostedt
                   ` (2 preceding siblings ...)
  2012-09-08 11:55 ` [PATCH 3/7] trace: Stop compiling in trace_clock unconditionally Steven Rostedt
@ 2012-09-08 11:55 ` Steven Rostedt
  2012-09-08 11:55 ` [PATCH 5/7] kprobes/x86: Fix kprobes to collectly handle IP on ftrace Steven Rostedt
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-09-08 11:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Peter Zijlstra, Frederic Weisbecker,
	Thomas Gleixner, H. Peter Anvin, Masami Hiramatsu

[-- Attachment #1: Type: text/plain, Size: 1796 bytes --]

Adjust x86 regs.ip to ip + MCOUNT_INSN_SIZE as like as
on x86-64. This helps us to consolidate codes which use
regs->ip on both of x86/x86-64.

Link: http://lkml.kernel.org/r/20120905143100.10329.60109.stgit@localhost.localdomain

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 arch/x86/kernel/entry_32.S |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 061ac17..f438a44 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1148,7 +1148,6 @@ ENTRY(ftrace_regs_caller)
 	 * ip location, and move flags into the return ip location.
 	 */
 	pushl 4(%esp)	/* save return ip into ip slot */
-	subl $MCOUNT_INSN_SIZE, (%esp)	/* Adjust ip */
 
 	pushl $0	/* Load 0 into orig_ax */
 	pushl %gs
@@ -1169,6 +1168,7 @@ ENTRY(ftrace_regs_caller)
 	movl $__KERNEL_CS,13*4(%esp)
 
 	movl 12*4(%esp), %eax	/* Load ip (1st parameter) */
+	subl $MCOUNT_INSN_SIZE, %eax	/* Adjust ip */
 	movl 0x4(%ebp), %edx	/* Load parent ip (2nd parameter) */
 	leal function_trace_op, %ecx /* Save ftrace_pos in 3rd parameter */
 	pushl %esp		/* Save pt_regs as 4th parameter */
@@ -1180,7 +1180,6 @@ GLOBAL(ftrace_regs_call)
 	movl 14*4(%esp), %eax	/* Move flags back into cs */
 	movl %eax, 13*4(%esp)	/* Needed to keep addl from modifying flags */
 	movl 12*4(%esp), %eax	/* Get return ip from regs->ip */
-	addl $MCOUNT_INSN_SIZE, %eax
 	movl %eax, 14*4(%esp)	/* Put return ip back for ret */
 
 	popl %ebx
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [PATCH 5/7] kprobes/x86: Fix kprobes to collectly handle IP on ftrace
  2012-09-08 11:55 [PATCH 0/7] [GIT PULL][v3.7] tracing: Updates and fixes (for 3.7 queue) Steven Rostedt
                   ` (3 preceding siblings ...)
  2012-09-08 11:55 ` [PATCH 4/7] ftrace/x86: Adjust x86 regs.ip as like as x86-64 Steven Rostedt
@ 2012-09-08 11:55 ` Steven Rostedt
  2012-09-08 11:55 ` [PATCH 6/7] ftrace/x86-64: Allow to change RIP in handlers Steven Rostedt
  2012-09-08 11:55 ` [PATCH 7/7] kprobes/x86: Fix to support jprobes on ftrace-based kprobe Steven Rostedt
  6 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-09-08 11:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Peter Zijlstra, Frederic Weisbecker,
	Thomas Gleixner, H. Peter Anvin, Masami Hiramatsu

[-- Attachment #1: Type: text/plain, Size: 1899 bytes --]

Current kprobe_ftrace_handler expects regs->ip == ip, but it is
incorrect (originally on x86-64). Actually, ftrace handler sets
regs->ip = ip + MCOUNT_INSN_SIZE.
kprobe_ftrace_handler must take care for that.

Link: http://lkml.kernel.org/r/20120905143112.10329.72069.stgit@localhost.localdomain

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 arch/x86/kernel/kprobes.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index 47ae102..f49f60c 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -1072,7 +1072,8 @@ void __kprobes kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
 	if (kprobe_running()) {
 		kprobes_inc_nmissed_count(p);
 	} else {
-		regs->ip += sizeof(kprobe_opcode_t);
+		/* Kprobe handler expects regs->ip = ip + 1 as breakpoint hit */
+		regs->ip = ip + sizeof(kprobe_opcode_t);
 
 		__this_cpu_write(current_kprobe, p);
 		kcb->kprobe_status = KPROBE_HIT_ACTIVE;
@@ -1080,13 +1081,15 @@ void __kprobes kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
 			p->pre_handler(p, regs);
 
 		if (unlikely(p->post_handler)) {
-			/* Emulate singlestep as if there is a 5byte nop */
+			/*
+			 * Emulate singlestep (and also recover regs->ip)
+			 * as if there is a 5byte nop
+			 */
 			regs->ip = ip + MCOUNT_INSN_SIZE;
 			kcb->kprobe_status = KPROBE_HIT_SSDONE;
 			p->post_handler(p, regs, 0);
 		}
 		__this_cpu_write(current_kprobe, NULL);
-		regs->ip = ip;	/* Recover for next callback */
 	}
 end:
 	local_irq_restore(flags);
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [PATCH 6/7] ftrace/x86-64: Allow to change RIP in handlers
  2012-09-08 11:55 [PATCH 0/7] [GIT PULL][v3.7] tracing: Updates and fixes (for 3.7 queue) Steven Rostedt
                   ` (4 preceding siblings ...)
  2012-09-08 11:55 ` [PATCH 5/7] kprobes/x86: Fix kprobes to collectly handle IP on ftrace Steven Rostedt
@ 2012-09-08 11:55 ` Steven Rostedt
  2012-09-08 11:55 ` [PATCH 7/7] kprobes/x86: Fix to support jprobes on ftrace-based kprobe Steven Rostedt
  6 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-09-08 11:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Peter Zijlstra, Frederic Weisbecker,
	Thomas Gleixner, H. Peter Anvin, Masami Hiramatsu

[-- Attachment #1: Type: text/plain, Size: 1077 bytes --]

Allow ftrace handlers to change RIP register (regs->ip)
in handlers. This will allow handlers to call another
function instead of original function.

Link: http://lkml.kernel.org/r/20120905143118.10329.5078.stgit@localhost.localdomain

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 arch/x86/kernel/entry_64.S |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index ed767b7..e9cc2b3 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -165,6 +165,10 @@ GLOBAL(ftrace_regs_call)
 	movq EFLAGS(%rsp), %rax
 	movq %rax, SS(%rsp)
 
+	/* Handlers can change the RIP */
+	movq RIP(%rsp), %rax
+	movq %rax, SS+8(%rsp)
+
 	/* restore the rest of pt_regs */
 	movq R15(%rsp), %r15
 	movq R14(%rsp), %r14
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [PATCH 7/7] kprobes/x86: Fix to support jprobes on ftrace-based kprobe
  2012-09-08 11:55 [PATCH 0/7] [GIT PULL][v3.7] tracing: Updates and fixes (for 3.7 queue) Steven Rostedt
                   ` (5 preceding siblings ...)
  2012-09-08 11:55 ` [PATCH 6/7] ftrace/x86-64: Allow to change RIP in handlers Steven Rostedt
@ 2012-09-08 11:55 ` Steven Rostedt
  6 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-09-08 11:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Fengguang Wu, Peter Zijlstra,
	Frederic Weisbecker, Thomas Gleixner, H. Peter Anvin,
	Masami Hiramatsu

[-- Attachment #1: Type: text/plain, Size: 4419 bytes --]

Fix kprobes/x86 to support jprobes on ftrace-based kprobes.
Because of -mfentry support of ftrace, ftrace is now put
on the beginning of function where jprobes are put.

Originally ftrace-based kprobes doesn't support jprobe
because it will change regs->ip and ftrace doesn't support
changing IP and ftrace itself doesn't conflict jprobe.
However, ftrace -mfentry support moves mcount call on the
top of functions where jprobes are put. This means that
jprobe always conflicts with ftrace-based kprobe and fails.

This patch allows ftrace-based kprobes to support jprobes
by allowing to modify regs->ip and kprobes breakpoint
handler also allows to skip singlestepping because there
is a ftrace call (not an original instruction).

Link: http://lkml.kernel.org/r/20120905143125.10329.90836.stgit@localhost.localdomain

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 arch/x86/kernel/kprobes.c |   42 +++++++++++++++++++++++++++++-------------
 kernel/kprobes.c          |    3 ---
 2 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index f49f60c..b7c2a85 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -541,6 +541,8 @@ reenter_kprobe(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb
 	return 1;
 }
 
+static void __kprobes skip_singlestep(struct kprobe *p, struct pt_regs *regs,
+				      struct kprobe_ctlblk *kcb);
 /*
  * Interrupts are disabled on entry as trap3 is an interrupt gate and they
  * remain disabled throughout this function.
@@ -599,6 +601,12 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
 	} else if (kprobe_running()) {
 		p = __this_cpu_read(current_kprobe);
 		if (p->break_handler && p->break_handler(p, regs)) {
+#ifdef KPROBES_CAN_USE_FTRACE
+			if (kprobe_ftrace(p)) {
+				skip_singlestep(p, regs, kcb);
+				return 1;
+			}
+#endif
 			setup_singlestep(p, regs, kcb, 0);
 			return 1;
 		}
@@ -1053,6 +1061,21 @@ int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
 }
 
 #ifdef KPROBES_CAN_USE_FTRACE
+static void __kprobes skip_singlestep(struct kprobe *p, struct pt_regs *regs,
+				      struct kprobe_ctlblk *kcb)
+{
+	/*
+	 * Emulate singlestep (and also recover regs->ip)
+	 * as if there is a 5byte nop
+	 */
+	regs->ip = (unsigned long)p->addr + MCOUNT_INSN_SIZE;
+	if (unlikely(p->post_handler)) {
+		kcb->kprobe_status = KPROBE_HIT_SSDONE;
+		p->post_handler(p, regs, 0);
+	}
+	__this_cpu_write(current_kprobe, NULL);
+}
+
 /* Ftrace callback handler for kprobes */
 void __kprobes kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
 				     struct ftrace_ops *ops, struct pt_regs *regs)
@@ -1077,19 +1100,12 @@ void __kprobes kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
 
 		__this_cpu_write(current_kprobe, p);
 		kcb->kprobe_status = KPROBE_HIT_ACTIVE;
-		if (p->pre_handler)
-			p->pre_handler(p, regs);
-
-		if (unlikely(p->post_handler)) {
-			/*
-			 * Emulate singlestep (and also recover regs->ip)
-			 * as if there is a 5byte nop
-			 */
-			regs->ip = ip + MCOUNT_INSN_SIZE;
-			kcb->kprobe_status = KPROBE_HIT_SSDONE;
-			p->post_handler(p, regs, 0);
-		}
-		__this_cpu_write(current_kprobe, NULL);
+		if (!p->pre_handler || !p->pre_handler(p, regs))
+			skip_singlestep(p, regs, kcb);
+		/*
+		 * If pre_handler returns !0, it sets regs->ip and
+		 * resets current kprobe.
+		 */
 	}
 end:
 	local_irq_restore(flags);
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 35b4315..098f396 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1418,9 +1418,6 @@ static __kprobes int check_kprobe_address_safe(struct kprobe *p,
 		/* Given address is not on the instruction boundary */
 		if ((unsigned long)p->addr != ftrace_addr)
 			return -EILSEQ;
-		/* break_handler (jprobe) can not work with ftrace */
-		if (p->break_handler)
-			return -EINVAL;
 		p->flags |= KPROBE_FLAG_FTRACE;
 #else	/* !KPROBES_CAN_USE_FTRACE */
 		return -EINVAL;
-- 
1.7.10.4



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH 1/7] perf: Enable function tracing for perf core
  2012-09-08 11:55 ` [PATCH 1/7] perf: Enable function tracing for perf core Steven Rostedt
@ 2012-09-08 13:06   ` Frederic Weisbecker
  2012-09-10 14:43     ` Steven Rostedt
  2012-09-13 15:58     ` Steven Rostedt
  2012-09-08 14:15   ` Namhyung Kim
  1 sibling, 2 replies; 13+ messages in thread
From: Frederic Weisbecker @ 2012-09-08 13:06 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kernel, Ingo Molnar, Andrew Morton, Andi Kleen

On Sat, Sep 08, 2012 at 07:55:16AM -0400, Steven Rostedt wrote:
> According to Steven R. there is no reason left to not support
> function tracing for the perf core. This makes it easier to debug
> perf.
> 
> Don't remove -pg for the x86 and generic perf core.

Actually, perf can use function tracing. A good reason for disabling
function tracing in perf is to avoid the overhead of recursive function
tracing, even though we are protected against tracing re-entrancy, this
still result in some overhead.

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

* Re: [PATCH 1/7] perf: Enable function tracing for perf core
  2012-09-08 11:55 ` [PATCH 1/7] perf: Enable function tracing for perf core Steven Rostedt
  2012-09-08 13:06   ` Frederic Weisbecker
@ 2012-09-08 14:15   ` Namhyung Kim
  2012-09-10 14:40     ` Steven Rostedt
  1 sibling, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2012-09-08 14:15 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kernel, Ingo Molnar, Andrew Morton, Andi Kleen

Hi Steve,

It seems you missed From: line?

Thanks,
Namhyung

On Sat, 08 Sep 2012 07:55:16 -0400, Steven Rostedt wrote:
> According to Steven R. there is no reason left to not support
> function tracing for the perf core. This makes it easier to debug
> perf.
>
> Don't remove -pg for the x86 and generic perf core.
>
> Link: http://lkml.kernel.org/r/1345306530-25665-2-git-send-email-andi@firstfloor.org
>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
>  arch/x86/kernel/cpu/Makefile |    1 -
>  kernel/events/Makefile       |    4 ----
>  2 files changed, 5 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
> index d30a6a9..6a16725 100644
> --- a/arch/x86/kernel/cpu/Makefile
> +++ b/arch/x86/kernel/cpu/Makefile
> @@ -5,7 +5,6 @@
>  # Don't trace early stages of a secondary CPU boot
>  ifdef CONFIG_FUNCTION_TRACER
>  CFLAGS_REMOVE_common.o = -pg
> -CFLAGS_REMOVE_perf_event.o = -pg
>  endif
>  
>  # Make sure load_percpu_segment has no stackprotector
> diff --git a/kernel/events/Makefile b/kernel/events/Makefile
> index 103f5d1..a630994 100644
> --- a/kernel/events/Makefile
> +++ b/kernel/events/Makefile
> @@ -1,7 +1,3 @@
> -ifdef CONFIG_FUNCTION_TRACER
> -CFLAGS_REMOVE_core.o = -pg
> -endif
> -
>  obj-y := core.o ring_buffer.o callchain.o
>  
>  obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o

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

* Re: [PATCH 1/7] perf: Enable function tracing for perf core
  2012-09-08 14:15   ` Namhyung Kim
@ 2012-09-10 14:40     ` Steven Rostedt
  0 siblings, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-09-10 14:40 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: linux-kernel, Ingo Molnar, Andrew Morton, Andi Kleen

On Sat, 2012-09-08 at 23:15 +0900, Namhyung Kim wrote:
> Hi Steve,
> 
> It seems you missed From: line?
> 
> Thanks,
> Namhyung
> 

Someone already pointed this out to me. The git pull is fine as all the
authorship is correct.

I recently reinstalled my machine and not all my scripts were in place.
My scripts does a git format-patch, and makes a quilt queue out of them.
But quilt doesn't like the headers of the files git makes, and my
scripts call another script that adds the proper 'From' lines for quilt.

That script didn't get installed properly, and quilt chopped off the git
'From' lines when it sent it out.

But don't worry, if you look at the git branch that I asked to pull,
everything is set up properly. I've also fixed my scripts so that the
next time it will add the proper From lines.

Just don't pull the patches directly from the mailing list ;-)

-- Steve



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

* Re: [PATCH 1/7] perf: Enable function tracing for perf core
  2012-09-08 13:06   ` Frederic Weisbecker
@ 2012-09-10 14:43     ` Steven Rostedt
  2012-09-13 15:58     ` Steven Rostedt
  1 sibling, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-09-10 14:43 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: linux-kernel, Ingo Molnar, Andrew Morton, Andi Kleen

On Sat, 2012-09-08 at 15:06 +0200, Frederic Weisbecker wrote:
> On Sat, Sep 08, 2012 at 07:55:16AM -0400, Steven Rostedt wrote:
> > According to Steven R. there is no reason left to not support
> > function tracing for the perf core. This makes it easier to debug
> > perf.
> > 
> > Don't remove -pg for the x86 and generic perf core.
> 
> Actually, perf can use function tracing. A good reason for disabling
> function tracing in perf is to avoid the overhead of recursive function
> tracing, even though we are protected against tracing re-entrancy, this
> still result in some overhead.

Yes, but perf shouldn't do a full function trace. It should be filtering
on what functions it wants to trace, and if it needs to, we can easily
make it not trace its own functions.

I've been thinking about adding function tracing into the trace
directory. As there's been several times I wanted it. The only files
that really shouldn't be traced in there is ftrace.c, trace_function.c
and trace_function_graph.c. The rest I believe is fair game.

-- Steve



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

* Re: [PATCH 1/7] perf: Enable function tracing for perf core
  2012-09-08 13:06   ` Frederic Weisbecker
  2012-09-10 14:43     ` Steven Rostedt
@ 2012-09-13 15:58     ` Steven Rostedt
  1 sibling, 0 replies; 13+ messages in thread
From: Steven Rostedt @ 2012-09-13 15:58 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: linux-kernel, Ingo Molnar, Andrew Morton, Andi Kleen

On Sat, 2012-09-08 at 15:06 +0200, Frederic Weisbecker wrote:
> On Sat, Sep 08, 2012 at 07:55:16AM -0400, Steven Rostedt wrote:
> > According to Steven R. there is no reason left to not support
> > function tracing for the perf core. This makes it easier to debug
> > perf.
> > 
> > Don't remove -pg for the x86 and generic perf core.
> 
> Actually, perf can use function tracing. A good reason for disabling
> function tracing in perf is to avoid the overhead of recursive function
> tracing, even though we are protected against tracing re-entrancy, this
> still result in some overhead.

As I believe the patch set is being held off due to whether or not to
function trace perf, I'll rebase without it, and push the result again.
I'll add this to the queue of patches I have to trace the event
functions as well, as they seem to do the same things.

-- Steve



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

end of thread, other threads:[~2012-09-13 15:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-08 11:55 [PATCH 0/7] [GIT PULL][v3.7] tracing: Updates and fixes (for 3.7 queue) Steven Rostedt
2012-09-08 11:55 ` [PATCH 1/7] perf: Enable function tracing for perf core Steven Rostedt
2012-09-08 13:06   ` Frederic Weisbecker
2012-09-10 14:43     ` Steven Rostedt
2012-09-13 15:58     ` Steven Rostedt
2012-09-08 14:15   ` Namhyung Kim
2012-09-10 14:40     ` Steven Rostedt
2012-09-08 11:55 ` [PATCH 2/7] tracing: Skip printing "OK" if failed to disable event Steven Rostedt
2012-09-08 11:55 ` [PATCH 3/7] trace: Stop compiling in trace_clock unconditionally Steven Rostedt
2012-09-08 11:55 ` [PATCH 4/7] ftrace/x86: Adjust x86 regs.ip as like as x86-64 Steven Rostedt
2012-09-08 11:55 ` [PATCH 5/7] kprobes/x86: Fix kprobes to collectly handle IP on ftrace Steven Rostedt
2012-09-08 11:55 ` [PATCH 6/7] ftrace/x86-64: Allow to change RIP in handlers Steven Rostedt
2012-09-08 11:55 ` [PATCH 7/7] kprobes/x86: Fix to support jprobes on ftrace-based kprobe Steven Rostedt

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).