Index of /linux/preemp-test

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory  -  
[   ]Makefile2020-03-19 04:53 826  
[TXT]README.html2020-03-19 04:53 5.3K 
[TXT]README.txt2020-03-19 04:53 5.1K 
[TXT]delay.c2020-03-19 04:53 2.2K 
[TXT]do_delay.c2020-03-19 04:53 1.5K 
[TXT]do_ptimer.c2020-03-19 04:53 5.7K 
[TXT]fitdata.cxx2020-03-19 04:53 2.7K 
[   ]gnuplot.cmd2020-03-19 04:53 846  
[TXT]ptimer.c2020-03-19 04:53 5.8K 
[DIR]ptimer/2020-03-19 04:53 -  
[TXT]read_ptimer.c2020-03-19 04:53 1.3K 
[TXT]readme.txt2020-03-19 04:53 4.5K 
[DIR]result1/2020-03-19 04:53 -  
[DIR]result2/2020-03-19 04:53 -  
[DIR]statistic/2020-03-19 04:53 -  
[IMG]test1-density-comp.gif2020-03-19 04:53 19K 
[IMG]test1-normal-distribution.gif2020-03-19 04:53 26K 
[IMG]test1-prek-distribution.gif2020-03-19 04:53 18K 
[IMG]test2-density-comp.gif2020-03-19 04:53 19K 
[IMG]test2-normal-distribution.gif2020-03-19 04:53 27K 
[IMG]test2-prek-distribution.gif2020-03-19 04:53 19K 

README for a bunch of preemption latency test utilities

Jun Sun,


This suite uses two virtual devices: /dev/delay, which introduces busy
looping inside kernel, and /dev/ptimer, which regulates periodic task
release.  By using /dev/ptimer we can measure the jitters due to 
kernel preemption delay.  By using /dev/delay, we can artifically
generate system calls with a specified in-kernel duration.

The test collects the intervals between two consecutive instance
releases while /dev/delay is accessed by another process.  Additional
workload may be present.

The collected data are then fitted with a Normal distribution curve.
Then we can compare the preemption delay statistically.  We can also
view the difference through gnuplot


Makefile generates the following targets.  Modify Makefile before you use it.

	driver for /dev/delay.  You can do write() on /dev/delay.
	It will do busy looping inside kernel for the specified number of

	It is a module.

	To create /dev/delay, su as root.  mknod /dev/delay c 241 0

	A userland program that uses /dev/delay to create random
	busy loopings inside kernel.

	You can specify the percent of time in kernel (and therefore in
	userland).  Yuo can specify the maximum number of microseconds
	for a single syscall.

	By default, it will spend 100% in kernel, and the maximum number
	of syscall duration is 1024 usecs.

	It is a module.

	Driver for /dev/ptimer.

	/dev/ptimer regulates the releases of a periodic task.  A periodic task
	is determined by its phase (the jiffies at which first instance starts)
	and its period (number of jiffies later when next instance should 

	A typically application would use ioctl() to set up period and
	phase.  And then do a loop:

		for(;;) {
			read(ptimer, &count, sizeof(count));
			/* do jobs */

	read() call will delay the process until next release point.
	Various policies guide what should happen if read() is made *after*
	next release point (an overrun case).  By default, read() does not 
	cause any delay in overrun case.  In fact, it will accumulate
	the number of misses releases in case of multiple instance overrun.

	ptimer.c is implemented based on timer_bh, and thus is arch and
	hardware independent.

	To create /dev/ptimer, su as root.  mknod /dev/ptimer c 240 0

	A test program of /dev/ptimer.

	a test program that uses /dev/ptimer and measure the interval
	between any two consecutive instance releases.  Essentially it
	measures the jitters in releases.

	Pass a single argument "realtime" will cause the test to be done
	with a realtime priority (recommanded).

	It produces an output data file "data"

	Created from fitdata.cxx and statistic library.
	It reads the data produced by do_ptimer.  It will fit the data
	with a Normal distribution.  Finally it will output the distribution
	curve for the experiemental data, the fitting Normal distribution
	and the density function of the fitting curve.  The output file
	is "".


1. start the target machine.

2. insmod -f delay.o; insmod ptimer.o

3. ./do_delay

4. (optional) introduce some other workload

5. [in another terminal] ./do_ptimer or ./do_ptimer realtime

6. copy data file to the host machine.

7. on the host machine, "fitdata data".  See some more explaination of
   the data fitting program.

8. use gnuplot to view curves if you want.  Refer to "gnuplot.cmd" file
   for some useful gnuplot commonds.


Some test results are put under result1/ and result2/.

machine: DDB5476 (MIPS), 166 MHz

test1: same as 'HOW TO TEST' with no optional workload

test2: same as test1 with another stress workload, whcih consists of
	three FPU-intensive processes.  It introduces more jitters.

Notations in filename:

	prek : run under preemptive kernel
	realtime : do_ptimer uses realtime priority
	normal : no realtime priority nor preemptive kernel
	.dist : the distribution and density data produced by fitdata
	.data : the raw data
	.gif : some output produced by gnuplot


fitdata will try to fit the sample data into a Normal distribution.
It outputs some parameters to the standard output and create file that contains all data points of distribution function
and desity function.  The file is suitable for gnuplotting to draw


count 	- number of sample points collected
overrun - the number of instance releases that slipped into next period
min 	- minimum value of the release interval
max	- maximum value of the release interval
miu	- average value of the release interval
sigma2	- sqaure of sigma
sigma	- standard deviation


Apparently, we see

. realtime case performs better than non-realtime case
. preemptive kernel is much better than normal kernel

However, in every test with preemptive kernel, I still see a couple of jitters 
up to 300 micro-seconds.  What are those jitters?  Interrupt blocking time? 
Taht long?


There seems to be a bug in setting next release point when an overrun
happens.  Need to chase it down.


Many of ideas in this test suite are inspired or directly influenced by 

	Jeremy Siegel,
	George Azinger,