All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Subject: [PATCH 37/38] trace-cmd: Have keep and profile be flags of buffer instance
Date: Wed, 03 Jan 2018 12:52:39 -0500	[thread overview]
Message-ID: <20180103175340.225782044@goodmis.org> (raw)
In-Reply-To: 20180103175202.044283643@goodmis.org

[-- Attachment #1: 0037-trace-cmd-Have-keep-and-profile-be-flags-of-buffer-i.patch --]
[-- Type: text/plain, Size: 5163 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Instead of having separate ints for true or false fields in the buffer
instance, have them be flags. This will allow us to easily add new ones.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 trace-local.h  |  9 +++++++--
 trace-record.c | 29 +++++++++++++++--------------
 2 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/trace-local.h b/trace-local.h
index 0665ec3c11c5..d45c66c31dca 100644
--- a/trace-local.h
+++ b/trace-local.h
@@ -160,6 +160,12 @@ char *strstrip(char *str);
 
 /* --- instance manipulation --- */
 
+enum buffer_instance_flags {
+	BUFFER_FL_KEEP		= 1 << 0,
+	BUFFER_FL_PROFILE	= 1 << 1,
+	BUFFER_FL_GUEST		= 1 << 2,
+};
+
 struct func_list {
 	struct func_list *next;
 	const char *func;
@@ -191,11 +197,10 @@ struct buffer_instance {
 
 	struct tracecmd_msg_handle *msg_handle;
 
+	int			flags;
 	int			tracing_on_init_val;
 	int			tracing_on_fd;
-	int			keep;
 	int			buffer_size;
-	int			profile;
 	int			cpu_count;
 };
 
diff --git a/trace-record.c b/trace-record.c
index e0dd5570a536..814c7e112285 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -177,7 +177,7 @@ static struct reset_file *reset_files;
 /* Triggers need to be cleared in a special way */
 static struct reset_file *reset_triggers;
 
-struct buffer_instance top_instance = { .keep = 1 };
+struct buffer_instance top_instance = { .flags = BUFFER_FL_KEEP };
 struct buffer_instance *buffer_instances;
 struct buffer_instance *first_instance;
 
@@ -3806,7 +3806,7 @@ static void make_instances(void)
 				die("mkdir %s", path);
 		} else
 			/* Don't delete instances that already exist */
-			instance->keep = 1;
+			instance->flags |= BUFFER_FL_KEEP;
 		tracecmd_put_tracing_file(path);
 	}
 }
