zephyr/arch/arm/core
Benjamin Walsh 88b3691415 kernel/arch: enhance the "ready thread" cache
The way the ready thread cache was implemented caused it to not always
be "hot", i.e. there could be some misses, which happened when the
cached thread was taken out of the ready queue. When that happened, it
was not replaced immediately, since doing so could mean that the
replacement might not run because the flow could be interrupted and
another thread could take its place. This was the more conservative
approach that insured that moving a thread to the cache would never be
wasted.

However, this caused two problems:

1. The cache could not be refilled until another thread context-switched
in, since there was no thread in the cache to compare priorities
against.

2. Interrupt exit code would always have to call into C to find what
thread to run when the current thread was not coop and did not have the
scheduler locked. Furthermore, it was possible for this code path to
encounter a cold cache and then it had to find out what thread to run
the long way.

To fix this, filling the cache is now more aggressive, i.e. the next
thread to put in the cache is found even in the case the current cached
thread is context-switched out. This ensures the interrupt exit code is
much faster on the slow path. In addition, since finding the next thread
to run is now always "get it from the cache", which is a simple fetch
from memory (_kernel.ready_q.cache), there is no need to call the more
complex C code.

On the ARM FRDM K64F board, this improvement is seen:

Before:

1- Measure time to switch from ISR back to interrupted task

   switching time is 215 tcs = 1791 nsec

2- Measure time from ISR to executing a different task (rescheduled)

   switch time is 315 tcs = 2625 nsec

After:

1- Measure time to switch from ISR back to interrupted task

   switching time is 130 tcs = 1083 nsec

2- Measure time from ISR to executing a different task (rescheduled)

   switch time is 225 tcs = 1875 nsec

These are the most dramatic improvements, but most of the numbers
generated by the latency_measure test are improved.

Fixes ZEP-1401.

Change-Id: I2eaac147048b1ec71a93bd0a285e743a39533973
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-12-15 15:50:02 -05:00
..
cortex_m arm: add CPU_CORTEX_M_HAS_PROGRAMMABLE_FAULT_PRIOS kconfig flag 2016-12-15 15:57:09 +00:00
offsets kernel/arm: fix race condition when setting _Swap() return value 2016-11-17 14:46:12 +00:00
Kconfig arm: systick: Some SoCs do not have systick 2016-11-27 19:39:26 +00:00
Makefile arm: remove support for legacy kernels 2016-11-04 22:56:18 +00:00
__aeabi_atexit.c build: Add C++ support 2016-02-05 20:25:23 -05:00
cpu_idle.S kernel/arch: consolidate tTCS and TNANO definitions 2016-11-12 07:04:52 -05:00
exc_exit.S kernel/arch: enhance the "ready thread" cache 2016-12-15 15:50:02 -05:00
fatal.c kernel/arch: consolidate tTCS and TNANO definitions 2016-11-12 07:04:52 -05:00
fault.c arm: Remove unused parameter warning 2016-12-03 14:49:09 +00:00
fault_s.S arch/arm: add initial support for Cortex-M0/M0+ 2016-10-22 01:25:53 +00:00
gdb_stub.S kernel/arch: consolidate tTCS and TNANO definitions 2016-11-12 07:04:52 -05:00
gdb_stub_irq_vector_table.c Fixed file description and applied doxygen style 2016-02-05 20:24:58 -05:00
irq_init.c Fixed file description and applied doxygen style 2016-02-05 20:24:58 -05:00
irq_manage.c arm: move IRQ_PRIORITY_OFFSET to header file, rename to _IRQ_PRIO_OFFSET 2016-12-15 15:57:08 +00:00
irq_offload.c arm: Fix irq offload inline asm memory ordering. 2016-12-11 11:19:02 +00:00
isr_wrapper.S kernel/arch: consolidate tTCS and TNANO definitions 2016-11-12 07:04:52 -05:00
swap.S kernel/arch: enhance the "ready thread" cache 2016-12-15 15:50:02 -05:00
sys_fatal_error_handler.c fatal error handlers: report which thread croaked 2016-11-17 14:36:50 +00:00
thread.c kernel: streamline initialization of _thread_base and timeouts 2016-11-23 00:27:42 +00:00
thread_abort.c kernel/arch: consolidate tTCS and TNANO definitions 2016-11-12 07:04:52 -05:00