Linux-Next discussions
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>
Cc: Costa Shulyupin <costa.shul@redhat.com>,
	Crystal Wood <crwood@redhat.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	Tomas Glozar <tglozar@redhat.com>
Subject: linux-next: manual merge of the ftrace tree with the tip-fixes tree
Date: Wed, 10 Jun 2026 16:33:22 +0100	[thread overview]
Message-ID: <aimDwlNq_RRLjg6X@sirena.co.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 48571 bytes --]

Hi all,

Today's linux-next merge of the ftrace tree got conflicts in:

  tools/tracing/rtla/src/common.c
  tools/tracing/rtla/src/common.h
  tools/tracing/rtla/src/osnoise_hist.c
  tools/tracing/rtla/src/osnoise_top.c
  tools/tracing/rtla/src/timerlat_hist.c
  tools/tracing/rtla/src/timerlat_top.c

between commit:

  e9e41d3035032e ("rtla: Fix parsing of multi-character short options")

from the tip-fixes tree and commits:

  704fe8f3d97bba ("tools/rtla: Fix --dump-tasks usage in timerlat")
  f03a59f949176c ("rtla: Stop the record trace on interrupt")
  5d9af63e80b5a2 ("rtla: Parse cmdline using libsubcmd")
  03d745b9843560 ("rtla/timerlat: Add -A/--aligned CLI option")

from the ftrace tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

diff --combined tools/tracing/rtla/src/common.c
index bc9d01ddd10295,d0a8a6edbf0cba..00000000000000
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@@ -5,12 -5,11 +5,11 @@@
  #include <signal.h>
  #include <stdlib.h>
  #include <string.h>
- #include <getopt.h>
  #include <sys/sysinfo.h>
  
  #include "common.h"
  
- struct trace_instance *trace_inst;
+ struct osnoise_tool *trace_tool;
  volatile int stop_tracing;
  int nr_cpus;
  
@@@ -21,12 -20,16 +20,16 @@@ static void stop_trace(int sig
  		 * Stop requested twice in a row; abort event processing and
  		 * exit immediately
  		 */
- 		tracefs_iterate_stop(trace_inst->inst);
+ 		if (trace_tool)
+ 			tracefs_iterate_stop(trace_tool->trace.inst);
  		return;
  	}
  	stop_tracing = 1;
- 	if (trace_inst)
- 		trace_instance_stop(trace_inst);
+ 	if (trace_tool) {
+ 		trace_instance_stop(&trace_tool->trace);
+ 		if (trace_tool->record)
+ 			trace_instance_stop(&trace_tool->record->trace);
+ 	}
  }
  
  /*
@@@ -53,96 -56,6 +56,6 @@@ static void unset_signals(struct common
  	}
  }
  
- /*
-  * getopt_auto - auto-generates optstring from long_options
-  */
- int getopt_auto(int argc, char **argv, const struct option *long_opts)
- {
- 	char opts[256];
- 	int n = 0;
- 
- 	for (int i = 0; long_opts[i].name; i++) {
- 		if (long_opts[i].val < 32 || long_opts[i].val > 127)
- 			continue;
- 
- 		if (n + 4 >= sizeof(opts))
- 			fatal("optstring buffer overflow");
- 
- 		opts[n++] = long_opts[i].val;
- 
- 		if (long_opts[i].has_arg == required_argument)
- 			opts[n++] = ':';
- 		else if (long_opts[i].has_arg == optional_argument) {
- 			opts[n++] = ':';
- 			opts[n++] = ':';
- 		}
- 	}
- 
- 	opts[n] = '\0';
- 
- 	return getopt_long(argc, argv, opts, long_opts, NULL);
- }
- 
- /*
-  * set_common_option - set common options
-  *
-  * @c: option character
-  * @argc: argument count
-  * @argv: argument vector
-  * @common: common parameters structure
-  *
-  * Parse command line options that are common to all rtla tools.
-  *
-  * Returns: 1 if the option was set, 0 otherwise.
-  */
- int set_common_option(int c, int argc, char **argv, struct common_params *common)
- {
- 	struct trace_events *tevent;
- 
- 	switch (c) {
- 	case 'c':
- 		if (parse_cpu_set(optarg, &common->monitored_cpus))
- 			fatal("Invalid -c cpu list");
- 		common->cpus = optarg;
- 		break;
- 	case 'C':
- 		common->cgroup = 1;
- 		common->cgroup_name = parse_optional_arg(argc, argv);
- 		break;
- 	case 'D':
- 		config_debug = 1;
- 		break;
- 	case 'd':
- 		common->duration = parse_seconds_duration(optarg);
- 		if (!common->duration)
- 			fatal("Invalid -d duration");
- 		break;
- 	case 'e':
- 		tevent = trace_event_alloc(optarg);
- 		if (!tevent)
- 			fatal("Error alloc trace event");
- 
- 		if (common->events)
- 			tevent->next = common->events;
- 		common->events = tevent;
- 		break;
- 	case 'H':
- 		common->hk_cpus = 1;
- 		if (parse_cpu_set(optarg, &common->hk_cpu_set))
- 			fatal("Error parsing house keeping CPUs");
- 		break;
- 	case 'P':
- 		if (parse_prio(optarg, &common->sched_param) == -1)
- 			fatal("Invalid -P priority");
- 		common->set_sched = 1;
- 		break;
- 	default:
- 		return 0;
- 	}
- 
- 	return 1;
- }
- 
  /*
   * common_apply_config - apply common configs to the initialized tool
   */
