public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rt-tests: pip_stress: Add option --usleep
@ 2025-01-23  6:04 Shizhao Chen
  2025-01-24  1:05 ` Crystal Wood
  0 siblings, 1 reply; 5+ messages in thread
From: Shizhao Chen @ 2025-01-23  6:04 UTC (permalink / raw)
  To: linux-rt-users; +Cc: John Kacur, Clark Williams

Different hardwares have different threasholds for usleep_val to
reliably trigger an prio inversion, add option --usleep to allow
specifying it at runtime, to facilitate testing of prio inheritance
on different platforms.

Signed-off-by: Shizhao Chen <shichen@redhat.com>
---
 src/pi_tests/pip_stress.8 |  6 +++++-
 src/pi_tests/pip_stress.c | 10 ++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/pi_tests/pip_stress.8 b/src/pi_tests/pip_stress.8
index 0d06dd2..f55e2d8 100644
--- a/src/pi_tests/pip_stress.8
+++ b/src/pi_tests/pip_stress.8
@@ -5,7 +5,8 @@
 .B pip_stress \- Priority Inheritance with processes
 .SH SYNOPSIS
 .B pip_stress
-
+.RB [ \-u|\-\-usleep
+.IR TIME ]
 .SH DESCRIPTION
 This program demonstrates the technique of using priority inheritance (PI)
 mutexes with processes instead of threads.
@@ -41,6 +42,9 @@ merely increase the time that the low priority process sleeps while
 holding the lock. (usleep);
 Also note that you have to run as a user with permission to change
 scheduling priorities.
+.SH OPTIONS
+.IP "\-u TIME,\-\-usleep=TIME"
+Specify the sleep time of the low priority process. Defaults to 500(us).
 .BR
 .SH AUTHOR
 pip_stress was written by John Kacur <jkacur at redhat.com>
diff --git a/src/pi_tests/pip_stress.c b/src/pi_tests/pip_stress.c
index fb0391b..782e5db 100644
--- a/src/pi_tests/pip_stress.c
+++ b/src/pi_tests/pip_stress.c
@@ -72,7 +72,9 @@ static void usage(int error)
 	printf("pip_stress V %1.2f\n", VERSION);
 	printf("Usage:\n"
 	       "pip_stress <options>\n"\
-	       "-h	--help                  Show this help menu.\n"
+	       "-h       --help          Show this help menu.\n"\
+	       "-u TIME  --usleep=TIME   Specify the sleep time of the low priority process.\n"\
+	       "                         Defaults to 500(us).\n"
 	       );
 	exit(error);
 }
@@ -88,16 +90,20 @@ int main(int argc, char *argv[])
 	for (;;) {
 		struct option long_options[] = {
 			{ "help",	no_argument,		NULL,	'h' },
+			{ "usleep",	required_argument,	NULL,	'u' },
 			{ NULL,		0,			NULL,	0 },
 		};
 
-		int c = getopt_long(argc, argv, "s:h", long_options, NULL);
+		int c = getopt_long(argc, argv, "hu:", long_options, NULL);
 		if (c == -1)
 			break;
 		switch (c) {
 		case 'h':
 			usage(0);
 			break;
+		case 'u':
+			usleep_val = (useconds_t)strtoul(optarg, NULL, 10);
+			break;
 		default:
 			usage(1);
 			break;
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] rt-tests: pip_stress: Add option --usleep
  2025-01-23  6:04 [PATCH] rt-tests: pip_stress: Add option --usleep Shizhao Chen
@ 2025-01-24  1:05 ` Crystal Wood
  2025-01-24  7:30   ` Shizhao Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Crystal Wood @ 2025-01-24  1:05 UTC (permalink / raw)
  To: Shizhao Chen, linux-rt-users; +Cc: John Kacur, Clark Williams

On Thu, 2025-01-23 at 14:04 +0800, Shizhao Chen wrote:
> Different hardwares have different threasholds for usleep_val to
> reliably trigger an prio inversion, add option --usleep to allow
> specifying it at runtime, to facilitate testing of prio inheritance
> on different platforms.
> 
> Signed-off-by: Shizhao Chen <shichen@redhat.com>
> ---
>  src/pi_tests/pip_stress.8 |  6 +++++-
>  src/pi_tests/pip_stress.c | 10 ++++++++--
>  2 files changed, 13 insertions(+), 3 deletions(-)

Hmm, looks like there was an earlier attempt (53956b6712fef1,
"pip_stress: parameterize usleep value to work-around platform issues")
that was missing the actual call to getopt... and then another commit
(1325cb7e9e3af08e, "Daniel Wagner <dwagner@suse.de>") that added getopt
but removed usleep -- while also adding a "-s" option that does nothing.
:-P

Some minor nits:

> @@ -41,6 +42,9 @@ merely increase the time that the low priority process sleeps while
>  holding the lock. (usleep);
>  Also note that you have to run as a user with permission to change
>  scheduling priorities.
> +.SH OPTIONS
> +.IP "\-u TIME,\-\-usleep=TIME"
> +Specify the sleep time of the low priority process. Defaults to 500(us).

The unit should be part of the description, not the default:

Specify the sleep time in usec of the low priority process.  Defaults to
500.

> -	       "-h	--help                  Show this help menu.\n"
> +	       "-h       --help          Show this help menu.\n"\
> +	       "-u TIME  --usleep=TIME   Specify the sleep time of the low priority process.\n"\
> +	       "                         Defaults to 500(us).\n"
>  	       );

Likewise here

> +		case 'u':
> +			usleep_val = (useconds_t)strtoul(optarg, NULL, 10);
> +			break;

Why is this cast needed?

-Crystal


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rt-tests: pip_stress: Add option --usleep
  2025-01-24  1:05 ` Crystal Wood
