rt-tests: deadline: Cleanups
PATCH 2/6 rt-tests: cyclicdeadline: Remove unused getcpu code
In reply to Kurt KanzenbachThe getcpu() system call isn't used in the program. Therefore, it can be removed.
--- src/sched_deadline/cyclicdeadline.c | 11 ----------- 1 file changed, 11 deletions(-)
src/sched_deadline/cyclicdeadline.c +0 -11
@@ -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 ;
Signature · 1 line
2.11.0
PATCH 3/6 rt-tests: deadline: Remove duplicated gettid() code
In reply to Kurt Kanzenbachgettid() is already implemented in the library code. Use that code instead.
--- src/sched_deadline/cyclicdeadline.c | 6 ++---- src/sched_deadline/deadline_test.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-)
src/sched_deadline/cyclicdeadline.c +2 -4
@@ -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);
src/sched_deadline/deadline_test.c +2 -4
@@ -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);
Signature · 1 line
2.11.0
PATCH 4/6 rt-tests: cyclicdeadline: Add options to usage
In reply to Kurt KanzenbachThe 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.
--- src/sched_deadline/cyclicdeadline.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
src/sched_deadline/cyclicdeadline.c +10 -2
@@ -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 ); }
Signature · 1 line
2.11.0
PATCH 5/6 rt-tests: cyclicdeadline: Print fail only if something failed
In reply to Kurt KanzenbachIt 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.
--- src/sched_deadline/cyclicdeadline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
src/sched_deadline/cyclicdeadline.c +3 -2
@@ -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);
Signature · 1 line
2.11.0
cover rt-tests: deadline: Cleanups
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(-)
Signature · 1 line
2.11.0
PATCH 6/6 rt-tests: cyclicdeadline: Fix cgroup setup
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.
--- src/sched_deadline/cyclicdeadline.c | 1 - 1 file changed, 1 deletion(-)
src/sched_deadline/cyclicdeadline.c +0 -1
@@ -1165,7 +1165,6 @@ int main (int argc, char **argv)exit (-1 ); } - all_cpus =1 ;if (!all_cpus) {int *pids;
Signature · 1 line
2.11.0
PATCH 1/6 rt-tests: deadline: Remove duplicated code for sched_{set,get}_attr
In reply to Kurt KanzenbachThe system calls for sched_get_attr() and sched_set_attr() are already implemented. Get rid of the code and use the existing libary.
--- src/sched_deadline/cyclicdeadline.c | 36 +------------------ src/sched_deadline/deadline_test.c | 72 ++----------------------------------- 2 files changed, 3 insertions(+), 105 deletions(-)
src/sched_deadline/cyclicdeadline.c +1 -35
@@ -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;
src/sched_deadline/deadline_test.c +2 -70
96 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH 1/6] rt-tests: deadline: Remove duplicated code for sched_{set,get}_attr
Quoted 186 lines · Kurt Kanzenbach
The system calls for
sched_get_attr()andsched_set_attr()are already implemented. Get rid of the code and use the existing libary.Signed-off-by Kurt Kanzenbach <[email protected]>--- src/sched_deadline/cyclicdeadline.c | 36 +------------------ src/sched_deadline/deadline_test.c | 72 ++----------------------------------- 2 files changed, 3 insertions(+), 105 deletions(-)src/sched_deadline/cyclicdeadline.c +1
-35@@ -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;src/sched_deadline/deadline_test.c +2
-70@@ -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. Signature · 1 line
2.11.0
Re: [PATCH 2/6] rt-tests: cyclicdeadline: Remove unused getcpu code
In reply to Kurt KanzenbachQuoted 41 lines · Kurt Kanzenbach
The
getcpu()system call isn't used in the program. Therefore, it can be removed.Signed-off-by Kurt Kanzenbach <[email protected]>--- src/sched_deadline/cyclicdeadline.c | 11 ----------- 1 file changed, 11 deletions(-)src/sched_deadline/cyclicdeadline.c +0
-11@@ -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 ;Signature · 1 line
2.11.0
Re: [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code
In reply to Kurt KanzenbachQuoted 74 lines · Kurt Kanzenbach
gettid()is already implemented in the library code. Use that code instead.Signed-off-by Kurt Kanzenbach <[email protected]>--- src/sched_deadline/cyclicdeadline.c | 6 ++---- src/sched_deadline/deadline_test.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-)src/sched_deadline/cyclicdeadline.c +2
-4@@ -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);src/sched_deadline/deadline_test.c +2
-4@@ -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);Signature · 1 line
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
Re: [PATCH 4/6] rt-tests: cyclicdeadline: Add options to usage
In reply to Kurt KanzenbachQuoted 39 lines · Kurt Kanzenbach
The current usage doesn't show the available options:
$ sudo ./cyclicdeadline -h usage: cyclicdeadlineSo, add the options to the help text to see what can be configured.
Signed-off-by Kurt Kanzenbach <[email protected]>--- src/sched_deadline/cyclicdeadline.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)src/sched_deadline/cyclicdeadline.c +10
-2@@ -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 ); }Signature · 1 line
2.11.0
Re: [PATCH 5/6] rt-tests: cyclicdeadline: Print fail only if something failed
In reply to Kurt KanzenbachQuoted 33 lines · 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 <[email protected]>--- src/sched_deadline/cyclicdeadline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)src/sched_deadline/cyclicdeadline.c +3
-2@@ -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);Signature · 1 line
2.11.0
Re: [PATCH 6/6] rt-tests: cyclicdeadline: Fix cgroup setup
In reply to Kurt KanzenbachQuoted 26 lines · 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_cpusvariable is reassigned after argument parsing. Remove it.Signed-off-by Kurt Kanzenbach <[email protected]>--- src/sched_deadline/cyclicdeadline.c | 1 - 1 file changed, 1 deletion(-)src/sched_deadline/cyclicdeadline.c +0
-1@@ -1165,7 +1165,6 @@ int main (int argc, char **argv)exit (-1 ); } - all_cpus =1 ;if (!all_cpus) {int *pids;Signature · 1 line
2.11.0
Re: [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code
In reply to John KacurQuoted 4 lines · John Kacur
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.
Quoted 1 line
Signed-off-by John Kacur <[email protected]>
Sebastian
Re: [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code
Quoted 10 lines · Sebastian Andrzej Siewior
Quoted 4 lines · John Kacur
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-develehm.
gettid()is defined in
src/lib/rt-utils.cso 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)
Quoted 10 lines
glibc 2.30 will have
gettid()[0] so maybe you could avoid using that one fromrt-utils.conce you detect it in glibc.Quoted 1 line
Signed-off-by John Kacur <[email protected]>Sebastian
Re: [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code
Quoted 17 lines · John Kacur
Quoted 10 lines · Sebastian Andrzej Siewior
Quoted 4 lines · John Kacur
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-develehm.
gettid()is defined in
src/lib/rt-utils.cso how should someone not have that one on his system?
The sentence does say, systems that don't have
gettid()in the LIBRARY.
Quoted 7 lines
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