Cyclictest

From RTwiki
(Difference between revisions)
Jump to: navigation, search
(fix the tarball link)
m (Run it)
Line 97: Line 97:
 
'''-s''' in combination with '''-n''' uses the nanosleep syscall and is not restricted to one thread
 
'''-s''' in combination with '''-n''' uses the nanosleep syscall and is not restricted to one thread
  
'''-t NUM''' set the number of test threads (default is 1)
+
'''-t NUM''' set the number of test threads (default is 1), -t without an argument makes the number of threads equal to the number of cpus
  
 
Create NUM test threads. See '''-d''', '''-i''' and '''-p''' for further information.
 
Create NUM test threads. See '''-d''', '''-i''' and '''-p''' for further information.

Revision as of 09:26, 16 June 2008

Cyclictest is a high resolution test program, written by User:Tglx

Contents

Documentation

Installation

Get the latest sources from the git repository or fetch a released tarball from the archive, untar into a directory of your choice and run make in the source directory. If you want to cross compile, just run make CROSS_COMPILE=<your-compiler-prefix> (for example make CROSS_COMPILE=arm-v4t-linux-gnueabi-).

You can run the resulting binary from there or install it.

Run it

Make sure to be root or use sudo to run cyclictest.

Without parameters cyclictest creates one thread with a 1ms interval timer.

cyclictest -h provides help text for the various options

-b USEC--breaktrace=USECsend break trace command when latency > USEC
-c CLOCK--clock=CLOCKselect clock

0 = CLOCK_MONOTONIC (default)

1 = CLOCK_REALTIME
-d DIST--distance=DISTdistance of thread intervals in us default=500
-i INTV--interval=INTVbase interval of thread in us default=1000
-l LOOPS--loops=LOOPSnumber of loops: default=0(endless)
-n--nanosleepuse clock_nanosleep
-p PRIO--prio=PRIOpriority of highest prio thread
-q--quietprint only a summary on exit
-r--relativeuse relative timer instead of absolute
-s--systemuse sys_nanosleep and sys_setitimer
-t NUM--threads=NUMnumber of threads: default=1
-v--verboseoutput values on stdout for statistics
format: n:c:v n=tasknum c=count v=value in us

-b is a debugging option to control the latency tracer in the realtime preemption patch.

It is useful to track down unexpected large latencies on a system. This option does only work with

  • CONFIG_PREEMPT_RT=y
  • CONFIG_WAKEUP_TIMING=y
  • CONFIG_LATENCY_TRACE=y
  • CONFIG_CRITICAL_PREEMPT_TIMING=y
  • CONFIG_CRITICAL_IRQSOFF_TIMING=y

kernel configuration options enabled. The USEC parameter to the -b option defines a maximum latency value, which is compared against the actual latencies of the test. Once the measured latency is higher than the given maximum, the kernel tracer and cyclictest is stopped. The trace can be read from /proc/latency_trace

mybox# cat /proc/latency_trace >trace.log

Please be aware that the tracer adds significant overhead to the kernel, so the latencies will be much higher than on a kernel with latency tracing disabled.

-c CLOCK selects the clock, which is used

  • 0 selects CLOCK_MONOTONIC, which is the monotonic increasing system time. This is the default selection
  • 1 selects CLOCK_REALTIME, which is the time of day time.

CLOCK_REALTIME can be set by settimeofday, while CLOCK_MONOTONIC can not be modified by the user.

This option has no influence when the -s option is given.

-d DIST set the distance of thread intervals in microseconds (default is 500us)

When cylictest is called with the -t option and more than one thread is created, then this distance value is added to the interval of the threads.

Interval(thread N) = Interval(thread N-1) + DIST

-i INTV set the base interval of the thread(s) in microseconds (default is 1000us)

This sets the interval of the first thread. See also -d.

-l LOOPS set the number of loops (default = 0(endless))

This option is useful for automated tests with a given number of test cycles. cyclictest is stopped once the number of timer intervals has been reached.

-n use clock_nanosleep instead of posix interval timers

Setting this option runs the tests with clock_nanosleep instead of posix interval timers.

-p PRIO set the priority of the first thread

The given priority is set to the first test thread. Each further thread gets a lower priority:

Priority(Thread N) = Priority(Thread N-1)

-q run the tests quiet and print only a summary on exit

Useful for automated tests, where only the summary output needs to be captured

-r use relative timers instead of absolute

The default behaviour of the tests is to use absolute timers. This option is there for completeness and should not be used for reproducible tests.

-s use sys_nanosleep and sys_setitimer instead of posix timers

Note, that -s can only be used with one thread because itimers are per process and not per thread. -s in combination with -n uses the nanosleep syscall and is not restricted to one thread

-t NUM set the number of test threads (default is 1), -t without an argument makes the number of threads equal to the number of cpus

Create NUM test threads. See -d, -i and -p for further information.

-v output values on stdout for statistics

This option is used to gather statistical information about the latency distribution. The output is sent to stdout. The output format is

n:c:v

where n=task number c=count v=latency value in us

Use this option in combination with -l

The OSADL Realtime LiveCD project provides a script to plot the latency distribution.

Expected Results

tglx's reference machine

All tests have been run on a Pentium III 400MHz based PC.

The tables show comparisons of vanilla Linux 2.6.16, Linux-2.6.16-hrt5 and Linux-2.6.16-rt12. The tests for intervals less than the jiffy resolution have not been run on vanilla Linux 2.6.16. The test thread runs in all cases with SCHED_FIFO and priority 80. All numbers are in microseconds.

  • Test case: clock_nanosleep(TIME_ABSTIME), Interval 10000 microseconds,. 10000 loops, no load.

Commandline: cyclictest -t 1 -p 80 -n -i 10000 -l 10000

Kernel min max avg
2.6.16 24 4043 1989
2.6.16-hrt5 12 94 20
2.6.16-rt12 6 40 10
  • Test case: clock_nanosleep(TIME_ABSTIME), Interval 10000 micro seconds,. 10000 loops, 100% load.

Commandline: cyclictest -t 1 -p 80 -n -i 10000 -l 10000

Kernel min max avg
2.6.16 55 4280 2198
2.6.16-hrt5 11 458 55
2.6.16-rt12 6 67 29
  • Test case: POSIX interval timer, Interval 10000 micro seconds,. 10000 loops, no load.

Commandline: cyclictest -t 1 -p 80 -i 10000 -l 10000

Kernel min max avg
2.6.16 21 4073 2098
2.6.16-hrt5 22 120 35
2.6.16-rt12 20 60 31
  • Test case: POSIX interval timer, Interval 10000 micro seconds,. 10000 loops, 100% load.

Commandline: cyclictest -t 1 -p 80 -i 10000 -l 10000

Kernel min max avg
2.6.16 82 4271 2089
2.6.16-hrt5 31 458 53
2.6.16-rt12 21 70 35
  • Test case: clock_nanosleep(TIME_ABSTIME), Interval 500 micro seconds,. 100000 loops, no load.

Commandline: cyclictest -t 1 -p 80 -i 10000 -n -l 100000

Kernel min max avg
2.6.16-hrt5 5 108 24
2.6.16-rt12 5 48 7
  • Test case: clock_nanosleep(TIME_ABSTIME), Interval 500 micro seconds,. 100000 loops, 100% load.

Commandline: cyclictest -t 1 -p 80 -i 500 -n -l 100000

Kernel min max avg
2.6.16-hrt5 9 684 56
2.6.16-rt12 10 60 22
  • Test case: POSIX interval timer, Interval 500 micro seconds,. 100000 loops, no load.

Commandline: cyclictest -t 1 -p 80 -i 500 -l 100000

Kernel min max avg
2.6.16-hrt5 8 119 22
2.6.16-rt12 12 78 16
  • Test case: POSIX interval timer, Interval 500 micro seconds,. 100000 loops, 100% load.

Commandline: cyclictest -t 1 -p 80 -i 500 -l 100000

Kernel min max avg
2.6.16-hrt5 16 489 58
2.6.16-rt12 12 95 29

External Links

FAQ

ps shows the wrong scheduling class SCHED_OTHER

Each cyclictest-task consist of one ore more threads. ps -ce shows only the main-process not the threads of the main-process. ps -eLc | grep cyclic shows the main-process an the containing threads with the correct scheduler class SCHED_FIFO.

#>./cyclictest -t 5 -p 80 -n -i 10000

#> ps -cLe | grep cyclic
 4764  4764 TS   19 pts/1    00:00:01 cyclictest
 4764  4765 FF  120 pts/1    00:00:00 cyclictest
 4764  4766 FF  119 pts/1    00:00:00 cyclictest
 4764  4767 FF  118 pts/1    00:00:00 cyclictest
 4764  4768 FF  117 pts/1    00:00:00 cyclictest
 4764  4769 FF  116 pts/1    00:00:00 cyclictest

chrt shows the wrong scheduling class SCHED_OTHER

Don't use the PID of the main-process, but the pid of one of the threads from the main-process. The threads are shown with ps -cLe | grep cyclic.

#> chrt -p 4766
pid 4766's current scheduling policy: SCHED_FIFO
pid 4766's current scheduling priority: 79
Personal tools