Skip to contentSkip to conversation

cyclictest: make clock_nanosleep as default and add option for POSIX timers.

PATCH In review Vedang Patel 3 participants 9 messages Mar 13, 2017 – Apr 11, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cyclictest: make clock_nanosleep as default and add option for POSIX timers.

it is recommended that clock_nanosleep should be used for real-time wherever available. So, make sure that cyclictest runs clock_nanosleep by default. Added an option to run POSIX timers. The '-n' option is redundant now. I did not remove it so that it does not break existing scripts.

---
 src/cyclictest/cyclictest.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
src/cyclictest/cyclictest.c +9 -3
index 00e5f3d59a5b..a185a8a99065 100644
@@ -1360,7 +1360,8 @@ static void display_help(int error)
 	       "                           format: n:c:v n=tasknum c=count v=value in us\n"
 	       "-w       --wakeup          task wakeup tracing (used with -b)\n"
 	       "-W       --wakeuprt        rt task wakeup tracing (used with -b)\n"
-	       "	 --dbg_cyclictest  print info useful for debugging cyclictest\n",
+	       "	 --dbg_cyclictest  print info useful for debugging cyclictest\n"
+	       "-x	 --posix_timers    use POSIX timers\n",
 	       tracers
 		);
 	if (error)
@@ -1368,7 +1369,7 @@ static void display_help(int error)
 	exit(EXIT_SUCCESS);
 }
 
-static int use_nanosleep;
+static int use_nanosleep = MODE_CLOCK_NANOSLEEP; /* use clock_nanosleep by default. */
 static int timermode = TIMER_ABSTIME;
 static int use_system;
 static int priority;
@@ -1489,6 +1490,7 @@ enum option_values {
 	OPT_TRIGGER_NODES, OPT_UNBUFFERED, OPT_NUMA, OPT_VERBOSE, OPT_WAKEUP,
 	OPT_WAKEUPRT, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP, OPT_NUMOPTS,
 	OPT_ALIGNED, OPT_SECALIGNED, OPT_LAPTOP, OPT_SMI, OPT_TRACEMARK,
+	OPT_POSIX_TIMERS,
 };
 
 /* Process commandline options */
@@ -1553,9 +1555,10 @@ static void process_options (int argc, char *argv[], int max_cpus)
 			{"dbg_cyclictest",   no_argument,       NULL, OPT_DBGCYCLIC },
 			{"policy",           required_argument, NULL, OPT_POLICY },
 			{"help",             no_argument,       NULL, OPT_HELP },
+			{"posix_timers",     no_argument,	NULL, OPT_POSIX_TIMERS },
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long(argc, argv, "a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:",
+		int c = getopt_long(argc, argv, "a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:x",
 				    long_options, &option_index);
 		if (c == -1)
 			break;
@@ -1756,6 +1759,9 @@ static void process_options (int argc, char *argv[], int max_cpus)
 		case 'W':
 		case OPT_WAKEUPRT:
 			tracetype = WAKEUPRT; break;
+		case 'x':
+		case OPT_POSIX_TIMERS:
+			use_nanosleep = MODE_CYCLIC; break;
 		case '?':
 		case OPT_HELP:
 			display_help(0); break;
Signature · 1 line
2.7.3
#1 lore raw

 Fixing a typo in John's email

-Vedang

Quoted 83 lines · Vedang Patel

it is recommended that clock_nanosleep should be used for real-time wherever available. So, make sure that cyclictest runs clock_nanosleep
by default. Added an option to run POSIX timers. The '-n' option is redundant now. I did not remove it so that it does not break existing scripts.

---
 src/cyclictest/cyclictest.c | 12 +++++++++---

 1 file changed, 9 insertions(+), 3 deletions(-)
src/cyclictest/cyclictest.c +0 -0
index 00e5f3d59a5b..a185a8a99065 100644
@@ -1360,7 +1360,8 @@ static void display_help(int error)

         "                           format: n:c:v n=tasknum c=count v=value in us\n"
         "-w       --wakeup          task wakeup tracing (used with -b)\n"
         "-W       --wakeuprt        rt task wakeup tracing (used with -b)\n"

src/cyclictest/cyclictest.c +0 -1
-	       "	 --dbg_cyclictest  print info useful for

debugging cyclictest\n",

src/cyclictest/cyclictest.c +1 -0
+	       "	 --dbg_cyclictest  print info useful for

debugging cyclictest\n"

src/cyclictest/cyclictest.c +1 -0
+	       "-x	 --posix_timers    use POSIX timers\n",

         tracers
  );
  if (error)

src/cyclictest/cyclictest.c +0 -0
@@ -1368,7 +1369,7 @@ static void display_help(int error)
  	exit(EXIT_SUCCESS);
  }

src/cyclictest/cyclictest.c +1 -1
-static int use_nanosleep;
+static int use_nanosleep = MODE_CLOCK_NANOSLEEP; /* use

clock_nanosleep by default. */
 static int timermode = TIMER_ABSTIME;
 static int use_system;
 static int priority;

src/cyclictest/cyclictest.c +1 -0
@@ -1489,6 +1490,7 @@ enum option_values {
  	OPT_TRIGGER_NODES, OPT_UNBUFFERED, OPT_NUMA, OPT_VERBOSE,
 OPT_WAKEUP,
  	OPT_WAKEUPRT, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP,
 OPT_NUMOPTS,
  	OPT_ALIGNED, OPT_SECALIGNED, OPT_LAPTOP, OPT_SMI,
 OPT_TRACEMARK,
+	OPT_POSIX_TIMERS,

 };

 /* Process commandline options */

