linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Subject: [PATCH 20/38] trace-cmd: Make send_metadata a flag in the output handle
Date: Wed, 03 Jan 2018 12:52:22 -0500	[thread overview]
Message-ID: <20180103175337.688999474@goodmis.org> (raw)
In-Reply-To: 20180103175202.044283643@goodmis.org

[-- Attachment #1: 0020-trace-cmd-Make-send_metadata-a-flag-in-the-output-ha.patch --]
[-- Type: text/plain, Size: 4779 bytes --]

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

Instead of having a global variable called "send_metadata", have the network
setup pass in a flag to enabled sending the meta data via messages instead
of just writing to the file descriptor.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 trace-cmd.h    |  2 +-
 trace-msg.c    |  4 ----
 trace-msg.h    |  1 -
 trace-output.c | 20 ++++++++++++++------
 trace-record.c |  3 ++-
 5 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/trace-cmd.h b/trace-cmd.h
index 6fd34d7fbd21..37177a6b6c3e 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -244,7 +244,7 @@ tracecmd_create_init_file_glob(const char *output_file,
 			       struct tracecmd_event_list *list);
 struct tracecmd_output *tracecmd_create_init_fd(int fd);
 struct tracecmd_output *
-tracecmd_create_init_fd_glob(int fd, struct tracecmd_event_list *list);
+tracecmd_create_init_fd_glob(int fd, struct tracecmd_event_list *list, bool send_meta);
 struct tracecmd_output *tracecmd_create_init_file(const char *output_file);
 struct tracecmd_output *tracecmd_create_init_file_override(const char *output_file,
 							   const char *tracing_dir,
diff --git a/trace-msg.c b/trace-msg.c
index 453901981c90..ab64f3f28f5e 100644
--- a/trace-msg.c
+++ b/trace-msg.c
@@ -70,7 +70,6 @@ int cpu_count;
 static int psfd;
 unsigned int page_size;
 int *client_ports;
-bool send_metadata;
 
 /* for server */
 static int *port_array;
@@ -398,9 +397,6 @@ int tracecmd_msg_send_init_data(int fd)
 	for (i = 0; i < cpus; i++)
 		client_ports[i] = ntohl(recv_msg.port_array[i]);
 
-	/* Next, send meta data */
-	send_metadata = true;
-
 	return 0;
 }
 
diff --git a/trace-msg.h b/trace-msg.h
index 0cc972cadc55..feae24ff4fd6 100644
--- a/trace-msg.h
+++ b/trace-msg.h
@@ -17,7 +17,6 @@ extern int cpu_count;
 /* for client */
 extern unsigned int page_size;
 extern int *client_ports;
-extern bool send_metadata;
 
 /* for server */
 extern bool done;
diff --git a/trace-output.c b/trace-output.c
index 9d7707f7ba79..d04c4019640f 100644
--- a/trace-output.c
+++ b/trace-output.c
@@ -57,10 +57,15 @@ struct tracecmd_option {
 	struct list_head list;
 };
 
+enum {
+	OUTPUT_FL_SEND_META	= (1 << 0),
+};
+
 struct tracecmd_output {
 	int		fd;
 	int		page_size;
 	int		cpus;
+	int		flags;
 	struct pevent	*pevent;
 	char		*tracing_dir;
 	int		options_written;
@@ -83,7 +88,7 @@ struct list_event_system {
 static stsize_t
 do_write_check(struct tracecmd_output *handle, const void *data, tsize_t size)
 {
-	if (send_metadata)
+	if (handle->flags & OUTPUT_FL_SEND_META)
 		return tracecmd_msg_metadata_send(handle->fd, data, size);
 
 	return __do_write_check(handle->fd, data, size);
@@ -777,7 +782,7 @@ static struct tracecmd_output *
 create_file_fd(int fd, struct tracecmd_input *ihandle,
 	       const char *tracing_dir,
 	       const char *kallsyms,
-	       struct tracecmd_event_list *list)
+	       struct tracecmd_event_list *list, bool send_meta)
 {
 	struct tracecmd_output *handle;
 	struct pevent *pevent;
@@ -789,6 +794,9 @@ create_file_fd(int fd, struct tracecmd_input *ihandle,
 		return NULL;
 	memset(handle, 0, sizeof(*handle));
 
+	if (send_meta)
+		handle->flags |= OUTPUT_FL_SEND_META;
+
 	handle->fd = fd;
 	if (tracing_dir) {
 		handle->tracing_dir = strdup(tracing_dir);
@@ -880,7 +888,7 @@ static struct tracecmd_output *create_file(const char *output_file,
 	if (fd < 0)
 		return NULL;
 
-	handle = create_file_fd(fd, ihandle, tracing_dir, kallsyms, list);
+	handle = create_file_fd(fd, ihandle, tracing_dir, kallsyms, list, false);
 	if (!handle) {
 		close(fd);
 		unlink(output_file);
@@ -1310,13 +1318,13 @@ struct tracecmd_output *tracecmd_create_file(const char *output_file,
 
 struct tracecmd_output *tracecmd_create_init_fd(int fd)
 {
-	return create_file_fd(fd, NULL, NULL, NULL, &all_event_list);
+	return create_file_fd(fd, NULL, NULL, NULL, &all_event_list, false);
 }
 
 struct tracecmd_output *
-tracecmd_create_init_fd_glob(int fd, struct tracecmd_event_list *list)
+tracecmd_create_init_fd_glob(int fd, struct tracecmd_event_list *list, bool send_meta)
 {
-	return create_file_fd(fd, NULL, NULL, NULL, list);
+	return create_file_fd(fd, NULL, NULL, NULL, list, send_meta);
 }
 
 struct tracecmd_output *
diff --git a/trace-record.c b/trace-record.c
index 5088f7ae0852..48640af8acac 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -2865,7 +2865,8 @@ again:
 		communicate_with_listener_v1(sfd);
 
 	/* Now create the handle through this socket */
-	network_handle = tracecmd_create_init_fd_glob(sfd, listed_events);
+	network_handle = tracecmd_create_init_fd_glob(sfd, listed_events,
+						      proto_ver == V2_PROTOCOL);
 
 	if (proto_ver == V2_PROTOCOL)
 		tracecmd_msg_finish_sending_metadata(sfd);
-- 
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 ` Steven Rostedt [this message]
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 ` [PATCH 37/38] trace-cmd: Have keep and profile be flags of buffer instance Steven Rostedt
2018-01-03 17:52 ` [PATCH 38/38] trace-cmd: Add network handle into " 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=20180103175337.688999474@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 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).