mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Vladislav Valtchev (VMware)" <vladislav.valtchev@gmail.com>
To: rostedt@goodmis.org
Cc: linux-kernel@vger.kernel.org, y.karadz@gmail.com,
	"Vladislav Valtchev (VMware)" <vladislav.valtchev@gmail.com>
Subject: [PATCH v2 09/10] trace-cmd: Extract finalize_record_trace()
Date: Thu, 30 Nov 2017 15:19:56 +0200	[thread overview]
Message-ID: <20171130131957.21617-10-vladislav.valtchev@gmail.com> (raw)
In-Reply-To: <20171130131957.21617-1-vladislav.valtchev@gmail.com>

This patch splits record_trace() in two parts by moving its finalization part
in a separate function. This will also allow splitting out trace-cmd extract
code from trace-cmd record code, by using a shared function.

Signed-off-by: Vladislav Valtchev (VMware) <vladislav.valtchev@gmail.com>
---
 trace-record.c | 48 ++++++++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/trace-record.c b/trace-record.c
index ec0eaed..749c205 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -4767,6 +4767,31 @@ static enum trace_type get_trace_cmd_type(enum trace_cmd cmd)
 	die("Trace type UNKNOWN for the given cmd_fun");
 }
 
+static void finalize_record_trace(struct common_record_context *ctx)
+{
+	if (keep)
+		return;
+
+	update_reset_files();
+	update_reset_triggers();
+	if (clear_function_filters)
+		clear_func_filters();
+
+	set_plugin("nop");
+
+	tracecmd_remove_instances();
+
+	/* If tracing_on was enabled before we started, set it on now */
+	for_all_instances(ctx->instance) {
+		if (ctx->instance->keep)
+			write_tracing_on(ctx->instance,
+					 ctx->instance->tracing_on_init_val);
+	}
+
+	if (host)
+		tracecmd_output_close(network_handle);
+}
+
 /*
  * This function contains common code for the following commands:
  * record, start, extract, stream, profile.
@@ -4910,28 +4935,7 @@ static void record_trace(int argc, char **argv,
 		print_stats();
 
 	destroy_stats();
-
-	if (keep)
-		return;
-
-	update_reset_files();
-	update_reset_triggers();
-	if (clear_function_filters)
-		clear_func_filters();
-
-	set_plugin("nop");
-
-	tracecmd_remove_instances();
-
-	/* If tracing_on was enabled before we started, set it on now */
-	for_all_instances(ctx->instance) {
-		if (ctx->instance->keep)
-			write_tracing_on(ctx->instance,
-					 ctx->instance->tracing_on_init_val);
-	}
-
-	if (host)
-		tracecmd_output_close(network_handle);
+	finalize_record_trace(ctx);
 }
 
 void trace_start(int argc, char **argv)
-- 
2.14.1

  parent reply	other threads:[~2017-11-30 13:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30 13:19 [PATCH v2 00/10] trace-cmd: Refactoring trace_record() Vladislav Valtchev (VMware)
2017-11-30 13:19 ` [PATCH v2 01/10] trace-cmd: Extract parse_record_options() from trace_record() Vladislav Valtchev (VMware)
2017-11-30 13:19 ` [PATCH v2 02/10] trace-cmd: Replacing cmd flags w/ a trace_cmd enum Vladislav Valtchev (VMware)
2017-11-30 13:19 ` [PATCH v2 03/10] trace-cmd: Extracting record_trace() Vladislav Valtchev (VMware)
2017-11-30 13:19 ` [PATCH v2 04/10] trace-cmd: Rename trace_profile() to do_trace_profile() Vladislav Valtchev (VMware)
2017-11-30 13:19 ` [PATCH v2 05/10] trace-cmd: Making start,extract,stream,profile separate funcs Vladislav Valtchev (VMware)
2017-11-30 13:19 ` [PATCH v2 06/10] trace-cmd: Extr. profile-specific code from record_trace Vladislav Valtchev (VMware)
2017-11-30 17:05   ` Steven Rostedt
2017-12-01 11:10     ` Vladislav Valtchev
2017-11-30 13:19 ` [PATCH v2 07/10] trace-cmd: Mov init_common_record_context in parse_record_options Vladislav Valtchev (VMware)
2017-11-30 17:07   ` Steven Rostedt
2017-12-01 11:20     ` Vladislav Valtchev
2017-11-30 13:19 ` [PATCH v2 08/10] trace-cmd: Introducing get_trace_cmd_type() Vladislav Valtchev (VMware)
2017-11-30 13:19 ` Vladislav Valtchev (VMware) [this message]
2017-11-30 13:19 ` [PATCH v2 10/10] trace-cmd: Fork record_trace() for the extract case Vladislav Valtchev (VMware)
2017-11-30 21:37 ` [PATCH v2 00/10] trace-cmd: Refactoring trace_record() Steven Rostedt
2017-12-01 10:46   ` Vladislav Valtchev

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=20171130131957.21617-10-vladislav.valtchev@gmail.com \
    --to=vladislav.valtchev@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=y.karadz@gmail.com \
    /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

all inboxes | Powered by JetHome®