Skip to contentSkip to conversation

Cyclictest in Xenomai-3

Xenomai Konstantinos Chalas 3 participants 12 messages Aug 27, 2015 – Aug 31, 2015 Kbuild

lore
Share & tools
lore
#0 lore raw

Hello everyone,

Is there any plans to port cyclictest over at xenomai-3 for the Cobalt kernel? I compiled the original source file from the rt-tests repo my self for xenomai-3,. For reference i used to get around 70 us worst case with the Beaglebone black using Xenomai-2, but it goes up to 200 us immediatly with the one i compiled. By the way, i followed the xeno-config procedure. Is there anyone who cares to provide an explanation?

Thanks,
Konstantinos Chalas

#1 lore raw
Quoted 9 lines · Konstantinos Chalas

Hello everyone,

Is there any plans to port cyclictest over at xenomai-3 for the Cobalt kernel? I compiled the original source file from the rt-tests repo my self for xenomai-3,. For reference i used to get around 70 us worst case with the Beaglebone black using Xenomai-2, but it goes up to 200 us immediatly with the one i compiled. By the way, i followed the xeno-config procedure. Is there anyone who cares to provide an explanation?

Any information about the exact build command used, the clock calibration from /proc/xenomai/clock/coreclk, and the options passed to cyclictest?

Btw, the vanilla cyclictest code had to be adapted for running over Xenomai 2.

Signature · 1 line
Philippe.
#2 lore raw

The build command for cyclictest was

gcc -Wall -Wno-nonnull -I/usr/xenomai/include/cobalt -I/usr/xenomai/include -march=armv7-a -mfpu=vfp3 -D_GNU_SOURCE -D_REENTRANT -D__COBALT__ -O2 -Wl,@/usr/xenomai/lib/cobalt.wrappers /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lcobalt -lpthread -lrt -march=armv7-a -mfpu=vfp3 -o cyclictest cyclictest.o -lrt -lpthread -lrttest -L

Also the clock calibration is (i already run the autotune utility),

root@beaglebone:~# cat /proc/xenomai/clock/coreclk
gravity: irq=499 kernel=1999 user=4999
devices: timer=timer2, clock=ipipe_tsc
 status: on
  setup: 999
  ticks: 350959191461

and finally i run cyclictest with Thanks for the interest!

cyclictest -n -p 99 -D 1000 -i 250 -m Thanks for the interest!**

Quoted 17 lines · Philippe Gerum
Quoted 9 lines · Konstantinos Chalas

Hello everyone,

Is there any plans to port cyclictest over at xenomai-3 for the Cobalt kernel? I compiled the original source file from the rt-tests repo my self for xenomai-3,. For reference i used to get around 70 us worst case with the Beaglebone black using Xenomai-2, but it goes up to 200 us immediatly with the one i compiled. By the way, i followed the xeno-config procedure. Is there anyone who cares to provide an explanation?

Any information about the exact build command used, the clock calibration from /proc/xenomai/clock/coreclk, and the options passed to cyclictest?

Btw, the vanilla cyclictest code had to be adapted for running over Xenomai 2.

#3 lore raw
Quoted 19 lines · Konstantinos Chalas

The build command for cyclictest was

gcc -Wall -Wno-nonnull -I/usr/xenomai/include/cobalt

(quoted diff) +0 -2
-I/usr/xenomai/include -march=armv7-a -mfpu=vfp3 -D_GNU_SOURCE
-D_REENTRANT -D__COBALT__ -O2 -Wl,@/usr/xenomai/lib/cobalt.wrappers  

/usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main

(quoted diff) +0 -2
-Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib
-lcobalt -lpthread -lrt -march=armv7-a -mfpu=vfp3   -o cyclictest

cyclictest.o -lrt -lpthread -lrttest -L

Also the clock calibration is (i already run the autotune utility),

root@beaglebone:~# cat /proc/xenomai/clock/coreclk
gravity: irq=499 kernel=1999 user=4999
devices: timer=timer2, clock=ipipe_tsc
 status: on
  setup: 999
  ticks: 350959191461
Quoted 3 lines

and finally i run cyclictest with Thanks for the interest!

cyclictest -n -p 99 -D 1000 -i 250 -m

No wonder why you get weird results, the cyclictest thread does not run with a real-time priority since it uses sched_setscheduler() which is not wrapped by cobalt (pthread_setschedparam() is). You can check this by looking at /proc/xenomai/sched/threads.

The quick and dirty hack below fixes it, and amends the Makefile to switch to the Xenomai libs from a cross-compilation root, when the COBALT variable is mentioned on the make command line. You may need to do some fixup there if you don't install under $crossroot/usr/xenomai though.

Makefile +6 -3
index a48e759..49301b6 100644
@@ -28,7 +28,7 @@ CPPFLAGS += -D_GNU_SOURCE -Isrc/include
 LDFLAGS ?=
 
 ifneq ($(filter x86_64 i386 ia64 mips powerpc,$(machinetype)),)
-NUMA 	:= 1
+NUMA 	:= 0
 ifdef HAVE_PARSE_CPUSTRING_ALL
 	CFLAGS += -DHAVE_PARSE_CPUSTRING_ALL
 endif
@@ -47,6 +47,11 @@ ifeq ($(NUMA),1)
 	NUMA_LIBS = -lnuma
 endif
 
+ifneq ($(COBALT),)
+	CFLAGS += $(shell DESTDIR=$(COBALT) $(COBALT)/usr/bin/xeno-config
--posix --cflags)
+	LDFLAGS += $(shell DESTDIR=$(COBALT) $(COBALT)/usr/bin/xeno-config
--posix --ldflags)
+endif
+
 VPATH	= src/cyclictest:

VPATH += src/signaltest:
VPATH += src/pi_tests:

src/cyclictest/cyclictest.c +1 -1
index 34053c5..92c7043 100644
@@ -795,7 +795,7 @@ void *timerthread(void *param)
 
 	memset(&schedp, 0, sizeof(schedp));
 	schedp.sched_priority = par->prio;
-	if (setscheduler(0, par->policy, &schedp))
+	if (pthread_setschedparam(pthread_self(), par->policy, &schedp))
 		fatal("timerthread%d: failed to set priority to %d\n", par->cpu,

par->prio);

/* Get current time */

Signature · 1 line
Philippe.
#4 lore raw

Great! Now, it is much better! Thanks for the interest.

I have noticed something else, when using clock_nanosleep, there is something wrong going on. Example output with clock_nanosleep:

root@beaglebone:~# cyclictest    -p 99  -i 250 -n
# /dev/cpu_dma_latency set to 0us
policy: fifo: loadavg: 1.13 1.18 1.15 1/243 2385

T: 0 ( 2384) P:99 I:250 C: 122168 Min: 0 Act: 9 *Avg:2147483647* Max: -1

The Avg value jumps to this insane number.
I didn't find any differences between the vanilla cyclictest and the xenomai-2.6 upstream cyclictest regarding the use of clock_nanosleep. Any ideas of where this behaviour would come from?

Thanks,
Konstantinos

Quoted 75 lines · Philippe Gerum
Quoted 19 lines · Konstantinos Chalas

The build command for cyclictest was

gcc -Wall -Wno-nonnull -I/usr/xenomai/include/cobalt

(quoted diff) +0 -2
-I/usr/xenomai/include -march=armv7-a -mfpu=vfp3 -D_GNU_SOURCE
-D_REENTRANT -D__COBALT__ -O2 -Wl,@/usr/xenomai/lib/cobalt.wrappers

/usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main

(quoted diff) +0 -2
-Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib
-lcobalt -lpthread -lrt -march=armv7-a -mfpu=vfp3   -o cyclictest

cyclictest.o -lrt -lpthread -lrttest -L

Also the clock calibration is (i already run the autotune utility),

root@beaglebone:~# cat /proc/xenomai/clock/coreclk
gravity: irq=499 kernel=1999 user=4999
devices: timer=timer2, clock=ipipe_tsc
  status: on
   setup: 999
   ticks: 350959191461
Quoted 3 lines

and finally i run cyclictest with Thanks for the interest!

cyclictest -n -p 99 -D 1000 -i 250 -m

No wonder why you get weird results, the cyclictest thread does not run with a real-time priority since it uses sched_setscheduler() which is not wrapped by cobalt (pthread_setschedparam() is). You can check this by looking at /proc/xenomai/sched/threads.

The quick and dirty hack below fixes it, and amends the Makefile to switch to the Xenomai libs from a cross-compilation root, when the COBALT variable is mentioned on the make command line. You may need to do some fixup there if you don't install under $crossroot/usr/xenomai though.

Makefile +6 -3
index a48e759..49301b6 100644
@@ -28,7 +28,7 @@ CPPFLAGS += -D_GNU_SOURCE -Isrc/include
  LDFLAGS ?=
 
  ifneq ($(filter x86_64 i386 ia64 mips powerpc,$(machinetype)),)
-NUMA 	:= 1
+NUMA 	:= 0
  ifdef HAVE_PARSE_CPUSTRING_ALL
  	CFLAGS += -DHAVE_PARSE_CPUSTRING_ALL
  endif
@@ -47,6 +47,11 @@ ifeq ($(NUMA),1)
  	NUMA_LIBS = -lnuma
  endif
 
+ifneq ($(COBALT),)
+	CFLAGS += $(shell DESTDIR=$(COBALT) $(COBALT)/usr/bin/xeno-config
--posix --cflags)
+	LDFLAGS += $(shell DESTDIR=$(COBALT) $(COBALT)/usr/bin/xeno-config
--posix --ldflags)
+endif
+
  VPATH	= src/cyclictest:
  VPATH	+= src/signaltest:
  VPATH	+= src/pi_tests:
src/cyclictest/cyclictest.c +1 -1
index 34053c5..92c7043 100644
@@ -795,7 +795,7 @@ void *timerthread(void *param)
 
  	memset(&schedp, 0, sizeof(schedp));
  	schedp.sched_priority = par->prio;
-	if (setscheduler(0, par->policy, &schedp))
+	if (pthread_setschedparam(pthread_self(), par->policy, &schedp))
  		fatal("timerthread%d: failed to set priority to %d\n", par->cpu,
 par->prio);
 

/* Get current time */

#5 lore raw
Quoted 9 lines · Konstantinos Chalas

Great! Now, it is much better! Thanks for the interest.

I have noticed something else, when using clock_nanosleep, there is something wrong going on. Example output with clock_nanosleep:

root@beaglebone:~# cyclictest    -p 99  -i 250 -n
# /dev/cpu_dma_latency set to 0us
policy: fifo: loadavg: 1.13 1.18 1.15 1/243 2385         
Quoted 7 lines

T: 0 ( 2384) P:99 I:250 C: 122168 Min: 0 Act: 9 *Avg:2147483647*
Max: -1

The Avg value jumps to this insane number.
I didn't find any differences between the vanilla cyclictest and the xenomai-2.6 upstream cyclictest regarding the use of clock_nanosleep. Any ideas of where this behaviour would come from?

Which kernel and I-pipe release are you running?

Signature · 1 line
Philippe.
#6 lore raw

Hello,

root@beaglebone:~# uname -a
Linux beaglebone 3.14.44+ #1 SMP PREEMPT Wed Aug 26 23:41:20 CEST 2015 armv7l GNU/Linux

and ipipe-core-3.14.44-arm-12

Thanks

Quoted 19 lines · Philippe Gerum
Quoted 9 lines · Konstantinos Chalas

Great! Now, it is much better! Thanks for the interest.

I have noticed something else, when using clock_nanosleep, there is something wrong going on. Example output with clock_nanosleep:

root@beaglebone:~# cyclictest    -p 99  -i 250 -n
# /dev/cpu_dma_latency set to 0us
policy: fifo: loadavg: 1.13 1.18 1.15 1/243 2385
Quoted 7 lines

T: 0 ( 2384) P:99 I:250 C: 122168 Min: 0 Act: 9 *Avg:2147483647*
Max: -1

The Avg value jumps to this insane number.
I didn't find any differences between the vanilla cyclictest and the xenomai-2.6 upstream cyclictest regarding the use of clock_nanosleep. Any ideas of where this behaviour would come from?

Which kernel and I-pipe release are you running?

#7 lore raw
Quoted 8 lines · Konstantinos Chalas

Hello,

root@beaglebone:~# uname -a
Linux beaglebone 3.14.44+ #1 SMP PREEMPT Wed Aug 26 23:41:20 CEST 2015
armv7l GNU/Linux

and ipipe-core-3.14.44-arm-12

Do you have any weird values appearing during a standard latency test? e.g.

# latency [-t0]
Quoted 23 lines

Thanks

Quoted 19 lines · Philippe Gerum
Quoted 9 lines · Konstantinos Chalas

Great! Now, it is much better! Thanks for the interest.

I have noticed something else, when using clock_nanosleep, there is something wrong going on. Example output with clock_nanosleep:

root@beaglebone:~# cyclictest    -p 99  -i 250 -n
# /dev/cpu_dma_latency set to 0us
policy: fifo: loadavg: 1.13 1.18 1.15 1/243 2385         
Quoted 7 lines

T: 0 ( 2384) P:99 I:250 C: 122168 Min: 0 Act: 9 *Avg:2147483647*
Max: -1

The Avg value jumps to this insane number.
I didn't find any differences between the vanilla cyclictest and the xenomai-2.6 upstream cyclictest regarding the use of clock_nanosleep. Any ideas of where this behaviour would come from?

Which kernel and I-pipe release are you running?

Signature · 1 line
Philippe.
#8 lore raw

No, besides a negative lat best value, like this:

RTH|----lat min|----lat avg|----lat max|-overrun|---msw|---lat best|--lat worst
RTD|      1.080|      3.013|     40.080|            0| 0|     -1.275|     43.961
Quoted 36 lines · Philippe Gerum
Quoted 8 lines · Konstantinos Chalas

Hello,

root@beaglebone:~# uname -a
Linux beaglebone 3.14.44+ #1 SMP PREEMPT Wed Aug 26 23:41:20 CEST 2015
armv7l GNU/Linux

and ipipe-core-3.14.44-arm-12

Do you have any weird values appearing during a standard latency test? e.g.

# latency [-t0]
Quoted 22 lines

Thanks

Quoted 19 lines · Philippe Gerum
Quoted 9 lines · Konstantinos Chalas

Great! Now, it is much better! Thanks for the interest.

I have noticed something else, when using clock_nanosleep, there is something wrong going on. Example output with clock_nanosleep:

root@beaglebone:~# cyclictest    -p 99  -i 250 -n
# /dev/cpu_dma_latency set to 0us
policy: fifo: loadavg: 1.13 1.18 1.15 1/243 2385
Quoted 7 lines

T: 0 ( 2384) P:99 I:250 C: 122168 Min: 0 Act: 9 *Avg:2147483647*
Max: -1

The Avg value jumps to this insane number.
I didn't find any differences between the vanilla cyclictest and the xenomai-2.6 upstream cyclictest regarding the use of clock_nanosleep. Any ideas of where this behaviour would come from?

Which kernel and I-pipe release are you running?

#9 lore raw
Quoted 6 lines · Konstantinos Chalas

No, besides a negative lat best value, like this:

RTH|----lat min|----lat avg|----lat max|-overrun|---msw|---lat best|--lat worst
RTD| 1.080| 3.013| 40.080| 0| 0|
-1.275| 43.961

Ok, that one is innocuous, this is only a timer calibration issue. The strange average value may be an issue in cyclictest since 2147483647 is 2^31-1, which is INT32_MAX. A bit like no sample had been recorded during such run.

Quoted 42 lines · Philippe Gerum
Quoted 38 lines · Konstantinos Chalas
Quoted 8 lines

Hello,

root@beaglebone:~# uname -a
Linux beaglebone 3.14.44+ #1 SMP PREEMPT Wed Aug 26 23:41:20 CEST 2015
armv7l GNU/Linux

and ipipe-core-3.14.44-arm-12

Do you have any weird values appearing during a standard latency test? e.g.

# latency [-t0]
Quoted 23 lines

Thanks

Quoted 20 lines · Philippe Gerum
Quoted 9 lines · Konstantinos Chalas

Great! Now, it is much better! Thanks for the interest.

I have noticed something else, when using clock_nanosleep, there is something wrong going on. Example output with clock_nanosleep:

root@beaglebone:~# cyclictest    -p 99  -i 250 -n
# /dev/cpu_dma_latency set to 0us
policy: fifo: loadavg: 1.13 1.18 1.15 1/243 2385
Quoted 8 lines

T: 0 ( 2384) P:99 I:250 C: 122168 Min: 0 Act: 9
*Avg:2147483647*
Max: -1

The Avg value jumps to this insane number.
I didn't find any differences between the vanilla cyclictest and the xenomai-2.6 upstream cyclictest regarding the use of clock_nanosleep. Any ideas of where this behaviour would come from?

Which kernel and I-pipe release are you running?

Signature · 1 line
Philippe.
#10 lore raw

It wasn't innocuous... The variable uint64_t diff was used to store the latency, which in turn took the value -1 because of the timer calibration issue , therefore when casted as unsigned produced 2^64-1. It works as it should after running autotune.