src/cyclictest/cyclictest.c +0 -0
@@ -1553,9 +1555,10 @@ static void process_options (int argc, char
 *argv[], int max_cpus)

  {"dbg_cyclictest",   no_argument,       NULL , OPT_DBGCYCLIC },
  {"policy",           required_argument, NULL, OPT_POLICY },
  {"help",             no_argument,       NULL , OPT_HELP },

src/cyclictest/cyclictest.c +1 -0
+			{"posix_timers",     no_argument,	NUL

L, OPT_POSIX_TIMERS },
  {NULL, 0, NULL, 0}
  };

src/cyclictest/cyclictest.c +0 -1
-		int c = getopt_long(argc, argv,

"a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:",

src/cyclictest/cyclictest.c +1 -0
+		int c = getopt_long(argc, argv,

"a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:x", long_options, &option_index); if (c == -1)
  break;

src/cyclictest/cyclictest.c +0 -0
@@ -1756,6 +1759,9 @@ static void process_options (int argc, char
 *argv[], int max_cpus)

  case 'W':
  case OPT_WAKEUPRT:
  tracetype = WAKEUPRT; break;

src/cyclictest/cyclictest.c +3 -0
+		case 'x':
+		case OPT_POSIX_TIMERS:
+			use_nanosleep = MODE_CYCLIC; break;

  case '?':
  case OPT_HELP:
  display_help(0); break;

#2 lore raw
Quoted 79 lines · Vedang

 Fixing a typo in John's email

-Vedang

Quoted 75 lines · Vedang Patel

it is recommended that clock_nanosleep should be used for real-time wherever available. So, make sure that cyclictest runs clock_nanosleep
by default. Added an option to run POSIX timers. The '-n' option is redundant now. I did not remove it so that it does not break existing scripts.

---
 src/cyclictest/cyclictest.c | 12 +++++++++---

 1 file changed, 9 insertions(+), 3 deletions(-)
src/cyclictest/cyclictest.c +0 -0
index 00e5f3d59a5b..a185a8a99065 100644
@@ -1360,7 +1360,8 @@ static void display_help(int error)

         "                           format: n:c:v n=tasknum c=count v=value in us\n"
         "-w       --wakeup          task wakeup tracing (used with -b)\n"
         "-W       --wakeuprt        rt task wakeup tracing (used with -b)\n"

src/cyclictest/cyclictest.c +0 -1
-	       "	 --dbg_cyclictest  print info useful for

debugging cyclictest\n",

src/cyclictest/cyclictest.c +1 -0
+	       "	 --dbg_cyclictest  print info useful for

debugging cyclictest\n"

src/cyclictest/cyclictest.c +1 -0
+	       "-x	 --posix_timers    use POSIX timers\n",

         tracers
  );
  if (error)

src/cyclictest/cyclictest.c +0 -0
@@ -1368,7 +1369,7 @@ static void display_help(int error)
  	exit(EXIT_SUCCESS);
  }

src/cyclictest/cyclictest.c +1 -1
-static int use_nanosleep;
+static int use_nanosleep = MODE_CLOCK_NANOSLEEP; /* use

clock_nanosleep by default. */
 static int timermode = TIMER_ABSTIME;
 static int use_system;
 static int priority;

src/cyclictest/cyclictest.c +1 -0
@@ -1489,6 +1490,7 @@ enum option_values {
  	OPT_TRIGGER_NODES, OPT_UNBUFFERED, OPT_NUMA, OPT_VERBOSE,
 OPT_WAKEUP,
  	OPT_WAKEUPRT, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP,
 OPT_NUMOPTS,
  	OPT_ALIGNED, OPT_SECALIGNED, OPT_LAPTOP, OPT_SMI,
 OPT_TRACEMARK,
+	OPT_POSIX_TIMERS,

 };

 /* Process commandline options */

src/cyclictest/cyclictest.c +0 -0
@@ -1553,9 +1555,10 @@ static void process_options (int argc, char
 *argv[], int max_cpus)

  {"dbg_cyclictest",   no_argument,       NULL , OPT_DBGCYCLIC },
  {"policy",           required_argument, NULL, OPT_POLICY },
  {"help",             no_argument,       NULL , OPT_HELP },

src/cyclictest/cyclictest.c +1 -0
+			{"posix_timers",     no_argument,	NUL

L, OPT_POSIX_TIMERS },
  {NULL, 0, NULL, 0}
  };

