diff --git a/arch/arc/core/cpu_idle.S b/arch/arc/core/cpu_idle.S index 08a01f0560f..f3660d67a3e 100644 --- a/arch/arc/core/cpu_idle.S +++ b/arch/arc/core/cpu_idle.S @@ -35,9 +35,9 @@ SECTION_VAR(BSS, k_cpu_sleep_mode) SECTION_FUNC(TEXT, k_cpu_idle) -#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP +#ifdef CONFIG_TRACING push_s blink - jl _sys_k_event_logger_enter_sleep + jl sys_trace_idle pop_s blink #endif @@ -56,9 +56,9 @@ SECTION_FUNC(TEXT, k_cpu_idle) */ SECTION_FUNC(TEXT, k_cpu_atomic_idle) -#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP +#ifdef CONFIG_TRACING push_s blink - jl _sys_k_event_logger_enter_sleep + jl sys_trace_idle pop_s blink #endif diff --git a/arch/arc/core/isr_wrapper.S b/arch/arc/core/isr_wrapper.S index 30eb0fecf33..c93e3a4cfe6 100644 --- a/arch/arc/core/isr_wrapper.S +++ b/arch/arc/core/isr_wrapper.S @@ -332,29 +332,14 @@ rirq_path: j_s [r2] #endif -#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP -GTEXT(_sys_k_event_logger_exit_sleep) - -.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) +#if defined(CONFIG_TRACING) +GTEXT(sys_trace_isr_enter) .macro log_interrupt_k_event clri r0 /* do not interrupt event logger operations */ push_s r0 push_s blink - jl _sys_k_event_logger_interrupt + jl sys_trace_isr_enter pop_s blink pop_s 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 */ exit_tickless_idle log_interrupt_k_event - log_sleep_k_event lr r0, [_ARC_V2_ICAUSE] /* handle software triggered interrupt */ diff --git a/arch/arc/include/kernel_event_logger_arch.h b/arch/arc/include/tracing_arch.h similarity index 81% rename from arch/arc/include/kernel_event_logger_arch.h rename to arch/arc/include/tracing_arch.h index e798ee37bb4..ec119598a6e 100644 --- a/arch/arc/include/kernel_event_logger_arch.h +++ b/arch/arc/include/tracing_arch.h @@ -9,8 +9,8 @@ * @brief Kernel event logger support for ARM */ -#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__ -#define __KERNEL_EVENT_LOGGER_ARCH_H__ +#ifndef __KERNEL_TRACING_H__ +#define __KERNEL_TRACING_H__ #ifdef __cplusplus extern "C" { @@ -33,4 +33,4 @@ int _sys_current_irq_key_get(void) } #endif -#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */ +#endif /* __KERNEL_TRACING_H__ */ diff --git a/arch/arm/core/swap_helper.S b/arch/arm/core/swap_helper.S index 3afdae2c357..1b6a14cda62 100644 --- a/arch/arm/core/swap_helper.S +++ b/arch/arm/core/swap_helper.S @@ -53,7 +53,7 @@ SECTION_FUNC(TEXT, __pendsv) #else pop {lr} #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 */ #if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) diff --git a/arch/arm/include/kernel_event_logger_arch.h b/arch/arm/include/tracing_arch.h similarity index 82% rename from arch/arm/include/kernel_event_logger_arch.h rename to arch/arm/include/tracing_arch.h index e25815017f1..dd2a9dc0c16 100644 --- a/arch/arm/include/kernel_event_logger_arch.h +++ b/arch/arm/include/tracing_arch.h @@ -9,8 +9,8 @@ * @brief Kernel event logger support for ARM */ -#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__ -#define __KERNEL_EVENT_LOGGER_ARCH_H__ +#ifndef __KERNEL_TRACING_H__ +#define __KERNEL_TRACING_H__ #ifdef __cplusplus extern "C" { @@ -34,4 +34,4 @@ int _sys_current_irq_key_get(void) } #endif -#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */ +#endif /* __KERNEL_TRACING_H__ */ diff --git a/arch/nios2/core/irq_manage.c b/arch/nios2/core/irq_manage.c index 4ca97ba9bd8..e9cc6d3130b 100644 --- a/arch/nios2/core/irq_manage.c +++ b/arch/nios2/core/irq_manage.c @@ -17,9 +17,9 @@ #include #include #include -#include #include #include +#include void _irq_spurious(void *unused) { @@ -86,9 +86,7 @@ void _enter_irq(u32_t ipending) while (ipending) { struct _isr_table_entry *ite; -#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT - _sys_k_event_logger_interrupt(); -#endif + sys_trace_isr_enter(); index = find_lsb_set(ipending) - 1; ipending &= ~(1 << index); @@ -100,6 +98,7 @@ void _enter_irq(u32_t ipending) read_timer_end_of_isr(); #endif ite->isr(ite->arg); + sys_trace_isr_exit(); } _kernel.nested--; diff --git a/arch/nios2/core/swap.S b/arch/nios2/core/swap.S index eceecdf7cef..6ea22fdb5c8 100644 --- a/arch/nios2/core/swap.S +++ b/arch/nios2/core/swap.S @@ -13,7 +13,7 @@ GTEXT(__swap) GTEXT(_thread_entry_wrapper) /* imports */ -GTEXT(_sys_k_event_logger_context_switch) +GTEXT(sys_trace_thread_switched_in) GTEXT(_k_neg_eagain) /* unsigned int __swap(unsigned int key) @@ -84,8 +84,8 @@ SECTION_FUNC(exception.other, __swap) ldw r4, (r5) stw r4, _thread_offset_to_retval(r11) -#if CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH - call _sys_k_event_logger_context_switch +#if CONFIG_TRACING + call sys_trace_thread_switched_in /* restore caller-saved r10 */ movhi r10, %hi(_kernel) ori r10, r10, %lo(_kernel) diff --git a/arch/nios2/include/kernel_event_logger_arch.h b/arch/nios2/include/tracing_arch.h similarity index 84% rename from arch/nios2/include/kernel_event_logger_arch.h rename to arch/nios2/include/tracing_arch.h index bb0706dfa68..e013bee03a1 100644 --- a/arch/nios2/include/kernel_event_logger_arch.h +++ b/arch/nios2/include/tracing_arch.h @@ -9,8 +9,8 @@ * @brief Kernel event logger support for Nios II */ -#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__ -#define __KERNEL_EVENT_LOGGER_ARCH_H__ +#ifndef __KERNEL_TRACING_H__ +#define __KERNEL_TRACING_H__ #include @@ -38,4 +38,4 @@ static inline int _sys_current_irq_key_get(void) } #endif -#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */ +#endif /* __KERNEL_TRACING_H__ */ diff --git a/arch/posix/core/cpuhalt.c b/arch/posix/core/cpuhalt.c index 8d829cd950d..f913d4793a3 100644 --- a/arch/posix/core/cpuhalt.c +++ b/arch/posix/core/cpuhalt.c @@ -19,7 +19,7 @@ #include "posix_core.h" #include "posix_soc_if.h" -#include "logging/kernel_event_logger.h" +#include /** * @@ -35,7 +35,7 @@ */ void k_cpu_idle(void) { - _sys_k_event_logger_enter_sleep(); + sys_trace_idle(); posix_irq_full_unlock(); posix_halt_cpu(); } @@ -62,6 +62,6 @@ void k_cpu_idle(void) void k_cpu_atomic_idle(unsigned int imask) { - _sys_k_event_logger_enter_sleep(); + sys_trace_idle(); posix_atomic_halt_cpu(imask); } diff --git a/arch/posix/core/swap.c b/arch/posix/core/swap.c index 9a0ad69a599..4d0450df419 100644 --- a/arch/posix/core/swap.c +++ b/arch/posix/core/swap.c @@ -50,9 +50,7 @@ unsigned int __swap(unsigned int key) _kernel.current->callee_saved.retval = -EAGAIN; /* retval may be modified with a call to _set_thread_return_value() */ -#if CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH - _sys_k_event_logger_context_switch(); -#endif + sys_trace_thread_switched_in(); posix_thread_status_t *ready_thread_ptr = (posix_thread_status_t *) diff --git a/arch/posix/include/kernel_event_logger_arch.h b/arch/posix/include/tracing_arch.h similarity index 83% rename from arch/posix/include/kernel_event_logger_arch.h rename to arch/posix/include/tracing_arch.h index 6dfa297293f..299e5151edb 100644 --- a/arch/posix/include/kernel_event_logger_arch.h +++ b/arch/posix/include/tracing_arch.h @@ -10,8 +10,8 @@ * @brief Kernel event logger support for ARM */ -#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__ -#define __KERNEL_EVENT_LOGGER_ARCH_H__ +#ifndef __KERNEL_TRACING_H__ +#define __KERNEL_TRACING_H__ #include "posix_soc_if.h" @@ -36,4 +36,4 @@ static inline int _sys_current_irq_key_get(void) } #endif -#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */ +#endif /* __KERNEL_TRACING_H__ */ diff --git a/arch/riscv32/core/isr.S b/arch/riscv32/core/isr.S index 8ea1eed8bee..1ee6225f730 100644 --- a/arch/riscv32/core/isr.S +++ b/arch/riscv32/core/isr.S @@ -21,16 +21,9 @@ GTEXT(_k_neg_eagain) GTEXT(_is_next_thread_current) GTEXT(_get_next_ready_thread) -#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH -GTEXT(_sys_k_event_logger_context_switch) -#endif - -#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) +#ifdef CONFIG_TRACING +GTEXT(sys_trace_thread_switched_in) +GTEXT(sys_trace_isr_enter) #endif #ifdef CONFIG_IRQ_OFFLOAD @@ -231,12 +224,8 @@ on_irq_stack: tail _irq_do_offload call_irq: -#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP - call _sys_k_event_logger_exit_sleep -#endif - -#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT - call _sys_k_event_logger_interrupt +#ifdef CONFIG_TRACING + call sys_trace_isr_enter #endif /* Get IRQ causing interrupt */ @@ -310,9 +299,9 @@ reschedule: #if CONFIG_TIMESLICING call _update_time_slice_before_swap #endif -#if CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH - call _sys_k_event_logger_context_switch -#endif /* CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH */ +#if CONFIG_TRACING + call sys_trace_thread_switched_in +#endif /* Get reference to _kernel */ la t0, _kernel diff --git a/arch/riscv32/include/kernel_event_logger_arch.h b/arch/riscv32/include/tracing_arch.h similarity index 85% rename from arch/riscv32/include/kernel_event_logger_arch.h rename to arch/riscv32/include/tracing_arch.h index 2e821ca8ea9..ec0a5bb2eab 100644 --- a/arch/riscv32/include/kernel_event_logger_arch.h +++ b/arch/riscv32/include/tracing_arch.h @@ -9,8 +9,8 @@ * @brief Kernel event logger support for RISCV32 */ -#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__ -#define __KERNEL_EVENT_LOGGER_ARCH_H__ +#ifndef __KERNEL_TRACING_H__ +#define __KERNEL_TRACING_H__ #include @@ -41,4 +41,4 @@ static inline int _sys_current_irq_key_get(void) } #endif -#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */ +#endif /* __KERNEL_TRACING_H__ */ diff --git a/arch/riscv32/soc/pulpino/pulpino_idle.c b/arch/riscv32/soc/pulpino/pulpino_idle.c index 346fc6b890c..3bc17c7d2f1 100644 --- a/arch/riscv32/soc/pulpino/pulpino_idle.c +++ b/arch/riscv32/soc/pulpino/pulpino_idle.c @@ -8,13 +8,12 @@ #include #include -#include +#include static ALWAYS_INLINE void pulpino_idle(unsigned int key) { -#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP - _sys_k_event_logger_enter_sleep(); -#endif + sys_trace_idle(); + /* unlock interrupts */ irq_unlock(key); diff --git a/arch/riscv32/soc/riscv-privilege/common/idle.c b/arch/riscv32/soc/riscv-privilege/common/idle.c index 679cf2c1827..190e243abe5 100644 --- a/arch/riscv32/soc/riscv-privilege/common/idle.c +++ b/arch/riscv32/soc/riscv-privilege/common/idle.c @@ -9,13 +9,11 @@ #include #include -#include +#include static ALWAYS_INLINE void riscv_idle(unsigned int key) { -#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP - _sys_k_event_logger_enter_sleep(); -#endif + sys_trace_idle(); /* unlock interrupts */ irq_unlock(key); diff --git a/arch/x86/core/cpuhalt.c b/arch/x86/core/cpuhalt.c index 9bbcf941b3f..a02e43dda18 100644 --- a/arch/x86/core/cpuhalt.c +++ b/arch/x86/core/cpuhalt.c @@ -24,7 +24,7 @@ */ #include -#include +#include #include #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) { _int_latency_stop(); - _sys_k_event_logger_enter_sleep(); + sys_trace_idle(); #if defined(CONFIG_BOOT_TIME_MEASUREMENT) __idle_time_stamp = (u64_t)k_cycle_get_32(); #endif @@ -76,7 +76,7 @@ void k_cpu_idle(void) void k_cpu_atomic_idle(unsigned int imask) { _int_latency_stop(); - _sys_k_event_logger_enter_sleep(); + sys_trace_idle(); __asm__ volatile ( "sti\n\t" diff --git a/arch/x86/core/intstub.S b/arch/x86/core/intstub.S index e232c276614..6447bfac3db 100644 --- a/arch/x86/core/intstub.S +++ b/arch/x86/core/intstub.S @@ -135,8 +135,7 @@ SECTION_FUNC(TEXT, _interrupt_enter) #if defined(CONFIG_INT_LATENCY_BENCHMARK) || \ - defined(CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT) || \ - defined(CONFIG_KERNEL_EVENT_LOGGER_SLEEP) + defined(CONFIG_TRACING) /* Save these as we are using to keep track of isr and isr_param */ pushl %eax @@ -153,13 +152,7 @@ SECTION_FUNC(TEXT, _interrupt_enter) call _int_latency_start #endif -#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT - call _sys_k_event_logger_interrupt -#endif - -#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP - call _sys_k_event_logger_exit_sleep -#endif + call sys_trace_isr_enter popl %edx popl %eax diff --git a/arch/x86/core/irq_manage.c b/arch/x86/core/irq_manage.c index b9c4e0f4da7..b01bf6b39db 100644 --- a/arch/x86/core/irq_manage.c +++ b/arch/x86/core/irq_manage.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include 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 * perform operations on _kernel. For now, leave as regular functions, a * 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 */ @@ -64,8 +63,6 @@ void _arch_isr_direct_header(void) { _int_latency_start(); 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 * so that _is_in_isr() works diff --git a/arch/x86/core/swap.S b/arch/x86/core/swap.S index 80abcdc4d73..396aca933a6 100644 --- a/arch/x86/core/swap.S +++ b/arch/x86/core/swap.S @@ -141,10 +141,10 @@ SECTION_FUNC(TEXT, __swap) movl _kernel_offset_to_current(%edi), %edx movl %esp, _thread_offset_to_esp(%edx) -#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH +#ifdef CONFIG_TRACING /* Register the context switch */ push %edx - call _sys_k_event_logger_context_switch + call sys_trace_thread_switched_in pop %edx #endif movl _kernel_offset_to_ready_q_cache(%edi), %eax diff --git a/arch/x86/include/kernel_event_logger_arch.h b/arch/x86/include/tracing_arch.h similarity index 83% rename from arch/x86/include/kernel_event_logger_arch.h rename to arch/x86/include/tracing_arch.h index a9f7f5f80f1..fcc8bb96bf2 100644 --- a/arch/x86/include/kernel_event_logger_arch.h +++ b/arch/x86/include/tracing_arch.h @@ -9,8 +9,8 @@ * @brief Kernel event logger support for x86 */ -#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__ -#define __KERNEL_EVENT_LOGGER_ARCH_H__ +#ifndef __KERNEL_TRACING_H__ +#define __KERNEL_TRACING_H__ #include @@ -35,4 +35,4 @@ static inline int _sys_current_irq_key_get(void) } #endif -#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */ +#endif /* __KERNEL_TRACING_H__ */ diff --git a/arch/xtensa/core/cpu_idle.c b/arch/xtensa/core/cpu_idle.c index c82993c5e5f..3a4927a22ed 100644 --- a/arch/xtensa/core/cpu_idle.c +++ b/arch/xtensa/core/cpu_idle.c @@ -3,7 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include +#include +#include /* * @brief Put the CPU in low-power mode @@ -14,9 +16,7 @@ */ void k_cpu_idle(void) { -#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP - _sys_k_event_logger_enter_sleep(); -#endif + sys_trace_idle(); __asm__ volatile ("waiti 0"); } /* @@ -28,9 +28,7 @@ void k_cpu_idle(void) */ void k_cpu_atomic_idle(unsigned int key) { -#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP - _sys_k_event_logger_enter_sleep(); -#endif + sys_trace_idle(); __asm__ volatile ("waiti 0\n\t" "wsr.ps %0\n\t" "rsync" :: "a"(key)); diff --git a/arch/xtensa/core/swap.S b/arch/xtensa/core/swap.S index 319248c6a9e..490336c15c2 100644 --- a/arch/xtensa/core/swap.S +++ b/arch/xtensa/core/swap.S @@ -75,12 +75,12 @@ __swap: s16i a3, a4, THREAD_OFFSET(cpEnable) /* clear saved cpenable */ #endif -#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH +#ifdef CONFIG_TRACING /* Register the context switch */ #ifdef __XTENSA_CALL0_ABI__ - call0 _sys_k_event_logger_context_switch + call0 sys_trace_thread_switched_in #else - call4 _sys_k_event_logger_context_switch + call4 sys_trace_thread_switched_in #endif #endif /* _thread := _kernel.ready_q.cache */ diff --git a/arch/xtensa/core/xtensa_vectors.S b/arch/xtensa/core/xtensa_vectors.S index 37c15f69af3..cd2736df473 100644 --- a/arch/xtensa/core/xtensa_vectors.S +++ b/arch/xtensa/core/xtensa_vectors.S @@ -166,28 +166,18 @@ #endif #endif -#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT +#ifdef CONFIG_TRACING /* * Register the interrupt. * We just saved all registers. */ #ifdef __XTENSA_CALL0_ABI__ - call0 _sys_k_event_logger_interrupt + call0 sys_trace_isr_enter #else - call4 _sys_k_event_logger_interrupt + call4 sys_trace_isr_enter #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 #ifdef XT_INTEXC_HOOKS /* Call interrupt hook if present to (pre)handle interrupts. */ diff --git a/arch/xtensa/include/kernel_event_logger_arch.h b/arch/xtensa/include/tracing_arch.h similarity index 82% rename from arch/xtensa/include/kernel_event_logger_arch.h rename to arch/xtensa/include/tracing_arch.h index d60d9963b9e..b6755e0716d 100644 --- a/arch/xtensa/include/kernel_event_logger_arch.h +++ b/arch/xtensa/include/tracing_arch.h @@ -8,8 +8,8 @@ * @brief Kernel event logger support for Xtensa */ -#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__ -#define __KERNEL_EVENT_LOGGER_ARCH_H__ +#ifndef __KERNEL_TRACING_H__ +#define __KERNEL_TRACING_H__ #ifdef __cplusplus @@ -33,4 +33,4 @@ static inline int _sys_current_irq_key_get(void) } #endif -#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */ +#endif /* __KERNEL_TRACING_H__ */ diff --git a/boards/posix/native_posix/irq_handler.c b/boards/posix/native_posix/irq_handler.c index fa3f2c92a9e..07e4c2fde62 100644 --- a/boards/posix/native_posix/irq_handler.c +++ b/boards/posix/native_posix/irq_handler.c @@ -18,7 +18,7 @@ #include "board_soc.h" #include "sw_isr_table.h" #include "soc.h" -#include "logging/kernel_event_logger.h" +#include typedef void (*normal_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() */ /* _int_latency_start(); */ - _sys_k_event_logger_interrupt(); + + sys_trace_isr_enter(); if (irq_vector_table[irq_nbr].func == NULL) { /* LCOV_EXCL_BR_LINE */ /* LCOV_EXCL_START */ @@ -86,8 +87,6 @@ void posix_irq_handler(void) _kernel.nested++; - _sys_k_event_logger_exit_sleep(); - while ((irq_nbr = hw_irq_ctrl_get_highest_prio_irq()) != -1) { int last_current_running_prio = hw_irq_ctrl_get_cur_prio(); int last_running_irq = currently_running_irq; diff --git a/doc/subsystems/logging/index.rst b/doc/subsystems/logging/index.rst index 1a28ed34031..d40ba18b734 100644 --- a/doc/subsystems/logging/index.rst +++ b/doc/subsystems/logging/index.rst @@ -5,5 +5,4 @@ Logging :maxdepth: 1 system_log - kernel_event_logger logger diff --git a/doc/subsystems/logging/kernel_event_logger.rst b/doc/subsystems/logging/kernel_event_logger.rst deleted file mode 100644 index 90f71470867..00000000000 --- a/doc/subsystems/logging/kernel_event_logger.rst +++ /dev/null @@ -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 `. 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 diff --git a/doc/zephyr.doxyfile.in b/doc/zephyr.doxyfile.in index 6c4779abe52..371e21f6373 100644 --- a/doc/zephyr.doxyfile.in +++ b/doc/zephyr.doxyfile.in @@ -1969,9 +1969,6 @@ INCLUDE_FILE_PATTERNS = # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. 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_CUSTOM_DATA=y" \ "CONFIG_ERRNO=y" \ diff --git a/drivers/timer/cortex_m_systick.c b/drivers/timer/cortex_m_systick.c index 48643f29c4e..14c3a38b0b2 100644 --- a/drivers/timer/cortex_m_systick.c +++ b/drivers/timer/cortex_m_systick.c @@ -220,10 +220,6 @@ void _timer_int_handler(void *unused) read_timer_start_of_tick_handler(); #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(); #ifdef CONFIG_SYS_POWER_MANAGEMENT diff --git a/drivers/timer/xtensa_sys_timer.c b/drivers/timer/xtensa_sys_timer.c index 1d152c07a3b..5d362c6458b 100644 --- a/drivers/timer/xtensa_sys_timer.c +++ b/drivers/timer/xtensa_sys_timer.c @@ -505,10 +505,8 @@ void _timer_int_handler(void *params) SET_TIMER_FIRE_TIME(GET_TIMER_CURRENT_TIME() + _xt_tick_divisor); #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(); #ifdef CONFIG_SMP /* The timer infractructure isn't prepared to handle diff --git a/include/logging/kernel_event_logger.h b/include/logging/kernel_event_logger.h deleted file mode 100644 index 0b6520835d1..00000000000 --- a/include/logging/kernel_event_logger.h +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright (c) 2015 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @file - * @brief Kernel event logger support. - */ - -#include - -#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 - -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__ */ diff --git a/kernel/Kconfig b/kernel/Kconfig index ffc41a6ddc4..bd1172542da 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -670,8 +670,6 @@ config MP_NUM_CPUS endmenu -source "kernel/Kconfig.event_logger" - source "kernel/Kconfig.power_mgmt" endmenu diff --git a/kernel/Kconfig.event_logger b/kernel/Kconfig.event_logger deleted file mode 100644 index c7b2ebefd03..00000000000 --- a/kernel/Kconfig.event_logger +++ /dev/null @@ -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 diff --git a/kernel/include/ksched.h b/kernel/include/ksched.h index 411409ee1ea..9983625ad79 100644 --- a/kernel/include/ksched.h +++ b/kernel/include/ksched.h @@ -8,10 +8,6 @@ #define _ksched__h_ #include - -#ifdef CONFIG_KERNEL_EVENT_LOGGER -#include -#endif /* CONFIG_KERNEL_EVENT_LOGGER */ #include #ifdef CONFIG_MULTITHREADING @@ -228,9 +224,6 @@ static inline void _ready_thread(struct k_thread *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) diff --git a/kernel/include/kswap.h b/kernel/include/kswap.h index bbe04ef20b2..15feac33a0c 100644 --- a/kernel/include/kswap.h +++ b/kernel/include/kswap.h @@ -21,7 +21,6 @@ extern void _check_stack_sentinel(void); #define _check_stack_sentinel() /**/ #endif -extern void _sys_k_event_logger_context_switch(void); /* In SMP, the irq_lock() is a spinlock which is implicitly released * 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(); #endif -#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH - _sys_k_event_logger_context_switch(); -#endif - new_thread = _get_next_ready_thread(); if (new_thread != old_thread) { diff --git a/kernel/thread.c b/kernel/thread.c index f8f5002193e..13e4ac17b75 100644 --- a/kernel/thread.c +++ b/kernel/thread.c @@ -560,9 +560,6 @@ void _k_thread_single_abort(struct k_thread *thread) thread->base.thread_state |= _THREAD_DEAD; sys_trace_thread_abort(thread); -#ifdef CONFIG_KERNEL_EVENT_LOGGER_THREAD - _sys_k_event_logger_thread_exit(thread); -#endif #ifdef CONFIG_USERSPACE /* Clear initailized state so that this thread object may be re-used diff --git a/samples/net/zperf/prj_frdm_k64f_prof.conf b/samples/net/zperf/prj_frdm_k64f_prof.conf deleted file mode 100644 index d47b63d7938..00000000000 --- a/samples/net/zperf/prj_frdm_k64f_prof.conf +++ /dev/null @@ -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 diff --git a/subsys/logging/CMakeLists.txt b/subsys/logging/CMakeLists.txt index 3df7e06c080..eabcec3ba2f 100644 --- a/subsys/logging/CMakeLists.txt +++ b/subsys/logging/CMakeLists.txt @@ -1,10 +1,4 @@ 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( diff --git a/subsys/logging/kernel_event_logger.c b/subsys/logging/kernel_event_logger.c deleted file mode 100644 index cd6adc11ebd..00000000000 --- a/subsys/logging/kernel_event_logger.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (c) 2015 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @file - * @brief Kernel event logger support. - */ - - -#include -#include -#include -#include -#include -#include - -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 */