Thank you very much for the help,
Konstantinos

Quoted 52 lines · Philippe Gerum
Quoted 6 lines · Konstantinos Chalas

No, besides a negative lat best value, like this:

RTH|----lat min|----lat avg|----lat max|-overrun|---msw|---lat best|--lat worst
RTD| 1.080| 3.013| 40.080| 0| 0|
-1.275| 43.961

Ok, that one is innocuous, this is only a timer calibration issue. The strange average value may be an issue in cyclictest since 2147483647 is 2^31-1, which is INT32_MAX. A bit like no sample had been recorded during such run.

Quoted 39 lines · Philippe Gerum
Quoted 37 lines · Konstantinos Chalas
Quoted 8 lines

Hello,

root@beaglebone:~# uname -a
Linux beaglebone 3.14.44+ #1 SMP PREEMPT Wed Aug 26 23:41:20 CEST 2015
armv7l GNU/Linux

and ipipe-core-3.14.44-arm-12

Do you have any weird values appearing during a standard latency test? e.g.

# latency [-t0]
Quoted 23 lines

Thanks

Quoted 20 lines · Philippe Gerum
Quoted 9 lines · Konstantinos Chalas

Great! Now, it is much better! Thanks for the interest.

I have noticed something else, when using clock_nanosleep, there is something wrong going on. Example output with clock_nanosleep:

root@beaglebone:~# cyclictest    -p 99  -i 250 -n
# /dev/cpu_dma_latency set to 0us
policy: fifo: loadavg: 1.13 1.18 1.15 1/243 2385
Quoted 8 lines

T: 0 ( 2384) P:99 I:250 C: 122168 Min: 0 Act: 9
*Avg:2147483647*
Max: -1

The Avg value jumps to this insane number.
I didn't find any differences between the vanilla cyclictest and the xenomai-2.6 upstream cyclictest regarding the use of clock_nanosleep. Any ideas of where this behaviour would come from?

Which kernel and I-pipe release are you running?

#11 lore raw
Quoted 3 lines · Konstantinos Chalas

It wasn't innocuous... The variable uint64_t diff was used to store the latency, which in turn took the value -1 because of the timer calibration issue ,

Which is innocuous. It only means that you got a task rescheduling early by a microsecond once due to the incorrect calibration. This does not reveal any malfunction.

therefore when casted as unsigned produced 2^64-1.

Quoted 61 lines

It works as it should after running autotune.

Thank you very much for the help,
Konstantinos

Quoted 53 lines · Philippe Gerum
Quoted 6 lines · Konstantinos Chalas

No, besides a negative lat best value, like this:

RTH|----lat min|----lat avg|----lat max|-overrun|---msw|---lat best|--lat worst
RTD| 1.080| 3.013| 40.080| 0| 0|
-1.275| 43.961

Ok, that one is innocuous, this is only a timer calibration issue. The strange average value may be an issue in cyclictest since 2147483647 is 2^31-1, which is INT32_MAX. A bit like no sample had been recorded during such run.

Quoted 40 lines · Philippe Gerum
Quoted 38 lines · Konstantinos Chalas
Quoted 8 lines

Hello,

root@beaglebone:~# uname -a
Linux beaglebone 3.14.44+ #1 SMP PREEMPT Wed Aug 26 23:41:20 CEST 2015
armv7l GNU/Linux

and ipipe-core-3.14.44-arm-12

Do you have any weird values appearing during a standard latency test? e.g.

# latency [-t0]
Quoted 24 lines

Thanks

Quoted 21 lines · Philippe Gerum
Quoted 13 lines · Konstantinos Chalas

Great! Now, it is much better! Thanks for the interest.

I have noticed something else, when using clock_nanosleep, there is something wrong going on. Example output with clock_nanosleep:

root@beaglebone:~# cyclictest    -p 99  -i 250 -n
# /dev/cpu_dma_latency set to 0us
policy: fifo: loadavg: 1.13 1.18 1.15 1/243 2385

T: 0 ( 2384) P:99 I:250 C: 122168 Min: 0 Act: 9
*Avg:2147483647*
Max: -1

Quoted 5 lines

The Avg value jumps to this insane number.
I didn't find any differences between the vanilla cyclictest and the xenomai-2.6 upstream cyclictest regarding the use of clock_nanosleep.
Any ideas of where this behaviour would come from?

Which kernel and I-pipe release are you running?

Signature · 1 line
Philippe.