src/cyclictest/cyclictest.c +0 -1
-		int c = getopt_long(argc, argv,

"a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:",

src/cyclictest/cyclictest.c +1 -0
+		int c = getopt_long(argc, argv,

"a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:x", long_options, &option_index); if (c == -1)
  break;

src/cyclictest/cyclictest.c +0 -0
@@ -1756,6 +1759,9 @@ static void process_options (int argc, char
 *argv[], int max_cpus)

  case 'W':

Quoted 8 lines
Quoted 8 lines

  case OPT_WAKEUPRT:
  tracetype = WAKEUPRT; break;

src/cyclictest/cyclictest.c +3 -0
+		case 'x':
+		case OPT_POSIX_TIMERS:
+			use_nanosleep = MODE_CYCLIC; break;

  case '?':
  case OPT_HELP:
  display_help(0); break;

We could apply this to the "unstable" developer version, in which case we are not concerned with maintaining compatibility with scripts etc, so you can go ahead and remove -n too.

Use either one of the following branches
unstable/devel/v1.1.1
unstable/devel/v1.1.1-devel

(yeah, I need to clean that up in the near future)

Thanks

John

#3 lore raw
Quoted 111 lines · John Kacur
Quoted 94 lines · Vedang

 Fixing a typo in John's email

-Vedang

Quoted 89 lines · Vedang Patel

it is recommended that clock_nanosleep should be used for real- time
wherever available. So, make sure that cyclictest runs clock_nanosleep
by default. Added an option to run POSIX timers. The '-n' option is
redundant now. I did not remove it so that it does not break existing
scripts.

---
 src/cyclictest/cyclictest.c | 12 +++++++++---

 1 file changed, 9 insertions(+), 3 deletions(-)
src/cyclictest/cyclictest.c +0 -0
index 00e5f3d59a5b..a185a8a99065 100644
@@ -1360,7 +1360,8 @@ static void display_help(int error)

         "                           format: n:c:v n=tasknum
c=count v=value in us\n"
         "-w       --wakeup          task wakeup tracing (used
with -b)\n"
         "-W       --wakeuprt        rt task wakeup tracing
(used with -b)\n"

src/cyclictest/cyclictest.c +0 -1
-	       "	 --dbg_cyclictest  print info useful for

debugging cyclictest\n",

src/cyclictest/cyclictest.c +1 -0
+	       "	 --dbg_cyclictest  print info useful for

debugging cyclictest\n"

src/cyclictest/cyclictest.c +1 -0
+	       "-x	 --posix_timers    use POSIX

timers\n",
         tracers
  );
  if (error)

src/cyclictest/cyclictest.c +0 -0
@@ -1368,7 +1369,7 @@ static void display_help(int error)
  	exit(EXIT_SUCCESS);
  }

src/cyclictest/cyclictest.c +1 -1
-static int use_nanosleep;
+static int use_nanosleep = MODE_CLOCK_NANOSLEEP; /* use

clock_nanosleep by default. */
 static int timermode = TIMER_ABSTIME;
 static int use_system;
 static int priority;

src/cyclictest/cyclictest.c +0 -0
@@ -1489,6 +1490,7 @@ enum option_values {
  	OPT_TRIGGER_NODES, OPT_UNBUFFERED, OPT_NUMA,
 OPT_VERBOSE,
 OPT_WAKEUP,
  	OPT_WAKEUPRT, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP,
 OPT_NUMOPTS,
  	OPT_ALIGNED, OPT_SECALIGNED, OPT_LAPTOP, OPT_SMI,

OPT_TRACEMARK,

src/cyclictest/cyclictest.c +1 -0
+	OPT_POSIX_TIMERS,

 };

 /* Process commandline options */

src/cyclictest/cyclictest.c +0 -0
@@ -1553,9 +1555,10 @@ static void process_options (int argc,

char
*argv[], int max_cpus)
  {"dbg_cyclictest",   no_argument, NULL
, OPT_DBGCYCLIC },
  {"policy",           required_argument, NULL, OPT_POLICY },
  {"help",             no_argument, NULL
, OPT_HELP },

src/cyclictest/cyclictest.c +1 -0
+			{"posix_timers",     no_argument,	

NUL
L, OPT_POSIX_TIMERS },
  {NULL, 0, NULL, 0}
  };

src/cyclictest/cyclictest.c +0 -1
-		int c = getopt_long(argc, argv,

"a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:",

src/cyclictest/cyclictest.c +1 -0
+		int c = getopt_long(argc, argv,

"a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:x", long_options, &option_index);
  if (c == -1)
  break;

src/cyclictest/cyclictest.c +0 -0
@@ -1756,6 +1759,9 @@ static void process_options (int argc, char
 *argv[], int max_cpus)

  case 'W':

Quoted 8 lines
Quoted 8 lines

  case OPT_WAKEUPRT:
  tracetype = WAKEUPRT; break;

src/cyclictest/cyclictest.c +3 -0
+		case 'x':
+		case OPT_POSIX_TIMERS:
+			use_nanosleep = MODE_CYCLIC; break;

  case '?':
  case OPT_HELP:
  display_help(0); break;

We could apply this to the "unstable" developer version, in which case we
are not concerned with maintaining compatibility with scripts etc, so you can go ahead and remove -n too.

Quoted 4 lines

Use either one of the following branches
unstable/devel/v1.1.1
unstable/devel/v1.1.1-devel

Thanks for the quick response, John. Sending another patch after removing '-n' option and rebasing on top of v1.1.1-devel.

Thanks,
Vedang Patel
Software Engineer
Intel Corporation

Quoted 5 lines

(yeah, I need to clean that up in the near future)

Thanks

John

#4 lore raw

PATCH 1/1 cyclictest: make clock_nanosleep as default and add option for POSIX timers.

In reply to John Kacur

it is recommended that clock_nanosleep should be used for real-time wherever available. So, make sure that cyclictest runs clock_nanosleep by default. Added an option to run POSIX timers. Removing the '-n' option because it is redundant now.

---
 src/cyclictest/cyclictest.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
src/cyclictest/cyclictest.c +9 -8
index 3f1bef1ffca9..cf82f8e1deaa 100644
@@ -1321,7 +1321,6 @@ static void display_help(int error)
 	       "-m       --mlockall        lock current and future memory allocations\n"
 	       "-M       --refresh_on_max  delay updating the screen until a new max\n"
 	       "			   latency is hit. Userful for low bandwidth.\n"
-	       "-n       --nanosleep       use clock_nanosleep\n"
 	       "	 --notrace	   suppress tracing\n"
 	       "-N       --nsecs           print results in ns instead of us (default us)\n"
 	       "-o RED   --oscope=RED      oscilloscope mode, reduce verbose output by RED\n"
@@ -1364,7 +1363,8 @@ static void display_help(int error)
 	       "                           format: n:c:v n=tasknum c=count v=value in us\n"
 	       "-w       --wakeup          task wakeup tracing (used with -b)\n"
 	       "-W       --wakeuprt        rt task wakeup tracing (used with -b)\n"
-	       "	 --dbg_cyclictest  print info useful for debugging cyclictest\n",
+	       "	 --dbg_cyclictest  print info useful for debugging cyclictest\n"
+	       "-x	 --posix_timers    use POSIX timers\n",
 	       tracers
 		);
 	if (error)
