diff mbox series

[rt-tests,v1,1/2] cyclicdeadline: Generate ftrace log entries in debug mode only

Message ID 20210523184016.32314-2-dwagner@suse.de
State New
Headers show
Series Silence cyclicdeadline | expand

Commit Message

Daniel Wagner May 23, 2021, 6:40 p.m. UTC
Introduce a new command line option --debug which enables the ftrace
log entries only if enabled. Currently, cyclicdeadline will log every
start of a cycle to kernel buffer, e.g. "cyclicdeadline -i 5000" gives

start at 30269625044 off=4 (period=30269625040 next=30269630040)
T: 0 (27109) I:5000 C:    230 Min:      2 Act:    2 Avg:    1 Max:       4
start at 30269635041 off=1 (period=30269635040 next=30269640040)
T: 0 (27109) I:5000 C:    232 Min:      1 Act:    1 Avg:    1 Max:       4

in case the kernel log levels are set higher which is usually the case
of CI systems.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/sched_deadline/cyclicdeadline.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 4c81891bbe63..dea9800b6507 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -87,8 +87,9 @@  static int cpu_count;
 static int all_cpus;
 static int nr_threads;
 static int use_nsecs;
-static int mark_fd;
+static int mark_fd = -1;
 static int quiet;
+static int debug_enabled;
 static char jsonfile[MAX_PATH];
 
 static int find_mount(const char *mount, char *debugfs)
@@ -602,6 +603,7 @@  static void usage(int error)
 	       "-D TIME  --duration        Specify a length for the test run.\n"
 	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
 	       "                           days\n"
+	       "         --debug           Enable ftrace logging\n"
 	       "-h       --help            Show this help menu.\n"
 	       "-i INTV  --interval        The shortest deadline for the tasks in us\n"
 	       "                           (default 1000us).\n"
@@ -985,7 +987,7 @@  static void write_stats(FILE *f, void *data)
 }
 
 enum options_valud {
-	OPT_AFFINITY=1, OPT_DURATION, OPT_HELP, OPT_INTERVAL,
+	OPT_AFFINITY=1, OPT_DURATION, OPT_DEBUG, OPT_HELP, OPT_INTERVAL,
 	OPT_JSON, OPT_STEP, OPT_THREADS, OPT_QUIET
 };
 
@@ -1019,6 +1021,7 @@  int main(int argc, char **argv)
 		static struct option options[] = {
 			{ "affinity",	optional_argument,	NULL,	OPT_AFFINITY },
 			{ "duration",	required_argument,	NULL,	OPT_DURATION },
+			{ "debug",	no_argument,		NULL,	OPT_DEBUG },
 			{ "help",	no_argument,		NULL,	OPT_HELP },
 			{ "interval",	required_argument,	NULL,	OPT_INTERVAL },
 			{ "json",	required_argument,	NULL,	OPT_JSON },
@@ -1062,6 +1065,9 @@  int main(int argc, char **argv)
 		case 'D':
 			duration = parse_time_string(optarg);
 			break;
+	        case OPT_DEBUG:
+			debug_enabled = 1;
+			break;
 		case OPT_QUIET:
 		case 'q':
 			quiet = 1;
@@ -1106,7 +1112,8 @@  int main(int argc, char **argv)
 	if (mlockall(MCL_CURRENT|MCL_FUTURE) == -1)
 		warn("mlockall");
 
-	setup_ftrace_marker();
+	if (debug_enabled)
+		setup_ftrace_marker();
 
 	thread = calloc(nr_threads, sizeof(*thread));
 	sched_data = calloc(nr_threads, sizeof(*sched_data));