@@@ -255,11 -168,10 +168,10 @@@ int run_tool(struct tool_ops *ops, int 
  	tool->params = params;
  
  	/*
- 	 * Save trace instance into global variable so that SIGINT can stop
- 	 * the timerlat tracer.
+ 	 * Expose the tool to signal handlers so they can stop the trace.
  	 * Otherwise, rtla could loop indefinitely when overloaded.
  	 */
- 	trace_inst = &tool->trace;
+ 	trace_tool = tool;
  
  	retval = ops->apply_config(tool);
  	if (retval) {
@@@ -267,7 -179,7 +179,7 @@@
  		goto out_free;
  	}
  
- 	retval = enable_tracer_by_name(trace_inst->inst, ops->tracer);
+ 	retval = enable_tracer_by_name(tool->trace.inst, ops->tracer);
  	if (retval) {
  		err_msg("Failed to enable %s tracer\n", ops->tracer);
  		goto out_free;
diff --combined tools/tracing/rtla/src/common.h
index 8921807bda988c,04b287a03f6d4c..00000000000000
--- a/tools/tracing/rtla/src/common.h
+++ b/tools/tracing/rtla/src/common.h
@@@ -1,7 -1,6 +1,6 @@@
  /* SPDX-License-Identifier: GPL-2.0 */
  #pragma once
  
- #include <getopt.h>
  #include "actions.h"
  #include "timerlat_u.h"
  #include "trace.h"
@@@ -52,18 -51,25 +51,25 @@@ struct osnoise_context 
  	/* -1 as init value because 0 is off */
  	int			orig_opt_workload;
  	int			opt_workload;
+ 
+ 	/* -1 as init value because 0 is off */
+ 	int			orig_opt_timerlat_align;
+ 	int			opt_timerlat_align;
+ 
+ 	/* 0 as init value */
+ 	unsigned long long	orig_timerlat_align_us;
+ 	unsigned long long	timerlat_align_us;
  };
  
- extern struct trace_instance *trace_inst;
  extern volatile int stop_tracing;
  
  struct hist_params {
- 	char			no_irq;
- 	char			no_thread;
- 	char			no_header;
- 	char			no_summary;
- 	char			no_index;
- 	char			with_zeros;
+ 	bool			no_irq;
+ 	bool			no_thread;
+ 	bool			no_header;
+ 	bool			no_summary;
+ 	bool			no_index;
+ 	bool			with_zeros;
  	int			bucket_size;
  	int			entries;
  };
@@@ -96,12 -102,12 +102,12 @@@ struct common_params 
  	/* Other parameters */
  	struct hist_params	hist;
  	int			output_divisor;
- 	int			pretty_output;
- 	int			quiet;
- 	int			user_workload;
- 	int			kernel_workload;
- 	int			user_data;
- 	int			aa_only;
+ 	bool			pretty_output;
+ 	bool			quiet;
+ 	bool			user_workload;
+ 	bool			kernel_workload;
+ 	bool			user_data;
+ 	bool			aa_only;
  
  	struct actions		threshold_actions;
  	struct actions		end_actions;
@@@ -177,18 -183,6 +183,6 @@@ int osnoise_set_stop_us(struct osnoise_
  int osnoise_set_stop_total_us(struct osnoise_context *context,
  			      long long stop_total_us);
  
- int getopt_auto(int argc, char **argv, const struct option *long_opts);
- 
- #define COMMON_OPTIONS \
- 	{"cpus",                required_argument,      0, 'c'},\
- 	{"cgroup",              optional_argument,      0, 'C'},\
- 	{"debug",               no_argument,            0, 'D'},\
- 	{"duration",            required_argument,      0, 'd'},\
- 	{"event",               required_argument,      0, 'e'},\
- 	{"house-keeping",       required_argument,      0, 'H'},\
- 	{"priority",            required_argument,      0, 'P'}
- int set_common_option(int c, int argc, char **argv, struct common_params *common);
- 
  int common_apply_config(struct osnoise_tool *tool, struct common_params *params);
  int top_main_loop(struct osnoise_tool *tool);
  int hist_main_loop(struct osnoise_tool *tool);
diff --combined tools/tracing/rtla/src/osnoise_hist.c
index cb4ce58c598799,dfa91d0681f8fc..00000000000000
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@@ -4,7 -4,6 +4,6 @@@
   */
  
  #define _GNU_SOURCE
- #include <getopt.h>
  #include <stdlib.h>
  #include <string.h>
  #include <signal.h>
@@@ -13,6 -12,7 +12,7 @@@
  #include <time.h>
  
  #include "osnoise.h"
+ #include "cli.h"
  
  struct osnoise_hist_cpu {
  	int			*samples;
@@@ -400,226 -400,6 +400,6 @@@ osnoise_print_stats(struct osnoise_too
  	osnoise_report_missed_events(tool);
  }
  
- /*
-  * osnoise_hist_usage - prints osnoise hist usage message
-  */
- static void osnoise_hist_usage(void)
- {
- 	static const char * const msg_start[] = {
- 		"[-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\",
- 		"	  [-T us] [-t [file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
- 		"	  [-c cpu-list] [-H cpu-list] [-P priority] [-b N] [-E N] [--no-header] [--no-summary] \\",
- 		"	  [--no-index] [--with-zeros] [-C [cgroup_name]] [--warm-up]",
- 		NULL,
- 	};
- 
- 	static const char * const msg_opts[] = {
- 		"	  -a/--auto: set automatic trace mode, stopping the session if argument in us sample is hit",
- 		"	  -p/--period us: osnoise period in us",
- 		"	  -r/--runtime us: osnoise runtime in us",
- 		"	  -s/--stop us: stop trace if a single sample is higher than the argument in us",
- 		"	  -S/--stop-total us: stop trace if the total sample is higher than the argument in us",
- 		"	  -T/--threshold us: the minimum delta to be considered a noise",
- 		"	  -c/--cpus cpu-list: list of cpus to run osnoise threads",
- 		"	  -H/--house-keeping cpus: run rtla control threads only on the given cpus",
- 		"	  -C/--cgroup [cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be inherited",
- 		"	  -d/--duration time[s|m|h|d]: duration of the session",
- 		"	  -D/--debug: print debug info",
- 		"	  -t/--trace [file]: save the stopped trace to [file|osnoise_trace.txt]",
- 		"	  -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
- 		"	     --filter <filter>: enable a trace event filter to the previous -e event",
- 		"	     --trigger <trigger>: enable a trace event trigger to the previous -e event",
- 		"	  -b/--bucket-size N: set the histogram bucket size (default 1)",
- 		"	  -E/--entries N: set the number of entries of the histogram (default 256)",
- 		"	     --no-header: do not print header",
- 		"	     --no-summary: do not print summary",
- 		"	     --no-index: do not print index",
- 		"	     --with-zeros: print zero only entries",
- 		"	  -P/--priority o:prio|r:prio|f:prio|d:runtime:period: set scheduling parameters",
- 		"		o:prio - use SCHED_OTHER with prio",
- 		"		r:prio - use SCHED_RR with prio",
- 		"		f:prio - use SCHED_FIFO with prio",
- 		"		d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period",
- 		"						       in nanoseconds",
- 		"	     --warm-up: let the workload run for s seconds before collecting data",
- 		"	     --trace-buffer-size kB: set the per-cpu trace buffer size in kB",
- 		"	     --on-threshold <action>: define action to be executed at stop-total threshold, multiple are allowed",
- 		"	     --on-end <action>: define action to be executed at measurement end, multiple are allowed",
- 		NULL,
- 	};
- 
- 	common_usage("osnoise", "hist", "a per-cpu histogram of the OS noise",
- 		     msg_start, msg_opts);
- }
- 
- /*
-  * osnoise_hist_parse_args - allocs, parse and fill the cmd line parameters
-  */
- static struct common_params
- *osnoise_hist_parse_args(int argc, char *argv[])
- {
- 	struct osnoise_params *params;
- 	int retval;
- 	int c;
- 	char *trace_output = NULL;
- 
- 	params = calloc_fatal(1, sizeof(*params));
- 
- 	actions_init(&params->common.threshold_actions);
- 	actions_init(&params->common.end_actions);
- 
- 	/* display data in microseconds */
- 	params->common.output_divisor = 1000;
- 	params->common.hist.bucket_size = 1;
- 	params->common.hist.entries = 256;
- 
- 	while (1) {
- 		static struct option long_options[] = {
- 			COMMON_OPTIONS,
- 			{"auto",		required_argument,	0, 'a'},
- 			{"bucket-size",		required_argument,	0, 'b'},
- 			{"entries",		required_argument,	0, 'E'},
- 			{"help",		no_argument,		0, 'h'},
- 			{"period",		required_argument,	0, 'p'},
- 			{"runtime",		required_argument,	0, 'r'},
- 			{"stop",		required_argument,	0, 's'},
- 			{"stop-total",		required_argument,	0, 'S'},
- 			{"trace",		optional_argument,	0, 't'},
- 			{"threshold",		required_argument,	0, 'T'},
- 			{"no-header",		no_argument,		0, '0'},
- 			{"no-summary",		no_argument,		0, '1'},
- 			{"no-index",		no_argument,		0, '2'},
- 			{"with-zeros",		no_argument,		0, '3'},
- 			{"trigger",		required_argument,	0, '4'},
- 			{"filter",		required_argument,	0, '5'},
- 			{"warm-up",		required_argument,	0, '6'},
- 			{"trace-buffer-size",	required_argument,	0, '7'},
- 			{"on-threshold",	required_argument,	0, '8'},
- 			{"on-end",		required_argument,	0, '9'},
- 			{0, 0, 0, 0}
- 		};
- 
- 		c = getopt_auto(argc, argv, long_options);
- 
- 		/* detect the end of the options. */
- 		if (c == -1)
- 			break;
- 
- 		if (set_common_option(c, argc, argv, &params->common))
- 			continue;
- 
- 		switch (c) {
- 		case 'a':
- 			/* set sample stop to auto_thresh */
- 			params->common.stop_us = get_llong_from_str(optarg);
- 
- 			/* set sample threshold to 1 */
- 			params->threshold = 1;
- 
- 			/* set trace */
- 			if (!trace_output)
- 				trace_output = "osnoise_trace.txt";
- 
- 			break;
- 		case 'b':
- 			params->common.hist.bucket_size = get_llong_from_str(optarg);
- 			if (params->common.hist.bucket_size == 0 ||
- 			    params->common.hist.bucket_size >= 1000000)
- 				fatal("Bucket size needs to be > 0 and <= 1000000");
- 			break;
- 		case 'E':
- 			params->common.hist.entries = get_llong_from_str(optarg);
- 			if (params->common.hist.entries < 10 ||
- 			    params->common.hist.entries > 9999999)
- 				fatal("Entries must be > 10 and < 9999999");
- 			break;
- 		case 'h':
- 		case '?':
- 			osnoise_hist_usage();
- 			break;
- 		case 'p':
- 			params->period = get_llong_from_str(optarg);
- 			if (params->period > 10000000)
- 				fatal("Period longer than 10 s");
- 			break;
- 		case 'r':
- 			params->runtime = get_llong_from_str(optarg);
- 			if (params->runtime < 100)
- 				fatal("Runtime shorter than 100 us");
- 			break;
- 		case 's':
- 			params->common.stop_us = get_llong_from_str(optarg);
- 			break;
- 		case 'S':
- 			params->common.stop_total_us = get_llong_from_str(optarg);
- 			break;
- 		case 'T':
- 			params->threshold = get_llong_from_str(optarg);
- 			break;
- 		case 't':
- 			trace_output = parse_optional_arg(argc, argv);
- 			if (!trace_output)
- 				trace_output = "osnoise_trace.txt";
- 			break;
- 		case '0': /* no header */
- 			params->common.hist.no_header = 1;
- 			break;
- 		case '1': /* no summary */
- 			params->common.hist.no_summary = 1;
- 			break;
- 		case '2': /* no index */
- 			params->common.hist.no_index = 1;
- 			break;
- 		case '3': /* with zeros */
- 			params->common.hist.with_zeros = 1;
- 			break;
- 		case '4': /* trigger */
- 			if (params->common.events)
- 				trace_event_add_trigger(params->common.events, optarg);
- 			else
- 				fatal("--trigger requires a previous -e");
- 			break;
- 		case '5': /* filter */
- 			if (params->common.events)
- 				trace_event_add_filter(params->common.events, optarg);
- 			else
- 				fatal("--filter requires a previous -e");
- 			break;
- 		case '6':
- 			params->common.warmup = get_llong_from_str(optarg);
- 			break;
- 		case '7':
- 			params->common.buffer_size = get_llong_from_str(optarg);
- 			break;
- 		case '8':
- 			retval = actions_parse(&params->common.threshold_actions, optarg,
- 					       "osnoise_trace.txt");
- 			if (retval)
- 				fatal("Invalid action %s", optarg);
- 			break;
- 		case '9':
- 			retval = actions_parse(&params->common.end_actions, optarg,
- 					       "osnoise_trace.txt");
- 			if (retval)
- 				fatal("Invalid action %s", optarg);
- 			break;
- 		default:
- 			fatal("Invalid option");
- 		}
- 	}
- 
- 	if (trace_output)
- 		actions_add_trace_output(&params->common.threshold_actions, trace_output);
- 
- 	if (geteuid())
- 		fatal("rtla needs root permission");
- 
- 	if (params->common.hist.no_index && !params->common.hist.with_zeros)
- 		fatal("no-index set and with-zeros not set - it does not make sense");
- 
- 	return &params->common;
- }
- 
  /*
   * osnoise_hist_apply_config - apply the hist configs to the initialized tool
   */
diff --combined tools/tracing/rtla/src/osnoise_top.c
index e65312ec26c434,512a6299cb0181..00000000000000
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@@ -4,7 -4,6 +4,6 @@@
   */
  
  #define _GNU_SOURCE
- #include <getopt.h>
  #include <stdlib.h>
  #include <string.h>
  #include <signal.h>
@@@ -13,6 -12,7 +12,7 @@@
  #include <time.h>
  
  #include "osnoise.h"
+ #include "cli.h"
  
  struct osnoise_top_cpu {
  	unsigned long long	sum_runtime;
@@@ -245,205 -245,6 +245,6 @@@ osnoise_print_stats(struct osnoise_too
  	osnoise_report_missed_events(top);
  }
  
- /*
-  * osnoise_top_usage - prints osnoise top usage message
-  */
- static void osnoise_top_usage(struct osnoise_params *params)
- {
- 	const char *tool, *mode, *desc;
- 
- 	static const char * const msg_start[] = {
- 		"[-q] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\",
- 		"	  [-T us] [-t [file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
- 		"	  [-c cpu-list] [-H cpu-list] [-P priority] [-C [cgroup_name]] [--warm-up s]",
- 		NULL,
- 	};
- 
- 	static const char * const msg_opts[] = {
- 		"	  -a/--auto: set automatic trace mode, stopping the session if argument in us sample is hit",
- 		"	  -p/--period us: osnoise period in us",
- 		"	  -r/--runtime us: osnoise runtime in us",
- 		"	  -s/--stop us: stop trace if a single sample is higher than the argument in us",
- 		"	  -S/--stop-total us: stop trace if the total sample is higher than the argument in us",
- 		"	  -T/--threshold us: the minimum delta to be considered a noise",
- 		"	  -c/--cpus cpu-list: list of cpus to run osnoise threads",
- 		"	  -H/--house-keeping cpus: run rtla control threads only on the given cpus",
- 		"	  -C/--cgroup [cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be inherited",
- 		"	  -d/--duration time[s|m|h|d]: duration of the session",
- 		"	  -D/--debug: print debug info",
- 		"	  -t/--trace [file]: save the stopped trace to [file|osnoise_trace.txt]",
- 		"	  -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
- 		"	     --filter <filter>: enable a trace event filter to the previous -e event",
- 		"	     --trigger <trigger>: enable a trace event trigger to the previous -e event",
- 		"	  -q/--quiet print only a summary at the end",
- 		"	  -P/--priority o:prio|r:prio|f:prio|d:runtime:period : set scheduling parameters",
- 		"		o:prio - use SCHED_OTHER with prio",
- 		"		r:prio - use SCHED_RR with prio",
- 		"		f:prio - use SCHED_FIFO with prio",
- 		"		d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period",
- 		"						       in nanoseconds",
- 		"	     --warm-up s: let the workload run for s seconds before collecting data",
- 		"	     --trace-buffer-size kB: set the per-cpu trace buffer size in kB",
- 		"	     --on-threshold <action>: define action to be executed at stop-total threshold, multiple are allowed",
- 		"	     --on-end: define action to be executed at measurement end, multiple are allowed",
- 		NULL,
- 	};
- 
- 	if (params->mode == MODE_OSNOISE) {
- 		tool = "osnoise";
- 		mode = "top";
- 		desc = "a per-cpu summary of the OS noise";
- 	} else {
- 		tool = "hwnoise";
- 		mode = "";
- 		desc = "a summary of hardware-related noise";
- 	}
- 
- 	common_usage(tool, mode, desc, msg_start, msg_opts);
- }
- 
- /*
-  * osnoise_top_parse_args - allocs, parse and fill the cmd line parameters
-  */
- struct common_params *osnoise_top_parse_args(int argc, char **argv)
- {
- 	struct osnoise_params *params;
- 	int retval;
- 	int c;
- 	char *trace_output = NULL;
- 
- 	params = calloc_fatal(1, sizeof(*params));
- 
- 	actions_init(&params->common.threshold_actions);
- 	actions_init(&params->common.end_actions);
- 
- 	if (strcmp(argv[0], "hwnoise") == 0) {
- 		params->mode = MODE_HWNOISE;
- 		/*
- 		 * Reduce CPU usage for 75% to avoid killing the system.
- 		 */
- 		params->runtime = 750000;
- 		params->period = 1000000;
- 	}
- 
- 	while (1) {
- 		static struct option long_options[] = {
- 			COMMON_OPTIONS,
- 			{"auto",		required_argument,	0, 'a'},
- 			{"help",		no_argument,		0, 'h'},
- 			{"period",		required_argument,	0, 'p'},
- 			{"quiet",		no_argument,		0, 'q'},
- 			{"runtime",		required_argument,	0, 'r'},
- 			{"stop",		required_argument,	0, 's'},
- 			{"stop-total",		required_argument,	0, 'S'},
- 			{"threshold",		required_argument,	0, 'T'},
- 			{"trace",		optional_argument,	0, 't'},
- 			{"trigger",		required_argument,	0, '0'},
- 			{"filter",		required_argument,	0, '1'},
- 			{"warm-up",		required_argument,	0, '2'},
- 			{"trace-buffer-size",	required_argument,	0, '3'},
- 			{"on-threshold",	required_argument,	0, '4'},
- 			{"on-end",		required_argument,	0, '5'},
- 			{0, 0, 0, 0}
- 		};
- 
- 		c = getopt_auto(argc, argv, long_options);
- 
- 		/* Detect the end of the options. */
- 		if (c == -1)
- 			break;
- 
- 		if (set_common_option(c, argc, argv, &params->common))
- 			continue;
- 
- 		switch (c) {
- 		case 'a':
- 			/* set sample stop to auto_thresh */
- 			params->common.stop_us = get_llong_from_str(optarg);
- 
- 			/* set sample threshold to 1 */
- 			params->threshold = 1;
- 
- 			/* set trace */
- 			if (!trace_output)
- 				trace_output = "osnoise_trace.txt";
- 
- 			break;
- 		case 'h':
- 		case '?':
- 			osnoise_top_usage(params);
- 			break;
- 		case 'p':
- 			params->period = get_llong_from_str(optarg);
- 			if (params->period > 10000000)
- 				fatal("Period longer than 10 s");
- 			break;
- 		case 'q':
- 			params->common.quiet = 1;
- 			break;
- 		case 'r':
- 			params->runtime = get_llong_from_str(optarg);
- 			if (params->runtime < 100)
- 				fatal("Runtime shorter than 100 us");
- 			break;
- 		case 's':
- 			params->common.stop_us = get_llong_from_str(optarg);
- 			break;
- 		case 'S':
- 			params->common.stop_total_us = get_llong_from_str(optarg);
- 			break;
- 		case 't':
- 			trace_output = parse_optional_arg(argc, argv);
- 			if (!trace_output)
- 				trace_output = "osnoise_trace.txt";
- 			break;
- 		case 'T':
- 			params->threshold = get_llong_from_str(optarg);
- 			break;
- 		case '0': /* trigger */
- 			if (params->common.events)
- 				trace_event_add_trigger(params->common.events, optarg);
- 			else
- 				fatal("--trigger requires a previous -e");
- 			break;
- 		case '1': /* filter */
- 			if (params->common.events)
- 				trace_event_add_filter(params->common.events, optarg);
- 			else
- 				fatal("--filter requires a previous -e");
- 			break;
- 		case '2':
- 			params->common.warmup = get_llong_from_str(optarg);
- 			break;
- 		case '3':
- 			params->common.buffer_size = get_llong_from_str(optarg);
- 			break;
- 		case '4':
- 			retval = actions_parse(&params->common.threshold_actions, optarg,
- 					       "osnoise_trace.txt");
- 			if (retval)
- 				fatal("Invalid action %s", optarg);
- 			break;
- 		case '5':
- 			retval = actions_parse(&params->common.end_actions, optarg,
- 					       "osnoise_trace.txt");
- 			if (retval)
- 				fatal("Invalid action %s", optarg);
- 			break;
- 		default:
- 			fatal("Invalid option");
- 		}
- 	}
- 
- 	if (trace_output)
- 		actions_add_trace_output(&params->common.threshold_actions, trace_output);
- 
- 	if (geteuid())
- 		fatal("osnoise needs root permission");
- 
- 	return &params->common;
- }
- 
  /*
   * osnoise_top_apply_config - apply the top configs to the initialized tool
   */
diff --combined tools/tracing/rtla/src/timerlat_hist.c
index 4b6708e333b8f4,df7b1398a966d8..00000000000000
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@@ -4,7 -4,6 +4,6 @@@
   */
  
  #define _GNU_SOURCE
- #include <getopt.h>
  #include <stdlib.h>
  #include <string.h>
  #include <signal.h>
@@@ -17,6 -16,7 +16,7 @@@
  #include "timerlat.h"
  #include "timerlat_aa.h"
  #include "timerlat_bpf.h"
+ #include "cli.h"
  #include "common.h"
  
  struct timerlat_hist_cpu {
@@@ -685,322 -685,6 +685,6 @@@ timerlat_print_stats(struct osnoise_too
  	osnoise_report_missed_events(tool);
  }
  
- /*
-  * timerlat_hist_usage - prints timerlat top usage message
-  */
- static void timerlat_hist_usage(void)
- {
- 	static const char * const msg_start[] = {
- 		"[-d s] [-D] [-n] [-a us] [-p us] [-i us] [-T us] [-s us] \\",
- 		"         [-t [file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] [-H cpu-list]\\",
- 		"	  [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [--no-summary] \\",
- 		"	  [--no-index] [--with-zeros] [--dma-latency us] [-C [cgroup_name]] [--no-aa] [--dump-task] [-u|-k]",
- 		"	  [--warm-up s] [--deepest-idle-state n]",
- 		NULL,
- 	};
- 
- 	static const char * const msg_opts[] = {
- 		"	  -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit",
- 		"	  -p/--period us: timerlat period in us",
- 		"	  -i/--irq us: stop trace if the irq latency is higher than the argument in us",
- 		"	  -T/--thread us: stop trace if the thread latency is higher than the argument in us",
- 		"	  -s/--stack us: save the stack trace at the IRQ if a thread latency is higher than the argument in us",
- 		"	  -c/--cpus cpus: run the tracer only on the given cpus",
- 		"	  -H/--house-keeping cpus: run rtla control threads only on the given cpus",
- 		"	  -C/--cgroup [cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be inherited",
- 		"	  -d/--duration time[m|h|d]: duration of the session in seconds",
- 		"	     --dump-tasks: prints the task running on all CPUs if stop conditions are met (depends on !--no-aa)",
- 		"	  -D/--debug: print debug info",
- 		"	  -t/--trace [file]: save the stopped trace to [file|timerlat_trace.txt]",
- 		"	  -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
- 		"	     --filter <filter>: enable a trace event filter to the previous -e event",
- 		"	     --trigger <trigger>: enable a trace event trigger to the previous -e event",
- 		"	  -n/--nano: display data in nanoseconds",
- 		"	     --no-aa: disable auto-analysis, reducing rtla timerlat cpu usage",
- 		"	  -b/--bucket-size N: set the histogram bucket size (default 1)",
- 		"	  -E/--entries N: set the number of entries of the histogram (default 256)",
- 		"	     --no-irq: ignore IRQ latencies",
- 		"	     --no-thread: ignore thread latencies",
- 		"	     --no-header: do not print header",
- 		"	     --no-summary: do not print summary",
- 		"	     --no-index: do not print index",
- 		"	     --with-zeros: print zero only entries",
- 		"	     --dma-latency us: set /dev/cpu_dma_latency latency <us> to reduce exit from idle latency",
- 		"	  -P/--priority o:prio|r:prio|f:prio|d:runtime:period : set scheduling parameters",
- 		"		o:prio - use SCHED_OTHER with prio",
- 		"		r:prio - use SCHED_RR with prio",
- 		"		f:prio - use SCHED_FIFO with prio",
- 		"		d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period",
- 		"						       in nanoseconds",
- 		"	  -u/--user-threads: use rtla user-space threads instead of kernel-space timerlat threads",
- 		"	  -k/--kernel-threads: use timerlat kernel-space threads instead of rtla user-space threads",
- 		"	  -U/--user-load: enable timerlat for user-defined user-space workload",
- 		"	     --warm-up s: let the workload run for s seconds before collecting data",
- 		"	     --trace-buffer-size kB: set the per-cpu trace buffer size in kB",
- 		"	     --deepest-idle-state n: only go down to idle state n on cpus used by timerlat to reduce exit from idle latency",
- 		"	     --on-threshold <action>: define action to be executed at latency threshold, multiple are allowed",
- 		"	     --on-end <action>: define action to be executed at measurement end, multiple are allowed",
- 		"	     --bpf-action <program>: load and execute BPF program when latency threshold is exceeded",
- 		"	     --stack-format <format>: set the stack format (truncate, skip, full)",
- 		NULL,
- 	};
- 
- 	common_usage("timerlat", "hist", "a per-cpu histogram of the timer latency",
- 		     msg_start, msg_opts);
- }
- 
- /*
-  * timerlat_hist_parse_args - allocs, parse and fill the cmd line parameters
-  */
- static struct common_params
- *timerlat_hist_parse_args(int argc, char *argv[])
- {
- 	struct timerlat_params *params;
- 	int auto_thresh;
- 	int retval;
- 	int c;
- 	char *trace_output = NULL;
- 
- 	params = calloc_fatal(1, sizeof(*params));
- 
- 	actions_init(&params->common.threshold_actions);
- 	actions_init(&params->common.end_actions);
- 
- 	/* disabled by default */
- 	params->dma_latency = -1;
- 
- 	/* disabled by default */
- 	params->deepest_idle_state = -2;
- 
- 	/* display data in microseconds */
- 	params->common.output_divisor = 1000;
- 	params->common.hist.bucket_size = 1;
- 	params->common.hist.entries = 256;
- 
- 	/* default to BPF mode */
- 	params->mode = TRACING_MODE_BPF;
- 
- 	/* default to truncate stack format */
- 	params->stack_format = STACK_FORMAT_TRUNCATE;
- 
- 	while (1) {
- 		static struct option long_options[] = {
- 			COMMON_OPTIONS,
- 			{"auto",		required_argument,	0, 'a'},
- 			{"bucket-size",		required_argument,	0, 'b'},
- 			{"entries",		required_argument,	0, 'E'},
- 			{"help",		no_argument,		0, 'h'},
- 			{"irq",			required_argument,	0, 'i'},
- 			{"nano",		no_argument,		0, 'n'},
- 			{"period",		required_argument,	0, 'p'},
- 			{"stack",		required_argument,	0, 's'},
- 			{"thread",		required_argument,	0, 'T'},
- 			{"trace",		optional_argument,	0, 't'},
- 			{"user-threads",	no_argument,		0, 'u'},
- 			{"kernel-threads",	no_argument,		0, 'k'},
- 			{"user-load",		no_argument,		0, 'U'},
- 			{"no-irq",		no_argument,		0, '0'},
- 			{"no-thread",		no_argument,		0, '1'},
- 			{"no-header",		no_argument,		0, '2'},
- 			{"no-summary",		no_argument,		0, '3'},
- 			{"no-index",		no_argument,		0, '4'},
- 			{"with-zeros",		no_argument,		0, '5'},
- 			{"trigger",		required_argument,	0, '6'},
- 			{"filter",		required_argument,	0, '7'},
- 			{"dma-latency",		required_argument,	0, '8'},
- 			{"no-aa",		no_argument,		0, '9'},
- 			{"dump-task",		no_argument,		0, '\1'},
- 			{"warm-up",		required_argument,	0, '\2'},
- 			{"trace-buffer-size",	required_argument,	0, '\3'},
- 			{"deepest-idle-state",	required_argument,	0, '\4'},
- 			{"on-threshold",	required_argument,	0, '\5'},
- 			{"on-end",		required_argument,	0, '\6'},
- 			{"bpf-action",		required_argument,	0, '\7'},
- 			{"stack-format",	required_argument,	0, '\10'},
- 			{0, 0, 0, 0}
- 		};
- 
- 		c = getopt_auto(argc, argv, long_options);
- 
- 		if (set_common_option(c, argc, argv, &params->common))
- 			continue;
- 
- 		/* detect the end of the options. */
- 		if (c == -1)
- 			break;
- 
- 		switch (c) {
- 		case 'a':
- 			auto_thresh = get_llong_from_str(optarg);
- 
- 			/* set thread stop to auto_thresh */
- 			params->common.stop_total_us = auto_thresh;
- 			params->common.stop_us = auto_thresh;
- 
- 			/* get stack trace */
- 			params->print_stack = auto_thresh;
- 
- 			/* set trace */
- 			if (!trace_output)
- 				trace_output = "timerlat_trace.txt";
- 
- 			break;
- 		case 'b':
- 			params->common.hist.bucket_size = get_llong_from_str(optarg);
- 			if (params->common.hist.bucket_size == 0 ||
- 			    params->common.hist.bucket_size >= 1000000)
- 				fatal("Bucket size needs to be > 0 and <= 1000000");
- 			break;
- 		case 'E':
- 			params->common.hist.entries = get_llong_from_str(optarg);
- 			if (params->common.hist.entries < 10 ||
- 			    params->common.hist.entries > 9999999)
- 				fatal("Entries must be > 10 and < 9999999");
- 			break;
- 		case 'h':
- 		case '?':
- 			timerlat_hist_usage();
- 			break;
- 		case 'i':
- 			params->common.stop_us = get_llong_from_str(optarg);
- 			break;
- 		case 'k':
- 			params->common.kernel_workload = 1;
- 			break;
- 		case 'n':
- 			params->common.output_divisor = 1;
- 			break;
- 		case 'p':
- 			params->timerlat_period_us = get_llong_from_str(optarg);
- 			if (params->timerlat_period_us > 1000000)
- 				fatal("Period longer than 1 s");
- 			break;
- 		case 's':
- 			params->print_stack = get_llong_from_str(optarg);
- 			break;
- 		case 'T':
- 			params->common.stop_total_us = get_llong_from_str(optarg);
- 			break;
- 		case 't':
- 			trace_output = parse_optional_arg(argc, argv);
- 			if (!trace_output)
- 				trace_output = "timerlat_trace.txt";
- 			break;
- 		case 'u':
- 			params->common.user_workload = 1;
- 			/* fallback: -u implies in -U */
- 		case 'U':
- 			params->common.user_data = 1;
- 			break;
- 		case '0': /* no irq */
- 			params->common.hist.no_irq = 1;
- 			break;
- 		case '1': /* no thread */
- 			params->common.hist.no_thread = 1;
- 			break;
- 		case '2': /* no header */
- 			params->common.hist.no_header = 1;
- 			break;
- 		case '3': /* no summary */
- 			params->common.hist.no_summary = 1;
- 			break;
- 		case '4': /* no index */
- 			params->common.hist.no_index = 1;
- 			break;
- 		case '5': /* with zeros */
- 			params->common.hist.with_zeros = 1;
- 			break;
- 		case '6': /* trigger */
- 			if (params->common.events)
- 				trace_event_add_trigger(params->common.events, optarg);
- 			else
- 				fatal("--trigger requires a previous -e");
- 			break;
- 		case '7': /* filter */
- 			if (params->common.events)
- 				trace_event_add_filter(params->common.events, optarg);
- 			else
- 				fatal("--filter requires a previous -e");
- 			break;
- 		case '8':
- 			params->dma_latency = get_llong_from_str(optarg);
- 			if (params->dma_latency < 0 || params->dma_latency > 10000)
- 				fatal("--dma-latency needs to be >= 0 and < 10000");
- 			break;
- 		case '9':
- 			params->no_aa = 1;
- 			break;
- 		case '\1':
- 			params->dump_tasks = 1;
- 			break;
- 		case '\2':
- 			params->common.warmup = get_llong_from_str(optarg);
- 			break;
- 		case '\3':
- 			params->common.buffer_size = get_llong_from_str(optarg);
- 			break;
- 		case '\4':
- 			params->deepest_idle_state = get_llong_from_str(optarg);
- 			break;
- 		case '\5':
- 			retval = actions_parse(&params->common.threshold_actions, optarg,
- 					       "timerlat_trace.txt");
- 			if (retval)
- 				fatal("Invalid action %s", optarg);
- 			break;
- 		case '\6':
- 			retval = actions_parse(&params->common.end_actions, optarg,
- 					       "timerlat_trace.txt");
- 			if (retval)
- 				fatal("Invalid action %s", optarg);
- 			break;
- 		case '\7':
- 			params->bpf_action_program = optarg;
- 			break;
- 		case '\10':
- 			params->stack_format = parse_stack_format(optarg);
- 			if (params->stack_format == -1)
- 				fatal("Invalid --stack-format option");
- 			break;
- 		default:
- 			fatal("Invalid option");
- 		}
- 	}
- 
- 	if (trace_output)
- 		actions_add_trace_output(&params->common.threshold_actions, trace_output);
- 
- 	if (geteuid())
- 		fatal("rtla needs root permission");
- 
- 	if (params->common.hist.no_irq && params->common.hist.no_thread)
- 		fatal("no-irq and no-thread set, there is nothing to do here");
- 
- 	if (params->common.hist.no_index && !params->common.hist.with_zeros)
- 		fatal("no-index set with with-zeros is not set - it does not make sense");
- 
- 	/*
- 	 * Auto analysis only happens if stop tracing, thus:
- 	 */
- 	if (!params->common.stop_us && !params->common.stop_total_us)
- 		params->no_aa = 1;
- 
- 	if (params->common.kernel_workload && params->common.user_workload)
- 		fatal("--kernel-threads and --user-threads are mutually exclusive!");
- 
- 	/*
- 	 * If auto-analysis or trace output is enabled, switch from BPF mode to
- 	 * mixed mode
- 	 */
- 	if (params->mode == TRACING_MODE_BPF &&
- 	    (params->common.threshold_actions.present[ACTION_TRACE_OUTPUT] ||
- 	     params->common.end_actions.present[ACTION_TRACE_OUTPUT] ||
- 	     !params->no_aa))
- 		params->mode = TRACING_MODE_MIXED;
- 
- 	return &params->common;
- }
- 
  /*
   * timerlat_hist_apply_config - apply the hist configs to the initialized tool
   */
diff --combined tools/tracing/rtla/src/timerlat_top.c
index 91f88bbebad9eb,18e1071a2e242b..00000000000000
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@@ -4,7 -4,6 +4,6 @@@
   */
  
  #define _GNU_SOURCE
- #include <getopt.h>
  #include <stdlib.h>
  #include <string.h>
  #include <signal.h>
@@@ -17,6 -16,7 +16,7 @@@
  #include "timerlat.h"
  #include "timerlat_aa.h"
  #include "timerlat_bpf.h"
+ #include "cli.h"
  #include "common.h"
  
  struct timerlat_top_cpu {
@@@ -459,290 -459,6 +459,6 @@@ timerlat_print_stats(struct osnoise_too
  	osnoise_report_missed_events(top);
  }
  
- /*
-  * timerlat_top_usage - prints timerlat top usage message
-  */
- static void timerlat_top_usage(void)
- {
- 	static const char *const msg_start[] = {
- 		"[-q] [-a us] [-d s] [-D] [-n] [-p us] [-i us] [-T us] [-s us] \\",
- 		"	  [[-t [file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] [-c cpu-list] [-H cpu-list]\\",
- 		"	  [-P priority] [--dma-latency us] [--aa-only us] [-C [cgroup_name]] [-u|-k] [--warm-up s] [--deepest-idle-state n]",
- 		NULL,
- 	};
- 
- 	static const char *const msg_opts[] = {
- 		"	  -a/--auto: set automatic trace mode, stopping the session if argument in us latency is hit",
- 		"	     --aa-only us: stop if <us> latency is hit, only printing the auto analysis (reduces CPU usage)",
- 		"	  -p/--period us: timerlat period in us",
- 		"	  -i/--irq us: stop trace if the irq latency is higher than the argument in us",
- 		"	  -T/--thread us: stop trace if the thread latency is higher than the argument in us",
- 		"	  -s/--stack us: save the stack trace at the IRQ if a thread latency is higher than the argument in us",
- 		"	  -c/--cpus cpus: run the tracer only on the given cpus",
- 		"	  -H/--house-keeping cpus: run rtla control threads only on the given cpus",
- 		"	  -C/--cgroup [cgroup_name]: set cgroup, if no cgroup_name is passed, the rtla's cgroup will be inherited",
- 		"	  -d/--duration time[s|m|h|d]: duration of the session",
- 		"	  -D/--debug: print debug info",
- 		"	     --dump-tasks: prints the task running on all CPUs if stop conditions are met (depends on !--no-aa)",
- 		"	  -t/--trace [file]: save the stopped trace to [file|timerlat_trace.txt]",
- 		"	  -e/--event <sys:event>: enable the <sys:event> in the trace instance, multiple -e are allowed",
- 		"	     --filter <command>: enable a trace event filter to the previous -e event",
- 		"	     --trigger <command>: enable a trace event trigger to the previous -e event",
- 		"	  -n/--nano: display data in nanoseconds",
- 		"	     --no-aa: disable auto-analysis, reducing rtla timerlat cpu usage",
- 		"	  -q/--quiet print only a summary at the end",
- 		"	     --dma-latency us: set /dev/cpu_dma_latency latency <us> to reduce exit from idle latency",
- 		"	  -P/--priority o:prio|r:prio|f:prio|d:runtime:period : set scheduling parameters",
- 		"		o:prio - use SCHED_OTHER with prio",
- 		"		r:prio - use SCHED_RR with prio",
- 		"		f:prio - use SCHED_FIFO with prio",
- 		"		d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime and period",
- 		"						       in nanoseconds",
- 		"	  -u/--user-threads: use rtla user-space threads instead of kernel-space timerlat threads",
- 		"	  -k/--kernel-threads: use timerlat kernel-space threads instead of rtla user-space threads",
- 		"	  -U/--user-load: enable timerlat for user-defined user-space workload",
- 		"	     --warm-up s: let the workload run for s seconds before collecting data",
- 		"	     --trace-buffer-size kB: set the per-cpu trace buffer size in kB",
- 		"	     --deepest-idle-state n: only go down to idle state n on cpus used by timerlat to reduce exit from idle latency",
- 		"	     --on-threshold <action>: define action to be executed at latency threshold, multiple are allowed",
- 		"	     --on-end: define action to be executed at measurement end, multiple are allowed",
- 		"	     --bpf-action <program>: load and execute BPF program when latency threshold is exceeded",
- 		"	     --stack-format <format>: set the stack format (truncate, skip, full)",
- 		NULL,
- 	};
- 
- 	common_usage("timerlat", "top", "a per-cpu summary of the timer latency",
- 		     msg_start, msg_opts);
- }
- 
- /*
-  * timerlat_top_parse_args - allocs, parse and fill the cmd line parameters
-  */
- static struct common_params
- *timerlat_top_parse_args(int argc, char **argv)
- {
- 	struct timerlat_params *params;
- 	long long auto_thresh;
- 	int retval;
- 	int c;
- 	char *trace_output = NULL;
- 
- 	params = calloc_fatal(1, sizeof(*params));
- 
- 	actions_init(&params->common.threshold_actions);
- 	actions_init(&params->common.end_actions);
- 
- 	/* disabled by default */
- 	params->dma_latency = -1;
- 
- 	/* disabled by default */
- 	params->deepest_idle_state = -2;
- 
- 	/* display data in microseconds */
- 	params->common.output_divisor = 1000;
- 
- 	/* default to BPF mode */
- 	params->mode = TRACING_MODE_BPF;
- 
- 	/* default to truncate stack format */
- 	params->stack_format = STACK_FORMAT_TRUNCATE;
- 
- 	while (1) {
- 		static struct option long_options[] = {
- 			COMMON_OPTIONS,
- 			{"auto",		required_argument,	0, 'a'},
- 			{"help",		no_argument,		0, 'h'},
- 			{"irq",			required_argument,	0, 'i'},
- 			{"nano",		no_argument,		0, 'n'},
- 			{"period",		required_argument,	0, 'p'},
- 			{"quiet",		no_argument,		0, 'q'},
- 			{"stack",		required_argument,	0, 's'},
- 			{"thread",		required_argument,	0, 'T'},
- 			{"trace",		optional_argument,	0, 't'},
- 			{"user-threads",	no_argument,		0, 'u'},
- 			{"kernel-threads",	no_argument,		0, 'k'},
- 			{"user-load",		no_argument,		0, 'U'},
- 			{"trigger",		required_argument,	0, '0'},
- 			{"filter",		required_argument,	0, '1'},
- 			{"dma-latency",		required_argument,	0, '2'},
- 			{"no-aa",		no_argument,		0, '3'},
- 			{"dump-tasks",		no_argument,		0, '4'},
- 			{"aa-only",		required_argument,	0, '5'},
- 			{"warm-up",		required_argument,	0, '6'},
- 			{"trace-buffer-size",	required_argument,	0, '7'},
- 			{"deepest-idle-state",	required_argument,	0, '8'},
- 			{"on-threshold",	required_argument,	0, '9'},
- 			{"on-end",		required_argument,	0, '\1'},
- 			{"bpf-action",		required_argument,	0, '\2'},
- 			{"stack-format",	required_argument,	0, '\3'},
- 			{0, 0, 0, 0}
- 		};
- 
- 		c = getopt_auto(argc, argv, long_options);
- 
- 		if (set_common_option(c, argc, argv, &params->common))
- 			continue;
- 
- 		/* detect the end of the options. */
- 		if (c == -1)
- 			break;
- 
- 		switch (c) {
- 		case 'a':
- 			auto_thresh = get_llong_from_str(optarg);
- 
- 			/* set thread stop to auto_thresh */
- 			params->common.stop_total_us = auto_thresh;
- 			params->common.stop_us = auto_thresh;
- 
- 			/* get stack trace */
- 			params->print_stack = auto_thresh;
- 
- 			/* set trace */
- 			if (!trace_output)
- 				trace_output = "timerlat_trace.txt";
- 
- 			break;
- 		case '5':
- 			/* it is here because it is similar to -a */
- 			auto_thresh = get_llong_from_str(optarg);
- 
- 			/* set thread stop to auto_thresh */
- 			params->common.stop_total_us = auto_thresh;
- 			params->common.stop_us = auto_thresh;
- 
- 			/* get stack trace */
- 			params->print_stack = auto_thresh;
- 
- 			/* set aa_only to avoid parsing the trace */
- 			params->common.aa_only = 1;
- 			break;
- 		case 'h':
- 		case '?':
- 			timerlat_top_usage();
- 			break;
- 		case 'i':
- 			params->common.stop_us = get_llong_from_str(optarg);
- 			break;
- 		case 'k':
- 			params->common.kernel_workload = true;
- 			break;
- 		case 'n':
- 			params->common.output_divisor = 1;
- 			break;
- 		case 'p':
- 			params->timerlat_period_us = get_llong_from_str(optarg);
- 			if (params->timerlat_period_us > 1000000)
- 				fatal("Period longer than 1 s");
- 			break;
- 		case 'q':
- 			params->common.quiet = 1;
- 			break;
- 		case 's':
- 			params->print_stack = get_llong_from_str(optarg);
- 			break;
- 		case 'T':
- 			params->common.stop_total_us = get_llong_from_str(optarg);
- 			break;
- 		case 't':
- 			trace_output = parse_optional_arg(argc, argv);
- 			if (!trace_output)
- 				trace_output = "timerlat_trace.txt";
- 			break;
- 		case 'u':
- 			params->common.user_workload = true;
- 			/* fallback: -u implies -U */
- 		case 'U':
- 			params->common.user_data = true;
- 			break;
- 		case '0': /* trigger */
- 			if (params->common.events)
- 				trace_event_add_trigger(params->common.events, optarg);
- 			else
- 				fatal("--trigger requires a previous -e");
- 			break;
- 		case '1': /* filter */
- 			if (params->common.events)
- 				trace_event_add_filter(params->common.events, optarg);
- 			else
- 				fatal("--filter requires a previous -e");
- 			break;
- 		case '2': /* dma-latency */
- 			params->dma_latency = get_llong_from_str(optarg);
- 			if (params->dma_latency < 0 || params->dma_latency > 10000)
- 				fatal("--dma-latency needs to be >= 0 and < 10000");
- 			break;
- 		case '3': /* no-aa */
- 			params->no_aa = 1;
- 			break;
- 		case '4':
- 			params->dump_tasks = 1;
- 			break;
- 		case '6':
- 			params->common.warmup = get_llong_from_str(optarg);
- 			break;
- 		case '7':
- 			params->common.buffer_size = get_llong_from_str(optarg);
- 			break;
- 		case '8':
- 			params->deepest_idle_state = get_llong_from_str(optarg);
- 			break;
- 		case '9':
- 			retval = actions_parse(&params->common.threshold_actions, optarg,
- 					       "timerlat_trace.txt");
- 			if (retval)
- 				fatal("Invalid action %s", optarg);
- 			break;
- 		case '\1':
- 			retval = actions_parse(&params->common.end_actions, optarg,
- 					       "timerlat_trace.txt");
- 			if (retval)
- 				fatal("Invalid action %s", optarg);
- 			break;
- 		case '\2':
- 			params->bpf_action_program = optarg;
- 			break;
- 		case '\3':
- 			params->stack_format = parse_stack_format(optarg);
- 			if (params->stack_format == -1)
- 				fatal("Invalid --stack-format option");
- 			break;
- 		default:
- 			fatal("Invalid option");
- 		}
- 	}
- 
- 	if (trace_output)
- 		actions_add_trace_output(&params->common.threshold_actions, trace_output);
- 
- 	if (geteuid())
- 		fatal("rtla needs root permission");
- 
- 	/*
- 	 * Auto analysis only happens if stop tracing, thus:
- 	 */
- 	if (!params->common.stop_us && !params->common.stop_total_us)
- 		params->no_aa = 1;
- 
- 	if (params->no_aa && params->common.aa_only)
- 		fatal("--no-aa and --aa-only are mutually exclusive!");
- 
- 	if (params->common.kernel_workload && params->common.user_workload)
- 		fatal("--kernel-threads and --user-threads are mutually exclusive!");
- 
- 	/*
- 	 * If auto-analysis or trace output is enabled, switch from BPF mode to
- 	 * mixed mode
- 	 */
- 	if (params->mode == TRACING_MODE_BPF &&
- 	    (params->common.threshold_actions.present[ACTION_TRACE_OUTPUT] ||
- 	     params->common.end_actions.present[ACTION_TRACE_OUTPUT] ||
- 	     !params->no_aa))
- 		params->mode = TRACING_MODE_MIXED;
- 
- 	return &params->common;
- }
- 
  /*
   * timerlat_top_apply_config - apply the top configs to the initialized tool
   */

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2026-06-10 15:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-10 15:33 Mark Brown [this message]
2026-06-10 16:47 ` linux-next: manual merge of the ftrace tree with the tip-fixes tree Tomas Glozar

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=aimDwlNq_RRLjg6X@sirena.co.uk \
    --to=broonie@kernel.org \
    --cc=costa.shul@redhat.com \
    --cc=crwood@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglozar@redhat.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