linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joel Fernandes <joelaf@google.com>
To: linux-kernel@vger.kernel.org
Cc: mikesart@gmail.com, Joel Fernandes <joelaf@google.com>,
	kernel-team@android.com, Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: [PATCH RFC v3 4/4] tracing/ftrace: Add support to record and display tgid
Date: Thu,  8 Jun 2017 19:53:27 -0700	[thread overview]
Message-ID: <20170609025327.9508-5-joelaf@google.com> (raw)
In-Reply-To: <20170609025327.9508-1-joelaf@google.com>

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.0.506.g27d5fe0cd-goog

      parent reply	other threads:[~2017-06-09  2:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09  2:53 [PATCH RFC v3 0/4] Add support to record and display tgid of tasks Joel Fernandes
2017-06-09  2:53 ` [PATCH RFC v3 1/4] tracing: Remove unused declaration of trace_stop_cmdline_recording Joel Fernandes
2017-06-13 18:19   ` Steven Rostedt
2017-06-09  2:53 ` [PATCH RFC v3 2/4] tracing: Add support for recording tgid of tasks Joel Fernandes
2017-06-13 18:52   ` Steven Rostedt
2017-06-13 23:47     ` Joel Fernandes
2017-06-09  2:53 ` [PATCH RFC v3 3/4] tracing: Add support for display of tgid in trace output Joel Fernandes
2017-06-09  2:53 ` Joel Fernandes [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170609025327.9508-5-joelaf@google.com \
    --to=joelaf@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikesart@gmail.com \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).