@@ -1372,7 +1372,7 @@ static void display_help(int error)
 	exit(EXIT_SUCCESS);
 }
 
-static int use_nanosleep;
+static int use_nanosleep = MODE_CLOCK_NANOSLEEP; /* use clock_nanosleep by default. */
 static int timermode = TIMER_ABSTIME;
 static int use_system;
 static int priority;
@@ -1493,6 +1493,7 @@ enum option_values {
 	OPT_TRIGGER_NODES, OPT_UNBUFFERED, OPT_NUMA, OPT_VERBOSE, OPT_WAKEUP,
 	OPT_WAKEUPRT, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP, OPT_NUMOPTS,
 	OPT_ALIGNED, OPT_SECALIGNED, OPT_LAPTOP, OPT_SMI, OPT_TRACEMARK,
+	OPT_POSIX_TIMERS,
 };
 
 /* Process commandline options */
@@ -1530,7 +1531,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
 			{"loops",            required_argument, NULL, OPT_LOOPS },
 			{"mlockall",         no_argument,       NULL, OPT_MLOCKALL },
 			{"refresh_on_max",   no_argument,       NULL, OPT_REFRESH },
-			{"nanosleep",        no_argument,       NULL, OPT_NANOSLEEP },
 			{"nsecs",            no_argument,       NULL, OPT_NSECS },
 			{"oscope",           required_argument, NULL, OPT_OSCOPE },
 			{"traceopt",         required_argument, NULL, OPT_TRACEOPT },
@@ -1557,9 +1557,10 @@ static void process_options (int argc, char *argv[], int max_cpus)
 			{"dbg_cyclictest",   no_argument,       NULL, OPT_DBGCYCLIC },
 			{"policy",           required_argument, NULL, OPT_POLICY },
 			{"help",             no_argument,       NULL, OPT_HELP },
+			{"posix_timers",     no_argument,	NULL, OPT_POSIX_TIMERS },
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long(argc, argv, "a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:",
+		int c = getopt_long(argc, argv, "a::A::b:Bc:Cd:D:Efh:H:i:Il:MNo:O:p:PmqrRsSt::uUvD:wWT:x",
 				    long_options, &option_index);
 		if (c == -1)
 			break;
@@ -1651,9 +1652,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
 		case 'M':
 		case OPT_REFRESH:
 			refresh_on_max = 1; break;
-		case 'n':
-		case OPT_NANOSLEEP:
-			use_nanosleep = MODE_CLOCK_NANOSLEEP; break;
 		case 'N':
 		case OPT_NSECS:
 			use_nsecs = 1; break;
@@ -1760,6 +1758,9 @@ static void process_options (int argc, char *argv[], int max_cpus)
 		case 'W':
 		case OPT_WAKEUPRT:
 			tracetype = WAKEUPRT; break;
+		case 'x':
+		case OPT_POSIX_TIMERS:
+			use_nanosleep = MODE_CYCLIC; break;
 		case '?':
 		case OPT_HELP:
 			display_help(0); break;
Signature · 1 line
2.7.3
#5 lore raw
Quoted 1 line · Vedang Patel

it is recommended that clock_nanosleep should be used for real-time

extreme nitpick: Captialize first word in a sentence.

Quoted 22 lines

wherever available. So, make sure that cyclictest runs clock_nanosleep by default. Added an option to run POSIX timers. Removing the '-n' option because it is redundant now.

---
 src/cyclictest/cyclictest.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
src/cyclictest/cyclictest.c +0 -1
index 3f1bef1ffca9..cf82f8e1deaa 100644
@@ -1321,7 +1321,6 @@ static void display_help(int error)
 	       "-m       --mlockall        lock current and future memory allocations\n"
 	       "-M       --refresh_on_max  delay updating the screen until a new max\n"
 	       "			   latency is hit. Userful for low bandwidth.\n"
-	       "-n       --nanosleep       use clock_nanosleep\n"
 	       "	 --notrace	   suppress tracing\n"
 	       "-N       --nsecs           print results in ns instead of us (default us)\n"
 	       "-o RED   --oscope=RED      oscilloscope mode, reduce verbose output by RED\n"

src/cyclictest/cyclictest.c static void display_help(int error) · line 1367

Quoted 6 lines
src/cyclictest/cyclictest.c +2 -1
@@ -1364,7 +1363,8 @@ static void display_help(int error)
 	       "                           format: n:c:v n=tasknum c=count v=value in us\n"
 	       "-w       --wakeup          task wakeup tracing (used with -b)\n"
 	       "-W       --wakeuprt        rt task wakeup tracing (used with -b)\n"
-	       "	 --dbg_cyclictest  print info useful for debugging cyclictest\n",
+	       "	 --dbg_cyclictest  print info useful for debugging cyclictest\n"
+	       "-x	 --posix_timers    use POSIX timers\n",

Since we are now removing all references to clock_nanosleep, perhaps add note here indicating that nanosleep is the default, i.e. something like

"use POSIX timers instead of clock_nanosleep"

src/cyclictest/cyclictest.c static void display_help(int error) · line 1375

Quoted 9 lines
src/cyclictest/cyclictest.c +1 -1
 	       tracers
 		);
 	if (error)
