kernel: event_logger: remove kernel_event_logger
Move to more generic tracing hooks that can be implemented in different ways and do not interfere with the kernel. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
457fc799ba
commit
a2248782a2
39 changed files with 75 additions and 1134 deletions
|
@ -35,9 +35,9 @@ SECTION_VAR(BSS, k_cpu_sleep_mode)
|
||||||
|
|
||||||
SECTION_FUNC(TEXT, k_cpu_idle)
|
SECTION_FUNC(TEXT, k_cpu_idle)
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
#ifdef CONFIG_TRACING
|
||||||
push_s blink
|
push_s blink
|
||||||
jl _sys_k_event_logger_enter_sleep
|
jl sys_trace_idle
|
||||||
pop_s blink
|
pop_s blink
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@ SECTION_FUNC(TEXT, k_cpu_idle)
|
||||||
*/
|
*/
|
||||||
SECTION_FUNC(TEXT, k_cpu_atomic_idle)
|
SECTION_FUNC(TEXT, k_cpu_atomic_idle)
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
#ifdef CONFIG_TRACING
|
||||||
push_s blink
|
push_s blink
|
||||||
jl _sys_k_event_logger_enter_sleep
|
jl sys_trace_idle
|
||||||
pop_s blink
|
pop_s blink
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -332,29 +332,14 @@ rirq_path:
|
||||||
j_s [r2]
|
j_s [r2]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
#if defined(CONFIG_TRACING)
|
||||||
GTEXT(_sys_k_event_logger_exit_sleep)
|
GTEXT(sys_trace_isr_enter)
|
||||||
|
|
||||||
.macro log_sleep_k_event
|
|
||||||
clri r0 /* do not interrupt event logger operations */
|
|
||||||
push_s r0
|
|
||||||
push_s blink
|
|
||||||
jl _sys_k_event_logger_exit_sleep
|
|
||||||
pop_s blink
|
|
||||||
pop_s r0
|
|
||||||
seti r0
|
|
||||||
.endm
|
|
||||||
#else
|
|
||||||
#define log_sleep_k_event
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT)
|
|
||||||
GTEXT(_sys_k_event_logger_interrupt)
|
|
||||||
|
|
||||||
.macro log_interrupt_k_event
|
.macro log_interrupt_k_event
|
||||||
clri r0 /* do not interrupt event logger operations */
|
clri r0 /* do not interrupt event logger operations */
|
||||||
push_s r0
|
push_s r0
|
||||||
push_s blink
|
push_s blink
|
||||||
jl _sys_k_event_logger_interrupt
|
jl sys_trace_isr_enter
|
||||||
pop_s blink
|
pop_s blink
|
||||||
pop_s r0
|
pop_s r0
|
||||||
seti r0
|
seti r0
|
||||||
|
@ -395,7 +380,6 @@ SECTION_FUNC(TEXT, _isr_demux)
|
||||||
/* r0 is available to be stomped here, and exit_tickless_idle uses it */
|
/* r0 is available to be stomped here, and exit_tickless_idle uses it */
|
||||||
exit_tickless_idle
|
exit_tickless_idle
|
||||||
log_interrupt_k_event
|
log_interrupt_k_event
|
||||||
log_sleep_k_event
|
|
||||||
|
|
||||||
lr r0, [_ARC_V2_ICAUSE]
|
lr r0, [_ARC_V2_ICAUSE]
|
||||||
/* handle software triggered interrupt */
|
/* handle software triggered interrupt */
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
* @brief Kernel event logger support for ARM
|
* @brief Kernel event logger support for ARM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__
|
#ifndef __KERNEL_TRACING_H__
|
||||||
#define __KERNEL_EVENT_LOGGER_ARCH_H__
|
#define __KERNEL_TRACING_H__
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -33,4 +33,4 @@ int _sys_current_irq_key_get(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */
|
#endif /* __KERNEL_TRACING_H__ */
|
|
@ -53,7 +53,7 @@ SECTION_FUNC(TEXT, __pendsv)
|
||||||
#else
|
#else
|
||||||
pop {lr}
|
pop {lr}
|
||||||
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
|
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH */
|
#endif /* CONFIG_TRACING */
|
||||||
|
|
||||||
/* protect the kernel state while we play with the thread lists */
|
/* protect the kernel state while we play with the thread lists */
|
||||||
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
|
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
* @brief Kernel event logger support for ARM
|
* @brief Kernel event logger support for ARM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__
|
#ifndef __KERNEL_TRACING_H__
|
||||||
#define __KERNEL_EVENT_LOGGER_ARCH_H__
|
#define __KERNEL_TRACING_H__
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -34,4 +34,4 @@ int _sys_current_irq_key_get(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */
|
#endif /* __KERNEL_TRACING_H__ */
|
|
@ -17,9 +17,9 @@
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <misc/printk.h>
|
#include <misc/printk.h>
|
||||||
#include <sw_isr_table.h>
|
#include <sw_isr_table.h>
|
||||||
#include <logging/kernel_event_logger.h>
|
|
||||||
#include <ksched.h>
|
#include <ksched.h>
|
||||||
#include <kswap.h>
|
#include <kswap.h>
|
||||||
|
#include <tracing.h>
|
||||||
|
|
||||||
void _irq_spurious(void *unused)
|
void _irq_spurious(void *unused)
|
||||||
{
|
{
|
||||||
|
@ -86,9 +86,7 @@ void _enter_irq(u32_t ipending)
|
||||||
while (ipending) {
|
while (ipending) {
|
||||||
struct _isr_table_entry *ite;
|
struct _isr_table_entry *ite;
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
sys_trace_isr_enter();
|
||||||
_sys_k_event_logger_interrupt();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
index = find_lsb_set(ipending) - 1;
|
index = find_lsb_set(ipending) - 1;
|
||||||
ipending &= ~(1 << index);
|
ipending &= ~(1 << index);
|
||||||
|
@ -100,6 +98,7 @@ void _enter_irq(u32_t ipending)
|
||||||
read_timer_end_of_isr();
|
read_timer_end_of_isr();
|
||||||
#endif
|
#endif
|
||||||
ite->isr(ite->arg);
|
ite->isr(ite->arg);
|
||||||
|
sys_trace_isr_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
_kernel.nested--;
|
_kernel.nested--;
|
||||||
|
|
|
@ -13,7 +13,7 @@ GTEXT(__swap)
|
||||||
GTEXT(_thread_entry_wrapper)
|
GTEXT(_thread_entry_wrapper)
|
||||||
|
|
||||||
/* imports */
|
/* imports */
|
||||||
GTEXT(_sys_k_event_logger_context_switch)
|
GTEXT(sys_trace_thread_switched_in)
|
||||||
GTEXT(_k_neg_eagain)
|
GTEXT(_k_neg_eagain)
|
||||||
|
|
||||||
/* unsigned int __swap(unsigned int key)
|
/* unsigned int __swap(unsigned int key)
|
||||||
|
@ -84,8 +84,8 @@ SECTION_FUNC(exception.other, __swap)
|
||||||
ldw r4, (r5)
|
ldw r4, (r5)
|
||||||
stw r4, _thread_offset_to_retval(r11)
|
stw r4, _thread_offset_to_retval(r11)
|
||||||
|
|
||||||
#if CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
#if CONFIG_TRACING
|
||||||
call _sys_k_event_logger_context_switch
|
call sys_trace_thread_switched_in
|
||||||
/* restore caller-saved r10 */
|
/* restore caller-saved r10 */
|
||||||
movhi r10, %hi(_kernel)
|
movhi r10, %hi(_kernel)
|
||||||
ori r10, r10, %lo(_kernel)
|
ori r10, r10, %lo(_kernel)
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
* @brief Kernel event logger support for Nios II
|
* @brief Kernel event logger support for Nios II
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__
|
#ifndef __KERNEL_TRACING_H__
|
||||||
#define __KERNEL_EVENT_LOGGER_ARCH_H__
|
#define __KERNEL_TRACING_H__
|
||||||
|
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
|
|
||||||
|
@ -38,4 +38,4 @@ static inline int _sys_current_irq_key_get(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */
|
#endif /* __KERNEL_TRACING_H__ */
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "posix_core.h"
|
#include "posix_core.h"
|
||||||
#include "posix_soc_if.h"
|
#include "posix_soc_if.h"
|
||||||
#include "logging/kernel_event_logger.h"
|
#include <tracing.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
*/
|
*/
|
||||||
void k_cpu_idle(void)
|
void k_cpu_idle(void)
|
||||||
{
|
{
|
||||||
_sys_k_event_logger_enter_sleep();
|
sys_trace_idle();
|
||||||
posix_irq_full_unlock();
|
posix_irq_full_unlock();
|
||||||
posix_halt_cpu();
|
posix_halt_cpu();
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,6 @@ void k_cpu_idle(void)
|
||||||
|
|
||||||
void k_cpu_atomic_idle(unsigned int imask)
|
void k_cpu_atomic_idle(unsigned int imask)
|
||||||
{
|
{
|
||||||
_sys_k_event_logger_enter_sleep();
|
sys_trace_idle();
|
||||||
posix_atomic_halt_cpu(imask);
|
posix_atomic_halt_cpu(imask);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,9 +50,7 @@ unsigned int __swap(unsigned int key)
|
||||||
_kernel.current->callee_saved.retval = -EAGAIN;
|
_kernel.current->callee_saved.retval = -EAGAIN;
|
||||||
/* retval may be modified with a call to _set_thread_return_value() */
|
/* retval may be modified with a call to _set_thread_return_value() */
|
||||||
|
|
||||||
#if CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
sys_trace_thread_switched_in();
|
||||||
_sys_k_event_logger_context_switch();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
posix_thread_status_t *ready_thread_ptr =
|
posix_thread_status_t *ready_thread_ptr =
|
||||||
(posix_thread_status_t *)
|
(posix_thread_status_t *)
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
* @brief Kernel event logger support for ARM
|
* @brief Kernel event logger support for ARM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__
|
#ifndef __KERNEL_TRACING_H__
|
||||||
#define __KERNEL_EVENT_LOGGER_ARCH_H__
|
#define __KERNEL_TRACING_H__
|
||||||
|
|
||||||
#include "posix_soc_if.h"
|
#include "posix_soc_if.h"
|
||||||
|
|
||||||
|
@ -36,4 +36,4 @@ static inline int _sys_current_irq_key_get(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */
|
#endif /* __KERNEL_TRACING_H__ */
|
|
@ -21,16 +21,9 @@ GTEXT(_k_neg_eagain)
|
||||||
GTEXT(_is_next_thread_current)
|
GTEXT(_is_next_thread_current)
|
||||||
GTEXT(_get_next_ready_thread)
|
GTEXT(_get_next_ready_thread)
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
#ifdef CONFIG_TRACING
|
||||||
GTEXT(_sys_k_event_logger_context_switch)
|
GTEXT(sys_trace_thread_switched_in)
|
||||||
#endif
|
GTEXT(sys_trace_isr_enter)
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
|
||||||
GTEXT(_sys_k_event_logger_exit_sleep)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
|
||||||
GTEXT(_sys_k_event_logger_interrupt)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_IRQ_OFFLOAD
|
#ifdef CONFIG_IRQ_OFFLOAD
|
||||||
|
@ -231,12 +224,8 @@ on_irq_stack:
|
||||||
tail _irq_do_offload
|
tail _irq_do_offload
|
||||||
|
|
||||||
call_irq:
|
call_irq:
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
#ifdef CONFIG_TRACING
|
||||||
call _sys_k_event_logger_exit_sleep
|
call sys_trace_isr_enter
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
|
||||||
call _sys_k_event_logger_interrupt
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Get IRQ causing interrupt */
|
/* Get IRQ causing interrupt */
|
||||||
|
@ -310,9 +299,9 @@ reschedule:
|
||||||
#if CONFIG_TIMESLICING
|
#if CONFIG_TIMESLICING
|
||||||
call _update_time_slice_before_swap
|
call _update_time_slice_before_swap
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
#if CONFIG_TRACING
|
||||||
call _sys_k_event_logger_context_switch
|
call sys_trace_thread_switched_in
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH */
|
#endif
|
||||||
/* Get reference to _kernel */
|
/* Get reference to _kernel */
|
||||||
la t0, _kernel
|
la t0, _kernel
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
* @brief Kernel event logger support for RISCV32
|
* @brief Kernel event logger support for RISCV32
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__
|
#ifndef __KERNEL_TRACING_H__
|
||||||
#define __KERNEL_EVENT_LOGGER_ARCH_H__
|
#define __KERNEL_TRACING_H__
|
||||||
|
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
|
|
||||||
|
@ -41,4 +41,4 @@ static inline int _sys_current_irq_key_get(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */
|
#endif /* __KERNEL_TRACING_H__ */
|
|
@ -8,13 +8,12 @@
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
|
||||||
#include <logging/kernel_event_logger.h>
|
#include <tracing.h>
|
||||||
|
|
||||||
static ALWAYS_INLINE void pulpino_idle(unsigned int key)
|
static ALWAYS_INLINE void pulpino_idle(unsigned int key)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
sys_trace_idle();
|
||||||
_sys_k_event_logger_enter_sleep();
|
|
||||||
#endif
|
|
||||||
/* unlock interrupts */
|
/* unlock interrupts */
|
||||||
irq_unlock(key);
|
irq_unlock(key);
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,11 @@
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
|
||||||
#include <logging/kernel_event_logger.h>
|
#include <tracing.h>
|
||||||
|
|
||||||
static ALWAYS_INLINE void riscv_idle(unsigned int key)
|
static ALWAYS_INLINE void riscv_idle(unsigned int key)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
sys_trace_idle();
|
||||||
_sys_k_event_logger_enter_sleep();
|
|
||||||
#endif
|
|
||||||
/* unlock interrupts */
|
/* unlock interrupts */
|
||||||
irq_unlock(key);
|
irq_unlock(key);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <zephyr.h>
|
#include <zephyr.h>
|
||||||
#include <logging/kernel_event_logger.h>
|
#include <tracing.h>
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
|
|
||||||
#ifdef CONFIG_BOOT_TIME_MEASUREMENT
|
#ifdef CONFIG_BOOT_TIME_MEASUREMENT
|
||||||
|
@ -45,7 +45,7 @@ extern u64_t __idle_time_stamp; /* timestamp when CPU went idle */
|
||||||
void k_cpu_idle(void)
|
void k_cpu_idle(void)
|
||||||
{
|
{
|
||||||
_int_latency_stop();
|
_int_latency_stop();
|
||||||
_sys_k_event_logger_enter_sleep();
|
sys_trace_idle();
|
||||||
#if defined(CONFIG_BOOT_TIME_MEASUREMENT)
|
#if defined(CONFIG_BOOT_TIME_MEASUREMENT)
|
||||||
__idle_time_stamp = (u64_t)k_cycle_get_32();
|
__idle_time_stamp = (u64_t)k_cycle_get_32();
|
||||||
#endif
|
#endif
|
||||||
|
@ -76,7 +76,7 @@ void k_cpu_idle(void)
|
||||||
void k_cpu_atomic_idle(unsigned int imask)
|
void k_cpu_atomic_idle(unsigned int imask)
|
||||||
{
|
{
|
||||||
_int_latency_stop();
|
_int_latency_stop();
|
||||||
_sys_k_event_logger_enter_sleep();
|
sys_trace_idle();
|
||||||
|
|
||||||
__asm__ volatile (
|
__asm__ volatile (
|
||||||
"sti\n\t"
|
"sti\n\t"
|
||||||
|
|
|
@ -135,8 +135,7 @@ SECTION_FUNC(TEXT, _interrupt_enter)
|
||||||
|
|
||||||
|
|
||||||
#if defined(CONFIG_INT_LATENCY_BENCHMARK) || \
|
#if defined(CONFIG_INT_LATENCY_BENCHMARK) || \
|
||||||
defined(CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT) || \
|
defined(CONFIG_TRACING)
|
||||||
defined(CONFIG_KERNEL_EVENT_LOGGER_SLEEP)
|
|
||||||
|
|
||||||
/* Save these as we are using to keep track of isr and isr_param */
|
/* Save these as we are using to keep track of isr and isr_param */
|
||||||
pushl %eax
|
pushl %eax
|
||||||
|
@ -153,13 +152,7 @@ SECTION_FUNC(TEXT, _interrupt_enter)
|
||||||
call _int_latency_start
|
call _int_latency_start
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
call sys_trace_isr_enter
|
||||||
call _sys_k_event_logger_interrupt
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
|
||||||
call _sys_k_event_logger_exit_sleep
|
|
||||||
#endif
|
|
||||||
|
|
||||||
popl %edx
|
popl %edx
|
||||||
popl %eax
|
popl %eax
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <misc/__assert.h>
|
#include <misc/__assert.h>
|
||||||
#include <misc/printk.h>
|
#include <misc/printk.h>
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <logging/kernel_event_logger.h>
|
#include <tracing.h>
|
||||||
#include <kswap.h>
|
#include <kswap.h>
|
||||||
|
|
||||||
extern void _SpuriousIntHandler(void *);
|
extern void _SpuriousIntHandler(void *);
|
||||||
|
@ -43,7 +43,6 @@ void *__attribute__((section(".spurNoErrIsr")))
|
||||||
* arch/cpu.h and kernel_structs.h; the inline functions typically need to
|
* arch/cpu.h and kernel_structs.h; the inline functions typically need to
|
||||||
* perform operations on _kernel. For now, leave as regular functions, a
|
* perform operations on _kernel. For now, leave as regular functions, a
|
||||||
* future iteration will resolve this.
|
* future iteration will resolve this.
|
||||||
* We have a similar issue with the k_event_logger functions.
|
|
||||||
*
|
*
|
||||||
* See https://github.com/zephyrproject-rtos/zephyr/issues/3056
|
* See https://github.com/zephyrproject-rtos/zephyr/issues/3056
|
||||||
*/
|
*/
|
||||||
|
@ -64,8 +63,6 @@ void _arch_isr_direct_header(void)
|
||||||
{
|
{
|
||||||
_int_latency_start();
|
_int_latency_start();
|
||||||
sys_trace_isr_enter();
|
sys_trace_isr_enter();
|
||||||
_sys_k_event_logger_interrupt();
|
|
||||||
_sys_k_event_logger_exit_sleep();
|
|
||||||
|
|
||||||
/* We're not going to unlock IRQs, but we still need to increment this
|
/* We're not going to unlock IRQs, but we still need to increment this
|
||||||
* so that _is_in_isr() works
|
* so that _is_in_isr() works
|
||||||
|
|
|
@ -141,10 +141,10 @@ SECTION_FUNC(TEXT, __swap)
|
||||||
movl _kernel_offset_to_current(%edi), %edx
|
movl _kernel_offset_to_current(%edi), %edx
|
||||||
movl %esp, _thread_offset_to_esp(%edx)
|
movl %esp, _thread_offset_to_esp(%edx)
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
#ifdef CONFIG_TRACING
|
||||||
/* Register the context switch */
|
/* Register the context switch */
|
||||||
push %edx
|
push %edx
|
||||||
call _sys_k_event_logger_context_switch
|
call sys_trace_thread_switched_in
|
||||||
pop %edx
|
pop %edx
|
||||||
#endif
|
#endif
|
||||||
movl _kernel_offset_to_ready_q_cache(%edi), %eax
|
movl _kernel_offset_to_ready_q_cache(%edi), %eax
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
* @brief Kernel event logger support for x86
|
* @brief Kernel event logger support for x86
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__
|
#ifndef __KERNEL_TRACING_H__
|
||||||
#define __KERNEL_EVENT_LOGGER_ARCH_H__
|
#define __KERNEL_TRACING_H__
|
||||||
|
|
||||||
#include <arch/x86/irq_controller.h>
|
#include <arch/x86/irq_controller.h>
|
||||||
|
|
||||||
|
@ -35,4 +35,4 @@ static inline int _sys_current_irq_key_get(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */
|
#endif /* __KERNEL_TRACING_H__ */
|
|
@ -3,7 +3,9 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <logging/kernel_event_logger.h>
|
#include <xtensa/tie/xt_core.h>
|
||||||
|
#include <xtensa/tie/xt_interrupt.h>
|
||||||
|
#include <tracing.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Put the CPU in low-power mode
|
* @brief Put the CPU in low-power mode
|
||||||
|
@ -14,9 +16,7 @@
|
||||||
*/
|
*/
|
||||||
void k_cpu_idle(void)
|
void k_cpu_idle(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
sys_trace_idle();
|
||||||
_sys_k_event_logger_enter_sleep();
|
|
||||||
#endif
|
|
||||||
__asm__ volatile ("waiti 0");
|
__asm__ volatile ("waiti 0");
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -28,9 +28,7 @@ void k_cpu_idle(void)
|
||||||
*/
|
*/
|
||||||
void k_cpu_atomic_idle(unsigned int key)
|
void k_cpu_atomic_idle(unsigned int key)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
sys_trace_idle();
|
||||||
_sys_k_event_logger_enter_sleep();
|
|
||||||
#endif
|
|
||||||
__asm__ volatile ("waiti 0\n\t"
|
__asm__ volatile ("waiti 0\n\t"
|
||||||
"wsr.ps %0\n\t"
|
"wsr.ps %0\n\t"
|
||||||
"rsync" :: "a"(key));
|
"rsync" :: "a"(key));
|
||||||
|
|
|
@ -75,12 +75,12 @@ __swap:
|
||||||
s16i a3, a4, THREAD_OFFSET(cpEnable) /* clear saved cpenable */
|
s16i a3, a4, THREAD_OFFSET(cpEnable) /* clear saved cpenable */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
#ifdef CONFIG_TRACING
|
||||||
/* Register the context switch */
|
/* Register the context switch */
|
||||||
#ifdef __XTENSA_CALL0_ABI__
|
#ifdef __XTENSA_CALL0_ABI__
|
||||||
call0 _sys_k_event_logger_context_switch
|
call0 sys_trace_thread_switched_in
|
||||||
#else
|
#else
|
||||||
call4 _sys_k_event_logger_context_switch
|
call4 sys_trace_thread_switched_in
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/* _thread := _kernel.ready_q.cache */
|
/* _thread := _kernel.ready_q.cache */
|
||||||
|
|
|
@ -166,28 +166,18 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
#ifdef CONFIG_TRACING
|
||||||
/*
|
/*
|
||||||
* Register the interrupt.
|
* Register the interrupt.
|
||||||
* We just saved all registers.
|
* We just saved all registers.
|
||||||
*/
|
*/
|
||||||
#ifdef __XTENSA_CALL0_ABI__
|
#ifdef __XTENSA_CALL0_ABI__
|
||||||
call0 _sys_k_event_logger_interrupt
|
call0 sys_trace_isr_enter
|
||||||
#else
|
#else
|
||||||
call4 _sys_k_event_logger_interrupt
|
call4 sys_trace_isr_enter
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
|
||||||
/*
|
|
||||||
* Register the sleep enter.
|
|
||||||
* We just saved all registers.
|
|
||||||
*/
|
|
||||||
#ifdef __XTENSA_CALL0_ABI__
|
|
||||||
call0 _sys_k_event_logger_exit_sleep
|
|
||||||
#else
|
|
||||||
call4 _sys_k_event_logger_exit_sleep
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef XT_INTEXC_HOOKS
|
#ifdef XT_INTEXC_HOOKS
|
||||||
/* Call interrupt hook if present to (pre)handle interrupts. */
|
/* Call interrupt hook if present to (pre)handle interrupts. */
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
* @brief Kernel event logger support for Xtensa
|
* @brief Kernel event logger support for Xtensa
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__
|
#ifndef __KERNEL_TRACING_H__
|
||||||
#define __KERNEL_EVENT_LOGGER_ARCH_H__
|
#define __KERNEL_TRACING_H__
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -33,4 +33,4 @@ static inline int _sys_current_irq_key_get(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */
|
#endif /* __KERNEL_TRACING_H__ */
|
|
@ -18,7 +18,7 @@
|
||||||
#include "board_soc.h"
|
#include "board_soc.h"
|
||||||
#include "sw_isr_table.h"
|
#include "sw_isr_table.h"
|
||||||
#include "soc.h"
|
#include "soc.h"
|
||||||
#include "logging/kernel_event_logger.h"
|
#include <tracing.h>
|
||||||
|
|
||||||
typedef void (*normal_irq_f_ptr)(void *);
|
typedef void (*normal_irq_f_ptr)(void *);
|
||||||
typedef int (*direct_irq_f_ptr)(void);
|
typedef int (*direct_irq_f_ptr)(void);
|
||||||
|
@ -35,7 +35,8 @@ static inline void vector_to_irq(int irq_nbr, int *may_swap)
|
||||||
* it is a bit senseless to call _int_latency_start/stop()
|
* it is a bit senseless to call _int_latency_start/stop()
|
||||||
*/
|
*/
|
||||||
/* _int_latency_start(); */
|
/* _int_latency_start(); */
|
||||||
_sys_k_event_logger_interrupt();
|
|
||||||
|
sys_trace_isr_enter();
|
||||||
|
|
||||||
if (irq_vector_table[irq_nbr].func == NULL) { /* LCOV_EXCL_BR_LINE */
|
if (irq_vector_table[irq_nbr].func == NULL) { /* LCOV_EXCL_BR_LINE */
|
||||||
/* LCOV_EXCL_START */
|
/* LCOV_EXCL_START */
|
||||||
|
@ -86,8 +87,6 @@ void posix_irq_handler(void)
|
||||||
|
|
||||||
_kernel.nested++;
|
_kernel.nested++;
|
||||||
|
|
||||||
_sys_k_event_logger_exit_sleep();
|
|
||||||
|
|
||||||
while ((irq_nbr = hw_irq_ctrl_get_highest_prio_irq()) != -1) {
|
while ((irq_nbr = hw_irq_ctrl_get_highest_prio_irq()) != -1) {
|
||||||
int last_current_running_prio = hw_irq_ctrl_get_cur_prio();
|
int last_current_running_prio = hw_irq_ctrl_get_cur_prio();
|
||||||
int last_running_irq = currently_running_irq;
|
int last_running_irq = currently_running_irq;
|
||||||
|
|
|
@ -5,5 +5,4 @@ Logging
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
|
||||||
system_log
|
system_log
|
||||||
kernel_event_logger
|
|
||||||
logger
|
logger
|
||||||
|
|
|
@ -1,272 +0,0 @@
|
||||||
.. _kernel_event_logger_v2:
|
|
||||||
|
|
||||||
Kernel Event Logger
|
|
||||||
###################
|
|
||||||
|
|
||||||
The kernel event logger records the occurrence of certain types of kernel
|
|
||||||
events, allowing them to be subsequently extracted and reviewed.
|
|
||||||
This capability can be helpful in profiling the operation of an application,
|
|
||||||
either for debugging purposes or for optimizing the performance the application.
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:local:
|
|
||||||
:depth: 2
|
|
||||||
|
|
||||||
Concepts
|
|
||||||
********
|
|
||||||
|
|
||||||
The kernel event logger does not exist unless it is configured for an
|
|
||||||
application. The capacity of the kernel event logger is also configurable.
|
|
||||||
By default, it has a ring buffer that can hold up to 128 32-bit words
|
|
||||||
of event information.
|
|
||||||
|
|
||||||
The kernel event logger is capable of recording the following predefined
|
|
||||||
event types:
|
|
||||||
|
|
||||||
* Interrupts.
|
|
||||||
* Context switching of threads.
|
|
||||||
* Kernel sleep events (i.e. entering and exiting a low power state).
|
|
||||||
|
|
||||||
The kernel event logger only records the predefined event types it has been
|
|
||||||
configured to record. Each event type can be enabled independently.
|
|
||||||
|
|
||||||
An application can also define and record custom event types.
|
|
||||||
The information recorded for a custom event, and the times
|
|
||||||
at which it is recorded, must be implemented by the application.
|
|
||||||
|
|
||||||
All events recorded by the kernel event logger remain in its ring buffer
|
|
||||||
until they are retrieved by the application for review and analysis. The
|
|
||||||
retrieval and analysis logic must be implemented by the application.
|
|
||||||
|
|
||||||
.. important::
|
|
||||||
An application must retrieve the events recorded by the kernel event logger
|
|
||||||
in a timely manner, otherwise new events will be dropped once the event
|
|
||||||
logger's ring buffer becomes full. A recommended approach is to use
|
|
||||||
a cooperative thread to retrieve the events, either on a periodic basis
|
|
||||||
or as its sole responsibility.
|
|
||||||
|
|
||||||
By default, the kernel event logger records all occurrences of all event types
|
|
||||||
that have been enabled. However, it can also be configured to allow an
|
|
||||||
application to dynamically start or stop the recording of events at any time,
|
|
||||||
and to control which event types are being recorded. This permits
|
|
||||||
the application to capture only the events that occur during times
|
|
||||||
of particular interest, thereby reducing the work needed to analyze them.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
The kernel event logger can also be instructed to ignore context switches
|
|
||||||
involving a single specified thread. This can be used to avoid recording
|
|
||||||
context switch events involving the thread that retrieves the events
|
|
||||||
from the kernel event logger.
|
|
||||||
|
|
||||||
Event Formats
|
|
||||||
=============
|
|
||||||
|
|
||||||
Each event recorded by the kernel event logger consists of one or more
|
|
||||||
32-bit words of data that describe the event.
|
|
||||||
|
|
||||||
An **interrupt event** has the following format:
|
|
||||||
|
|
||||||
.. code-block:: c
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u32_t timestamp; /* time of interrupt */
|
|
||||||
u32_t interrupt_id; /* ID of interrupt */
|
|
||||||
};
|
|
||||||
|
|
||||||
A **context-switch event** has the following format:
|
|
||||||
|
|
||||||
.. code-block:: c
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u32_t timestamp; /* time of context switch */
|
|
||||||
u32_t context_id; /* ID of thread that was switched out */
|
|
||||||
};
|
|
||||||
|
|
||||||
A **sleep event** has the following format:
|
|
||||||
|
|
||||||
.. code-block:: c
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u32_t sleep_timestamp; /* time when CPU entered sleep mode */
|
|
||||||
u32_t wake_timestamp; /* time when CPU exited sleep mode */
|
|
||||||
u32_t interrupt_id; /* ID of interrupt that woke CPU */
|
|
||||||
};
|
|
||||||
|
|
||||||
A **custom event** must have a type ID that does not conflict with
|
|
||||||
any existing predefined event type ID. The format of a custom event
|
|
||||||
is application-defined, but must contain at least one 32-bit data word.
|
|
||||||
A custom event may utilize a variable size, to allow different events
|
|
||||||
of a single type to record differing amounts of information.
|
|
||||||
|
|
||||||
Timestamps
|
|
||||||
==========
|
|
||||||
|
|
||||||
By default, the timestamp recorded with each predefined event is obtained from
|
|
||||||
the kernel's :ref:`hardware clock <clocks_v2>`. This 32-bit clock counts up
|
|
||||||
extremely rapidly, which means the timestamp value wraps around frequently.
|
|
||||||
(For example, the Lakemont APIC timer for Quark SE wraps every 134 seconds.)
|
|
||||||
This wraparound must be accounted for when analyzing kernel event logger data.
|
|
||||||
In addition, care must be taken when tickless idle is enabled, in case a sleep
|
|
||||||
duration exceeds 2^32 clock cycles.
|
|
||||||
|
|
||||||
If desired, the kernel event logger can be configured to record
|
|
||||||
a custom timestamp, rather than the default timestamp.
|
|
||||||
The application registers the callback function that generates the custom 32-bit
|
|
||||||
timestamp at run-time by calling :cpp:func:`sys_k_event_logger_set_timer()`.
|
|
||||||
|
|
||||||
Implementation
|
|
||||||
**************
|
|
||||||
|
|
||||||
Retrieving An Event
|
|
||||||
===================
|
|
||||||
|
|
||||||
An event can be retrieved from the kernel event logger in a blocking or
|
|
||||||
non-blocking manner using the following APIs:
|
|
||||||
|
|
||||||
* :cpp:func:`sys_k_event_logger_get()`
|
|
||||||
* :cpp:func:`sys_k_event_logger_get_wait()`
|
|
||||||
* :cpp:func:`sys_k_event_logger_get_wait_timeout()`
|
|
||||||
|
|
||||||
In each case, the API also returns the type and size of the event, as well
|
|
||||||
as the event information itself. The API also indicates how many events
|
|
||||||
were dropped between the occurrence of the previous event and the retrieved
|
|
||||||
event.
|
|
||||||
|
|
||||||
The following code illustrates how a thread can retrieve the events
|
|
||||||
recorded by the kernel event logger.
|
|
||||||
|
|
||||||
.. code-block:: c
|
|
||||||
|
|
||||||
u16_t event_id;
|
|
||||||
u8_t dropped_count;
|
|
||||||
u32_t data[3];
|
|
||||||
u8_t data_size;
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
/* retrieve an event */
|
|
||||||
data_size = SIZE32_OF(data);
|
|
||||||
res = sys_k_event_logger_get_wait(&event_id, &dropped_count, data,
|
|
||||||
&data_size);
|
|
||||||
|
|
||||||
if (dropped_count > 0) {
|
|
||||||
/* ... Process the dropped events count ... */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res > 0) {
|
|
||||||
/* process the event */
|
|
||||||
switch (event_id) {
|
|
||||||
case KERNEL_EVENT_LOGGER_CONTEXT_SWITCH_EVENT_ID:
|
|
||||||
/* ... Process the context switch event ... */
|
|
||||||
break;
|
|
||||||
case KERNEL_EVENT_LOGGER_INTERRUPT_EVENT_ID:
|
|
||||||
/* ... Process the interrupt event ... */
|
|
||||||
break;
|
|
||||||
case KERNEL_EVENT_LOGGER_SLEEP_EVENT_ID:
|
|
||||||
/* ... Process the sleep event ... */
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("unrecognized event id %d\n", event_id);
|
|
||||||
}
|
|
||||||
} else if (res == -EMSGSIZE) {
|
|
||||||
/* ... Data array is too small to hold the event! ... */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Adding a Custom Event Type
|
|
||||||
==========================
|
|
||||||
|
|
||||||
A custom event type must use an integer type ID that does not duplicate
|
|
||||||
an existing type ID. The type IDs for the predefined events can be found
|
|
||||||
in :file:`include/logging/kernel_event_logger.h`. If dynamic recording of
|
|
||||||
events is enabled, the event type ID must not exceed 32.
|
|
||||||
|
|
||||||
Custom events can be written to the kernel event logger using the following
|
|
||||||
APIs:
|
|
||||||
|
|
||||||
* :cpp:func:`sys_k_event_logger_put()`
|
|
||||||
* :cpp:func:`sys_k_event_logger_put_timed()`
|
|
||||||
|
|
||||||
Both of these APIs record an event as long as there is room in the kernel
|
|
||||||
event logger's ring buffer. To enable dynamic recording of a custom event type,
|
|
||||||
the application must first call :cpp:func:`sys_k_must_log_event()` to determine
|
|
||||||
if event recording is currently active for that event type.
|
|
||||||
|
|
||||||
The following code illustrates how an application can write a custom
|
|
||||||
event consisting of two 32-bit words to the kernel event logger.
|
|
||||||
|
|
||||||
.. code-block:: c
|
|
||||||
|
|
||||||
#define MY_CUSTOM_EVENT_ID 8
|
|
||||||
|
|
||||||
/* record custom event only if recording is currently wanted */
|
|
||||||
if (sys_k_must_log_event(MY_CUSTOM_EVENT_ID)) {
|
|
||||||
u32_t data[2];
|
|
||||||
|
|
||||||
data[0] = custom_data_1;
|
|
||||||
data[1] = custom_data_2;
|
|
||||||
|
|
||||||
sys_k_event_logger_put(MY_CUSTOM_EVENT_ID, data, ARRAY_SIZE(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
The following code illustrates how an application can write a custom event
|
|
||||||
that records just a timestamp using a single 32-bit word.
|
|
||||||
|
|
||||||
.. code-block:: c
|
|
||||||
|
|
||||||
#define MY_CUSTOM_TIME_ONLY_EVENT_ID 9
|
|
||||||
|
|
||||||
if (sys_k_must_log_event(MY_CUSTOM_TIME_ONLY_EVENT_ID)) {
|
|
||||||
sys_k_event_logger_put_timed(MY_CUSTOM_TIME_ONLY_EVENT_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
Configuration Options
|
|
||||||
*********************
|
|
||||||
|
|
||||||
Related configuration options:
|
|
||||||
|
|
||||||
* :option:`CONFIG_KERNEL_EVENT_LOGGER`
|
|
||||||
* :option:`CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH`
|
|
||||||
* :option:`CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT`
|
|
||||||
* :option:`CONFIG_KERNEL_EVENT_LOGGER_SLEEP`
|
|
||||||
* :option:`CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE`
|
|
||||||
* :option:`CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC`
|
|
||||||
* :option:`CONFIG_KERNEL_EVENT_LOGGER_CUSTOM_TIMESTAMP`
|
|
||||||
|
|
||||||
Related Functions
|
|
||||||
*******************
|
|
||||||
|
|
||||||
The following kernel event logger APIs are provided by
|
|
||||||
:file:`kernel_event_logger.h`:
|
|
||||||
|
|
||||||
* :cpp:func:`sys_k_event_logger_register_as_collector()`
|
|
||||||
* :cpp:func:`sys_k_event_logger_get()`
|
|
||||||
* :cpp:func:`sys_k_event_logger_get_wait()`
|
|
||||||
* :cpp:func:`sys_k_event_logger_get_wait_timeout()`
|
|
||||||
* :cpp:func:`sys_k_must_log_event()`
|
|
||||||
* :cpp:func:`sys_k_event_logger_put()`
|
|
||||||
* :cpp:func:`sys_k_event_logger_put_timed()`
|
|
||||||
* :cpp:func:`sys_k_event_logger_get_mask()`
|
|
||||||
* :cpp:func:`sys_k_event_logger_set_mask()`
|
|
||||||
* :cpp:func:`sys_k_event_logger_set_timer()`
|
|
||||||
|
|
||||||
APIs
|
|
||||||
****
|
|
||||||
|
|
||||||
Event Logger
|
|
||||||
============
|
|
||||||
|
|
||||||
An event logger is an object that can record the occurrence of significant
|
|
||||||
events, which can be subsequently extracted and reviewed.
|
|
||||||
|
|
||||||
.. doxygengroup:: event_logger
|
|
||||||
:project: Zephyr
|
|
||||||
|
|
||||||
Kernel Event Logger
|
|
||||||
===================
|
|
||||||
|
|
||||||
The kernel event logger records the occurrence of significant kernel events,
|
|
||||||
which can be subsequently extracted and reviewed.
|
|
||||||
(See :ref:`kernel_event_logger_v2`.)
|
|
||||||
|
|
||||||
.. doxygengroup:: kernel_event_logger
|
|
||||||
:project: Zephyr
|
|
|
@ -1969,9 +1969,6 @@ INCLUDE_FILE_PATTERNS =
|
||||||
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
||||||
|
|
||||||
PREDEFINED = "CONFIG_SYS_CLOCK_EXISTS=y" \
|
PREDEFINED = "CONFIG_SYS_CLOCK_EXISTS=y" \
|
||||||
"CONFIG_KERNEL_EVENT_LOGGER=y" \
|
|
||||||
"CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC=y" \
|
|
||||||
"CONFIG_KERNEL_EVENT_LOGGER_CUSTOM_TIMESTAMP=y" \
|
|
||||||
"CONFIG_THREAD_MONITOR=y" \
|
"CONFIG_THREAD_MONITOR=y" \
|
||||||
"CONFIG_THREAD_CUSTOM_DATA=y" \
|
"CONFIG_THREAD_CUSTOM_DATA=y" \
|
||||||
"CONFIG_ERRNO=y" \
|
"CONFIG_ERRNO=y" \
|
||||||
|
|
|
@ -220,10 +220,6 @@ void _timer_int_handler(void *unused)
|
||||||
read_timer_start_of_tick_handler();
|
read_timer_start_of_tick_handler();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
|
||||||
extern void _sys_k_event_logger_interrupt(void);
|
|
||||||
_sys_k_event_logger_interrupt();
|
|
||||||
#endif
|
|
||||||
sys_trace_isr_enter();
|
sys_trace_isr_enter();
|
||||||
|
|
||||||
#ifdef CONFIG_SYS_POWER_MANAGEMENT
|
#ifdef CONFIG_SYS_POWER_MANAGEMENT
|
||||||
|
|
|
@ -505,10 +505,8 @@ void _timer_int_handler(void *params)
|
||||||
SET_TIMER_FIRE_TIME(GET_TIMER_CURRENT_TIME() + _xt_tick_divisor);
|
SET_TIMER_FIRE_TIME(GET_TIMER_CURRENT_TIME() + _xt_tick_divisor);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
|
||||||
extern void _sys_k_event_logger_interrupt(void);
|
extern void _sys_k_event_logger_interrupt(void);
|
||||||
_sys_k_event_logger_interrupt();
|
sys_trace_isr_enter();
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
/* The timer infractructure isn't prepared to handle
|
/* The timer infractructure isn't prepared to handle
|
||||||
|
|
|
@ -1,339 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2015 Intel Corporation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* @brief Kernel event logger support.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <logging/event_logger.h>
|
|
||||||
|
|
||||||
#ifndef __KERNEL_EVENT_LOGGER_H__
|
|
||||||
#define __KERNEL_EVENT_LOGGER_H__
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* predefined event types */
|
|
||||||
|
|
||||||
#define KERNEL_EVENT_LOGGER_CONTEXT_SWITCH_EVENT_ID BIT(0)
|
|
||||||
#define KERNEL_EVENT_LOGGER_INTERRUPT_EVENT_ID BIT(1)
|
|
||||||
#define KERNEL_EVENT_LOGGER_SLEEP_EVENT_ID BIT(2)
|
|
||||||
#define KERNEL_EVENT_LOGGER_THREAD_EVENT_ID BIT(3)
|
|
||||||
|
|
||||||
#ifndef _ASMLANGUAGE
|
|
||||||
|
|
||||||
extern struct event_logger sys_k_event_logger;
|
|
||||||
extern int _sys_k_event_logger_mask;
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
|
||||||
extern void _sys_k_event_logger_enter_sleep(void);
|
|
||||||
extern void _sys_k_event_logger_exit_sleep(void);
|
|
||||||
#else
|
|
||||||
static inline void _sys_k_event_logger_enter_sleep(void) {}
|
|
||||||
static inline void _sys_k_event_logger_exit_sleep(void) {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
|
||||||
extern void _sys_k_event_logger_interrupt(void);
|
|
||||||
#else
|
|
||||||
static inline void _sys_k_event_logger_interrupt(void) {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_THREAD
|
|
||||||
#include <kernel.h>
|
|
||||||
|
|
||||||
enum sys_k_event_logger_thread_event {
|
|
||||||
KERNEL_LOG_THREAD_EVENT_READYQ,
|
|
||||||
KERNEL_LOG_THREAD_EVENT_PEND,
|
|
||||||
KERNEL_LOG_THREAD_EVENT_EXIT,
|
|
||||||
};
|
|
||||||
|
|
||||||
extern void _sys_k_event_logger_thread_ready(struct k_thread *thread);
|
|
||||||
extern void _sys_k_event_logger_thread_pend(struct k_thread *thread);
|
|
||||||
extern void _sys_k_event_logger_thread_exit(struct k_thread *thread);
|
|
||||||
#else
|
|
||||||
static inline void _sys_k_event_logger_thread_create(void *thread) {}
|
|
||||||
static inline void _sys_k_event_logger_thread_ready(void *thread) {}
|
|
||||||
static inline void _sys_k_event_logger_thread_pend(void *thread) {}
|
|
||||||
static inline void _sys_k_event_logger_thread_exit(void *thread) {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Kernel Event Logger
|
|
||||||
* @defgroup kernel_event_logger Kernel Event Logger
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef sys_k_timer_func_t
|
|
||||||
* @brief Event timestamp generator function type.
|
|
||||||
*
|
|
||||||
* A timestamp generator function is executed when the kernel event logger
|
|
||||||
* generates an event containing a timestamp.
|
|
||||||
*
|
|
||||||
* @return Timestamp value (application-defined).
|
|
||||||
*/
|
|
||||||
typedef u32_t (*sys_k_timer_func_t)(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @cond INTERNAL_HIDDEN
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CUSTOM_TIMESTAMP
|
|
||||||
extern sys_k_timer_func_t _sys_k_get_time;
|
|
||||||
#else
|
|
||||||
#define _sys_k_get_time k_cycle_get_32
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_CUSTOM_TIMESTAMP */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* INTERNAL_HIDDEN @endcond
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set kernel event logger timestamp function.
|
|
||||||
*
|
|
||||||
* This routine instructs the kernel event logger to call @a func
|
|
||||||
* whenever it needs to generate an event timestamp. By default,
|
|
||||||
* the kernel's hardware timer is used.
|
|
||||||
*
|
|
||||||
* @note
|
|
||||||
* On some boards the hardware timer is not a pure hardware up counter,
|
|
||||||
* which can lead to timestamp errors. For example, boards using the LOAPIC
|
|
||||||
* timer can run it in periodic mode, which requires software to update
|
|
||||||
* a count of accumulated cycles each time the timer hardware resets itself
|
|
||||||
* to zero. This can result in an incorrect timestamp being generated
|
|
||||||
* if it occurs after the timer hardware has reset but before the timer ISR
|
|
||||||
* has updated accumulated cycle count.
|
|
||||||
*
|
|
||||||
* @param func Address of timestamp function to be used.
|
|
||||||
*
|
|
||||||
* @return N/A
|
|
||||||
*/
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CUSTOM_TIMESTAMP
|
|
||||||
static inline void sys_k_event_logger_set_timer(sys_k_timer_func_t func)
|
|
||||||
{
|
|
||||||
_sys_k_get_time = func;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_CUSTOM_TIMESTAMP */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set kernel event logger filtering mask.
|
|
||||||
*
|
|
||||||
* This routine specifies which events are recorded by the kernel event logger.
|
|
||||||
* It can only be used when dynamic event logging has been configured.
|
|
||||||
*
|
|
||||||
* Each mask bit corresponds to a kernel event type. The least significant
|
|
||||||
* mask bit corresponds to event type 1, the next bit to event type 2,
|
|
||||||
* and so on.
|
|
||||||
*
|
|
||||||
* @param value Bitmask indicating events to be recorded.
|
|
||||||
*
|
|
||||||
* @return N/A
|
|
||||||
*/
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC
|
|
||||||
static inline void sys_k_event_logger_set_mask(int value)
|
|
||||||
{
|
|
||||||
_sys_k_event_logger_mask = value;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get kernel event logger filtering mask.
|
|
||||||
*
|
|
||||||
* This routine indicates which events are currently being recorded by
|
|
||||||
* the kernel event logger. It can only be used when dynamic event logging
|
|
||||||
* has been configured. By default, no events are recorded.
|
|
||||||
*
|
|
||||||
* @return Bitmask indicating events that are being recorded.
|
|
||||||
*/
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC
|
|
||||||
static inline int sys_k_event_logger_get_mask(void)
|
|
||||||
{
|
|
||||||
return _sys_k_event_logger_mask;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Indicate if an event type is currently being recorded.
|
|
||||||
*
|
|
||||||
* This routine indicates if event type @a event_type should be recorded
|
|
||||||
* by the kernel event logger when the event occurs. The routine should be
|
|
||||||
* used by code that writes an event to the kernel event logger to ensure
|
|
||||||
* that only events of interest to the application are recorded.
|
|
||||||
*
|
|
||||||
* @param event_type Event ID.
|
|
||||||
*
|
|
||||||
* @return 1 if event should be recorded, or 0 if not.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static inline int sys_k_must_log_event(int event_type)
|
|
||||||
{
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC
|
|
||||||
return !!(_sys_k_event_logger_mask & event_type);
|
|
||||||
#else
|
|
||||||
ARG_UNUSED(event_type);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Write an event to the kernel event logger.
|
|
||||||
*
|
|
||||||
* This routine writes an event message to the kernel event logger.
|
|
||||||
*
|
|
||||||
* @param event_id Event ID.
|
|
||||||
* @param event_data Address of event data.
|
|
||||||
* @param data_size Size of event data (number of 32-bit words).
|
|
||||||
*
|
|
||||||
* @return N/A
|
|
||||||
*/
|
|
||||||
static inline void sys_k_event_logger_put(u16_t event_id,
|
|
||||||
u32_t *event_data,
|
|
||||||
u8_t data_size)
|
|
||||||
{
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER
|
|
||||||
sys_event_logger_put(&sys_k_event_logger, event_id,
|
|
||||||
event_data, data_size);
|
|
||||||
#else
|
|
||||||
ARG_UNUSED(event_id);
|
|
||||||
ARG_UNUSED(event_data);
|
|
||||||
ARG_UNUSED(data_size);
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER */
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Write an event to the kernel event logger (with timestamp only).
|
|
||||||
*
|
|
||||||
* This routine writes an event message to the kernel event logger.
|
|
||||||
* The event records a single 32-bit word containing a timestamp.
|
|
||||||
*
|
|
||||||
* @param event_id Event ID.
|
|
||||||
*
|
|
||||||
* @return N/A
|
|
||||||
*/
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER
|
|
||||||
extern void sys_k_event_logger_put_timed(u16_t event_id);
|
|
||||||
#else
|
|
||||||
static inline void sys_k_event_logger_put_timed(u16_t event_id)
|
|
||||||
{
|
|
||||||
ARG_UNUSED(event_id);
|
|
||||||
};
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Retrieves a kernel event message, or returns without waiting.
|
|
||||||
*
|
|
||||||
* This routine retrieves the next recorded event from the kernel event logger,
|
|
||||||
* or returns immediately if no such event exists.
|
|
||||||
*
|
|
||||||
* @param event_id Area to store event type ID.
|
|
||||||
* @param dropped Area to store number of events that were dropped between
|
|
||||||
* the previous event and the retrieved event.
|
|
||||||
* @param event_data Buffer to store event data.
|
|
||||||
* @param data_size Size of event data buffer (number of 32-bit words).
|
|
||||||
*
|
|
||||||
* @retval positive_integer Number of event data words retrieved;
|
|
||||||
* @a event_id, @a dropped, and @a buffer have been updated.
|
|
||||||
* @retval 0 Returned without waiting; no event was retrieved.
|
|
||||||
* @retval -EMSGSIZE Buffer too small; @a data_size now indicates
|
|
||||||
* the size of the event to be retrieved.
|
|
||||||
*/
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER
|
|
||||||
static inline int sys_k_event_logger_get(u16_t *event_id, u8_t *dropped,
|
|
||||||
u32_t *event_data, u8_t *data_size)
|
|
||||||
{
|
|
||||||
return sys_event_logger_get(&sys_k_event_logger, event_id, dropped,
|
|
||||||
event_data, data_size);
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Retrieves a kernel event message.
|
|
||||||
*
|
|
||||||
* This routine retrieves the next recorded event from the kernel event logger.
|
|
||||||
* If there is no such event the caller pends until it is available.
|
|
||||||
*
|
|
||||||
* @param event_id Area to store event type ID.
|
|
||||||
* @param dropped Area to store number of events that were dropped between
|
|
||||||
* the previous event and the retrieved event.
|
|
||||||
* @param event_data Buffer to store event data.
|
|
||||||
* @param data_size Size of event data buffer (number of 32-bit words).
|
|
||||||
*
|
|
||||||
* @retval positive_integer Number of event data words retrieved;
|
|
||||||
* @a event_id, @a dropped, and @a buffer have been updated.
|
|
||||||
* @retval -EMSGSIZE Buffer too small; @a data_size now indicates
|
|
||||||
* the size of the event to be retrieved.
|
|
||||||
*/
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER
|
|
||||||
static inline int sys_k_event_logger_get_wait(u16_t *event_id,
|
|
||||||
u8_t *dropped, u32_t *event_data, u8_t *data_size)
|
|
||||||
{
|
|
||||||
return sys_event_logger_get_wait(&sys_k_event_logger, event_id, dropped,
|
|
||||||
event_data, data_size);
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Retrieves a kernel event message, or waits for a specified time.
|
|
||||||
*
|
|
||||||
* This routine retrieves the next recorded event from the kernel event logger.
|
|
||||||
* If there is no such event the caller pends until it is available or until
|
|
||||||
* the specified timeout expires.
|
|
||||||
*
|
|
||||||
* @param event_id Area to store event type ID.
|
|
||||||
* @param dropped Area to store number of events that were dropped between
|
|
||||||
* the previous event and the retrieved event.
|
|
||||||
* @param event_data Buffer to store event data.
|
|
||||||
* @param data_size Size of event data buffer (number of 32-bit words).
|
|
||||||
* @param timeout Timeout in system clock ticks.
|
|
||||||
*
|
|
||||||
* @retval positive_integer Number of event data words retrieved;
|
|
||||||
* @a event_id, @a dropped, and @a buffer have been updated.
|
|
||||||
* @retval 0 Waiting period timed out; no event was retrieved.
|
|
||||||
* @retval -EMSGSIZE Buffer too small; @a data_size now indicates
|
|
||||||
* the size of the event to be retrieved.
|
|
||||||
*/
|
|
||||||
#if defined(CONFIG_KERNEL_EVENT_LOGGER)
|
|
||||||
static inline int sys_k_event_logger_get_wait_timeout(u16_t *event_id,
|
|
||||||
u8_t *dropped, u32_t *event_data,
|
|
||||||
u8_t *data_size, u32_t timeout)
|
|
||||||
{
|
|
||||||
return sys_event_logger_get_wait_timeout(&sys_k_event_logger, event_id,
|
|
||||||
dropped, event_data,
|
|
||||||
data_size, timeout);
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Register thread that retrieves kernel events.
|
|
||||||
*
|
|
||||||
* This routine instructs the kernel event logger not to record context
|
|
||||||
* switch events for the calling thread. It is typically called by the thread
|
|
||||||
* that retrieves events from the kernel event logger.
|
|
||||||
*
|
|
||||||
* @return N/A
|
|
||||||
*/
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
|
||||||
void sys_k_event_logger_register_as_collector(void);
|
|
||||||
#else
|
|
||||||
static inline void sys_k_event_logger_register_as_collector(void) {};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @} end defgroup kernel_event_logger
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* _ASMLANGUAGE */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __KERNEL_EVENT_LOGGER_H__ */
|
|
|
@ -670,8 +670,6 @@ config MP_NUM_CPUS
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
source "kernel/Kconfig.event_logger"
|
|
||||||
|
|
||||||
source "kernel/Kconfig.power_mgmt"
|
source "kernel/Kconfig.power_mgmt"
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright (c) 2014-2015 Wind River Systems, Inc.
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
menuconfig KERNEL_EVENT_LOGGER
|
|
||||||
bool "Enable kernel event logger features"
|
|
||||||
select RING_BUFFER
|
|
||||||
help
|
|
||||||
This feature enables the usage of the profiling logger. Provides the
|
|
||||||
logging of sleep events (either entering or leaving low power conditions),
|
|
||||||
context switch events, interrupt events, boot events and a method to
|
|
||||||
collect these event messages.
|
|
||||||
|
|
||||||
if KERNEL_EVENT_LOGGER
|
|
||||||
config KERNEL_EVENT_LOGGER_BUFFER_SIZE
|
|
||||||
int "Kernel event logger buffer size"
|
|
||||||
default 128
|
|
||||||
help
|
|
||||||
Buffer size in 32-bit words.
|
|
||||||
|
|
||||||
config KERNEL_EVENT_LOGGER_DYNAMIC
|
|
||||||
bool "Kernel event logger dynamic enabling"
|
|
||||||
help
|
|
||||||
If enabled, kernel event logger is not logging any data to the ring buffer
|
|
||||||
It is up to the application to set the appropriate flags to enable/disable the
|
|
||||||
logging of each event type.
|
|
||||||
|
|
||||||
config KERNEL_EVENT_LOGGER_CUSTOM_TIMESTAMP
|
|
||||||
bool "Kernel event logger custom timestamp"
|
|
||||||
help
|
|
||||||
This flag enables the possibility to set the timer function to be used to
|
|
||||||
populate kernel event logger timestamp. This has to be done at runtime by
|
|
||||||
calling sys_k_event_logger_set_timer and providing the function callback.
|
|
||||||
|
|
||||||
menu "Kernel event logging points"
|
|
||||||
|
|
||||||
config KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
|
||||||
bool "Context switch event logging point"
|
|
||||||
help
|
|
||||||
Enable the context switch event messages.
|
|
||||||
|
|
||||||
config KERNEL_EVENT_LOGGER_INTERRUPT
|
|
||||||
bool "Interrupt event logging point"
|
|
||||||
help
|
|
||||||
Enable interrupt event messages. These messages provide the following
|
|
||||||
information: The time when interrupts occur.
|
|
||||||
|
|
||||||
config KERNEL_EVENT_LOGGER_SLEEP
|
|
||||||
bool "Sleep event logging point"
|
|
||||||
depends on SYS_POWER_MANAGEMENT
|
|
||||||
help
|
|
||||||
Enable low power condition event messages. These messages provide the
|
|
||||||
following information:
|
|
||||||
|
|
||||||
- When the CPU went to sleep mode.
|
|
||||||
- When the CPU woke up.
|
|
||||||
- The ID of the interrupt that woke the CPU up.
|
|
||||||
|
|
||||||
config KERNEL_EVENT_LOGGER_THREAD
|
|
||||||
bool "Thread event logging point"
|
|
||||||
help
|
|
||||||
Enable thread event messages. These messages provide the following
|
|
||||||
information:
|
|
||||||
|
|
||||||
- When threads are marked as ready to be executed.
|
|
||||||
- When threads are marked as pending.
|
|
||||||
- When threads end.
|
|
||||||
|
|
||||||
Context switching messages should be enabled by enabling the
|
|
||||||
CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH setting instead.
|
|
||||||
|
|
||||||
endmenu
|
|
||||||
|
|
||||||
endif
|
|
|
@ -8,10 +8,6 @@
|
||||||
#define _ksched__h_
|
#define _ksched__h_
|
||||||
|
|
||||||
#include <kernel_structs.h>
|
#include <kernel_structs.h>
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER
|
|
||||||
#include <logging/kernel_event_logger.h>
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER */
|
|
||||||
#include <tracing.h>
|
#include <tracing.h>
|
||||||
|
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_MULTITHREADING
|
||||||
|
@ -228,9 +224,6 @@ static inline void _ready_thread(struct k_thread *thread)
|
||||||
|
|
||||||
sys_trace_thread_ready(thread);
|
sys_trace_thread_ready(thread);
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_THREAD
|
|
||||||
_sys_k_event_logger_thread_ready(thread);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void _ready_one_thread(_wait_q_t *wq)
|
static inline void _ready_one_thread(_wait_q_t *wq)
|
||||||
|
|
|
@ -21,7 +21,6 @@ extern void _check_stack_sentinel(void);
|
||||||
#define _check_stack_sentinel() /**/
|
#define _check_stack_sentinel() /**/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void _sys_k_event_logger_context_switch(void);
|
|
||||||
|
|
||||||
/* In SMP, the irq_lock() is a spinlock which is implicitly released
|
/* In SMP, the irq_lock() is a spinlock which is implicitly released
|
||||||
* and reacquired on context switch to preserve the existing
|
* and reacquired on context switch to preserve the existing
|
||||||
|
@ -64,10 +63,6 @@ static inline unsigned int _Swap(unsigned int key)
|
||||||
sys_trace_thread_switched_out();
|
sys_trace_thread_switched_out();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
|
||||||
_sys_k_event_logger_context_switch();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
new_thread = _get_next_ready_thread();
|
new_thread = _get_next_ready_thread();
|
||||||
|
|
||||||
if (new_thread != old_thread) {
|
if (new_thread != old_thread) {
|
||||||
|
|
|
@ -560,9 +560,6 @@ void _k_thread_single_abort(struct k_thread *thread)
|
||||||
thread->base.thread_state |= _THREAD_DEAD;
|
thread->base.thread_state |= _THREAD_DEAD;
|
||||||
|
|
||||||
sys_trace_thread_abort(thread);
|
sys_trace_thread_abort(thread);
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_THREAD
|
|
||||||
_sys_k_event_logger_thread_exit(thread);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_USERSPACE
|
#ifdef CONFIG_USERSPACE
|
||||||
/* Clear initailized state so that this thread object may be re-used
|
/* Clear initailized state so that this thread object may be re-used
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
CONFIG_NETWORKING=y
|
|
||||||
CONFIG_NET_LOG=y
|
|
||||||
CONFIG_NET_IPV6=y
|
|
||||||
CONFIG_NET_IPV4=y
|
|
||||||
CONFIG_NET_DHCPV4=y
|
|
||||||
CONFIG_NET_UDP=y
|
|
||||||
CONFIG_NET_TCP=y
|
|
||||||
CONFIG_NET_STATISTICS=y
|
|
||||||
|
|
||||||
CONFIG_NET_PKT_RX_COUNT=14
|
|
||||||
CONFIG_NET_PKT_TX_COUNT=14
|
|
||||||
CONFIG_NET_BUF_RX_COUNT=30
|
|
||||||
CONFIG_NET_BUF_TX_COUNT=30
|
|
||||||
CONFIG_NET_BUF_DATA_SIZE=128
|
|
||||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=5
|
|
||||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=5
|
|
||||||
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=2
|
|
||||||
CONFIG_NET_MAX_CONTEXTS=10
|
|
||||||
|
|
||||||
CONFIG_INIT_STACKS=y
|
|
||||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
|
||||||
CONFIG_SYS_LOG_SHOW_COLOR=y
|
|
||||||
CONFIG_PRINTK=y
|
|
||||||
|
|
||||||
CONFIG_NET_L2_ETHERNET=y
|
|
||||||
|
|
||||||
CONFIG_NET_SHELL=y
|
|
||||||
|
|
||||||
#
|
|
||||||
# Profiler
|
|
||||||
#
|
|
||||||
CONFIG_RING_BUFFER=y
|
|
||||||
CONFIG_KERNEL_EVENT_LOGGER=y
|
|
||||||
CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE=10000
|
|
||||||
CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH=y
|
|
||||||
CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT=y
|
|
||||||
CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC=y
|
|
|
@ -1,10 +1,4 @@
|
||||||
zephyr_sources_ifdef(CONFIG_SYS_LOG sys_log.c)
|
zephyr_sources_ifdef(CONFIG_SYS_LOG sys_log.c)
|
||||||
zephyr_sources_ifdef(
|
|
||||||
CONFIG_KERNEL_EVENT_LOGGER
|
|
||||||
event_logger.c
|
|
||||||
kernel_event_logger.c
|
|
||||||
)
|
|
||||||
|
|
||||||
zephyr_sources_ifdef(CONFIG_SYS_LOG_BACKEND_NET sys_log_net.c)
|
zephyr_sources_ifdef(CONFIG_SYS_LOG_BACKEND_NET sys_log_net.c)
|
||||||
|
|
||||||
zephyr_sources_ifdef(
|
zephyr_sources_ifdef(
|
||||||
|
|
|
@ -1,246 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2015 Intel Corporation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* @brief Kernel event logger support.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <logging/kernel_event_logger.h>
|
|
||||||
#include <misc/util.h>
|
|
||||||
#include <init.h>
|
|
||||||
#include <kernel_structs.h>
|
|
||||||
#include <kernel_event_logger_arch.h>
|
|
||||||
#include <misc/__assert.h>
|
|
||||||
|
|
||||||
struct event_logger sys_k_event_logger;
|
|
||||||
|
|
||||||
u32_t _sys_k_event_logger_buffer[CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE];
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
|
||||||
void *_collector_coop_thread;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
|
||||||
u32_t _sys_k_event_logger_sleep_start_time;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC
|
|
||||||
int _sys_k_event_logger_mask;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int initialized;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize the kernel event logger system.
|
|
||||||
*
|
|
||||||
* @details Initialize the ring buffer and the sync semaphore.
|
|
||||||
*
|
|
||||||
* @return No return value.
|
|
||||||
*/
|
|
||||||
static int _sys_k_event_logger_init(struct device *arg)
|
|
||||||
{
|
|
||||||
ARG_UNUSED(arg);
|
|
||||||
|
|
||||||
sys_event_logger_init(&sys_k_event_logger, _sys_k_event_logger_buffer,
|
|
||||||
CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE);
|
|
||||||
|
|
||||||
initialized = 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
SYS_INIT(_sys_k_event_logger_init,
|
|
||||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CUSTOM_TIMESTAMP
|
|
||||||
/*
|
|
||||||
* _sys_k_get_time()
|
|
||||||
*
|
|
||||||
* This function pointer can be invoked to generate an event timestamp.
|
|
||||||
* By default it uses the kernel's hardware clock, but can be changed
|
|
||||||
* to point to an application-defined routine.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
sys_k_timer_func_t _sys_k_get_time = k_cycle_get_32;
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_CUSTOM_TIMESTAMP */
|
|
||||||
|
|
||||||
void sys_k_event_logger_put_timed(u16_t event_id)
|
|
||||||
{
|
|
||||||
u32_t data[1];
|
|
||||||
|
|
||||||
data[0] = _sys_k_get_time();
|
|
||||||
|
|
||||||
sys_event_logger_put(&sys_k_event_logger, event_id, data,
|
|
||||||
ARRAY_SIZE(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
|
||||||
void _sys_k_event_logger_context_switch(void)
|
|
||||||
{
|
|
||||||
extern struct _kernel _kernel;
|
|
||||||
u32_t data[2];
|
|
||||||
|
|
||||||
extern void _sys_event_logger_put_non_preemptible(
|
|
||||||
struct event_logger *logger,
|
|
||||||
u16_t event_id,
|
|
||||||
u32_t *event_data,
|
|
||||||
u8_t data_size);
|
|
||||||
|
|
||||||
const int event_id = KERNEL_EVENT_LOGGER_CONTEXT_SWITCH_EVENT_ID;
|
|
||||||
|
|
||||||
if (!sys_k_must_log_event(event_id)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if the kernel event logger has not been initialized, do nothing */
|
|
||||||
if (sys_k_event_logger.ring_buf.buf == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_collector_coop_thread == _kernel.current) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data[0] = _sys_k_get_time();
|
|
||||||
data[1] = (u32_t)_kernel.current;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The mechanism we use to log the kernel events uses a sync semaphore
|
|
||||||
* to inform that there are available events to be collected. The
|
|
||||||
* context switch event can be triggered from a task. When we signal a
|
|
||||||
* semaphore from a thread is waiting for that semaphore, a
|
|
||||||
* context switch is generated immediately. Due to the fact that we
|
|
||||||
* register the context switch event while the context switch is being
|
|
||||||
* processed, a new context switch can be generated before the kernel
|
|
||||||
* finishes processing the current context switch. We need to prevent
|
|
||||||
* this because the kernel is not able to handle it. The
|
|
||||||
* _sem_give_non_preemptible function does not trigger a context
|
|
||||||
* switch when we signal the semaphore from any type of thread. Using
|
|
||||||
* _sys_event_logger_put_non_preemptible function, that internally
|
|
||||||
* uses _sem_give_non_preemptible function for signaling the sync
|
|
||||||
* semaphore, allow us registering the context switch event without
|
|
||||||
* triggering any new context switch during the process.
|
|
||||||
*/
|
|
||||||
_sys_event_logger_put_non_preemptible(&sys_k_event_logger,
|
|
||||||
KERNEL_EVENT_LOGGER_CONTEXT_SWITCH_EVENT_ID, data,
|
|
||||||
ARRAY_SIZE(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ASSERT_CURRENT_IS_COOP_THREAD() \
|
|
||||||
__ASSERT(_current->base.prio < 0, "must be a coop thread")
|
|
||||||
|
|
||||||
void sys_k_event_logger_register_as_collector(void)
|
|
||||||
{
|
|
||||||
ASSERT_CURRENT_IS_COOP_THREAD();
|
|
||||||
|
|
||||||
_collector_coop_thread = _kernel.current;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
|
||||||
void _sys_k_event_logger_interrupt(void)
|
|
||||||
{
|
|
||||||
u32_t data[2];
|
|
||||||
|
|
||||||
if (!initialized) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sys_k_must_log_event(KERNEL_EVENT_LOGGER_INTERRUPT_EVENT_ID)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if the kernel event logger has not been initialized, we do nothing */
|
|
||||||
if (sys_k_event_logger.ring_buf.buf == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data[0] = _sys_k_get_time();
|
|
||||||
data[1] = _sys_current_irq_key_get();
|
|
||||||
|
|
||||||
sys_k_event_logger_put(KERNEL_EVENT_LOGGER_INTERRUPT_EVENT_ID, data,
|
|
||||||
ARRAY_SIZE(data));
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
|
||||||
void _sys_k_event_logger_enter_sleep(void)
|
|
||||||
{
|
|
||||||
if (!sys_k_must_log_event(KERNEL_EVENT_LOGGER_SLEEP_EVENT_ID)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_sys_k_event_logger_sleep_start_time = k_cycle_get_32();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _sys_k_event_logger_exit_sleep(void)
|
|
||||||
{
|
|
||||||
u32_t data[3];
|
|
||||||
|
|
||||||
if (!sys_k_must_log_event(KERNEL_EVENT_LOGGER_SLEEP_EVENT_ID)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_sys_k_event_logger_sleep_start_time != 0) {
|
|
||||||
data[0] = _sys_k_get_time();
|
|
||||||
data[1] = (k_cycle_get_32() - _sys_k_event_logger_sleep_start_time)
|
|
||||||
/ sys_clock_hw_cycles_per_tick;
|
|
||||||
/* register the cause of exiting sleep mode */
|
|
||||||
data[2] = _sys_current_irq_key_get();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* if _sys_k_event_logger_sleep_start_time is different to zero, means
|
|
||||||
* that the CPU was sleeping, so we reset it to identify that the event
|
|
||||||
* was processed and that any the next interrupt is no awaing the CPU.
|
|
||||||
*/
|
|
||||||
_sys_k_event_logger_sleep_start_time = 0;
|
|
||||||
|
|
||||||
sys_k_event_logger_put(KERNEL_EVENT_LOGGER_SLEEP_EVENT_ID, data,
|
|
||||||
ARRAY_SIZE(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_SLEEP */
|
|
||||||
|
|
||||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_THREAD
|
|
||||||
static void log_thread_event(enum sys_k_event_logger_thread_event event,
|
|
||||||
struct k_thread *thread)
|
|
||||||
{
|
|
||||||
u32_t data[3];
|
|
||||||
|
|
||||||
if (!initialized) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sys_k_must_log_event(KERNEL_EVENT_LOGGER_THREAD_EVENT_ID)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data[0] = _sys_k_get_time();
|
|
||||||
data[1] = (u32_t)(thread ? thread : _kernel.current);
|
|
||||||
data[2] = (u32_t)event;
|
|
||||||
|
|
||||||
sys_k_event_logger_put(KERNEL_EVENT_LOGGER_THREAD_EVENT_ID, data,
|
|
||||||
ARRAY_SIZE(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
void _sys_k_event_logger_thread_ready(struct k_thread *thread)
|
|
||||||
{
|
|
||||||
log_thread_event(KERNEL_LOG_THREAD_EVENT_READYQ, thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _sys_k_event_logger_thread_pend(struct k_thread *thread)
|
|
||||||
{
|
|
||||||
log_thread_event(KERNEL_LOG_THREAD_EVENT_PEND, thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _sys_k_event_logger_thread_exit(struct k_thread *thread)
|
|
||||||
{
|
|
||||||
log_thread_event(KERNEL_LOG_THREAD_EVENT_EXIT, thread);
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_THREAD */
|
|
Loading…
Add table
Add a link
Reference in a new issue