@ 2025-01-24  7:30   ` Shizhao Chen
  2025-01-24  7:51     ` [PATCH v2] " Shizhao Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Shizhao Chen @ 2025-01-24  7:30 UTC (permalink / raw)
  To: Crystal Wood; +Cc: linux-rt-users, John Kacur, Clark Williams

On Fri, Jan 24, 2025 at 9:06 AM Crystal Wood <crwood@redhat.com> wrote:
>
> On Thu, 2025-01-23 at 14:04 +0800, Shizhao Chen wrote:
> > Different hardwares have different threasholds for usleep_val to
> > reliably trigger an prio inversion, add option --usleep to allow
> > specifying it at runtime, to facilitate testing of prio inheritance
> > on different platforms.
> >
> > Signed-off-by: Shizhao Chen <shichen@redhat.com>
> > ---
> >  src/pi_tests/pip_stress.8 |  6 +++++-
> >  src/pi_tests/pip_stress.c | 10 ++++++++--
> >  2 files changed, 13 insertions(+), 3 deletions(-)
>
> Hmm, looks like there was an earlier attempt (53956b6712fef1,
> "pip_stress: parameterize usleep value to work-around platform issues")
> that was missing the actual call to getopt... and then another commit
> (1325cb7e9e3af08e, "Daniel Wagner <dwagner@suse.de>") that added getopt
> but removed usleep -- while also adding a "-s" option that does nothing.
> :-P

Yeah I kinda stole the option from clark :)

>
> Some minor nits:
>
> > @@ -41,6 +42,9 @@ merely increase the time that the low priority process sleeps while
> >  holding the lock. (usleep);
> >  Also note that you have to run as a user with permission to change
> >  scheduling priorities.
> > +.SH OPTIONS
> > +.IP "\-u TIME,\-\-usleep=TIME"
> > +Specify the sleep time of the low priority process. Defaults to 500(us).
>
> The unit should be part of the description, not the default:
>
> Specify the sleep time in usec of the low priority process.  Defaults to
> 500.

I hesitated several times whether I should add the (us) at the end,
your version looks much better, thanks!

