lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1303382458-11072-3-git-send-email-jolsa@redhat.com>
Date:	Thu, 21 Apr 2011 12:40:57 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	rostedt@...dmis.org, fweisbec@...il.com, mingo@...hat.com,
	a.p.zijlstra@...llo.nl
Cc:	linux-kernel@...r.kernel.org
Subject: [RFC,PATCH 2/3] trace,perf: add support for registering ftrace/function tracepoint event via perf

Added support to enable ftrace/function tracepoint via perf interface.

wbr,
jirka
---
 kernel/trace/ftrace.c |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 00fe267..49fbc8c 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3228,10 +3228,41 @@ ftrace_function_call_trace(unsigned long ip, unsigned long parent_ip)
 	local_irq_restore(flags);
 }
 
+static void
+ftrace_function_call_perf(unsigned long ip, unsigned long parent_ip)
+{
+	struct ftrace_entry *entry;
+	struct hlist_head *head;
+	unsigned long flags;
+	int rctx;
+
+	local_irq_save(flags);
+
+	BUILD_BUG_ON(sizeof(*entry) > PERF_MAX_TRACE_SIZE);
+
+	entry = (struct ftrace_entry *) perf_trace_buf_prepare(sizeof(*entry),
+						TRACE_FN, NULL, &rctx);
+	if (!entry)
+		return;
+
+	entry->ip = ip;
+	entry->parent_ip = parent_ip;
+
+	head = this_cpu_ptr(event_function.perf_events);
+	perf_trace_buf_submit(entry, sizeof(*entry), rctx, 0,
+			      1, NULL, head);
+
+	local_irq_restore(flags);
+}
+
 static struct ftrace_ops ftrace_trace_ops __read_mostly = {
 	.func = ftrace_function_call_trace,
 };
 
+static struct ftrace_ops ftrace_perf_ops __read_mostly = {
+	.func = ftrace_function_call_perf,
+};
+
 int ftrace_event_class_register(struct ftrace_event_call *call,
 				enum trace_reg type)
 {
@@ -3246,8 +3277,9 @@ int ftrace_event_class_register(struct ftrace_event_call *call,
 	case TRACE_REG_UNREGISTER:
 		return unregister_ftrace_function(&ftrace_trace_ops);
 	case TRACE_REG_PERF_REGISTER:
+		return register_ftrace_function(&ftrace_perf_ops);
 	case TRACE_REG_PERF_UNREGISTER:
-		break;
+		return unregister_ftrace_function(&ftrace_perf_ops);
 	}
 
 	return -EINVAL;
-- 
1.7.1

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