Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1674437

[PATCH v4 3/3] tracing/ftrace: Add support to record and display tgid

From Joel Fernandes <joelaf@google.com>
Newsgroups linux.kernel
Subject [PATCH v4 3/3] tracing/ftrace: Add support to record and display tgid
Date 2017-06-26 07:40 +0200
Message-ID <tWuUG-6FZ-19@gated-at.bofh.it> (permalink)
References <tWuUG-6FZ-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Make function tracer able to record tgid if/when record-tgid is enabled.

Cc: kernel-team@android.com
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Tested-by: Michael Sartain <mikesart@gmail.com>
Signed-off-by: Joel Fernandes <joelaf@google.com>
---
 kernel/trace/trace_functions.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index a3bddbfd0874..d6bdc38ab273 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -27,6 +27,7 @@ static void
 function_stack_trace_call(unsigned long ip, unsigned long parent_ip,
 			  struct ftrace_ops *op, struct pt_regs *pt_regs);
 static struct tracer_flags func_flags;
+static bool tgid_recorded;
 
 /* Our option */
 enum {
@@ -104,6 +105,11 @@ static int function_trace_init(struct trace_array *tr)
 	put_cpu();
 
 	tracing_start_cmdline_record();
+
+	if (tr->trace_flags & TRACE_ITER_RECORD_TGID) {
+		tgid_recorded = true;
+		tracing_start_tgid_record();
+	}
 	tracing_start_function_trace(tr);
 	return 0;
 }
@@ -112,6 +118,10 @@ static void function_trace_reset(struct trace_array *tr)
 {
 	tracing_stop_function_trace(tr);
 	tracing_stop_cmdline_record();
+	if (tgid_recorded) {
+		tracing_stop_tgid_record();
+		tgid_recorded = false;
+	}
 	ftrace_reset_array_ops(tr);
 }
 
@@ -252,6 +262,21 @@ func_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
 	return 0;
 }
 
+static int
+func_tracer_flag_changed(struct trace_array *tr, unsigned int mask,
+			 int enabled)
+{
+	if (mask == TRACE_ITER_RECORD_TGID) {
+		tgid_recorded = !!enabled;
+		if (enabled)
+			tracing_start_tgid_record();
+		else
+			tracing_stop_tgid_record();
+	}
+
+	return 0;
+}
+
 static struct tracer function_trace __tracer_data =
 {
 	.name		= "function",
@@ -260,6 +285,7 @@ static struct tracer function_trace __tracer_data =
 	.start		= function_trace_start,
 	.flags		= &func_flags,
 	.set_flag	= func_set_flag,
+	.flag_changed	= func_tracer_flag_changed,
 	.allow_instances = true,
 #ifdef CONFIG_FTRACE_SELFTEST
 	.selftest	= trace_selftest_startup_function,
-- 
2.13.1.611.g7e3b11ae1-goog

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4 0/3] tracing: Add support for recording tgid of tasks  Joel Fernandes <joelaf@google.com> - 2017-06-26 07:40 +0200
  [PATCH v4 3/3] tracing/ftrace: Add support to record and display tgid Joel Fernandes <joelaf@google.com> - 2017-06-26 07:40 +0200
    Re: [PATCH v4 3/3] tracing/ftrace: Add support to record and display tgid Joel Fernandes <joelaf@google.com> - 2017-06-27 05:20 +0200
  [PATCH v4 1/3] tracing: Add support for recording tgid of tasks Joel Fernandes <joelaf@google.com> - 2017-06-26 07:40 +0200
    Re: [PATCH v4 1/3] tracing: Add support for recording tgid of tasks Steven Rostedt <rostedt@goodmis.org> - 2017-06-26 19:00 +0200
      Re: [PATCH v4 1/3] tracing: Add support for recording tgid of tasks Steven Rostedt <rostedt@goodmis.org> - 2017-06-26 21:10 +0200
      Re: [PATCH v4 1/3] tracing: Add support for recording tgid of tasks Joel Fernandes <joelaf@google.com> - 2017-06-26 21:10 +0200
        Re: [PATCH v4 1/3] tracing: Add support for recording tgid of tasks Joel Fernandes <joelaf@google.com> - 2017-06-26 21:20 +0200
          Re: [PATCH v4 1/3] tracing: Add support for recording tgid of tasks Steven Rostedt <rostedt@goodmis.org> - 2017-06-26 21:30 +0200
        Re: [PATCH v4 1/3] tracing: Add support for recording tgid of tasks Joel Fernandes <joelaf@google.com> - 2017-06-26 21:20 +0200
        Re: [PATCH v4 1/3] tracing: Add support for recording tgid of tasks Steven Rostedt <rostedt@goodmis.org> - 2017-06-26 21:20 +0200
  [PATCH v4 2/3] tracing: Add support for display of tgid in trace output Joel Fernandes <joelaf@google.com> - 2017-06-26 07:40 +0200

csiph-web