Interrupt latency questions
Antonio Del Cinque wrote:
[...]
Quoted 3 lines
Then I open an ssh connection with the target, and run a "cat
/dev/zerofile". The target
is mounted on an NFS root filesystem, so this generates a high number
of
Quoted 1 line
fast ethernet interrupts. Now the oscilloscope shows 15 uS jitter in
the worst case,
Quoted 1 line
and a visible variance. I would assume this effect as increased max
latency.
This figure has already been seen with SoC in the range of the e300, and sometime worse.
Quoted 1 line
The ethernet interrupt is handled only in Linux domain by the original
vanilla handler,
Quoted 1 line
but Linux should be stalled/preempted when the timer interrupt occurs.
So I assume
Quoted 1 line
that latency is to be justified by the time it takes to adeos to record
an
Quoted 1 line
ethernet interrupt event in the i-logs when the timer interrupt is
executing or ready to
Quoted 1 line
execute. Is this correct?
Cache miss and TLB miss are also good latency killers. To some extent, long DMA transfers can bog down the system bus.
Quoted 1 line
Is there any way to lower max latency for the timer interrupt?
Has anybody tried to play with cache locking?
Signature · 1 line
Stephane
Thank you,
I think your considerations are the right ones.
The DMA controller is not generating any interrupt, so I assume it is not actually working. I'm trying to verify that the jitter is caused by cache/TLB misses. I don't have much reference on how to lock the cache, so I'll just try to have the cache dirty in any other way to see if it causes the same jitter.
Antonio
Quoted 34 lines · Fillod Stephane
Antonio Del Cinque wrote:
[...]Quoted 3 lines
Then I open an ssh connection with the target, and run a "cat
/dev/zerofile". The target
is mounted on an NFS root filesystem, so this generates a high numberof
Quoted 1 line
fast ethernet interrupts. Now the oscilloscope shows 15 uS jitter in
the worst case,
Quoted 1 line
and a visible variance. I would assume this effect as increased max
latency.
This figure has already been seen with SoC in the range of the e300, and sometime worse.
Quoted 1 line
The ethernet interrupt is handled only in Linux domain by the original
vanilla handler,
Quoted 1 line
but Linux should be stalled/preempted when the timer interrupt occurs.
So I assume
Quoted 1 line
that latency is to be justified by the time it takes to adeos to record
an
Quoted 1 line
ethernet interrupt event in the i-logs when the timer interrupt is
executing or ready to
Quoted 1 line
execute. Is this correct?
Cache miss and TLB miss are also good latency killers. To some extent, long DMA transfers can bog down the system bus.
Quoted 1 line
Is there any way to lower max latency for the timer interrupt?
Has anybody tried to play with cache locking?
--
Stephane
Quoted 8 lines · Antonio Del Cinque
Thank you,
I think your considerations are the right ones.The DMA controller is not generating any interrupt, so I assume it is not actually working. I'm trying to verify that the jitter is caused by cache/TLB misses. I don't have much reference on how to lock the cache, so I'll just try to have the cache dirty in any other way to see if it causes the same jitter.
A good way to do this is to use the cache calibrator:
http://homepages.cwi.nl/~manegold/Calibrator/
Signature · 1 line
Gilles.
Hi,
sorry, I needed time to implement your suggestions, but finally I got some results. I checked for cache related issues, and found that latency is highly related to cache misses.
I found the way to disable the instruction cache (the e300 powerpc core has a 32 KB i-cache and a 32 KB d-cache, but I couldn't disable the d-cache because of segmentation faults), and I changed the test to measure interrupt latency.
Now I have a Xenomai real time task. The task is periodic (I used rt_task_set_periodic() and rt_task_wait_period()) and, at every period, it toggles a GPIO pin configured as an output, by calling the GPIO rtdm driver ioctl command. The pin is short circuited with another pin which is configured as an input, generating an interrupt in the powerpc. The interrupt routine, registerd via rtdm_irq_request() in the same GPIO rtdm driver, toggles another GPIO pin configured as an output, so I see the two IO pins on the oscilloscope, the first generating the interrupt, and the second indicating that the interrupt routine has been executed.
When the cache is enabled I see a latency between 2 and 5 uS with no load, but if I create a non real time load the latency raises (for example to 12 uS with the cache calibrator running), and this is non deterministic, since it dependes on the cache use.
When I disable the i-cache the latency goes to 16 uS with no load, this is 11 to 14 uS over latency! Non real time task now only sligthly affect the latency, but I have the following problem: if I start real time tasks (for example I run /usr/local/xenomai/share/xenomai/testsuite/cyclic/run) the GPIO interrupt latency is not commonly affected, but occasionally it gets to 50 uS. I can't explain this. Could you help me?
The delay is not continuos, it jumps from 16-20 to 38-50 uS. Now the i-cache is disabled, so it seems another interrupt routine, running in Xenomai domain, gets interleaved with the GPIO interrupt rountine.
Is there any way to track these kind of latency in the ipipe, a kind of worst latency case tracker? I see only "virtual" IRQs 512 and 515 running in Xenomai domain. I cannot see where they are set up. I guess one of them is the system timer, and I know this is commonly driven by the powerpc decrementer. Is the GPIO interrupt latency due to the system timer interrupt? If this is the case, where can I disable the system timer in Xenomai, or modify the interrupt routine? I must run in interrupt context because of latency requirements (they asked me for deterministic latencies under 20 uS).
Thank you, very much
Antonio
Quoted 18 lines · Gilles Chanteperdrix
Quoted 6 lines · Antonio Del Cinque
Thank you,
I think your considerations are the right ones.The DMA controller is not generating any interrupt, so I assume it is not actually working. I'm trying to verify that the jitter is caused by cache/TLB misses. I don't have much reference on how to lock the cache,
so
Quoted 1 line
I'll just try to have the cache dirty in any other way to see if it
causes
Quoted 1 line
the same jitter.
A good way to do this is to use the cache calibrator:
http://homepages.cwi.nl/~manegold/Calibrator/<http://homepages.cwi.nl/%7Emanegold/Calibrator/>--
Gilles.
Quoted 9 lines · Antonio Del Cinque
Is there any way to track these kind of latency in the ipipe, a kind of worst latency case tracker? I see only "virtual" IRQs 512 and 515 running in Xenomai domain. I cannot see where they are set up. I guess one of them is the system timer, and I know this is commonly driven by the powerpc decrementer. Is the GPIO interrupt latency due to the system timer interrupt? If this is the case, where can I disable the system timer in Xenomai, or modify the interrupt routine? I must run in interrupt context because of latency requirements (they asked me for deterministic latencies under 20 uS).
Yes, there is the I-pipe tracer:
http://www.xenomai.org/index.php/I-pipe:Tracer
Xenomai latency test has a -f option which triggers a trace for the worst case.
Signature · 1 line
Gilles.
Hello,
Quoted 9 lines · Antonio Del Cinque
Hi,
sorry, I needed time to implement your suggestions, but finally I got some results. I checked for cache related issues, and found that latency is highly related to cache misses.I found the way to disable the instruction cache (the e300 powerpc core has a 32 KB i-cache and a 32 KB d-cache, but I couldn't disable the d-cache because of segmentation faults), and I changed the test to measure interrupt latency.
What system are you exactly using. Your latency figures are already really good.
Quoted 9 lines
Now I have a Xenomai real time task. The task is periodic (I used
rt_task_set_periodic()andrt_task_wait_period()) and, at every period, it toggles a GPIO pin configured as an output, by calling the GPIO rtdm driver ioctl command. The pin is short circuited with another pin which is configured as an input, generating an interrupt in the powerpc. The interrupt routine, registerd viartdm_irq_request()in the same GPIO rtdm driver, toggles another GPIO pin configured as an output, so I see the two IO pins on the oscilloscope, the first generating the interrupt, and the second indicating that the interrupt routine has been executed.
I have done similar tests with gpioirqbench:
http://www.denx.de/wiki/DULG/AN2008_03_Xenomai_gpioirqbench
Quoted 4 lines
When the cache is enabled I see a latency between 2 and 5 uS with no load, but if I create a non real time load the latency raises (for example to 12 uS with the cache calibrator running), and this is non deterministic, since it dependes on the cache use.
Additionally try to run "while ls; do ls /bin; done" in a telnet session.
Quoted 7 lines
When I disable the i-cache the latency goes to 16 uS with no load, this is 11 to 14 uS over latency! Non real time task now only sligthly affect the latency, but I have the following problem: if I start real time tasks (for example I run
/usr/local/xenomai/share/xenomai/testsuite/cyclic/run) the GPIO interrupt latency is not commonly affected, but occasionally it gets to 50 uS. I can't explain this. Could you help me?
Running the systems with caches disabled does make little sense because it would make the system very very slow (apart from the fact that it's not easily possible with Linux).
Quoted 4 lines
The delay is not continuos, it jumps from 16-20 to 38-50 uS. Now the i-cache is disabled, so it seems another interrupt routine, running in Xenomai domain, gets interleaved with the GPIO interrupt rountine.
Quoted 9 lines
Is there any way to track these kind of latency in the ipipe, a kind of worst latency case tracker? I see only "virtual" IRQs 512 and 515 running in Xenomai domain. I cannot see where they are set up. I guess one of them is the system timer, and I know this is commonly driven by the powerpc decrementer. Is the GPIO interrupt latency due to the system timer interrupt? If this is the case, where can I disable the system timer in Xenomai, or modify the interrupt routine? I must run in interrupt context because of latency requirements (they asked me for deterministic latencies under 20 uS).
As I see it, the main latencies are caused by cache refills. If the latencies are not good enough, choose a faster system (more MHz, bigger L1 or L2 cache or faster memory) but 20 us is very challenging already for a PC. Moving your task to kernel space or even to the ISR gives better result, of course, as you can see from:
http://www.denx.de/wiki/DULG/AN2008_03_Xenomai_gpioirqbench
Wolfgang.