@@ -1372,7 +1372,7 @@ static void display_help(int error)
 	exit(EXIT_SUCCESS);
 }
 
-static int use_nanosleep;
+static int use_nanosleep = MODE_CLOCK_NANOSLEEP; /* use clock_nanosleep by default. */

Not sure if you really need the trailing comment, but I'll leave that up to John (I'd drop it)

Quoted 42 lines
src/cyclictest/cyclictest.c +3 -5
 static int timermode = TIMER_ABSTIME;
 static int use_system;
 static int priority;
@@ -1493,6 +1493,7 @@ enum option_values {
 	OPT_TRIGGER_NODES, OPT_UNBUFFERED, OPT_NUMA, OPT_VERBOSE, OPT_WAKEUP,
 	OPT_WAKEUPRT, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP, OPT_NUMOPTS,
 	OPT_ALIGNED, OPT_SECALIGNED, OPT_LAPTOP, OPT_SMI, OPT_TRACEMARK,
+	OPT_POSIX_TIMERS,
 };
 
 /* Process commandline options */
@@ -1530,7 +1531,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
 			{"loops",            required_argument, NULL, OPT_LOOPS },
 			{"mlockall",         no_argument,       NULL, OPT_MLOCKALL },
 			{"refresh_on_max",   no_argument,       NULL, OPT_REFRESH },
-			{"nanosleep",        no_argument,       NULL, OPT_NANOSLEEP },
 			{"nsecs",            no_argument,       NULL, OPT_NSECS },
 			{"oscope",           required_argument, NULL, OPT_OSCOPE },
 			{"traceopt",         required_argument, NULL, OPT_TRACEOPT },
@@ -1557,9 +1557,10 @@ static void process_options (int argc, char *argv[], int max_cpus)
 			{"dbg_cyclictest",   no_argument,       NULL, OPT_DBGCYCLIC },
 			{"policy",           required_argument, NULL, OPT_POLICY },
 			{"help",             no_argument,       NULL, OPT_HELP },
