All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] sched_rr_get_interval: run tests under SCHED_RR policy
@ 2016-06-03 13:16 Jan Stancek
  2016-06-06 11:59 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek @ 2016-06-03 13:16 UTC (permalink / raw)
  To: ltp

Man page says:
 The specified process should be running under the SCHED_RR
 scheduling policy.

sched_rr_get_interval_1-1 can rarely fail if run as
SCHED_OTHER, because time quantum calculated/returned by
get_rr_interval_fair() can change between two calls.
For example it depends on number of running tasks on runq.

This patch sets sched policy to SCHED_RR.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 .../conformance/interfaces/sched_rr_get_interval/1-1.c | 15 ++++++++++++---
 .../conformance/interfaces/sched_rr_get_interval/2-1.c | 15 ++++++++++++---
 .../conformance/interfaces/sched_rr_get_interval/3-1.c | 18 +++++++++++++-----
 3 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/1-1.c
index 28ef9eba6ebe..e7a1e846e5a3 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/1-1.c
@@ -11,12 +11,13 @@
  * Test that the current execution time limit is returned for the calling
  * process when pid = 0.
  */
-#include <stdio.h>
-#include <sched.h>
 #include <errno.h>
+#include <sched.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
 #include <unistd.h>
 #include "posixtest.h"