>
> > -            "-h      --help                  Show this help menu.\n"
> > +            "-h       --help          Show this help menu.\n"\
> > +            "-u TIME  --usleep=TIME   Specify the sleep time of the low priority process.\n"\
> > +            "                         Defaults to 500(us).\n"
> >              );
>
> Likewise here
>
> > +             case 'u':
> > +                     usleep_val = (useconds_t)strtoul(optarg, NULL, 10);
> > +                     break;
>
> Why is this cast needed?

It's not needed - just me being unfamiliar with C. :P I'll remove it.

>
>
> -Crystal
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] rt-tests: pip_stress: Add option --usleep
  2025-01-24  7:30   ` Shizhao Chen
@ 2025-01-24  7:51     ` Shizhao Chen
  2025-01-29 21:57       ` John Kacur
  0 siblings, 1 reply; 5+ messages in thread
From: Shizhao Chen @ 2025-01-24  7:51 UTC (permalink / raw)
  To: linux-rt-users; +Cc: Crystal Wood, John Kacur, Clark Williams

Different hardwares have different threasholds for usleep_val to
reliably trigger an prio inversion, add option --usleep to allow
specifying it at runtime, to facilitate testing of prio inheritance
on different platforms.

Signed-off-by: Shizhao Chen <shichen@redhat.com>
---
 src/pi_tests/pip_stress.8 |  6 +++++-
 src/pi_tests/pip_stress.c | 10 ++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/pi_tests/pip_stress.8 b/src/pi_tests/pip_stress.8
index 0d06dd2..0f65ad1 100644
--- a/src/pi_tests/pip_stress.8
+++ b/src/pi_tests/pip_stress.8
@@ -5,7 +5,8 @@
 .B pip_stress \- Priority Inheritance with processes
 .SH SYNOPSIS
 .B pip_stress
-
+.RB [ \-u|\-\-usleep
+.IR TIME ]
 .SH DESCRIPTION
 This program demonstrates the technique of using priority inheritance (PI)
 mutexes with processes instead of threads.
@@ -41,6 +42,9 @@ merely increase the time that the low priority process sleeps while
 holding the lock. (usleep);
 Also note that you have to run as a user with permission to change
 scheduling priorities.
+.SH OPTIONS
+.IP "\-u TIME,\-\-usleep=TIME"
+Specify the sleep time in usec of the low priority process. Defaults to 500.
 .BR
 .SH AUTHOR
 pip_stress was written by John Kacur <jkacur at redhat.com>
diff --git a/src/pi_tests/pip_stress.c b/src/pi_tests/pip_stress.c
index fb0391b..9bd225f 100644
--- a/src/pi_tests/pip_stress.c
+++ b/src/pi_tests/pip_stress.c
@@ -72,7 +72,9 @@ static void usage(int error)
 	printf("pip_stress V %1.2f\n", VERSION);
 	printf("Usage:\n"
 	       "pip_stress <options>\n"\
-	       "-h	--help                  Show this help menu.\n"
+	       "-h       --help          Show this help menu.\n"\
+	       "-u TIME  --usleep=TIME   Specify the sleep time in usec of the low priority process.\n"\
+	       "                         Defaults to 500.\n"
 	       );
 	exit(error);
 }
@@ -88,16 +90,20 @@ int main(int argc, char *argv[])
 	for (;;) {
 		struct option long_options[] = {
 			{ "help",	no_argument,		NULL,	'h' },
+			{ "usleep",	required_argument,	NULL,	'u' },
 			{ NULL,		0,			NULL,	0 },
 		};
 
-		int c = getopt_long(argc, argv, "s:h", long_options, NULL);
+		int c = getopt_long(argc, argv, "hu:", long_options, NULL);
 		if (c == -1)
 			break;
 		switch (c) {
 		case 'h':
 			usage(0);
 			break;
+		case 'u':
+			usleep_val = strtoul(optarg, NULL, 10);
+			break;
 		default:
 			usage(1);
 			break;
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] rt-tests: pip_stress: Add option --usleep
  2025-01-24  7:51     ` [PATCH v2] " Shizhao Chen