@@ -3819,7 +3819,7 @@ void tracecmd_remove_instances(void)
 
 	for_each_instance(instance) {
 		/* Only delete what we created */
-		if (instance->keep)
+		if (instance->flags & BUFFER_FL_KEEP)
 			continue;
 		if (instance->tracing_on_fd > 0) {
 			close(instance->tracing_on_fd);
@@ -3901,7 +3901,8 @@ static void check_function_plugin(void)
 
 static int __check_doing_something(struct buffer_instance *instance)
 {
-	return instance->profile || instance->plugin || instance->events;
+	return (instance->flags & BUFFER_FL_PROFILE) ||
+		instance->plugin || instance->events;
 }
 
 static void check_doing_something(void)
@@ -4429,7 +4430,7 @@ void trace_reset(int argc, char **argv)
 				die("Failed to create instance");
 			add_instance(instance, local_cpu_count);
 			/* -d will remove keep */
-			instance->keep = 1;
+			instance->flags |= BUFFER_FL_KEEP;
 			break;
 		case 't':
 			/* Force to use top instance */
@@ -4441,18 +4442,18 @@ void trace_reset(int argc, char **argv)
 			last_specified_all = 1;
 			add_all_instances();
 			for_each_instance(instance) {
-				instance->keep = 1;
+				instance->flags |= BUFFER_FL_KEEP;
 			}
 			break;
 		case 'd':
 			if (last_specified_all) {
 				for_each_instance(inst) {
-					inst->keep = 0;
+					instance->flags &= ~BUFFER_FL_KEEP;
 				}
 			} else {
 				if (is_top_instance(instance))
 					die("Can not delete top level buffer");
-				instance->keep = 0;
+				instance->flags &= ~BUFFER_FL_KEEP;
 			}
 			break;
 		}
@@ -4769,7 +4770,7 @@ static void parse_record_options(int argc,
 				die("Failed to create instance");
 			add_instance(ctx->instance, local_cpu_count);
 			if (IS_PROFILE(ctx))
-				ctx->instance->profile = 1;
+				ctx->instance->flags |= BUFFER_FL_PROFILE;
 			break;
 		case 'k':
 			keep = 1;
@@ -4791,7 +4792,7 @@ static void parse_record_options(int argc,
 			break;
 		case OPT_profile:
 			handle_init = trace_init_profile;
-			ctx->instance->profile = 1;
+			ctx->instance->flags |= BUFFER_FL_PROFILE;
 			ctx->events = 1;
 			break;
 		case OPT_stderr:
@@ -4895,7 +4896,7 @@ static void finalize_record_trace(struct common_record_context *ctx)
 
 	/* If tracing_on was enabled before we started, set it on now */
 	for_all_instances(instance) {
-		if (instance->keep)
+		if (instance->flags & BUFFER_FL_KEEP)
 			write_tracing_on(instance,
 					 instance->tracing_on_init_val);
 	}
@@ -4933,7 +4934,7 @@ static void record_trace(int argc, char **argv,
 	/* Save the state of tracing_on before starting */
 	for_all_instances(instance) {
 
-		if (!ctx->manual && instance->profile)
+		if (!ctx->manual && instance->flags & BUFFER_FL_PROFILE)
 			enable_profile(instance);
 
 		instance->tracing_on_init_val = read_tracing_on(instance);
@@ -5052,7 +5053,7 @@ void trace_extract(int argc, char **argv)
 	/* Save the state of tracing_on before starting */
 	for_all_instances(instance) {
 
-		if (!ctx.manual && instance->profile)
+		if (!ctx.manual && instance->flags & BUFFER_FL_PROFILE)
 			enable_profile(ctx.instance);
 
 		instance->tracing_on_init_val = read_tracing_on(instance);
@@ -5124,7 +5125,7 @@ void trace_profile(int argc, char **argv)
 	 * If no instances were set, then enable profiling on the top instance.
 	 */
 	if (!buffer_instances)
-		top_instance.profile = 1;
+		top_instance.flags |= BUFFER_FL_PROFILE;
 
 	record_trace(argc, argv, &ctx);
 	do_trace_profile();
-- 
2.13.2

  parent reply	other threads:[~2018-01-03 17:53 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-03 17:52 [PATCH 00/38] trace-cmd: Simplify the msg handling Steven Rostedt
2018-01-03 17:52 ` [PATCH 01/38] trace-cmd recorder: Check if pipe_size was modified by fcntl(F_GETPIPE_SZ) Steven Rostedt
2018-01-03 17:52 ` [PATCH 02/38] pevent: Simplify pointer print logic and fix %pF Steven Rostedt
2018-01-03 17:52 ` [PATCH 03/38] pevent: Handle new pointer processing of bprint strings Steven Rostedt
2018-01-03 17:52 ` [PATCH 04/38] trace-cmd record: Fix clearing out the ctx->instance when used in for_all_instances() Steven Rostedt
2018-01-03 17:52 ` [PATCH 05/38] trace-cmd: Remove the creating of msg out of tracecmd_msg_send() Steven Rostedt
2018-01-03 17:52 ` [PATCH 06/38] trace-cmd: Move tracecmd_msg_send_and_wait_for_msg() into its only user Steven Rostedt
2018-01-03 17:52 ` [PATCH 07/38] trace-cmd: Turn tracecmd_msg data into an anonymous union Steven Rostedt
2018-01-03 17:52 ` [PATCH 08/38] trace-cmd: Remove unused structure tracecmd_msg_error Steven Rostedt
2018-01-03 17:52 ` [PATCH 09/38] trace-cmd: Move size and cmd in tracecmd_msg into its own header struct Steven Rostedt
2018-01-03 17:52 ` [PATCH 10/38] trace-cmd: Move the tracecmd_msg pointers into their own union Steven Rostedt
2018-01-03 17:52 ` [PATCH 11/38] trace-cmd: Just use the buf field for sending pointers Steven Rostedt
2018-01-03 17:52 ` [PATCH 12/38] trace-cmd: Use an array to map msg types and min sizes Steven Rostedt
2018-01-03 17:52 ` [PATCH 13/38] trace-cmd: Merge msg_do_write_check() into msg_write() Steven Rostedt
2018-01-03 17:52 ` [PATCH 14/38] trace-cmd: Simplify msg_free() by using min sizes Steven Rostedt
2018-01-03 17:52 ` [PATCH 15/38] trace-cmd: Add tracecmd_msg_init() helper function Steven Rostedt
2018-01-03 17:52 ` [PATCH 16/38] trace-cmd: Remove mulitplexer tracecmd_msg_create() Steven Rostedt
2018-01-03 17:52 ` [PATCH 17/38] trace-cmd: Simplify msg_read_extra() Steven Rostedt
2018-01-03 17:52 ` [PATCH 18/38] trace-cmd: Have msg_free() zero out msg contents Steven Rostedt
2018-01-03 17:52 ` [PATCH 19/38] trace-cmd: Verify RINIT was received after TINIT msg sent Steven Rostedt
2018-01-03 17:52 ` [PATCH 20/38] trace-cmd: Make send_metadata a flag in the output handle Steven Rostedt
2018-01-03 17:52 ` [PATCH 21/38] trace-cmd: Pass cpu count and port array to make_rinit() Steven Rostedt
2018-01-03 17:52 ` [PATCH 22/38] trace-cmd: Pass cpu_count instead of having it as a global Steven Rostedt
2018-01-03 17:52 ` [PATCH 23/38] trace-cmd: Pass in client_ports instead of using a global variable Steven Rostedt
2018-01-03 17:52 ` [PATCH 24/38] trace-cmd msg: Add debug prints of messages sent and received Steven Rostedt
2018-01-03 17:52 ` [PATCH 25/38] trace-cmd msg: Move the saved closing fd to the caller Steven Rostedt
2018-01-03 17:52 ` [PATCH 26/38] trace-cmd listen: Add better output on error of connections Steven Rostedt
2018-01-03 17:52 ` [PATCH 27/38] trace-cmd msg: Create a msg_handle to pass around for saved state Steven Rostedt
2018-01-03 17:52 ` [PATCH 28/38] trace-cmd msg: Add server structure of msg_handler Steven Rostedt
2018-01-03 20:31   ` [PATCH 28/38 v2] " Steven Rostedt
2018-01-03 17:52 ` [PATCH 29/38] trace-cmd: Remove global use_tcp variable Steven Rostedt
2018-01-03 17:52 ` [PATCH 30/38] trace-cmd: Move protocol version into msg_handler Steven Rostedt
2018-01-03 17:52 ` [PATCH 31/38] tracecmd: Clean up handling of cpu_count Steven Rostedt
2018-01-03 17:52 ` [PATCH 32/38] tracecmd listen: Have pagesize passed as return not parameter Steven Rostedt
2018-01-03 17:52 ` [PATCH 33/38] trace-cmd: Have cpu_count reside in instances and not be global Steven Rostedt
2018-01-03 17:52 ` [PATCH 34/38] trace-cmd: Add option CPUCOUNT to buffer instance options Steven Rostedt
2018-01-03 17:52 ` [PATCH 35/38] trace-cmd: Have msg_handle part of the buffer instance Steven Rostedt
2018-01-03 17:52 ` [PATCH 36/38] trace-cmd record: Allow instances to be recorded over the network Steven Rostedt
2018-01-03 17:52 ` Steven Rostedt [this message]
2018-01-03 17:52 ` [PATCH 38/38] trace-cmd: Add network handle into buffer instance Steven Rostedt

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=20180103175340.225782044@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.