+			{"posix_timers",     no_argument,	NULL, OPT_POSIX_TIMERS },
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long(argc, argv, "a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:",
+		int c = getopt_long(argc, argv, "a::A::b:Bc:Cd:D:Efh:H:i:Il:MNo:O:p:PmqrRsSt::uUvD:wWT:x",
 				    long_options, &option_index);
 		if (c == -1)
 			break;
@@ -1651,9 +1652,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
 		case 'M':
 		case OPT_REFRESH:
 			refresh_on_max = 1; break;
-		case 'n':
-		case OPT_NANOSLEEP:
-			use_nanosleep = MODE_CLOCK_NANOSLEEP; break;
 		case 'N':
 		case OPT_NSECS:
 			use_nsecs = 1; break;

src/cyclictest/cyclictest.c static void process_options (int argc, char *argv[], int max_cpus) · line 1766

Quoted 9 lines
src/cyclictest/cyclictest.c +3 -0
@@ -1760,6 +1758,9 @@ static void process_options (int argc, char *argv[], int max_cpus)
 		case 'W':
 		case OPT_WAKEUPRT:
 			tracetype = WAKEUPRT; break;
+		case 'x':
+		case OPT_POSIX_TIMERS:
+			use_nanosleep = MODE_CYCLIC; break;
 		case '?':
 		case OPT_HELP:
 			display_help(0); break;

As a side-observation that does not have anything to do with your patch, it seems like there's a lovely mix of spaces and TABS in this file (i.e. starting a line with a few spaces, then TABs and then possibly more spaces for final alignment).

Could be my mailclient pulling my foot though, I just found it a bit strange.

Quoted 3 lines
Signature · 1 line
2.7.3

A part form my minor nitpicks, nice change!

Signature · 1 line
Henrik Austad
#6 lore raw
Quoted 148 lines · Henrik Austad
Quoted 2 lines · Vedang Patel

it is recommended that clock_nanosleep should be used for real-time

extreme nitpick: Captialize first word in a sentence.

Quoted 40 lines

wherever available. So, make sure that cyclictest runs clock_nanosleep
by default. Added an option to run POSIX timers. Removing the '-n' option because it is redundant now.

---
 src/cyclictest/cyclictest.c | 17 +++++++++--------

 1 file changed, 9 insertions(+), 8 deletions(-)
src/cyclictest/cyclictest.c +0 -0
index 3f1bef1ffca9..cf82f8e1deaa 100644
@@ -1321,7 +1321,6 @@ static void display_help(int error)

         "-m       --mlockall        lock current and future memory allocations\n"
         "-M       --refresh_on_max  delay updating the screen until a new max\n"
         "    latency is hit. Userful
for low bandwidth.\n"

src/cyclictest/cyclictest.c +0 -1
-	       "-n       --nanosleep       use clock_nanosleep\n"

         "  --notrace    suppress tracing\n"
         "-N       --nsecs           print results in ns instead of us (default us)\n"
         "-o RED   --oscope=RED      oscilloscope mode, reduce verbose output by RED\n"

src/cyclictest/cyclictest.c +0 -0
@@ -1364,7 +1363,8 @@ static void display_help(int error)

         "                           format: n:c:v n=tasknum c=count v=value in us\n"
         "-w       --wakeup          task wakeup tracing (used with -b)\n"
         "-W       --wakeuprt        rt task wakeup tracing (used with -b)\n"

src/cyclictest/cyclictest.c +0 -1
-	       "	 --dbg_cyclictest  print info useful for

debugging cyclictest\n",

src/cyclictest/cyclictest.c +1 -0
+	       "	 --dbg_cyclictest  print info useful for

debugging cyclictest\n"

src/cyclictest/cyclictest.c static void display_help(int error) · line 1367

Quoted 1 line
src/cyclictest/cyclictest.c +1 -0
+	       "-x	 --posix_timers    use POSIX timers\n",

Since we are now removing all references to clock_nanosleep, perhaps add
note here indicating that nanosleep is the default, i.e. something like

"use POSIX timers instead of clock_nanosleep"

Quoted 11 lines

         tracers
  );
  if (error)

src/cyclictest/cyclictest.c +0 -0
@@ -1372,7 +1372,7 @@ static void display_help(int error)
  	exit(EXIT_SUCCESS);
  }

src/cyclictest/cyclictest.c +1 -1
-static int use_nanosleep;
+static int use_nanosleep = MODE_CLOCK_NANOSLEEP; /* use

clock_nanosleep by default. */

Not sure if you really need the trailing comment, but I'll leave that up to
John (I'd drop it)

Quoted 70 lines

 static int timermode = TIMER_ABSTIME;
 static int use_system;
 static int priority;

src/cyclictest/cyclictest.c +1 -0
@@ -1493,6 +1493,7 @@ enum option_values {
  	OPT_TRIGGER_NODES, OPT_UNBUFFERED, OPT_NUMA, OPT_VERBOSE,
 OPT_WAKEUP,
  	OPT_WAKEUPRT, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP,
 OPT_NUMOPTS,
  	OPT_ALIGNED, OPT_SECALIGNED, OPT_LAPTOP, OPT_SMI,
 OPT_TRACEMARK,
+	OPT_POSIX_TIMERS,

 };

 /* Process commandline options */

src/cyclictest/cyclictest.c +0 -0
@@ -1530,7 +1531,6 @@ static void process_options (int argc, char
 *argv[], int max_cpus)
  			{"loops",            required_argument,
 NULL, OPT_LOOPS },

  {"mlockall",         no_argument,       NU LL, OPT_MLOCKALL },
  {"refresh_on_max",   no_argument,       NU LL, OPT_REFRESH },

src/cyclictest/cyclictest.c +0 -1
-			{"nanosleep",        no_argument,       NU

LL, OPT_NANOSLEEP },
  {"nsecs",            no_argument,       NU LL, OPT_NSECS },
  {"oscope",           required_argument, NULL, OPT_OSCOPE },
  {"traceopt",         required_argument, NULL, OPT_TRACEOPT },

src/cyclictest/cyclictest.c +0 -0
@@ -1557,9 +1557,10 @@ static void process_options (int argc, char
 *argv[], int max_cpus)

  {"dbg_cyclictest",   no_argument,       NU LL, OPT_DBGCYCLIC },
  {"policy",           required_argument, NULL, OPT_POLICY },
  {"help",             no_argument,       NU LL, OPT_HELP },

src/cyclictest/cyclictest.c +1 -0
+			{"posix_timers",     no_argument,	N

ULL, OPT_POSIX_TIMERS },
  {NULL, 0, NULL, 0}
  };