@ 2025-01-29 21:57       ` John Kacur
  0 siblings, 0 replies; 5+ messages in thread
From: John Kacur @ 2025-01-29 21:57 UTC (permalink / raw)
  To: Shizhao Chen; +Cc: linux-rt-users, Crystal Wood, Clark Williams



On Fri, 24 Jan 2025, Shizhao Chen wrote:

> Different hardwares have different threasholds for usleep_val to
> reliably trigger an prio inversion, add option --usleep to allow
> specifying it at runtime, to facilitate testing of prio inheritance
> on different platforms.
> 
> Signed-off-by: Shizhao Chen <shichen@redhat.com>
> ---
>  src/pi_tests/pip_stress.8 |  6 +++++-
>  src/pi_tests/pip_stress.c | 10 ++++++++--
>  2 files changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/src/pi_tests/pip_stress.8 b/src/pi_tests/pip_stress.8
> index 0d06dd2..0f65ad1 100644
> --- a/src/pi_tests/pip_stress.8
> +++ b/src/pi_tests/pip_stress.8
> @@ -5,7 +5,8 @@
>  .B pip_stress \- Priority Inheritance with processes
>  .SH SYNOPSIS
>  .B pip_stress
> -
> +.RB [ \-u|\-\-usleep
> +.IR TIME ]
>  .SH DESCRIPTION
>  This program demonstrates the technique of using priority inheritance (PI)
>  mutexes with processes instead of threads.
> @@ -41,6 +42,9 @@ merely increase the time that the low priority process sleeps while
>  holding the lock. (usleep);
>  Also note that you have to run as a user with permission to change
>  scheduling priorities.
> +.SH OPTIONS
> +.IP "\-u TIME,\-\-usleep=TIME"
> +Specify the sleep time in usec of the low priority process. Defaults to 500.
>  .BR
>  .SH AUTHOR
>  pip_stress was written by John Kacur <jkacur at redhat.com>
> diff --git a/src/pi_tests/pip_stress.c b/src/pi_tests/pip_stress.c
> index fb0391b..9bd225f 100644
> --- a/src/pi_tests/pip_stress.c
> +++ b/src/pi_tests/pip_stress.c
> @@ -72,7 +72,9 @@ static void usage(int error)
>  	printf("pip_stress V %1.2f\n", VERSION);
>  	printf("Usage:\n"
>  	       "pip_stress <options>\n"\
> -	       "-h	--help                  Show this help menu.\n"
> +	       "-h       --help          Show this help menu.\n"\
> +	       "-u TIME  --usleep=TIME   Specify the sleep time in usec of the low priority process.\n"\
> +	       "                         Defaults to 500.\n"
>  	       );
>  	exit(error);
>  }
> @@ -88,16 +90,20 @@ int main(int argc, char *argv[])
>  	for (;;) {
>  		struct option long_options[] = {
>  			{ "help",	no_argument,		NULL,	'h' },
> +			{ "usleep",	required_argument,	NULL,	'u' },
>  			{ NULL,		0,			NULL,	0 },
>  		};
>  
> -		int c = getopt_long(argc, argv, "s:h", long_options, NULL);
> +		int c = getopt_long(argc, argv, "hu:", long_options, NULL);
>  		if (c == -1)
>  			break;
>  		switch (c) {
>  		case 'h':
>  			usage(0);
>  			break;
> +		case 'u':
> +			usleep_val = strtoul(optarg, NULL, 10);
> +			break;
>  		default:
>  			usage(1);
>  			break;
> -- 
> 2.47.1
> 
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-01-29 21:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-23  6:04 [PATCH] rt-tests: pip_stress: Add option --usleep Shizhao Chen
2025-01-24  1:05 ` Crystal Wood
2025-01-24  7:30   ` Shizhao Chen
2025-01-24  7:51     ` [PATCH v2] " Shizhao Chen
2025-01-29 21:57       ` John Kacur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox