Introduction

This page is intended to serve as a collecting point for presentations, documents, results, links and descriptions
about testing Realtime performance of Linux systems. In the first section, please upload or place links to presentations
or documentsion on the subject of RT testing for linux.

Terminology

Test programs

RT Measurement programs

Here is a list of programs that have been used for realtime testing:

lpptest

* lpptest - included in the RT-preempt patch
* It consists of a
1. driver in the linux kernel, to toggle a bit on the parallel port, and watch for a response toggle back
2. a user program to cause the measurement to happen
3. a driver to respond to this toggling
* with the RT-preempt patch applied, see:
* drivers/char/lpptest.c
* scripts/testlpp.c
* For some other modifications, see http://www.ussg.iu.edu/hypermail/linux/kernel/0702.2/0342.html
* remove dependency on TSC

This requires a separate machine to send the signal on the parallel port and receive the response.
(Can this be run with a loopback cable? It seems like this would disturb the findings).

Are there any writeups of use of this test?

RealFeel

This program is a very simple test of how well a periodic interrupt is processed. The program programs a periodic interrupt
using /dev/rtc to fire at a fixed interval. The program measures the time duration from interrupt to interrupt, and compares
this to the expected value for the duration. This simple program just prints a list of variances from the expected value,
forever.

This program uses the TSC in user space for timestamps.

RealFeel (ETRI version rf-etri)

This program (latency.c) extends realfeel in several ways:

* it adds command line arguments to allow runtime control of most parameters
* it adds a histogram feature to dump the results to a histogram
* it can do both linear and logarithmic histograms
* it locks the process pages in memory (very important)
* it changes the scheduling priority to SCHED_FIFO, at highest priority (very important)
* it adds conditional code to trigger output to a parallel port pin (for capture to an external probe or logic analyzer)
* it abstracts the routine to get the timestamp, with the function: getticks()
* it handles the interrupt signal and does a clean exit of the main loop (on user break?)
* it tracks min, max and average latency for whole run, and for every 1000 cycles of the loop
* it adds a timestamp to the /dev/rtc driver, and reads this as part of the rtc data
* how is rtc timestamp used??

LRTB

Hourglass

* Hourglass is a synthetic real-time application that can be used to learn how CPU scheduling in a general-purpose operating system works at microsecond and millisecond granularities
* See: http://www.cs.utah.edu/~regehr/hourglass/

Woerner test

Trevor Woerner wrote an interesting test which received an interrupt on the serial port, and pushed data through several
processes, before sending back out the serial port. This test requires an external machine for triggering the test and measuring
the results.

Stress programs

Stress actions

Here are some things that will kill your RT performance:

* write the time of day to the CMOS of your RTC (see drivers/char/rtc.c - only by code inspection, no test yet)
* have a bus-master device do a long DMA on the bus
* get a page fault on your RT process (can be prevented with mlockall)
* get multiple TLB flushes on your RT code path (how to cause this??)
* get lots of instruction and data cache misses on your RT code path
* how to cause this?
* go down error paths in the RT case?
* be ON a big error case when the RT event happens?
* push your main RT code path and data sets out of cache with other work (in your RT process), prior to the next RT event?
* access data in a very non-localized way on your RT code path

Test Hardware

* LRTB uses a 3-machine system:
* target, host, and logger
* target is the system under test
* host is a control system, and it also collects the data
* logger is a special machine used to cause interrupts on the target, and record the time it takes for the target to respond
* Paulo Marqes offered to create custom hardware for the logger

Issues and Techniques

This is a list of issues and techniques for dealing with them, having to do with
testing realtime performance in Linux.

ping flood isn't good as stress test

At one of the sessions at ELC 2007, Nicholas McGuire stated that a pingflood test
is actually a poor test of RT performance, since it causes locality in the networking
code rather than stressing the system.

Here is a list of issues that have to be dealt with:

* what tests are available on all platforms?
* is special clock hardware or registers required for a test (e.g. realfeel, which only supports i386?)
* does the program cross-compile?
* Does generation of the test conditions perturb the test results?
* Is special external hardware required?
* How is the system stressed?
* How to stress memory (cause cache-flushes and swapping)
* How to stress bad code paths (long error paths, fault injection?)
* How is performance measured?

Using the LATENCY_TRACE option

Quote about latency-test from Ingo:
{{{i'm seeing roughly half of that worst-case IRQ latency on similar
hardware (2GHz Athlon64), so i believe your system has some hardware
latency that masks the capabilities of the underlying RTOS. It would be
interesting to see IRQSOFF_TIMING + LATENCY_TRACE critical path
information from the -RT tree. Just enable those two options in the
.config (on the host side), and do:

echo 0 > /proc/sys/kernel/preempt_max_latency

and the kernel will begin measuring and tracing worst-case latency
paths. Then put some load on the host when you see a 50+ usec latency
reported to the syslog, send me the /proc/latency_trace. It should be a
matter of a few minutes to capture this information.
}}}

Number of samples recommended

Ingo wrote:
{{{
also, i'm wondering why you tested with only 1,000,000 samples. I
routinely do 100,000,000 sample tests, and i did one overnight test with
more than 1 billion samples, and the latency difference is quite
significant between say 1,000,000 samples and 100,000,000 samples. All
you need to do is to increase the rate of interrupts generated by the
logger - e.g. my testbox can handle 80,000 irqs/sec with only 15% CPU
overhead.
}}}

Things to watch for in testing

otherwise par_test_irq_handler will run with interrupts enabled, opening
the window for other interrupts to be injected and increasing the
worst-case latency! Take a look at drivers/char/lpptest.c how to do this
properly. Also, double-check that there is no IRQ 7 thread running on
the PREEMPT_RT kernel, to make sure you are measuring irq latencies.

* [attachment:p-a03_wilshire.pdf Real Time Linux: Testing and Evaluation] - By Phil Wilshire of Lineo at the Second Real Time Linux Workshop, 2000
* This paper discusses the different benchmarking tools used to evaluate the performance of Linux and
their suitability for evaluating Real Time system Performance. It is focused on RTAI.

Notes on ineffective tests

Nicholas !McGuire wrote:
{{{
The tests noted in the LKML post on this page are very problematic,
ping - -f is not testing RT at all, it keeps the kernel in a very small active
page set thus reducing page related penalties, the while loop using dd
is also not too helpfull as it will de-facto run only in memory and cause
absolutely no disk/mass-storage related interaction (try the same with
mount -o remount,sync / first and it will be devastating ! (limited to ext2/ext3/ufs))
}}}

Notes on test requirements - need to test kernel error paths

Nichoal !McGuire wrote:

The big problem with RT tests published is that they are all looking at the good case,
they are loading the system but assuming successfull operations. The worst cases pop
up when you run in the error paths of the kernel - then a trivial application can
induce very large jitter in the system (run crashme in the background and rerun
the tests...)

Notes on test requirements - need for usage profile

Also lmbench can give a statistic view of things (and not even that very precisely
in some case i.e. context switch measurements are flawed) so this is not of much
help for descision makers which variant to use - it does not help if the average
performance is good but the mobile phone or mp3 klicks at 1s intervals
"deterministically" - so I guess RT benchmarks need a notion of usage-profile
to be of value.