src/cyclictest/cyclictest.c +0 -1
-		int c = getopt_long(argc, argv,

"a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:",

src/cyclictest/cyclictest.c +1 -0
+		int c = getopt_long(argc, argv,

"a::A::b:Bc:Cd:D:Efh:H:i:Il:MNo:O:p:PmqrRsSt::uUvD:wWT:x", long_options, &option_index); if (c == -1)
  break;

src/cyclictest/cyclictest.c +0 -0
@@ -1651,9 +1652,6 @@ static void process_options (int argc, char
 *argv[], int max_cpus)

  case 'M':
  case OPT_REFRESH:
  refresh_on_max = 1; break;

src/cyclictest/cyclictest.c +0 -3
-		case 'n':
-		case OPT_NANOSLEEP:
-			use_nanosleep = MODE_CLOCK_NANOSLEEP;

break;
  case 'N':
  case OPT_NSECS:
  use_nsecs = 1; break;

src/cyclictest/cyclictest.c +0 -0
@@ -1760,6 +1758,9 @@ static void process_options (int argc, char
 *argv[], int max_cpus)

  case 'W':
  case OPT_WAKEUPRT:
  tracetype = WAKEUPRT; break;

src/cyclictest/cyclictest.c +3 -0
+		case 'x':
+		case OPT_POSIX_TIMERS:
+			use_nanosleep = MODE_CYCLIC; break;
Quoted 3 lines

  case '?':
  case OPT_HELP:
  display_help(0); break;

As a side-observation that does not have anything to do with your patch, it
seems like there's a lovely mix of spaces and TABS in this file (i.e.
starting a line with a few spaces, then TABs and then possibly more spaces
for final alignment).

Quoted 8 lines

Could be my mailclient pulling my foot though, I just found it a bit strange.

Quoted 4 lines

--
2.7.3

A part form my minor nitpicks, nice change!

Thanks for the review Henrik!

I agree with your suggestions. Will make the changes and send out new version of the patch.

-Vedang

Quoted 1 line
#7 lore raw

PATCH 1/1 cyclictest: make clock_nanosleep as default and add option for POSIX timers.

It is recommended that clock_nanosleep should be used for real-time wherever available. So, make sure that cyclictest runs clock_nanosleep by default. Added an option to run POSIX timers. Removing the '-n' option because it is redundant now.

---
 src/cyclictest/cyclictest.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
src/cyclictest/cyclictest.c +9 -8
index 3f1bef1ffca9..0b134410244b 100644
@@ -1321,7 +1321,6 @@ static void display_help(int error)
 	       "-m       --mlockall        lock current and future memory allocations\n"
 	       "-M       --refresh_on_max  delay updating the screen until a new max\n"
 	       "			   latency is hit. Userful for low bandwidth.\n"
-	       "-n       --nanosleep       use clock_nanosleep\n"
 	       "	 --notrace	   suppress tracing\n"
 	       "-N       --nsecs           print results in ns instead of us (default us)\n"
 	       "-o RED   --oscope=RED      oscilloscope mode, reduce verbose output by RED\n"
@@ -1364,7 +1363,8 @@ static void display_help(int error)
 	       "                           format: n:c:v n=tasknum c=count v=value in us\n"
 	       "-w       --wakeup          task wakeup tracing (used with -b)\n"
 	       "-W       --wakeuprt        rt task wakeup tracing (used with -b)\n"
-	       "	 --dbg_cyclictest  print info useful for debugging cyclictest\n",
+	       "	 --dbg_cyclictest  print info useful for debugging cyclictest\n"
+	       "-x	 --posix_timers    use POSIX timers instead of clock_nanosleep.\n",
 	       tracers
 		);
 	if (error)
@@ -1372,7 +1372,7 @@ static void display_help(int error)
 	exit(EXIT_SUCCESS);
 }
 
-static int use_nanosleep;
+static int use_nanosleep = MODE_CLOCK_NANOSLEEP;
 static int timermode = TIMER_ABSTIME;
 static int use_system;
 static int priority;
@@ -1493,6 +1493,7 @@ enum option_values {
 	OPT_TRIGGER_NODES, OPT_UNBUFFERED, OPT_NUMA, OPT_VERBOSE, OPT_WAKEUP,
 	OPT_WAKEUPRT, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP, OPT_NUMOPTS,
 	OPT_ALIGNED, OPT_SECALIGNED, OPT_LAPTOP, OPT_SMI, OPT_TRACEMARK,
+	OPT_POSIX_TIMERS,
 };
 
 /* Process commandline options */
@@ -1530,7 +1531,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
 			{"loops",            required_argument, NULL, OPT_LOOPS },
 			{"mlockall",         no_argument,       NULL, OPT_MLOCKALL },
 			{"refresh_on_max",   no_argument,       NULL, OPT_REFRESH },
-			{"nanosleep",        no_argument,       NULL, OPT_NANOSLEEP },
 			{"nsecs",            no_argument,       NULL, OPT_NSECS },
 			{"oscope",           required_argument, NULL, OPT_OSCOPE },
 			{"traceopt",         required_argument, NULL, OPT_TRACEOPT },
@@ -1557,9 +1557,10 @@ static void process_options (int argc, char *argv[], int max_cpus)
 			{"dbg_cyclictest",   no_argument,       NULL, OPT_DBGCYCLIC },
 			{"policy",           required_argument, NULL, OPT_POLICY },
 			{"help",             no_argument,       NULL, OPT_HELP },
+			{"posix_timers",     no_argument,	NULL, OPT_POSIX_TIMERS },
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long(argc, argv, "a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:",
+		int c = getopt_long(argc, argv, "a::A::b:Bc:Cd:D:Efh:H:i:Il:MNo:O:p:PmqrRsSt::uUvD:wWT:x",
 				    long_options, &option_index);
 		if (c == -1)
 			break;
@@ -1651,9 +1652,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
 		case 'M':
 		case OPT_REFRESH:
 			refresh_on_max = 1; break;
-		case 'n':
-		case OPT_NANOSLEEP:
-			use_nanosleep = MODE_CLOCK_NANOSLEEP; break;
 		case 'N':
 		case OPT_NSECS:
 			use_nsecs = 1; break;
@@ -1760,6 +1758,9 @@ static void process_options (int argc, char *argv[], int max_cpus)
 		case 'W':
 		case OPT_WAKEUPRT:
 			tracetype = WAKEUPRT; break;
+		case 'x':
+		case OPT_POSIX_TIMERS:
+			use_nanosleep = MODE_CYCLIC; break;
 		case '?':
 		case OPT_HELP:
 			display_help(0); break;
Signature · 1 line
2.7.3
Applied
#8 lore raw
Quoted 93 lines · Vedang Patel

It is recommended that clock_nanosleep should be used for real-time wherever available. So, make sure that cyclictest runs clock_nanosleep by default. Added an option to run POSIX timers. Removing the '-n' option because it is redundant now.

---
 src/cyclictest/cyclictest.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
src/cyclictest/cyclictest.c +9 -8
index 3f1bef1ffca9..0b134410244b 100644
@@ -1321,7 +1321,6 @@ static void display_help(int error)
 	       "-m       --mlockall        lock current and future memory allocations\n"
 	       "-M       --refresh_on_max  delay updating the screen until a new max\n"
 	       "			   latency is hit. Userful for low bandwidth.\n"
-	       "-n       --nanosleep       use clock_nanosleep\n"
 	       "	 --notrace	   suppress tracing\n"
 	       "-N       --nsecs           print results in ns instead of us (default us)\n"
 	       "-o RED   --oscope=RED      oscilloscope mode, reduce verbose output by RED\n"
@@ -1364,7 +1363,8 @@ static void display_help(int error)
 	       "                           format: n:c:v n=tasknum c=count v=value in us\n"
 	       "-w       --wakeup          task wakeup tracing (used with -b)\n"
 	       "-W       --wakeuprt        rt task wakeup tracing (used with -b)\n"
-	       "	 --dbg_cyclictest  print info useful for debugging cyclictest\n",
+	       "	 --dbg_cyclictest  print info useful for debugging cyclictest\n"
+	       "-x	 --posix_timers    use POSIX timers instead of clock_nanosleep.\n",
 	       tracers
 		);
 	if (error)
@@ -1372,7 +1372,7 @@ static void display_help(int error)
 	exit(EXIT_SUCCESS);
 }
 
-static int use_nanosleep;
+static int use_nanosleep = MODE_CLOCK_NANOSLEEP;
 static int timermode = TIMER_ABSTIME;
 static int use_system;
 static int priority;
@@ -1493,6 +1493,7 @@ enum option_values {
 	OPT_TRIGGER_NODES, OPT_UNBUFFERED, OPT_NUMA, OPT_VERBOSE, OPT_WAKEUP,
 	OPT_WAKEUPRT, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP, OPT_NUMOPTS,
 	OPT_ALIGNED, OPT_SECALIGNED, OPT_LAPTOP, OPT_SMI, OPT_TRACEMARK,
+	OPT_POSIX_TIMERS,
 };
 
 /* Process commandline options */
@@ -1530,7 +1531,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
 			{"loops",            required_argument, NULL, OPT_LOOPS },
 			{"mlockall",         no_argument,       NULL, OPT_MLOCKALL },
 			{"refresh_on_max",   no_argument,       NULL, OPT_REFRESH },
-			{"nanosleep",        no_argument,       NULL, OPT_NANOSLEEP },
 			{"nsecs",            no_argument,       NULL, OPT_NSECS },
 			{"oscope",           required_argument, NULL, OPT_OSCOPE },
 			{"traceopt",         required_argument, NULL, OPT_TRACEOPT },
@@ -1557,9 +1557,10 @@ static void process_options (int argc, char *argv[], int max_cpus)
 			{"dbg_cyclictest",   no_argument,       NULL, OPT_DBGCYCLIC },
 			{"policy",           required_argument, NULL, OPT_POLICY },
 			{"help",             no_argument,       NULL, OPT_HELP },
+			{"posix_timers",     no_argument,	NULL, OPT_POSIX_TIMERS },
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long(argc, argv, "a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:",
+		int c = getopt_long(argc, argv, "a::A::b:Bc:Cd:D:Efh:H:i:Il:MNo:O:p:PmqrRsSt::uUvD:wWT:x",
 				    long_options, &option_index);
 		if (c == -1)
 			break;
@@ -1651,9 +1652,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
 		case 'M':
 		case OPT_REFRESH:
 			refresh_on_max = 1; break;
-		case 'n':
-		case OPT_NANOSLEEP:
-			use_nanosleep = MODE_CLOCK_NANOSLEEP; break;
 		case 'N':
 		case OPT_NSECS:
 			use_nsecs = 1; break;
@@ -1760,6 +1758,9 @@ static void process_options (int argc, char *argv[], int max_cpus)
 		case 'W':
 		case OPT_WAKEUPRT:
 			tracetype = WAKEUPRT; break;
+		case 'x':
+		case OPT_POSIX_TIMERS:
+			use_nanosleep = MODE_CYCLIC; break;
 		case '?':
 		case OPT_HELP:
 			display_help(0); break;
Signature · 3 lines
2.7.3

--

Applied, thank you

John