linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] rt-tests: deadline: Cleanups
@ 2019-06-18 10:38 Kurt Kanzenbach
  2019-06-18 10:38 ` [PATCH 1/6] rt-tests: deadline: Remove duplicated code for sched_{set,get}_attr Kurt Kanzenbach
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Kurt Kanzenbach @ 2019-06-18 10:38 UTC (permalink / raw)
  To: John Kacur, Clark Williams; +Cc: rt-users, Kurt Kanzenbach

Hi,

this addresses some issues in the deadline tests:

 - Remove duplicated code
 - Add usage message to cyclicdeadline
 - Fix cgroup setup for cyclicdeadline

Thanks,
Kurt

Kurt Kanzenbach (6):
  rt-tests: deadline: Remove duplicated code for sched_{set,get}_attr
  rt-tests: cyclicdeadline: Remove unused getcpu code
  rt-tests: deadline: Remove duplicated gettid() code
  rt-tests: cyclicdeadline: Add options to usage
  rt-tests: cyclicdeadline: Print fail only if something failed
  rt-tests: cyclicdeadline: Fix cgroup setup

 src/sched_deadline/cyclicdeadline.c | 71 ++++++++-------------------------
 src/sched_deadline/deadline_test.c  | 78 ++-----------------------------------
 2 files changed, 20 insertions(+), 129 deletions(-)

-- 
2.11.0


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

* [PATCH 1/6] rt-tests: deadline: Remove duplicated code for sched_{set,get}_attr
  2019-06-18 10:38 [PATCH 0/6] rt-tests: deadline: Cleanups Kurt Kanzenbach
@ 2019-06-18 10:38 ` Kurt Kanzenbach
  2019-06-19 15:46   ` John Kacur
  2019-06-18 10:38 ` [PATCH 2/6] rt-tests: cyclicdeadline: Remove unused getcpu code Kurt Kanzenbach
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Kurt Kanzenbach @ 2019-06-18 10:38 UTC (permalink / raw)
  To: John Kacur, Clark Williams; +Cc: rt-users, Kurt Kanzenbach

The system calls for sched_get_attr() and sched_set_attr() are already
implemented. Get rid of the code and use the existing libary.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 src/sched_deadline/cyclicdeadline.c | 36 +------------------
 src/sched_deadline/deadline_test.c  | 72 ++-----------------------------------
 2 files changed, 3 insertions(+), 105 deletions(-)

diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 47892daf747b..754670c4e7d4 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -22,31 +22,17 @@
 #include <linux/magic.h>
 
 #include <rt-utils.h>
+#include <rt-sched.h>
 
 #ifdef __i386__
-#ifndef __NR_sched_setattr
-#define __NR_sched_setattr		351
-#endif
-#ifndef __NR_sched_getattr
-#define __NR_sched_getattr		352
-#endif
 #ifndef __NR_getcpu
 #define __NR_getcpu			309
 #endif
 #else /* x86_64 */
-#ifndef __NR_sched_setattr
-#define __NR_sched_setattr		314
-#endif
-#ifndef __NR_sched_getattr
-#define __NR_sched_getattr		315
-#endif
 #ifndef __NR_getcpu
 #define __NR_getcpu			309
 #endif
 #endif /* i386 or x86_64 */
-#ifndef SCHED_DEADLINE
-#define SCHED_DEADLINE		6
-#endif
 
 #define _STR(x) #x
 #define STR(x) _STR(x)
@@ -58,8 +44,6 @@
 #define CPUSET_LOCAL	"my_cpuset"
 
 #define gettid() syscall(__NR_gettid)
-#define sched_setattr(pid, attr, flags) syscall(__NR_sched_setattr, pid, attr, flags)
-#define sched_getattr(pid, attr, size, flags) syscall(__NR_sched_getattr, pid, attr, size, flags)
 #define getcpu(cpup, nodep, unused) syscall(__NR_getcpu, cpup, nodep, unused)
 
 typedef unsigned long long u64;
@@ -115,24 +99,6 @@ struct sched_data {
 	char buff[BUFSIZ+1];
 };
 
-struct sched_attr {
-	u32 size;
-
-	u32 sched_policy;
-	u64 sched_flags;
-
-	/* SCHED_NORMAL, SCHED_BATCH */
-	s32 sched_nice;
-
-	/* SCHED_FIFO, SCHED_RR */
-	u32 sched_priority;
-
-	/* SCHED_DEADLINE */
-	u64 sched_runtime;
-	u64 sched_deadline;
-	u64 sched_period;
-};
-
 static int shutdown;
 
 static pthread_barrier_t barrier;
diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c
index b01e3f27e00f..c3b9dceb5209 100644
--- a/src/sched_deadline/deadline_test.c
+++ b/src/sched_deadline/deadline_test.c
@@ -51,6 +51,8 @@
 #include <linux/unistd.h>
 #include <linux/magic.h>
 
+#include <rt-sched.h>
+
 /**
  * usage - show the usage of the program and exit.
  * @argv: The program passed in args
@@ -82,43 +84,6 @@ static void usage(char **argv)
 	exit(-1);
 }
 
-/*
- * sched_setattr() and sched_getattr() are new system calls. We need to
- * hardcode it here.
- */
-#if defined(__i386__)
-
-#ifndef __NR_sched_setattr
-#define __NR_sched_setattr		351
-#endif
-#ifndef __NR_sched_getattr
-#define __NR_sched_getattr		352
-#endif
-
-#elif defined(__x86_64__)
-
-#ifndef __NR_sched_setattr
-#define __NR_sched_setattr		314
-#endif
-#ifndef __NR_sched_getattr
-#define __NR_sched_getattr		315
-#endif
-
-#endif /* i386 or x86_64 */
-
-#if !defined(__NR_sched_setattr)
-# error "Your arch does not support sched_setattr()"
-#endif
-
-#if !defined(__NR_sched_getattr)
-# error "Your arch does not support sched_getattr()"
-#endif
-
-/* If not included in the headers, define sched deadline policy numbe */
-#ifndef SCHED_DEADLINE
-#define SCHED_DEADLINE		6
-#endif
-
 #define _STR(x) #x
 #define STR(x) _STR(x)
 
@@ -140,45 +105,12 @@ static void usage(char **argv)
 
 /* Define the system call interfaces */
 #define gettid() syscall(__NR_gettid)
-#define sched_setattr(pid, attr, flags) syscall(__NR_sched_setattr, pid, attr, flags)
-#define sched_getattr(pid, attr, size, flags) syscall(__NR_sched_getattr, pid, attr, size, flags)
 
 typedef unsigned long long u64;
 typedef unsigned int u32;
 typedef int s32;
 
 /**
- * struct sched_attr - get/set attr system call descriptor.
- *
- * This is the descriptor defined for setting SCHED_DEADLINE tasks.
- * It will someday be in a header file.
- *
- * The fields specific for deadline:
- *
- *  @sched_policy: 6 is for deadline
- *  @sched_runtime: The runtime in nanoseconds
- *  @sched_deadline: The deadline in nanoseconds.
- *  @sched_period: The period, if different than deadline (not used here)
- */
-struct sched_attr {
-	u32 size;
-
-	u32 sched_policy;
-	u64 sched_flags;
-
-	/* SCHED_NORMAL, SCHED_BATCH */
-	s32 sched_nice;
-
-	/* SCHED_FIFO, SCHED_RR */
-	u32 sched_priority;
-
-	/* SCHED_DEADLINE */
-	u64 sched_runtime;
-	u64 sched_deadline;
-	u64 sched_period;
-};
-
-/**
  * struct sched_data - the descriptor for the threads.
  *
  * This is the descriptor that will be passed as the thread data.
-- 
2.11.0


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

* [PATCH 2/6] rt-tests: cyclicdeadline: Remove unused getcpu code
  2019-06-18 10:38 [PATCH 0/6] rt-tests: deadline: Cleanups Kurt Kanzenbach
  2019-06-18 10:38 ` [PATCH 1/6] rt-tests: deadline: Remove duplicated code for sched_{set,get}_attr Kurt Kanzenbach
@ 2019-06-18 10:38 ` Kurt Kanzenbach
  2019-06-19 15:46   ` John Kacur
  2019-06-18 10:38 ` [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code Kurt Kanzenbach
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Kurt Kanzenbach @ 2019-06-18 10:38 UTC (permalink / raw)
  To: John Kacur, Clark Williams; +Cc: rt-users, Kurt Kanzenbach

The getcpu() system call isn't used in the program. Therefore, it can be
removed.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 src/sched_deadline/cyclicdeadline.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 754670c4e7d4..2b83665cab66 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -24,16 +24,6 @@
 #include <rt-utils.h>
 #include <rt-sched.h>
 
-#ifdef __i386__
-#ifndef __NR_getcpu
-#define __NR_getcpu			309
-#endif
-#else /* x86_64 */
-#ifndef __NR_getcpu
-#define __NR_getcpu			309
-#endif
-#endif /* i386 or x86_64 */
-
 #define _STR(x) #x
 #define STR(x) _STR(x)
 #ifndef MAXPATH
@@ -44,7 +34,6 @@
 #define CPUSET_LOCAL	"my_cpuset"
 
 #define gettid() syscall(__NR_gettid)
-#define getcpu(cpup, nodep, unused) syscall(__NR_getcpu, cpup, nodep, unused)
 
 typedef unsigned long long u64;
 typedef unsigned int u32;
-- 
2.11.0


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

* [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code
  2019-06-18 10:38 [PATCH 0/6] rt-tests: deadline: Cleanups Kurt Kanzenbach
  2019-06-18 10:38 ` [PATCH 1/6] rt-tests: deadline: Remove duplicated code for sched_{set,get}_attr Kurt Kanzenbach
  2019-06-18 10:38 ` [PATCH 2/6] rt-tests: cyclicdeadline: Remove unused getcpu code Kurt Kanzenbach
@ 2019-06-18 10:38 ` Kurt Kanzenbach
  2019-06-19 15:48   ` John Kacur
  2019-06-18 10:38 ` [PATCH 4/6] rt-tests: cyclicdeadline: Add options to usage Kurt Kanzenbach
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Kurt Kanzenbach @ 2019-06-18 10:38 UTC (permalink / raw)
  To: John Kacur, Clark Williams; +Cc: rt-users, Kurt Kanzenbach

gettid() is already implemented in the library code. Use that code instead.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 src/sched_deadline/cyclicdeadline.c | 6 ++----
 src/sched_deadline/deadline_test.c  | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 2b83665cab66..17786db45612 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -33,8 +33,6 @@
 #define CPUSET_ALL	"my_cpuset_all"
 #define CPUSET_LOCAL	"my_cpuset"
 
-#define gettid() syscall(__NR_gettid)
-
 typedef unsigned long long u64;
 typedef unsigned int u32;
 typedef int s32;
@@ -755,7 +753,7 @@ void *run_deadline(void *data)
 	attr.sched_runtime = sd->runtime_us * 1000;
 	attr.sched_deadline = sd->deadline_us * 1000;
 
-	printf("thread[%ld] runtime=%lldus deadline=%lldus\n",
+	printf("thread[%d] runtime=%lldus deadline=%lldus\n",
 	       gettid(), sd->runtime_us, sd->deadline_us);
 
 	pthread_barrier_wait(&barrier);
@@ -1195,7 +1193,7 @@ int main (int argc, char **argv)
 		system("cat /sys/fs/cgroup/cpuset/my_cpuset/tasks");
 	}
 
-	printf("main thread %ld\n", gettid());
+	printf("main thread %d\n", gettid());
 
 	pthread_barrier_wait(&barrier);
 	printf("fail 2 %d\n", fail);
diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c
index c3b9dceb5209..e2898de328bb 100644
--- a/src/sched_deadline/deadline_test.c
+++ b/src/sched_deadline/deadline_test.c
@@ -51,6 +51,7 @@
 #include <linux/unistd.h>
 #include <linux/magic.h>
 
+#include <rt-utils.h>
 #include <rt-sched.h>
 
 /**
@@ -103,9 +104,6 @@ static void usage(char **argv)
 #define CPUSET_ALL	"my_cpuset_all"
 #define CPUSET_LOCAL	"my_cpuset"
 
-/* Define the system call interfaces */
-#define gettid() syscall(__NR_gettid)
-
 typedef unsigned long long u64;
 typedef unsigned int u32;
 typedef int s32;
@@ -1267,7 +1265,7 @@ void *run_deadline(void *data)
 	attr.sched_runtime = sched_data->runtime_us * 1000;
 	attr.sched_deadline = sched_data->deadline_us * 1000;
 
-	printf("thread[%ld] runtime=%lldus deadline=%lldus loops=%lld\n",
+	printf("thread[%d] runtime=%lldus deadline=%lldus loops=%lld\n",
 	       gettid(), sched_data->runtime_us,
 	       sched_data->deadline_us, sched_data->loops_per_period);
 
-- 
2.11.0


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

* [PATCH 4/6] rt-tests: cyclicdeadline: Add options to usage
  2019-06-18 10:38 [PATCH 0/6] rt-tests: deadline: Cleanups Kurt Kanzenbach
                   ` (2 preceding siblings ...)
  2019-06-18 10:38 ` [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code Kurt Kanzenbach
@ 2019-06-18 10:38 ` Kurt Kanzenbach
  2019-06-19 15:48   ` John Kacur
  2019-06-18 10:38 ` [PATCH 5/6] rt-tests: cyclicdeadline: Print fail only if something failed Kurt Kanzenbach
  2019-06-18 10:38 ` [PATCH 6/6] rt-tests: cyclicdeadline: Fix cgroup setup Kurt Kanzenbach
  5 siblings, 1 reply; 16+ messages in thread
From: Kurt Kanzenbach @ 2019-06-18 10:38 UTC (permalink / raw)
  To: John Kacur, Clark Williams; +Cc: rt-users, Kurt Kanzenbach

The current usage doesn't show the available options:

 $ sudo ./cyclicdeadline -h
 usage: cyclicdeadline

So, add the options to the help text to see what can be configured.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 src/sched_deadline/cyclicdeadline.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 17786db45612..7cffe826b944 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -631,8 +631,16 @@ static void usage(char **argv)
 		p--;
 	p++;
 
-	printf("usage: %s\n"
-	       "\n",p);
+	printf("usage: %s [options]\n"
+	       " -h - Show this help menu\n"
+	       " -a - Use all CPUs\n"
+	       " -c cpulist - Comma/hyphen separated list of CPUs to run deadline tasks on\n"
+	       " -i interval(us) - The shortest deadline for the tasks (default 1000us)\n"
+	       " -s step(us) - The amount to increase the deadline for each task (default 500us)\n"
+	       " -t threads - The number of threads to run as deadline (default 1)\n"
+	       " -D time - Specify a length for the test run\n"
+	       "           Append 'm', 'h', or 'd' to specify minutes, hours or days\n"
+	       "\n", p);
 	exit(-1);
 }
 
-- 
2.11.0


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

* [PATCH 5/6] rt-tests: cyclicdeadline: Print fail only if something failed
  2019-06-18 10:38 [PATCH 0/6] rt-tests: deadline: Cleanups Kurt Kanzenbach
                   ` (3 preceding siblings ...)
  2019-06-18 10:38 ` [PATCH 4/6] rt-tests: cyclicdeadline: Add options to usage Kurt Kanzenbach
@ 2019-06-18 10:38 ` Kurt Kanzenbach
  2019-06-19 15:49   ` John Kacur
  2019-06-18 10:38 ` [PATCH 6/6] rt-tests: cyclicdeadline: Fix cgroup setup Kurt Kanzenbach
  5 siblings, 1 reply; 16+ messages in thread
From: Kurt Kanzenbach @ 2019-06-18 10:38 UTC (permalink / raw)
  To: John Kacur, Clark Williams; +Cc: rt-users, Kurt Kanzenbach

It is interesting to see what went wrong in case something did. However, the
fail statement is printed always. That is confusing.

Furthermore, the fail value is always 1 when a failure happened. There is no
need to print it.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 src/sched_deadline/cyclicdeadline.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 7cffe826b944..16d986a02244 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -1204,10 +1204,11 @@ int main (int argc, char **argv)
 	printf("main thread %d\n", gettid());
 
 	pthread_barrier_wait(&barrier);
-	printf("fail 2 %d\n", fail);
 
-	if (fail)
+	if (fail) {
+		printf("fail 2\n");
 		exit(-1);
+	}
 
 	pthread_barrier_wait(&barrier);
 
-- 
2.11.0


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

* [PATCH 6/6] rt-tests: cyclicdeadline: Fix cgroup setup
  2019-06-18 10:38 [PATCH 0/6] rt-tests: deadline: Cleanups Kurt Kanzenbach
                   ` (4 preceding siblings ...)
  2019-06-18 10:38 ` [PATCH 5/6] rt-tests: cyclicdeadline: Print fail only if something failed Kurt Kanzenbach
@ 2019-06-18 10:38 ` Kurt Kanzenbach
  2019-06-19 15:49   ` John Kacur
  5 siblings, 1 reply; 16+ messages in thread
From: Kurt Kanzenbach @ 2019-06-18 10:38 UTC (permalink / raw)
  To: John Kacur, Clark Williams; +Cc: rt-users, Kurt Kanzenbach

Deadline tasks cannot be pinned to specific CPUs by using affinities. Cgroups
have to be used instead. Cylicdeadline has code to do so. However, that code is
never executed, because the all_cpus variable is reassigned after argument
parsing. Remove it.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 src/sched_deadline/cyclicdeadline.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 16d986a02244..7b5e8b36c4ea 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -1165,7 +1165,6 @@ int main (int argc, char **argv)
 		exit(-1);
 	}
 
-	all_cpus = 1;
 	if (!all_cpus) {
 		int *pids;
 
-- 
2.11.0


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

* Re: [PATCH 1/6] rt-tests: deadline: Remove duplicated code for sched_{set,get}_attr
  2019-06-18 10:38 ` [PATCH 1/6] rt-tests: deadline: Remove duplicated code for sched_{set,get}_attr Kurt Kanzenbach
@ 2019-06-19 15:46   ` John Kacur
  0 siblings, 0 replies; 16+ messages in thread
From: John Kacur @ 2019-06-19 15:46 UTC (permalink / raw)
  To: Kurt Kanzenbach; +Cc: Clark Williams, rt-users



On Tue, 18 Jun 2019, Kurt Kanzenbach wrote:

> The system calls for sched_get_attr() and sched_set_attr() are already
> implemented. Get rid of the code and use the existing libary.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  src/sched_deadline/cyclicdeadline.c | 36 +------------------
>  src/sched_deadline/deadline_test.c  | 72 ++-----------------------------------
>  2 files changed, 3 insertions(+), 105 deletions(-)
> 
> diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
> index 47892daf747b..754670c4e7d4 100644
> --- a/src/sched_deadline/cyclicdeadline.c
> +++ b/src/sched_deadline/cyclicdeadline.c
> @@ -22,31 +22,17 @@
>  #include <linux/magic.h>
>  
>  #include <rt-utils.h>
> +#include <rt-sched.h>
>  
>  #ifdef __i386__
> -#ifndef __NR_sched_setattr
> -#define __NR_sched_setattr		351
> -#endif
> -#ifndef __NR_sched_getattr
> -#define __NR_sched_getattr		352
> -#endif
>  #ifndef __NR_getcpu
>  #define __NR_getcpu			309
>  #endif
>  #else /* x86_64 */
> -#ifndef __NR_sched_setattr
> -#define __NR_sched_setattr		314
> -#endif
> -#ifndef __NR_sched_getattr
> -#define __NR_sched_getattr		315
> -#endif
>  #ifndef __NR_getcpu
>  #define __NR_getcpu			309
>  #endif
>  #endif /* i386 or x86_64 */
> -#ifndef SCHED_DEADLINE
> -#define SCHED_DEADLINE		6
> -#endif
>  
>  #define _STR(x) #x
>  #define STR(x) _STR(x)
> @@ -58,8 +44,6 @@
>  #define CPUSET_LOCAL	"my_cpuset"
>  
>  #define gettid() syscall(__NR_gettid)
> -#define sched_setattr(pid, attr, flags) syscall(__NR_sched_setattr, pid, attr, flags)
> -#define sched_getattr(pid, attr, size, flags) syscall(__NR_sched_getattr, pid, attr, size, flags)
>  #define getcpu(cpup, nodep, unused) syscall(__NR_getcpu, cpup, nodep, unused)
>  
>  typedef unsigned long long u64;
> @@ -115,24 +99,6 @@ struct sched_data {
>  	char buff[BUFSIZ+1];
>  };
>  
> -struct sched_attr {
> -	u32 size;
> -
> -	u32 sched_policy;
> -	u64 sched_flags;
> -
> -	/* SCHED_NORMAL, SCHED_BATCH */
> -	s32 sched_nice;
> -
> -	/* SCHED_FIFO, SCHED_RR */
> -	u32 sched_priority;
> -
> -	/* SCHED_DEADLINE */
> -	u64 sched_runtime;
> -	u64 sched_deadline;
> -	u64 sched_period;
> -};
> -
>  static int shutdown;
>  
>  static pthread_barrier_t barrier;
> diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c
> index b01e3f27e00f..c3b9dceb5209 100644
> --- a/src/sched_deadline/deadline_test.c
> +++ b/src/sched_deadline/deadline_test.c
> @@ -51,6 +51,8 @@
>  #include <linux/unistd.h>
>  #include <linux/magic.h>
>  
> +#include <rt-sched.h>
> +
>  /**
>   * usage - show the usage of the program and exit.
>   * @argv: The program passed in args
> @@ -82,43 +84,6 @@ static void usage(char **argv)
>  	exit(-1);
>  }
>  
> -/*
> - * sched_setattr() and sched_getattr() are new system calls. We need to
> - * hardcode it here.
> - */
> -#if defined(__i386__)
> -
> -#ifndef __NR_sched_setattr
> -#define __NR_sched_setattr		351
> -#endif
> -#ifndef __NR_sched_getattr
> -#define __NR_sched_getattr		352
> -#endif
> -
> -#elif defined(__x86_64__)
> -
> -#ifndef __NR_sched_setattr
> -#define __NR_sched_setattr		314
> -#endif
> -#ifndef __NR_sched_getattr
> -#define __NR_sched_getattr		315
> -#endif
> -
> -#endif /* i386 or x86_64 */
> -
> -#if !defined(__NR_sched_setattr)
> -# error "Your arch does not support sched_setattr()"
> -#endif
> -
> -#if !defined(__NR_sched_getattr)
> -# error "Your arch does not support sched_getattr()"
> -#endif
> -
> -/* If not included in the headers, define sched deadline policy numbe */
> -#ifndef SCHED_DEADLINE
> -#define SCHED_DEADLINE		6
> -#endif
> -
>  #define _STR(x) #x
>  #define STR(x) _STR(x)
>  
> @@ -140,45 +105,12 @@ static void usage(char **argv)
>  
>  /* Define the system call interfaces */
>  #define gettid() syscall(__NR_gettid)
> -#define sched_setattr(pid, attr, flags) syscall(__NR_sched_setattr, pid, attr, flags)
> -#define sched_getattr(pid, attr, size, flags) syscall(__NR_sched_getattr, pid, attr, size, flags)
>  
>  typedef unsigned long long u64;
>  typedef unsigned int u32;
>  typedef int s32;
>  
>  /**
> - * struct sched_attr - get/set attr system call descriptor.
> - *
> - * This is the descriptor defined for setting SCHED_DEADLINE tasks.
> - * It will someday be in a header file.
> - *
> - * The fields specific for deadline:
> - *
> - *  @sched_policy: 6 is for deadline
> - *  @sched_runtime: The runtime in nanoseconds
> - *  @sched_deadline: The deadline in nanoseconds.
> - *  @sched_period: The period, if different than deadline (not used here)
> - */
> -struct sched_attr {
> -	u32 size;
> -
> -	u32 sched_policy;
> -	u64 sched_flags;
> -
> -	/* SCHED_NORMAL, SCHED_BATCH */
> -	s32 sched_nice;
> -
> -	/* SCHED_FIFO, SCHED_RR */
> -	u32 sched_priority;
> -
> -	/* SCHED_DEADLINE */
> -	u64 sched_runtime;
> -	u64 sched_deadline;
> -	u64 sched_period;
> -};
> -
> -/**
>   * struct sched_data - the descriptor for the threads.
>   *
>   * This is the descriptor that will be passed as the thread data.
> -- 
> 2.11.0
> 

Signed-off-by: John Kacur <jkacur@redhat.com>

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

* Re: [PATCH 2/6] rt-tests: cyclicdeadline: Remove unused getcpu code
  2019-06-18 10:38 ` [PATCH 2/6] rt-tests: cyclicdeadline: Remove unused getcpu code Kurt Kanzenbach
@ 2019-06-19 15:46   ` John Kacur
  0 siblings, 0 replies; 16+ messages in thread
From: John Kacur @ 2019-06-19 15:46 UTC (permalink / raw)
  To: Kurt Kanzenbach; +Cc: Clark Williams, rt-users



On Tue, 18 Jun 2019, Kurt Kanzenbach wrote:

> The getcpu() system call isn't used in the program. Therefore, it can be
> removed.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  src/sched_deadline/cyclicdeadline.c | 11 -----------
>  1 file changed, 11 deletions(-)
> 
> diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
> index 754670c4e7d4..2b83665cab66 100644
> --- a/src/sched_deadline/cyclicdeadline.c
> +++ b/src/sched_deadline/cyclicdeadline.c
> @@ -24,16 +24,6 @@
>  #include <rt-utils.h>
>  #include <rt-sched.h>
>  
> -#ifdef __i386__
> -#ifndef __NR_getcpu
> -#define __NR_getcpu			309
> -#endif
> -#else /* x86_64 */
> -#ifndef __NR_getcpu
> -#define __NR_getcpu			309
> -#endif
> -#endif /* i386 or x86_64 */
> -
>  #define _STR(x) #x
>  #define STR(x) _STR(x)
>  #ifndef MAXPATH
> @@ -44,7 +34,6 @@
>  #define CPUSET_LOCAL	"my_cpuset"
>  
>  #define gettid() syscall(__NR_gettid)
> -#define getcpu(cpup, nodep, unused) syscall(__NR_getcpu, cpup, nodep, unused)
>  
>  typedef unsigned long long u64;
>  typedef unsigned int u32;
> -- 
> 2.11.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

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

* Re: [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code
  2019-06-18 10:38 ` [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code Kurt Kanzenbach
@ 2019-06-19 15:48   ` John Kacur
  2019-06-24 13:40     ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 16+ messages in thread
From: John Kacur @ 2019-06-19 15:48 UTC (permalink / raw)
  To: Kurt Kanzenbach; +Cc: Clark Williams, rt-users



On Tue, 18 Jun 2019, Kurt Kanzenbach wrote:

> gettid() is already implemented in the library code. Use that code instead.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  src/sched_deadline/cyclicdeadline.c | 6 ++----
>  src/sched_deadline/deadline_test.c  | 6 ++----
>  2 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
> index 2b83665cab66..17786db45612 100644
> --- a/src/sched_deadline/cyclicdeadline.c
> +++ b/src/sched_deadline/cyclicdeadline.c
> @@ -33,8 +33,6 @@
>  #define CPUSET_ALL	"my_cpuset_all"
>  #define CPUSET_LOCAL	"my_cpuset"
>  
> -#define gettid() syscall(__NR_gettid)
> -
>  typedef unsigned long long u64;
>  typedef unsigned int u32;
>  typedef int s32;
> @@ -755,7 +753,7 @@ void *run_deadline(void *data)
>  	attr.sched_runtime = sd->runtime_us * 1000;
>  	attr.sched_deadline = sd->deadline_us * 1000;
>  
> -	printf("thread[%ld] runtime=%lldus deadline=%lldus\n",
> +	printf("thread[%d] runtime=%lldus deadline=%lldus\n",
>  	       gettid(), sd->runtime_us, sd->deadline_us);
>  
>  	pthread_barrier_wait(&barrier);
> @@ -1195,7 +1193,7 @@ int main (int argc, char **argv)
>  		system("cat /sys/fs/cgroup/cpuset/my_cpuset/tasks");
>  	}
>  
> -	printf("main thread %ld\n", gettid());
> +	printf("main thread %d\n", gettid());
>  
>  	pthread_barrier_wait(&barrier);
>  	printf("fail 2 %d\n", fail);
> diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c
> index c3b9dceb5209..e2898de328bb 100644
> --- a/src/sched_deadline/deadline_test.c
> +++ b/src/sched_deadline/deadline_test.c
> @@ -51,6 +51,7 @@
>  #include <linux/unistd.h>
>  #include <linux/magic.h>
>  
> +#include <rt-utils.h>
>  #include <rt-sched.h>
>  
>  /**
> @@ -103,9 +104,6 @@ static void usage(char **argv)
>  #define CPUSET_ALL	"my_cpuset_all"
>  #define CPUSET_LOCAL	"my_cpuset"
>  
> -/* Define the system call interfaces */
> -#define gettid() syscall(__NR_gettid)
> -
>  typedef unsigned long long u64;
>  typedef unsigned int u32;
>  typedef int s32;
> @@ -1267,7 +1265,7 @@ void *run_deadline(void *data)
>  	attr.sched_runtime = sched_data->runtime_us * 1000;
>  	attr.sched_deadline = sched_data->deadline_us * 1000;
>  
> -	printf("thread[%ld] runtime=%lldus deadline=%lldus loops=%lld\n",
> +	printf("thread[%d] runtime=%lldus deadline=%lldus loops=%lld\n",
>  	       gettid(), sched_data->runtime_us,
>  	       sched_data->deadline_us, sched_data->loops_per_period);
>  
> -- 
> 2.11.0
> 
> 

If anyone objects because they are actively using systems that don't have 
gettid() in the library, please speak-up, for now this is in 
unstable/devel/latest-devel
 Signed-off-by: John Kacur <jkacur@redhat.com>

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

* Re: [PATCH 4/6] rt-tests: cyclicdeadline: Add options to usage
  2019-06-18 10:38 ` [PATCH 4/6] rt-tests: cyclicdeadline: Add options to usage Kurt Kanzenbach
@ 2019-06-19 15:48   ` John Kacur
  0 siblings, 0 replies; 16+ messages in thread
From: John Kacur @ 2019-06-19 15:48 UTC (permalink / raw)
  To: Kurt Kanzenbach; +Cc: Clark Williams, rt-users



On Tue, 18 Jun 2019, Kurt Kanzenbach wrote:

> The current usage doesn't show the available options:
> 
>  $ sudo ./cyclicdeadline -h
>  usage: cyclicdeadline
> 
> So, add the options to the help text to see what can be configured.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  src/sched_deadline/cyclicdeadline.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
> index 17786db45612..7cffe826b944 100644
> --- a/src/sched_deadline/cyclicdeadline.c
> +++ b/src/sched_deadline/cyclicdeadline.c
> @@ -631,8 +631,16 @@ static void usage(char **argv)
>  		p--;
>  	p++;
>  
> -	printf("usage: %s\n"
> -	       "\n",p);
> +	printf("usage: %s [options]\n"
> +	       " -h - Show this help menu\n"
> +	       " -a - Use all CPUs\n"
> +	       " -c cpulist - Comma/hyphen separated list of CPUs to run deadline tasks on\n"
> +	       " -i interval(us) - The shortest deadline for the tasks (default 1000us)\n"
> +	       " -s step(us) - The amount to increase the deadline for each task (default 500us)\n"
> +	       " -t threads - The number of threads to run as deadline (default 1)\n"
> +	       " -D time - Specify a length for the test run\n"
> +	       "           Append 'm', 'h', or 'd' to specify minutes, hours or days\n"
> +	       "\n", p);
>  	exit(-1);
>  }
>  
> -- 
> 2.11.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

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

* Re: [PATCH 5/6] rt-tests: cyclicdeadline: Print fail only if something failed
  2019-06-18 10:38 ` [PATCH 5/6] rt-tests: cyclicdeadline: Print fail only if something failed Kurt Kanzenbach
@ 2019-06-19 15:49   ` John Kacur
  0 siblings, 0 replies; 16+ messages in thread
From: John Kacur @ 2019-06-19 15:49 UTC (permalink / raw)
  To: Kurt Kanzenbach; +Cc: Clark Williams, rt-users



On Tue, 18 Jun 2019, Kurt Kanzenbach wrote:

> It is interesting to see what went wrong in case something did. However, the
> fail statement is printed always. That is confusing.
> 
> Furthermore, the fail value is always 1 when a failure happened. There is no
> need to print it.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  src/sched_deadline/cyclicdeadline.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
> index 7cffe826b944..16d986a02244 100644
> --- a/src/sched_deadline/cyclicdeadline.c
> +++ b/src/sched_deadline/cyclicdeadline.c
> @@ -1204,10 +1204,11 @@ int main (int argc, char **argv)
>  	printf("main thread %d\n", gettid());
>  
>  	pthread_barrier_wait(&barrier);
> -	printf("fail 2 %d\n", fail);
>  
> -	if (fail)
> +	if (fail) {
> +		printf("fail 2\n");
>  		exit(-1);
> +	}
>  
>  	pthread_barrier_wait(&barrier);
>  
> -- 
> 2.11.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

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

* Re: [PATCH 6/6] rt-tests: cyclicdeadline: Fix cgroup setup
  2019-06-18 10:38 ` [PATCH 6/6] rt-tests: cyclicdeadline: Fix cgroup setup Kurt Kanzenbach
@ 2019-06-19 15:49   ` John Kacur
  0 siblings, 0 replies; 16+ messages in thread
From: John Kacur @ 2019-06-19 15:49 UTC (permalink / raw)
  To: Kurt Kanzenbach; +Cc: Clark Williams, rt-users



On Tue, 18 Jun 2019, Kurt Kanzenbach wrote:

> Deadline tasks cannot be pinned to specific CPUs by using affinities. Cgroups
> have to be used instead. Cylicdeadline has code to do so. However, that code is
> never executed, because the all_cpus variable is reassigned after argument
> parsing. Remove it.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  src/sched_deadline/cyclicdeadline.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
> index 16d986a02244..7b5e8b36c4ea 100644
> --- a/src/sched_deadline/cyclicdeadline.c
> +++ b/src/sched_deadline/cyclicdeadline.c
> @@ -1165,7 +1165,6 @@ int main (int argc, char **argv)
>  		exit(-1);
>  	}
>  
> -	all_cpus = 1;
>  	if (!all_cpus) {
>  		int *pids;
>  
> -- 
> 2.11.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

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

* Re: [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code
  2019-06-19 15:48   ` John Kacur
@ 2019-06-24 13:40     ` Sebastian Andrzej Siewior
  2019-06-25  9:29       ` John Kacur
  0 siblings, 1 reply; 16+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-06-24 13:40 UTC (permalink / raw)
  To: John Kacur; +Cc: Kurt Kanzenbach, Clark Williams, rt-users

On 2019-06-19 17:48:09 [+0200], John Kacur wrote:
> 
> If anyone objects because they are actively using systems that don't have 
> gettid() in the library, please speak-up, for now this is in 
> unstable/devel/latest-devel

ehm. gettid() is defined in
	src/lib/rt-utils.c

so how should someone not have that one on his system?

glibc 2.30 will have gettid() [0] so maybe you could avoid using that
one from rt-utils.c once you detect it in glibc.

[0] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92;hp=f289e656ec8221756519a601042bc9fbe1b310fb

>  Signed-off-by: John Kacur <jkacur@redhat.com>

Sebastian

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

* Re: [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code
  2019-06-24 13:40     ` Sebastian Andrzej Siewior
@ 2019-06-25  9:29       ` John Kacur
  2019-06-25 13:52         ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 16+ messages in thread
From: John Kacur @ 2019-06-25  9:29 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: Kurt Kanzenbach, Clark Williams, rt-users



On Mon, 24 Jun 2019, Sebastian Andrzej Siewior wrote:

> On 2019-06-19 17:48:09 [+0200], John Kacur wrote:
> > 
> > If anyone objects because they are actively using systems that don't have 
> > gettid() in the library, please speak-up, for now this is in 
> > unstable/devel/latest-devel
> 
> ehm. gettid() is defined in
> 	src/lib/rt-utils.c
> 
> so how should someone not have that one on his system?

The sentence does say, systems that don't have gettid() in the LIBRARY.

That being said, Kurt, would like to come up with a smarter patch that 
uses the glibc version if detected else falls back on this one?

Then you need to clean it up everywhere, not just for the deadline tests.

Consider this patch NAKed for now. (it's only in the latest-devel not the 
latest version anyway)


> 
> glibc 2.30 will have gettid() [0] so maybe you could avoid using that
> one from rt-utils.c once you detect it in glibc.
> 
> [0] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92;hp=f289e656ec8221756519a601042bc9fbe1b310fb
> 
> >  Signed-off-by: John Kacur <jkacur@redhat.com>
> 
> Sebastian
> 

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

* Re: [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code
  2019-06-25  9:29       ` John Kacur
@ 2019-06-25 13:52         ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 16+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-06-25 13:52 UTC (permalink / raw)
  To: John Kacur; +Cc: Kurt Kanzenbach, Clark Williams, rt-users

On 2019-06-25 11:29:28 [+0200], John Kacur wrote:
> 
> 
> On Mon, 24 Jun 2019, Sebastian Andrzej Siewior wrote:
> 
> > On 2019-06-19 17:48:09 [+0200], John Kacur wrote:
> > > 
> > > If anyone objects because they are actively using systems that don't have 
> > > gettid() in the library, please speak-up, for now this is in 
> > > unstable/devel/latest-devel
> > 
> > ehm. gettid() is defined in
> > 	src/lib/rt-utils.c
> > 
> > so how should someone not have that one on his system?
> 
> The sentence does say, systems that don't have gettid() in the LIBRARY.
> 
> That being said, Kurt, would like to come up with a smarter patch that 
> uses the glibc version if detected else falls back on this one?
> 
> Then you need to clean it up everywhere, not just for the deadline tests.
> 
> Consider this patch NAKed for now. (it's only in the latest-devel not the 
> latest version anyway)

=>
- The #define macro for gettid is used in rt-tests since day one. This
  includes cyclictest.c among other files.

- In commit 7efada9d5be26 ("rt-utils: Add gettid()") (which is 0.9)
  tall Daniel introduced a fucntion which can be used instead of the
  define. Based in the grep in my current checkout I don't see any users
  except for pi_stress

- Kurt tried to use the function from rt-tests instead of the define.

Based on what I see you can today use it everywhere. It is not that
simple to use it from glibc because you don't have a compile check to
check for that libc function.

Sebastian

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

end of thread, other threads:[~2019-06-25 13:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-18 10:38 [PATCH 0/6] rt-tests: deadline: Cleanups Kurt Kanzenbach
2019-06-18 10:38 ` [PATCH 1/6] rt-tests: deadline: Remove duplicated code for sched_{set,get}_attr Kurt Kanzenbach
2019-06-19 15:46   ` John Kacur
2019-06-18 10:38 ` [PATCH 2/6] rt-tests: cyclicdeadline: Remove unused getcpu code Kurt Kanzenbach
2019-06-19 15:46   ` John Kacur
2019-06-18 10:38 ` [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code Kurt Kanzenbach
2019-06-19 15:48   ` John Kacur
2019-06-24 13:40     ` Sebastian Andrzej Siewior
2019-06-25  9:29       ` John Kacur
2019-06-25 13:52         ` Sebastian Andrzej Siewior
2019-06-18 10:38 ` [PATCH 4/6] rt-tests: cyclicdeadline: Add options to usage Kurt Kanzenbach
2019-06-19 15:48   ` John Kacur
2019-06-18 10:38 ` [PATCH 5/6] rt-tests: cyclicdeadline: Print fail only if something failed Kurt Kanzenbach
2019-06-19 15:49   ` John Kacur
2019-06-18 10:38 ` [PATCH 6/6] rt-tests: cyclicdeadline: Fix cgroup setup Kurt Kanzenbach
2019-06-19 15:49   ` John Kacur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).