mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Josef Bacik <jbacik@fb.com>
Cc: <kernel-team@fb.com>, <linux-kernel@vger.kernel.org>,
	Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: Re: [PATCH 04/11] trace-cmd: add global functions for live tracing
Date: Tue, 9 Jul 2019 09:09:17 -0400	[thread overview]
Message-ID: <20190709090917.7705c1da@gandalf.local.home> (raw)
In-Reply-To: <1448053053-24188-5-git-send-email-jbacik@fb.com>

On Fri, 20 Nov 2015 15:57:26 -0500
Josef Bacik <jbacik@fb.com> wrote:

> We need a few functions to disable/enable tracing as well as add events to be
> enabled on the first instance, this patch turns a couple of these local
> functions into library functions.  Thanks,

Hi Josef,

Not sure you still use this, as it's not really a library function
anymore. But we are currently cleaning up the trace-cmd code to create
a real library, and doing it in baby steps. The
tracecmd_enable_events() function is causing some issues and it was
added by you. Are you OK if we remove it. At least temporarily until we
separate out the "enabling" part into the library?

Thanks!

-- Steve


> 
> Signed-off-by: Josef Bacik <jbacik@fb.com>
> ---
>  trace-cmd.h    |  5 +++++
>  trace-record.c | 45 +++++++++++++++++++++++++++------------------
>  2 files changed, 32 insertions(+), 18 deletions(-)
> 
> diff --git a/trace-cmd.h b/trace-cmd.h
> index b4fa7fd..9a9ca30 100644
> --- a/trace-cmd.h
> +++ b/trace-cmd.h
> @@ -268,6 +268,11 @@ int tracecmd_start_recording(struct tracecmd_recorder *recorder, unsigned long s
>  void tracecmd_stop_recording(struct tracecmd_recorder *recorder);
>  void tracecmd_stat_cpu(struct trace_seq *s, int cpu);
>  long tracecmd_flush_recording(struct tracecmd_recorder *recorder);
> +int tracecmd_add_event(const char *event_str, int stack);
> +void tracecmd_enable_events(void);
> +void tracecmd_disable_all_tracing(int disable_tracer);
> +void tracecmd_disable_tracing(void);
> +void tracecmd_enable_tracing(void);
>  
>  /* --- Plugin handling --- */
>  extern struct pevent_plugin_option trace_ftrace_options[];
> diff --git a/trace-record.c b/trace-record.c
> index 417b701..7c471ab 100644
> --- a/trace-record.c
> +++ b/trace-record.c
> @@ -841,7 +841,6 @@ static void update_ftrace_pids(int reset)
>  
>  static void update_event_filters(struct buffer_instance *instance);
>  static void update_pid_event_filters(struct buffer_instance *instance);
> -static void enable_tracing(void);
>  
>  /**
>   * make_pid_filter - create a filter string to all pids against @field
> @@ -1106,7 +1105,7 @@ static void run_cmd(enum trace_type type, int argc, char **argv)
>  	if (!pid) {
>  		/* child */
>  		update_task_filter();
> -		enable_tracing();
> +		tracecmd_enable_tracing();
>  		enable_ptrace();
>  		/*
>  		 * If we are using stderr for stdout, switch
> @@ -1795,7 +1794,7 @@ static int read_tracing_on(struct buffer_instance *instance)
>  	return ret;
>  }
>  
> -static void enable_tracing(void)
> +void tracecmd_enable_tracing(void)
>  {
>  	struct buffer_instance *instance;
>  
> @@ -1808,7 +1807,7 @@ static void enable_tracing(void)
>  		reset_max_latency();
>  }
>  
> -static void disable_tracing(void)
> +void tracecmd_disable_tracing(void)
>  {
>  	struct buffer_instance *instance;
>  
> @@ -1816,9 +1815,9 @@ static void disable_tracing(void)
>  		write_tracing_on(instance, 0);
>  }
>  
> -static void disable_all(int disable_tracer)
> +void tracecmd_disable_all_tracing(int disable_tracer)
>  {
> -	disable_tracing();
> +	tracecmd_disable_tracing();
>  
>  	if (disable_tracer) {
>  		disable_func_stack_trace();
> @@ -1991,6 +1990,11 @@ static void enable_events(struct buffer_instance *instance)
>  	}
>  }
>  
> +void tracecmd_enable_events(void)
> +{
> +	enable_events(first_instance);
> +}
> +
>  static void set_clock(struct buffer_instance *instance)
>  {
>  	char *path;
> @@ -3074,15 +3078,15 @@ static char *get_date_to_ts(void)
>  	}
>  
>  	for (i = 0; i < date2ts_tries; i++) {
> -		disable_tracing();
> +		tracecmd_disable_tracing();
>  		clear_trace();
> -		enable_tracing();
> +		tracecmd_enable_tracing();
>  
>  		gettimeofday(&start, NULL);
>  		write(tfd, STAMP, 5);
>  		gettimeofday(&end, NULL);
>  
> -		disable_tracing();
> +		tracecmd_disable_tracing();
>  		ts = find_time_stamp(pevent);
>  		if (!ts)
>  			continue;
> @@ -3699,6 +3703,11 @@ profile_add_event(struct buffer_instance *instance, const char *event_str, int s
>  	return 0;
>  }
>  
> +int tracecmd_add_event(const char *event_str, int stack)
> +{
> +	return profile_add_event(first_instance, event_str, stack);
> +}
> +
>  static void enable_profile(struct buffer_instance *instance)
>  {
>  	int stacktrace = 0;
> @@ -3891,7 +3900,7 @@ void trace_record (int argc, char **argv)
>  
>  		}
>  		update_first_instance(instance, topt);
> -		disable_tracing();
> +		tracecmd_disable_tracing();
>  		exit(0);
>  	} else if (strcmp(argv[1], "restart") == 0) {
>  		for (;;) {
> @@ -3922,7 +3931,7 @@ void trace_record (int argc, char **argv)
>  
>  		}
>  		update_first_instance(instance, topt);
> -		enable_tracing();
> +		tracecmd_enable_tracing();
>  		exit(0);
>  	} else if (strcmp(argv[1], "reset") == 0) {
>  		/* if last arg is -a, then -b and -d apply to all instances */
> @@ -3984,7 +3993,7 @@ void trace_record (int argc, char **argv)
>  			}
>  		}
>  		update_first_instance(instance, topt);
> -		disable_all(1);
> +		tracecmd_disable_all_tracing(1);
>  		set_buffer_size();
>  		clear_filters();
>  		clear_triggers();
> @@ -4314,7 +4323,7 @@ void trace_record (int argc, char **argv)
>  
>  	if (!extract) {
>  		fset = set_ftrace(!disable, total_disable);
> -		disable_all(1);
> +		tracecmd_disable_all_tracing(1);
>  
>  		for_all_instances(instance)
>  			set_clock(instance);
> @@ -4365,7 +4374,7 @@ void trace_record (int argc, char **argv)
>  	} else {
>  		if (!(type & (TRACE_TYPE_RECORD | TRACE_TYPE_STREAM))) {
>  			update_task_filter();
> -			enable_tracing();
> +			tracecmd_enable_tracing();
>  			exit(0);
>  		}
>  
> @@ -4373,7 +4382,7 @@ void trace_record (int argc, char **argv)
>  			run_cmd(type, (argc - optind) - 1, &argv[optind + 1]);
>  		else {
>  			update_task_filter();
> -			enable_tracing();
> +			tracecmd_enable_tracing();
>  			/* We don't ptrace ourself */
>  			if (do_ptrace && filter_pid >= 0)
>  				ptrace_attach(filter_pid);
> @@ -4383,7 +4392,7 @@ void trace_record (int argc, char **argv)
>  				trace_or_sleep(type);
>  		}
>  
> -		disable_tracing();
> +		tracecmd_disable_tracing();
>  		if (!latency)
>  			stop_threads(type);
>  	}
> @@ -4391,7 +4400,7 @@ void trace_record (int argc, char **argv)
>  	record_stats();
>  
>  	if (!keep)
> -		disable_all(0);
> +		tracecmd_disable_all_tracing(0);
>  
>  	/* extract records the date after extraction */
>  	if (extract && date) {
> @@ -4399,7 +4408,7 @@ void trace_record (int argc, char **argv)
>  		 * We need to start tracing, don't let other traces
>  		 * screw with our trace_marker.
>  		 */
> -		disable_all(1);
> +		tracecmd_disable_all_tracing(1);
>  		date2ts = get_date_to_ts();
>  	}
>  


  reply	other threads:[~2019-07-09 13:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-20 20:57 [PATCH 00/11] trace-cmd: make libtracecmd a linkable object Josef Bacik
2015-11-20 20:57 ` [PATCH 01/11] trace-cmd: add install_libs target to trace-cmd Josef Bacik
2015-11-20 20:57 ` [PATCH 02/11] trace-cmd: make libtracecmd a little more library friendly Josef Bacik
2015-11-20 20:57 ` [PATCH 03/11] trace-cmd: add a function to create a top instance Josef Bacik
2015-11-20 20:57 ` [PATCH 04/11] trace-cmd: add global functions for live tracing Josef Bacik
2019-07-09 13:09   ` Steven Rostedt [this message]
2019-07-09 13:56     ` Josef Bacik
2015-11-20 20:57 ` [PATCH 05/11] trace-cmd: allow for custom show and handle init Josef Bacik
2015-11-20 20:57 ` [PATCH 06/11] trace-cmd: add helpers for starting and stopping threads Josef Bacik
2015-11-20 20:57 ` [PATCH 07/11] trace-cmd: add trace-hash to libtracecmd Josef Bacik
2015-11-20 20:57 ` [PATCH 08/11] trace-cmd: add trace-stat and -ldl " Josef Bacik
2015-11-20 20:57 ` [PATCH 09/11] trace-cmd: disentangle profile and read from record Josef Bacik
2015-11-20 20:57 ` [PATCH 10/11] trace-cmd: add a helper function for stream polling Josef Bacik
2015-11-20 20:57 ` [PATCH 11/11] trace-cmd: add tracecmd_expand_event_list Josef Bacik
2016-11-21 17:13 ` [PATCH 00/11] trace-cmd: make libtracecmd a linkable object Steven Rostedt
2016-11-21 20:06   ` Josef Bacik

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=20190709090917.7705c1da@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=jbacik@fb.com \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®