-#include <time.h>
 
 int main(void)
 {
@@ -25,6 +26,14 @@ int main(void)
 	struct timespec interval1;
 	int result0 = -1;
 	int result1 = -1;
+	struct sched_param param;
+
+	param.sched_priority = sched_get_priority_min(SCHED_RR);
+	if (sched_setscheduler(0, SCHED_RR, &param) == -1) {
+		printf("sched_setscheduler failed: %d (%s)\n",
+			errno, strerror(errno));
+		return PTS_UNRESOLVED;
+	}
 
 	interval0.tv_sec = -1;
 	interval0.tv_nsec = -1;
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/2-1.c
index 0b29586ab3b5..5dedf1f6e7ff 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/2-1.c
@@ -10,16 +10,25 @@
  *
  * sched_rr_get_interval() returns 0 on success.
  */
-#include <stdio.h>
-#include <sched.h>
 #include <errno.h>
-#include "posixtest.h"
+#include <sched.h>
+#include <stdio.h>
+#include <string.h>
 #include <time.h>
+#include "posixtest.h"
 
 int main(void)
 {
 	struct timespec interval;
 	int result = -2;
+	struct sched_param param;
+
+	param.sched_priority = sched_get_priority_min(SCHED_RR);
+	if (sched_setscheduler(0, SCHED_RR, &param) == -1) {
+		printf("sched_setscheduler failed: %d (%s)\n",
+			errno, strerror(errno));
+		return PTS_UNRESOLVED;
+	}
 
 	interval.tv_sec = -1;
 	interval.tv_nsec = -1;
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/3-1.c
index 75fc5a0a5463..ee421a1973bc 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/3-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/3-1.c
@@ -13,20 +13,28 @@
  * The test create a child process which exit immediately and call
  * sched_rr_get_interval with the pid of defunct child.
  */
-#include <stdio.h>
-#include <sched.h>
 #include <errno.h>
-#include <unistd.h>
+#include <sched.h>
+#include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
 #include <sys/wait.h>
 #include "posixtest.h"
-#include <time.h>
 
 int main(void)
 {
-
 	struct timespec interval;
 	int result = -2, child_pid, stat_loc;
+	struct sched_param param;
+
+	param.sched_priority = sched_get_priority_min(SCHED_RR);
+	if (sched_setscheduler(0, SCHED_RR, &param) == -1) {
+		printf("sched_setscheduler failed: %d (%s)\n",
+			errno, strerror(errno));
+		return PTS_UNRESOLVED;
+	}
 
 	/* Create a child process which exit immediately */
 	child_pid = fork();
-- 
1.8.3.1


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

* [LTP] [PATCH] sched_rr_get_interval: run tests under SCHED_RR policy
  2016-06-03 13:16 [LTP] [PATCH] sched_rr_get_interval: run tests under SCHED_RR policy Jan Stancek
@ 2016-06-06 11:59 ` Cyril Hrubis
  2016-06-06 13:51   ` Jan Stancek
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2016-06-06 11:59 UTC (permalink / raw)
  To: ltp

Hi!
> Man page says:
>  The specified process should be running under the SCHED_RR
>  scheduling policy.

There does not seem to be such limitation in POSIX at:

http://pubs.opengroup.org/onlinepubs/9699919799/

But they explain that the the time quantum returned by the call is only
applicable for SCHED_RR in schedulling policies at:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_08_04_01

> sched_rr_get_interval_1-1 can rarely fail if run as
> SCHED_OTHER, because time quantum calculated/returned by
> get_rr_interval_fair() can change between two calls.
> For example it depends on number of running tasks on runq.

So this is fine, acked.

> This patch sets sched policy to SCHED_RR.
> 
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> ---
>  .../conformance/interfaces/sched_rr_get_interval/1-1.c | 15 ++++++++++++---
>  .../conformance/interfaces/sched_rr_get_interval/2-1.c | 15 ++++++++++++---
>  .../conformance/interfaces/sched_rr_get_interval/3-1.c | 18 +++++++++++++-----
>  3 files changed, 37 insertions(+), 11 deletions(-)
> 
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/1-1.c
> index 28ef9eba6ebe..e7a1e846e5a3 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/1-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/1-1.c
> @@ -11,12 +11,13 @@
>   * Test that the current execution time limit is returned for the calling
>   * process when pid = 0.
>   */
> -#include <stdio.h>
> -#include <sched.h>
>  #include <errno.h>
> +#include <sched.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <time.h>
>  #include <unistd.h>
>  #include "posixtest.h"
> -#include <time.h>
>  
>  int main(void)
>  {
> @@ -25,6 +26,14 @@ int main(void)
>  	struct timespec interval1;
>  	int result0 = -1;
>  	int result1 = -1;
> +	struct sched_param param;
> +
> +	param.sched_priority = sched_get_priority_min(SCHED_RR);
> +	if (sched_setscheduler(0, SCHED_RR, &param) == -1) {
> +		printf("sched_setscheduler failed: %d (%s)\n",
> +			errno, strerror(errno));
> +		return PTS_UNRESOLVED;
> +	}
>  
>  	interval0.tv_sec = -1;
>  	interval0.tv_nsec = -1;
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/2-1.c
> index 0b29586ab3b5..5dedf1f6e7ff 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/2-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/2-1.c
> @@ -10,16 +10,25 @@
>   *
>   * sched_rr_get_interval() returns 0 on success.
>   */
> -#include <stdio.h>
> -#include <sched.h>
>  #include <errno.h>
> -#include "posixtest.h"
> +#include <sched.h>
> +#include <stdio.h>
> +#include <string.h>
>  #include <time.h>
> +#include "posixtest.h"
>  
>  int main(void)
>  {
>  	struct timespec interval;
>  	int result = -2;
> +	struct sched_param param;
> +
> +	param.sched_priority = sched_get_priority_min(SCHED_RR);
> +	if (sched_setscheduler(0, SCHED_RR, &param) == -1) {
> +		printf("sched_setscheduler failed: %d (%s)\n",
> +			errno, strerror(errno));
> +		return PTS_UNRESOLVED;
> +	}
>  
>  	interval.tv_sec = -1;
>  	interval.tv_nsec = -1;
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/3-1.c
> index 75fc5a0a5463..ee421a1973bc 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/3-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/3-1.c
> @@ -13,20 +13,28 @@
>   * The test create a child process which exit immediately and call
>   * sched_rr_get_interval with the pid of defunct child.
>   */
> -#include <stdio.h>
> -#include <sched.h>
>  #include <errno.h>
> -#include <unistd.h>
> +#include <sched.h>
> +#include <stdio.h>
>  #include <stdlib.h>
> +#include <string.h>
> +#include <time.h>
> +#include <unistd.h>
>  #include <sys/wait.h>
>  #include "posixtest.h"
> -#include <time.h>
>  
>  int main(void)
>  {
> -
>  	struct timespec interval;
>  	int result = -2, child_pid, stat_loc;
> +	struct sched_param param;
> +
> +	param.sched_priority = sched_get_priority_min(SCHED_RR);
> +	if (sched_setscheduler(0, SCHED_RR, &param) == -1) {
> +		printf("sched_setscheduler failed: %d (%s)\n",
> +			errno, strerror(errno));
> +		return PTS_UNRESOLVED;
> +	}
>  
>  	/* Create a child process which exit immediately */
>  	child_pid = fork();
> -- 
> 1.8.3.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH] sched_rr_get_interval: run tests under SCHED_RR policy
  2016-06-06 11:59 ` Cyril Hrubis
@ 2016-06-06 13:51   ` Jan Stancek
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Stancek @ 2016-06-06 13:51 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: ltp@lists.linux.it
> Sent: Monday, 6 June, 2016 1:59:41 PM
> Subject: Re: [LTP] [PATCH] sched_rr_get_interval: run tests under SCHED_RR policy
> 
> Hi!
> > Man page says:
> >  The specified process should be running under the SCHED_RR
> >  scheduling policy.
> 
> There does not seem to be such limitation in POSIX at:
> 
> http://pubs.opengroup.org/onlinepubs/9699919799/
> 
> But they explain that the the time quantum returned by the call is only
> applicable for SCHED_RR in schedulling policies at:
> 
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_08_04_01
> 
> > sched_rr_get_interval_1-1 can rarely fail if run as
> > SCHED_OTHER, because time quantum calculated/returned by
> > get_rr_interval_fair() can change between two calls.
> > For example it depends on number of running tasks on runq.
> 
> So this is fine, acked.

Pushed.

Regards,
Jan

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

end of thread, other threads:[~2016-06-06 13:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-03 13:16 [LTP] [PATCH] sched_rr_get_interval: run tests under SCHED_RR policy Jan Stancek
2016-06-06 11:59 ` Cyril Hrubis
2016-06-06 13:51   ` Jan Stancek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.