Rename Profiler to Event Logger.
In order to have a name according to the functionality of the feature. This commit rename any text, function and variable related with the Profiler name to Event logger. Change-Id: I4f612cbc7c37965c35a64f06cc3ce5e3249d90e5 Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
This commit is contained in:
parent
16504c27c1
commit
e378747706
34 changed files with 361 additions and 351 deletions
|
@ -120,9 +120,9 @@ SECTION_FUNC(TEXT, _NanoIdleValClear)
|
|||
*/
|
||||
|
||||
SECTION_FUNC(TEXT, nano_cpu_idle)
|
||||
#ifdef CONFIG_PROFILER_SLEEP
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
||||
push {lr}
|
||||
bl _sys_profiler_enter_sleep
|
||||
bl _sys_k_event_logger_enter_sleep
|
||||
pop {lr}
|
||||
#endif
|
||||
|
||||
|
@ -161,9 +161,9 @@ SECTION_FUNC(TEXT, nano_cpu_idle)
|
|||
*/
|
||||
|
||||
SECTION_FUNC(TEXT, nano_cpu_atomic_idle)
|
||||
#ifdef CONFIG_PROFILER_SLEEP
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
||||
push {lr}
|
||||
bl _sys_profiler_enter_sleep
|
||||
bl _sys_k_event_logger_enter_sleep
|
||||
pop {lr}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -58,9 +58,9 @@ SECTION_FUNC(TEXT, _isr_wrapper)
|
|||
|
||||
push {lr} /* lr is now the first item on the stack */
|
||||
|
||||
#ifdef CONFIG_PROFILER_INTERRUPT
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
||||
push {lr}
|
||||
bl _sys_profiler_interrupt
|
||||
bl _sys_k_event_logger_interrupt
|
||||
pop {lr}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -58,10 +58,10 @@ SECTION_FUNC(TEXT, __pendsv)
|
|||
|
||||
_GDB_STUB_EXC_ENTRY
|
||||
|
||||
#ifdef CONFIG_PROFILER_CONTEXT_SWITCH
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
||||
/* Register the context switch */
|
||||
push {lr}
|
||||
bl _sys_profiler_context_switch
|
||||
bl _sys_k_event_logger_context_switch
|
||||
pop {lr}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
/*
|
||||
* @file
|
||||
* @brief Profiler support for ARM
|
||||
* @brief Kernel event logger support for ARM
|
||||
*/
|
||||
|
||||
#ifndef __PROFILE_ARM_H__
|
||||
#define __PROFILE_ARM_H__
|
||||
#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__
|
||||
#define __KERNEL_EVENT_LOGGER_ARCH_H__
|
||||
|
||||
/**
|
||||
* @brief Get the identification of the current interrupt.
|
||||
|
@ -35,4 +35,4 @@ int _sys_current_irq_key_get(void)
|
|||
return _IpsrGet();
|
||||
}
|
||||
|
||||
#endif /* __PROFILE_ARM_H__ */
|
||||
#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */
|
|
@ -70,8 +70,8 @@ SECTION_FUNC(TEXT, nano_cpu_idle)
|
|||
#ifdef CONFIG_INT_LATENCY_BENCHMARK
|
||||
call _int_latency_stop
|
||||
#endif
|
||||
#ifdef CONFIG_PROFILER_SLEEP
|
||||
call _sys_profiler_enter_sleep
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
||||
call _sys_k_event_logger_enter_sleep
|
||||
#endif
|
||||
#if defined(CONFIG_BOOT_TIME_MEASUREMENT)
|
||||
rdtsc /* record idle timestamp */
|
||||
|
@ -113,8 +113,8 @@ SECTION_FUNC(TEXT, nano_cpu_atomic_idle)
|
|||
#ifdef CONFIG_INT_LATENCY_BENCHMARK
|
||||
call _int_latency_stop
|
||||
#endif
|
||||
#ifdef CONFIG_PROFILER_SLEEP
|
||||
call _sys_profiler_enter_sleep
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
||||
call _sys_k_event_logger_enter_sleep
|
||||
#endif
|
||||
sti /* make sure interrupts are enabled */
|
||||
|
||||
|
|
|
@ -153,12 +153,12 @@ SECTION_FUNC(TEXT, _IntEnt)
|
|||
popl %eax
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PROFILER_INTERRUPT
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
||||
/*
|
||||
* Preserve EAX as it contains the stub return address.
|
||||
*/
|
||||
pushl %eax
|
||||
call _sys_profiler_interrupt
|
||||
call _sys_k_event_logger_interrupt
|
||||
popl %eax
|
||||
#endif
|
||||
|
||||
|
|
|
@ -121,11 +121,11 @@ SECTION_FUNC(TEXT, _Swap)
|
|||
movl __tNANO_current_OFFSET (%eax), %ecx
|
||||
movl %esp, __tTCS_coopReg_OFFSET + __tCoopReg_esp_OFFSET (%ecx)
|
||||
|
||||
#ifdef CONFIG_PROFILER_CONTEXT_SWITCH
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
||||
/* save %eax since it used as the return value for _Swap */
|
||||
pushl %eax
|
||||
/* Register the context switch */
|
||||
call _sys_profiler_context_switch
|
||||
call _sys_k_event_logger_context_switch
|
||||
/* restore _Swap's %eax */
|
||||
popl %eax
|
||||
#endif
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
/*
|
||||
* @file
|
||||
* @brief Profiler support for x86
|
||||
* @brief Kernel event logger support for x86
|
||||
*/
|
||||
|
||||
#ifndef __PROFILE_X86_H__
|
||||
#define __PROFILE_X86_H__
|
||||
#ifndef __KERNEL_EVENT_LOGGER_ARCH_H__
|
||||
#define __KERNEL_EVENT_LOGGER_ARCH_H__
|
||||
|
||||
/**
|
||||
* @brief Get the identification of the current interrupt.
|
||||
|
@ -37,4 +37,4 @@ int _sys_current_irq_key_get(void)
|
|||
return _loapic_isr_vector_get();
|
||||
}
|
||||
|
||||
#endif /* __PROFILE_X86_H__ */
|
||||
#endif /* __KERNEL_EVENT_LOGGER_ARCH_H__ */
|
|
@ -233,9 +233,9 @@ void _TIMER_INT_HANDLER(void *unused)
|
|||
{
|
||||
ARG_UNUSED(unused);
|
||||
|
||||
#ifdef CONFIG_PROFILER_INTERRUPT
|
||||
extern void _sys_profiler_interrupt(void);
|
||||
_sys_profiler_interrupt();
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
||||
extern void _sys_k_event_logger_interrupt(void);
|
||||
_sys_k_event_logger_interrupt();
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -16,27 +16,27 @@
|
|||
|
||||
/*
|
||||
* @file
|
||||
* @brief Profiler support.
|
||||
* @brief Kernel event logger support.
|
||||
*/
|
||||
|
||||
|
||||
#include <misc/event_logger.h>
|
||||
|
||||
#ifndef __PROFILE_H__
|
||||
#define __PROFILE_H__
|
||||
#ifndef __KERNEL_EVENT_LOGGER_H__
|
||||
#define __KERNEL_EVENT_LOGGER_H__
|
||||
|
||||
#ifdef CONFIG_KERNEL_PROFILER
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER
|
||||
|
||||
#ifdef CONFIG_PROFILER_CONTEXT_SWITCH
|
||||
#define PROFILER_CONTEXT_SWITCH_EVENT_ID 0x0001
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
||||
#define KERNEL_EVENT_LOGGER_CONTEXT_SWITCH_EVENT_ID 0x0001
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PROFILER_INTERRUPT
|
||||
#define PROFILER_INTERRUPT_EVENT_ID 0x0002
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
||||
#define KERNEL_EVENT_LOGGER_INTERRUPT_EVENT_ID 0x0002
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PROFILER_SLEEP
|
||||
#define PROFILER_SLEEP_EVENT_ID 0x0003
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
||||
#define KERNEL_EVENT_LOGGER_SLEEP_EVENT_ID 0x0003
|
||||
#endif
|
||||
|
||||
#ifndef _ASMLANGUAGE
|
||||
|
@ -44,44 +44,44 @@
|
|||
* Global variable of the ring buffer that allows user to implement
|
||||
* their own reading routine.
|
||||
*/
|
||||
struct event_logger sys_profiler_logger;
|
||||
struct event_logger sys_k_event_logger;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Sends a profile event message to the profiler.
|
||||
* @brief Sends a event message to the kernel event logger.
|
||||
*
|
||||
* @details Sends a profile message to the profiler logger
|
||||
* @details Sends a event message to the kernel event logger
|
||||
* and informs that there are messages available.
|
||||
*
|
||||
* @param event_id The identification of the profiler event.
|
||||
* @param event_id The identification of the event.
|
||||
* @param data Pointer to the data of the message.
|
||||
* @param data_size Size of the data in 32-bit words.
|
||||
*
|
||||
* @return No return value.
|
||||
*/
|
||||
#define sys_profiler_put(event_id, data, data_size) \
|
||||
sys_event_logger_put(&sys_profiler_logger, event_id, data, data_size)
|
||||
#define sys_k_event_logger_put(event_id, data, data_size) \
|
||||
sys_event_logger_put(&sys_k_event_logger, event_id, data, data_size)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Sends a profile event message to the profiler with the current
|
||||
* @brief Sends a event message to the kernel event logger with the current
|
||||
* timestamp.
|
||||
*
|
||||
* @details Sends a profile message to the profiler logger and informs that
|
||||
* @details Sends a event message to the kernel event logger and informs that
|
||||
* there messages available. The timestamp when the event occurred is stored
|
||||
* as part of the event message.
|
||||
*
|
||||
* @param event_id The identification of the profiler event.
|
||||
* @param event_id The identification of the event.
|
||||
*
|
||||
* @return No return value.
|
||||
*/
|
||||
void sys_profiler_put_timed(uint16_t event_id);
|
||||
void sys_k_event_logger_put_timed(uint16_t event_id);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Retrieves a profiler event message.
|
||||
* @brief Retrieves a kernel event message.
|
||||
*
|
||||
* @details Retrieves a profiler event message copying it to the provided
|
||||
* @details Retrieves a kernel event message copying it to the provided
|
||||
* buffer. If the buffer is smaller than the message size the function returns
|
||||
* an error. The function retrieves messages in FIFO order.
|
||||
*
|
||||
|
@ -91,22 +91,22 @@ void sys_profiler_put_timed(uint16_t event_id);
|
|||
* @param buffer_size Size of the buffer in 32-bit words.
|
||||
*
|
||||
* @return -EMSGSIZE if the buffer size is smaller than the message size,
|
||||
* the amount of 32-bit words copied or zero if there are no profile event
|
||||
* the amount of 32-bit words copied or zero if there are no kernel event
|
||||
* messages available.
|
||||
*/
|
||||
#define sys_profiler_get(event_id, dropped, buffer, buffer_size) \
|
||||
sys_event_logger_get(&sys_profiler_logger, event_id, dropped, buffer, \
|
||||
#define sys_k_event_logger_get(event_id, dropped, buffer, buffer_size) \
|
||||
sys_event_logger_get(&sys_k_event_logger, event_id, dropped, buffer, \
|
||||
buffer_size)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Retrieves a profiler event message, wait if there is no message
|
||||
* @brief Retrieves a kernel event message, wait if there is no message
|
||||
* available.
|
||||
*
|
||||
* @details Retrieves a profiler event message copying it to the provided
|
||||
* @details Retrieves a kernel event message copying it to the provided
|
||||
* buffer. If the buffer is smaller than the message size the function returns
|
||||
* an error. The function retrieves messages in FIFO order. If there is no
|
||||
* profiler event message available the caller pends until a new message is
|
||||
* kernel event message available the caller pends until a new message is
|
||||
* logged.
|
||||
*
|
||||
* @param event_id Pointer to the id of the event fetched
|
||||
|
@ -117,21 +117,21 @@ void sys_profiler_put_timed(uint16_t event_id);
|
|||
* @return -EMSGSIZE if the buffer size is smaller than the message size, or
|
||||
* the amount of 32-bit words copied.
|
||||
*/
|
||||
#define sys_profiler_get_wait(event_id, dropped, buffer, buffer_size) \
|
||||
sys_event_logger_get_wait(&sys_profiler_logger, event_id, dropped, \
|
||||
#define sys_k_event_logger_get_wait(event_id, dropped, buffer, buffer_size) \
|
||||
sys_event_logger_get_wait(&sys_k_event_logger, event_id, dropped, \
|
||||
buffer, buffer_size)
|
||||
|
||||
|
||||
#ifdef CONFIG_NANO_TIMEOUTS
|
||||
|
||||
/**
|
||||
* @brief Retrieves a profiler event message, wait with a timeout if there is
|
||||
* @brief Retrieves a kernel event message, wait with a timeout if there is
|
||||
* no profiling event messages available.
|
||||
*
|
||||
* @details Retrieves a profiler event message copying it to the provided
|
||||
* @details Retrieves a kernel event message copying it to the provided
|
||||
* buffer. If the buffer is smaller than the message size the function returns
|
||||
* an error. The function retrieves messages in FIFO order. If there are no
|
||||
* profiler event messages available the caller pends until a new message is
|
||||
* kernel event messages available the caller pends until a new message is
|
||||
* logged or the timeout expires.
|
||||
*
|
||||
* @param event_id Pointer to the id of the event fetched
|
||||
|
@ -144,42 +144,42 @@ void sys_profiler_put_timed(uint16_t event_id);
|
|||
* amount of 32-bit words copied or zero if the timeout expires and the was no
|
||||
* message available.
|
||||
*/
|
||||
#define sys_profiler_get_wait_timeout(event_id, dropped, buffer, buffer_size, \
|
||||
#define sys_k_event_logger_get_wait_timeout(event_id, dropped, buffer, buffer_size, \
|
||||
timeout) \
|
||||
sys_event_logger_get_wait_timeout(event_id, dropped, \
|
||||
&sys_profiler_logger, buffer, \
|
||||
&sys_k_event_logger, buffer, \
|
||||
buffer_size, timeout)
|
||||
#endif /* CONFIG_NANO_TIMEOUTS */
|
||||
|
||||
|
||||
#ifdef CONFIG_PROFILER_CONTEXT_SWITCH
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
||||
|
||||
/**
|
||||
* @brief Register the fiber that calls the function as collector
|
||||
*
|
||||
* @details Initialize internal profiling data. This avoid registering the
|
||||
* context switch of the collector fiber when CONFIG_PROFILE_THREAD_SWITCH
|
||||
* is enable.
|
||||
* @details Initialize internal profiling data. This avoid registering
|
||||
* the context switch of the collector fiber when
|
||||
* CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH is enable.
|
||||
*
|
||||
* @return No return value.
|
||||
*/
|
||||
void sys_profiler_register_as_collector(void);
|
||||
#else /* !CONFIG_PROFILER_CONTEXT_SWITCH */
|
||||
static inline void sys_profiler_register_as_collector(void) {};
|
||||
#endif /* CONFIG_PROFILER_CONTEXT_SWITCH */
|
||||
void sys_k_event_logger_register_as_collector(void);
|
||||
#else /* !CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH */
|
||||
static inline void sys_k_event_logger_register_as_collector(void) {};
|
||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH */
|
||||
|
||||
#endif /* _ASMLANGUAGE */
|
||||
|
||||
#else /* !CONFIG_KERNEL_PROFILER */
|
||||
#else /* !CONFIG_KERNEL_EVENT_LOGGER */
|
||||
|
||||
#ifndef _ASMLANGUAGE
|
||||
|
||||
static inline void sys_profiler_put(uint16_t event_id, uint32_t *event_data,
|
||||
static inline void sys_k_event_logger_put(uint16_t event_id, uint32_t *event_data,
|
||||
uint8_t data_size) {};
|
||||
static inline void sys_profiler_put_timed(uint16_t event_id) {};
|
||||
static inline void sys_k_event_logger_put_timed(uint16_t event_id) {};
|
||||
|
||||
#endif /* _ASMLANGUAGE */
|
||||
|
||||
#endif /* CONFIG_KERNEL_PROFILER */
|
||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER */
|
||||
|
||||
#endif /* __PROFILE_H__ */
|
||||
#endif /* __KERNEL_EVENT_LOGGER_H__ */
|
|
@ -94,51 +94,51 @@ config EVENT_LOGGER
|
|||
Enable event logging feature. Allow the usage of a ring buffer to
|
||||
transmit event messages with a single interface to collect them.
|
||||
|
||||
config KERNEL_PROFILER
|
||||
config KERNEL_EVENT_LOGGER
|
||||
bool
|
||||
prompt "Enable profiler features"
|
||||
prompt "Enable kernel event logger features"
|
||||
default n
|
||||
select EVENT_LOGGER
|
||||
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 profile messages.
|
||||
collect these event messages.
|
||||
|
||||
config PROFILER_BUFFER_SIZE
|
||||
config KERNEL_EVENT_LOGGER_BUFFER_SIZE
|
||||
int
|
||||
prompt "Profiler buffer size"
|
||||
prompt "Kernel event logger buffer size"
|
||||
default 128
|
||||
depends on KERNEL_PROFILER
|
||||
depends on KERNEL_EVENT_LOGGER
|
||||
help
|
||||
Buffer size in 32-bit words.
|
||||
|
||||
|
||||
menu "Profiler points"
|
||||
depends on KERNEL_PROFILER
|
||||
menu "Kernel event logging points"
|
||||
depends on KERNEL_EVENT_LOGGER
|
||||
|
||||
config PROFILER_CONTEXT_SWITCH
|
||||
config KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
||||
bool
|
||||
prompt "Context switch profiler point"
|
||||
prompt "Context switch event logging point"
|
||||
default n
|
||||
depends on KERNEL_PROFILER
|
||||
depends on KERNEL_EVENT_LOGGER
|
||||
help
|
||||
Enable the context switch event messages.
|
||||
|
||||
config PROFILER_INTERRUPT
|
||||
config KERNEL_EVENT_LOGGER_INTERRUPT
|
||||
bool
|
||||
prompt "Interrupt profiler point"
|
||||
prompt "Interrupt event logging point"
|
||||
default n
|
||||
depends on KERNEL_PROFILER
|
||||
depends on KERNEL_EVENT_LOGGER
|
||||
help
|
||||
Enable interrupt event messages. These messages provide the following
|
||||
information: The time when interrupts occur.
|
||||
|
||||
config PROFILER_SLEEP
|
||||
config KERNEL_EVENT_LOGGER_SLEEP
|
||||
bool
|
||||
prompt "Sleep profiler point"
|
||||
prompt "Sleep event logging point"
|
||||
default n
|
||||
depends on KERNEL_PROFILER && ADVANCED_POWER_MANAGEMENT
|
||||
depends on KERNEL_EVENT_LOGGER && ADVANCED_POWER_MANAGEMENT
|
||||
help
|
||||
Enable low power condition event messages. These messages provide the
|
||||
following information:
|
||||
|
|
|
@ -320,9 +320,9 @@ void _sys_power_save_idle_exit(int32_t ticks)
|
|||
#else
|
||||
ARG_UNUSED(ticks);
|
||||
#endif /* CONFIG_TICKLESS_IDLE */
|
||||
#ifdef CONFIG_PROFILER_SLEEP
|
||||
extern void _sys_profiler_exit_sleep(void);
|
||||
_sys_profiler_exit_sleep();
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
||||
extern void _sys_k_event_logger_exit_sleep(void);
|
||||
_sys_k_event_logger_exit_sleep();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -14,5 +14,5 @@ obj-$(CONFIG_INT_LATENCY_BENCHMARK) += int_latency_bench.o
|
|||
obj-$(CONFIG_ADVANCED_POWER_MANAGEMENT) += idle.o
|
||||
obj-$(CONFIG_NANO_TIMERS) += nano_timer.o
|
||||
obj-$(CONFIG_EVENT_LOGGER) += event_logger.o
|
||||
obj-$(CONFIG_KERNEL_PROFILER) += profiler.o
|
||||
obj-$(CONFIG_KERNEL_EVENT_LOGGER) += kernel_event_logger.o
|
||||
obj-$(CONFIG_RING_BUFFER) += ring_buffer.o
|
||||
|
|
155
kernel/nanokernel/kernel_event_logger.c
Normal file
155
kernel/nanokernel/kernel_event_logger.c
Normal file
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Intel Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @file
|
||||
* @brief Kernel event logger support.
|
||||
*/
|
||||
|
||||
|
||||
#include <misc/kernel_event_logger.h>
|
||||
#include <misc/util.h>
|
||||
#include <init.h>
|
||||
#include <nano_private.h>
|
||||
#include <kernel_event_logger_arch.h>
|
||||
|
||||
uint32_t _sys_k_event_logger_buffer[CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE];
|
||||
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
|
||||
void *_collector_fiber;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
||||
uint32_t _sys_k_event_logger_sleep_start_time;
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
return 0;
|
||||
}
|
||||
DECLARE_DEVICE_INIT_CONFIG(kernel_event_logger_0, "",
|
||||
_sys_k_event_logger_init, NULL);
|
||||
nano_early_init(kernel_event_logger_0, NULL);
|
||||
|
||||
|
||||
void sys_k_event_logger_put_timed(uint16_t event_id)
|
||||
{
|
||||
uint32_t data[1];
|
||||
|
||||
data[0] = nano_tick_get_32();
|
||||
|
||||
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 tNANO _nanokernel;
|
||||
uint32_t data[2];
|
||||
|
||||
extern void _sys_event_logger_put_non_preemptible(
|
||||
struct event_logger *logger,
|
||||
uint16_t event_id,
|
||||
uint32_t *event_data,
|
||||
uint8_t data_size);
|
||||
|
||||
/* if the kernel event logger has not been initialized, we do nothing */
|
||||
if (sys_k_event_logger.ring_buf.buf == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_collector_fiber != _nanokernel.current) {
|
||||
data[0] = nano_tick_get_32();
|
||||
data[1] = (uint32_t)_nanokernel.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 task and a fiber 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));
|
||||
}
|
||||
}
|
||||
|
||||
void sys_k_event_logger_register_as_collector(void)
|
||||
{
|
||||
_collector_fiber = _nanokernel.current;
|
||||
}
|
||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH */
|
||||
|
||||
|
||||
#ifdef CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT
|
||||
void _sys_k_event_logger_interrupt(void)
|
||||
{
|
||||
uint32_t data[2];
|
||||
|
||||
data[0] = nano_tick_get_32();
|
||||
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)
|
||||
{
|
||||
_sys_k_event_logger_sleep_start_time = nano_cycle_get_32();
|
||||
}
|
||||
|
||||
void _sys_k_event_logger_exit_sleep(void)
|
||||
{
|
||||
uint32_t data[3];
|
||||
|
||||
data[0] = nano_tick_get_32();
|
||||
data[1] = (nano_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();
|
||||
|
||||
sys_k_event_logger_put(KERNEL_EVENT_LOGGER_SLEEP_EVENT_ID, data,
|
||||
ARRAY_SIZE(data));
|
||||
}
|
||||
#endif /* CONFIG_KERNEL_EVENT_LOGGER_SLEEP */
|
|
@ -1,157 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Intel Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @file
|
||||
* @brief Profiler support.
|
||||
*/
|
||||
|
||||
|
||||
#include <misc/profiler.h>
|
||||
#include <misc/util.h>
|
||||
#include <init.h>
|
||||
#include <nano_private.h>
|
||||
#include <profiler_arch.h>
|
||||
|
||||
uint32_t _sys_profiler_buffer[CONFIG_PROFILER_BUFFER_SIZE];
|
||||
|
||||
#ifdef CONFIG_PROFILER_CONTEXT_SWITCH
|
||||
void *_collector_fiber;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PROFILER_SLEEP
|
||||
uint32_t _sys_profiler_sleep_start_time;
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize the profiler system.
|
||||
*
|
||||
* @details Initialize the ring buffer and the sync semaphore.
|
||||
*
|
||||
* @return No return value.
|
||||
*/
|
||||
static int _sys_profiler_init(struct device *arg)
|
||||
{
|
||||
ARG_UNUSED(arg);
|
||||
|
||||
sys_event_logger_init(&sys_profiler_logger, _sys_profiler_buffer,
|
||||
CONFIG_PROFILER_BUFFER_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
DECLARE_DEVICE_INIT_CONFIG(profiler_0, "", _sys_profiler_init, NULL);
|
||||
nano_early_init(profiler_0, NULL);
|
||||
|
||||
|
||||
void sys_profiler_put_timed(uint16_t event_id)
|
||||
{
|
||||
uint32_t data[1];
|
||||
|
||||
data[0] = nano_tick_get_32();
|
||||
|
||||
sys_event_logger_put(&sys_profiler_logger, event_id, data,
|
||||
ARRAY_SIZE(data));
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PROFILER_CONTEXT_SWITCH
|
||||
void _sys_profiler_context_switch(void)
|
||||
{
|
||||
extern tNANO _nanokernel;
|
||||
uint32_t data[2];
|
||||
|
||||
extern void _sys_event_logger_put_non_preemptible(
|
||||
struct event_logger *logger,
|
||||
uint16_t event_id,
|
||||
uint32_t *event_data,
|
||||
uint8_t data_size);
|
||||
|
||||
/* if the profiler has not been initialized, we do nothing */
|
||||
if (sys_profiler_logger.ring_buf.buf == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_collector_fiber != _nanokernel.current) {
|
||||
data[0] = nano_tick_get_32();
|
||||
data[1] = (uint32_t)_nanokernel.current;
|
||||
|
||||
/*
|
||||
* The mechanism we use to log the profile 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 task and a fiber 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_profiler_logger,
|
||||
PROFILER_CONTEXT_SWITCH_EVENT_ID,
|
||||
data,
|
||||
ARRAY_SIZE(data));
|
||||
}
|
||||
}
|
||||
|
||||
void sys_profiler_register_as_collector(void)
|
||||
{
|
||||
_collector_fiber = _nanokernel.current;
|
||||
}
|
||||
#endif /* CONFIG_PROFILER_CONTEXT_SWITCH */
|
||||
|
||||
|
||||
#ifdef CONFIG_PROFILER_INTERRUPT
|
||||
void _sys_profiler_interrupt(void)
|
||||
{
|
||||
uint32_t data[2];
|
||||
|
||||
data[0] = nano_tick_get_32();
|
||||
data[1] = _sys_current_irq_key_get();
|
||||
|
||||
sys_profiler_put(PROFILER_INTERRUPT_EVENT_ID, data, ARRAY_SIZE(data));
|
||||
}
|
||||
#endif /* CONFIG_PROFILER_INTERRUPT */
|
||||
|
||||
|
||||
#ifdef CONFIG_PROFILER_SLEEP
|
||||
void _sys_profiler_enter_sleep(void)
|
||||
{
|
||||
_sys_profiler_sleep_start_time = nano_cycle_get_32();
|
||||
}
|
||||
|
||||
void _sys_profiler_exit_sleep(void)
|
||||
{
|
||||
uint32_t data[3];
|
||||
|
||||
data[0] = nano_tick_get_32();
|
||||
data[1] = (nano_cycle_get_32() - _sys_profiler_sleep_start_time) /
|
||||
sys_clock_hw_cycles_per_tick;
|
||||
/* register the cause of exiting sleep mode */
|
||||
data[2] = _sys_current_irq_key_get();
|
||||
|
||||
sys_profiler_put(PROFILER_SLEEP_EVENT_ID, data, ARRAY_SIZE(data));
|
||||
}
|
||||
#endif /* CONFIG_PROFILER_SLEEP */
|
|
@ -1,4 +1,4 @@
|
|||
Title: Profiler Sample
|
||||
Title: Kernel Event Logger Sample
|
||||
|
||||
Description:
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
% TASK NAME PRIO ENTRY STACK GROUPS
|
||||
% ==================================================
|
||||
TASK profiler 5 profiler_demo 1024 [EXE]
|
||||
TASK k_logger 5 k_event_logger_demo 1024 [EXE]
|
||||
TASK phi1Task0 6 philEntry 1024 [PHI]
|
||||
TASK philTask1 6 philEntry 1024 [PHI]
|
||||
TASK philTask2 6 philEntry 1024 [PHI]
|
|
@ -0,0 +1,11 @@
|
|||
CONFIG_COMPILER_OPT="-O0"
|
||||
CONFIG_NUM_IRQS=43
|
||||
CONFIG_NANO_TIMEOUTS=y
|
||||
CONFIG_RING_BUFFER=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE=16
|
||||
CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT=y
|
||||
CONFIG_ADVANCED_POWER_MANAGEMENT=y
|
||||
CONFIG_TICKLESS_IDLE=n
|
||||
CONFIG_KERNEL_EVENT_LOGGER_SLEEP=y
|
|
@ -1,11 +1,11 @@
|
|||
# Let stack canaries use non-random number generator.
|
||||
# This option is NOT to be used in production code.
|
||||
CONFIG_RING_BUFFER=y
|
||||
CONFIG_KERNEL_PROFILER=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER=y
|
||||
CONFIG_NANO_TIMEOUTS=y
|
||||
CONFIG_PROFILER_BUFFER_SIZE=16
|
||||
CONFIG_PROFILER_CONTEXT_SWITCH=y
|
||||
CONFIG_PROFILER_INTERRUPT=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE=16
|
||||
CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_INTERRUPT=y
|
||||
CONFIG_ADVANCED_POWER_MANAGEMENT=y
|
||||
CONFIG_TICKLESS_IDLE=y
|
||||
CONFIG_PROFILER_SLEEP=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_SLEEP=y
|
|
@ -0,0 +1,3 @@
|
|||
ccflags-y += ${PROJECTINCLUDE} -I${ZEPHYR_BASE}/samples/microkernel/apps/philosophers/src
|
||||
|
||||
obj-y = kernel_event_collector_sample.o ../../../../microkernel/apps/philosophers/src/phil_fiber.o
|
|
@ -1,4 +1,4 @@
|
|||
/* profiler_collector_sample.c - Profiler sample project */
|
||||
/* kernel_event_collector_sample.c - Kernel event collector sample project */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Intel Corporation
|
||||
|
@ -19,17 +19,17 @@
|
|||
#include <zephyr.h>
|
||||
|
||||
#include "phil.h"
|
||||
#include <misc/profiler.h>
|
||||
#include <misc/kernel_event_logger.h>
|
||||
#include <string.h>
|
||||
|
||||
#define RANDOM(x) (((nano_tick_get_32() * ((x) +1)) & 0x2F) + 1)
|
||||
#define RANDOM(x) (((nano_tick_get_32() * ((x) + 1)) & 0x2F) + 1)
|
||||
|
||||
#define TEST_EVENT_ID 255
|
||||
|
||||
extern void philEntry(void);
|
||||
|
||||
#define STSIZE 1024
|
||||
char __stack profiler_stack[2][STSIZE];
|
||||
char __stack kernel_event_logger_stack[2][STSIZE];
|
||||
|
||||
struct context_switch_data_t {
|
||||
uint32_t thread_id;
|
||||
|
@ -37,7 +37,7 @@ struct context_switch_data_t {
|
|||
uint32_t count;
|
||||
};
|
||||
|
||||
int total_dropped_counter=0;
|
||||
int total_dropped_counter;
|
||||
|
||||
#define MAX_BUFFER_CONTEXT_DATA 20
|
||||
|
||||
|
@ -56,7 +56,7 @@ struct sleep_data_t {
|
|||
struct sleep_data_t sleep_event_data;
|
||||
|
||||
int is_busy_task_awake;
|
||||
int forks_available=1;
|
||||
int forks_available = 1;
|
||||
|
||||
|
||||
void register_context_switch_data(uint32_t timestamp, uint32_t thread_id)
|
||||
|
@ -64,17 +64,17 @@ void register_context_switch_data(uint32_t timestamp, uint32_t thread_id)
|
|||
int found;
|
||||
int i;
|
||||
|
||||
found=0;
|
||||
for (i=0; (i<MAX_BUFFER_CONTEXT_DATA) && (found==0); i++) {
|
||||
found = 0;
|
||||
for (i = 0; (i < MAX_BUFFER_CONTEXT_DATA) && (found == 0); i++) {
|
||||
if (context_switch_summary_data[i].thread_id == thread_id) {
|
||||
context_switch_summary_data[i].last_time_executed = timestamp;
|
||||
context_switch_summary_data[i].count += 1;
|
||||
found=1;
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
for (i=0; i<MAX_BUFFER_CONTEXT_DATA; i++) {
|
||||
for (i = 0; i < MAX_BUFFER_CONTEXT_DATA; i++) {
|
||||
if (context_switch_summary_data[i].thread_id == 0) {
|
||||
context_switch_summary_data[i].thread_id = thread_id;
|
||||
context_switch_summary_data[i].last_time_executed = timestamp;
|
||||
|
@ -152,7 +152,7 @@ void busy_task_entry(void)
|
|||
* go to sleep for 1000 ticks allowing the system entering to sleep
|
||||
* mode if required.
|
||||
*/
|
||||
is_busy_task_awake=0;
|
||||
is_busy_task_awake = 0;
|
||||
task_sleep(1000);
|
||||
ticks_when_awake = nano_tick_get_32();
|
||||
|
||||
|
@ -160,8 +160,8 @@ void busy_task_entry(void)
|
|||
* keep the cpu busy for 1000 ticks preventing the system entering
|
||||
* to sleep mode.
|
||||
*/
|
||||
is_busy_task_awake=1;
|
||||
while(nano_tick_get_32() - ticks_when_awake < 1000) {
|
||||
is_busy_task_awake = 1;
|
||||
while (nano_tick_get_32() - ticks_when_awake < 1000) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ void summary_data_printer(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
while(1) {
|
||||
while (1) {
|
||||
/* print task data */
|
||||
PRINTF("\x1b[1;32HFork manager task");
|
||||
if (forks_available) {
|
||||
|
@ -211,7 +211,7 @@ void summary_data_printer(void)
|
|||
PRINTF("\x1b[13;1HCONTEXT SWITCH EVENT DATA");
|
||||
PRINTF("\x1b[14;1H-------------------------");
|
||||
PRINTF("\x1b[15;1HThread ID Switches");
|
||||
for (i=0; i<MAX_BUFFER_CONTEXT_DATA; i++) {
|
||||
for (i = 0; i < MAX_BUFFER_CONTEXT_DATA; i++) {
|
||||
if (context_switch_summary_data[i].thread_id != 0) {
|
||||
print_context_data(context_switch_summary_data[i].thread_id,
|
||||
context_switch_summary_data[i].count,
|
||||
|
@ -236,8 +236,10 @@ void summary_data_printer(void)
|
|||
PRINTF("\x1b[15;32HINTERRUPT EVENT DATA");
|
||||
PRINTF("\x1b[16;32H--------------------");
|
||||
PRINTF("\x1b[17;32HInterrupt counters");
|
||||
int line=0;
|
||||
for (i=0; i<255; i++) {
|
||||
|
||||
int line = 0;
|
||||
|
||||
for (i = 0; i < 255; i++) {
|
||||
if (interrupt_counters[i] > 0) {
|
||||
PRINTF("\x1b[%d;%dHirq #%d : %d times", 18 + line, 32, i,
|
||||
interrupt_counters[i]);
|
||||
|
@ -252,9 +254,9 @@ void summary_data_printer(void)
|
|||
|
||||
|
||||
/**
|
||||
* @brief Profiler data collector fiber
|
||||
* @brief Kernel event data collector fiber
|
||||
*
|
||||
* @details Collect the profiler messages and process them depending
|
||||
* @details Collect the kernel event messages and process them depending
|
||||
* the kind of event received.
|
||||
*
|
||||
* @return No return value.
|
||||
|
@ -269,12 +271,13 @@ void profiling_data_collector(void)
|
|||
/* We register the fiber as collector to avoid this fiber generating a
|
||||
* context switch event every time it collects the data
|
||||
*/
|
||||
sys_profiler_register_as_collector();
|
||||
sys_k_event_logger_register_as_collector();
|
||||
|
||||
while(1) {
|
||||
while (1) {
|
||||
/* collect the data */
|
||||
uint8_t data_length = SIZE32_OF(data);
|
||||
res = sys_profiler_get_wait(&event_id, &dropped_count, data,
|
||||
|
||||
res = sys_k_event_logger_get_wait(&event_id, &dropped_count, data,
|
||||
&data_length);
|
||||
if (res > 0) {
|
||||
/* Register the amount of droppped events occurred */
|
||||
|
@ -284,7 +287,7 @@ void profiling_data_collector(void)
|
|||
|
||||
/* process the data */
|
||||
switch (event_id) {
|
||||
case PROFILER_CONTEXT_SWITCH_EVENT_ID:
|
||||
case KERNEL_EVENT_LOGGER_CONTEXT_SWITCH_EVENT_ID:
|
||||
if (data_length != 2) {
|
||||
PRINTF("\x1b[13;1HError in context switch message. "
|
||||
"event_id = %d, Expected %d, received %d\n",
|
||||
|
@ -293,7 +296,7 @@ void profiling_data_collector(void)
|
|||
register_context_switch_data(data[0], data[1]);
|
||||
}
|
||||
break;
|
||||
case PROFILER_INTERRUPT_EVENT_ID:
|
||||
case KERNEL_EVENT_LOGGER_INTERRUPT_EVENT_ID:
|
||||
if (data_length != 2) {
|
||||
PRINTF("\x1b[13;1HError in sleep message. "
|
||||
"event_id = %d, Expected %d, received %d\n",
|
||||
|
@ -302,7 +305,7 @@ void profiling_data_collector(void)
|
|||
register_interrupt_event_data(data[0], data[1]);
|
||||
}
|
||||
break;
|
||||
case PROFILER_SLEEP_EVENT_ID:
|
||||
case KERNEL_EVENT_LOGGER_SLEEP_EVENT_ID:
|
||||
if (data_length != 3) {
|
||||
PRINTF("\x1b[13;1HError in sleep message. "
|
||||
"event_id = %d, Expected %d, received %d\n",
|
||||
|
@ -317,7 +320,7 @@ void profiling_data_collector(void)
|
|||
} else {
|
||||
/* This error should never happen */
|
||||
if (res == -EMSGSIZE) {
|
||||
PRINTF("FATAL ERROR. The buffer provided to collect the"
|
||||
PRINTF("FATAL ERROR. The buffer provided to collect the "
|
||||
"profiling events is too small\n");
|
||||
}
|
||||
}
|
||||
|
@ -328,17 +331,17 @@ void profiling_data_collector(void)
|
|||
/**
|
||||
* @brief Start the demo fibers
|
||||
*
|
||||
* @details Start the profiler data colector fiber and the summary printer
|
||||
* @details Start the kernel event data colector fiber and the summary printer
|
||||
* fiber that shows the context switch data.
|
||||
*
|
||||
* @return No return value.
|
||||
*/
|
||||
void profiler_fiber_start(void)
|
||||
void kernel_event_logger_fiber_start(void)
|
||||
{
|
||||
PRINTF("\x1b[2J\x1b[15;1H");
|
||||
task_fiber_start(&profiler_stack[0][0], STSIZE,
|
||||
task_fiber_start(&kernel_event_logger_stack[0][0], STSIZE,
|
||||
(nano_fiber_entry_t) profiling_data_collector, 0, 0, 6, 0);
|
||||
task_fiber_start(&profiler_stack[1][0], STSIZE,
|
||||
task_fiber_start(&kernel_event_logger_stack[1][0], STSIZE,
|
||||
(nano_fiber_entry_t) summary_data_printer, 0, 0, 6, 0);
|
||||
}
|
||||
|
||||
|
@ -349,7 +352,7 @@ struct nano_sem forks[N_PHILOSOPHERS];
|
|||
/**
|
||||
* @brief Manokernel entry point.
|
||||
*
|
||||
* @details Start the profiler data colector fiber. Then
|
||||
* @details Start the kernel event data colector fiber. Then
|
||||
* do wait forever.
|
||||
* @return No return value.
|
||||
*/
|
||||
|
@ -357,7 +360,7 @@ int main(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
profiler_fiber_start();
|
||||
kernel_event_logger_fiber_start();
|
||||
|
||||
/* initialize philosopher semaphores */
|
||||
for (i = 0; i < N_PHILOSOPHERS; i++) {
|
||||
|
@ -383,14 +386,14 @@ int main(void)
|
|||
/**
|
||||
* @brief Microkernel task.
|
||||
*
|
||||
* @details Start the profiler data colector fiber. Then
|
||||
* @details Start the kernel event data colector fiber. Then
|
||||
* do wait forever.
|
||||
*
|
||||
* @return No return value.
|
||||
*/
|
||||
void profiler_demo(void)
|
||||
void k_event_logger_demo(void)
|
||||
{
|
||||
profiler_fiber_start();
|
||||
kernel_event_logger_fiber_start();
|
||||
|
||||
task_group_start(PHI);
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
CONFIG_COMPILER_OPT="-O0"
|
||||
CONFIG_NUM_IRQS=43
|
||||
CONFIG_NANO_TIMEOUTS=y
|
||||
CONFIG_RING_BUFFER=y
|
||||
CONFIG_KERNEL_PROFILER=y
|
||||
CONFIG_PROFILER_BUFFER_SIZE=16
|
||||
CONFIG_PROFILER_CONTEXT_SWITCH=y
|
||||
CONFIG_PROFILER_INTERRUPT=y
|
||||
CONFIG_ADVANCED_POWER_MANAGEMENT=y
|
||||
CONFIG_TICKLESS_IDLE=n
|
||||
CONFIG_PROFILER_SLEEP=y
|
|
@ -1,3 +0,0 @@
|
|||
ccflags-y += ${PROJECTINCLUDE} -I${ZEPHYR_BASE}/samples/microkernel/apps/philosophers/src
|
||||
|
||||
obj-y = profiler_collector_sample.o ../../../../microkernel/apps/philosophers/src/phil_fiber.o
|
|
@ -1,6 +1,6 @@
|
|||
KERNEL_TYPE = nano
|
||||
PLATFORM_CONFIG ?= basic_atom
|
||||
SOURCE_DIR = $(ZEPHYR_BASE)/samples/microkernel/apps/profiler_sample/src/
|
||||
SOURCE_DIR = $(ZEPHYR_BASE)/samples/microkernel/apps/kernel_event_logger_sample/src/
|
||||
MDEF_FILE = prj.mdef
|
||||
CONF_FILE = prj_$(ARCH).conf
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
Title: Profiler Sample
|
||||
Title: Kernel Event Logger Sample
|
||||
|
||||
Description:
|
||||
|
||||
A sample that shows how profiler events can be retrieved.
|
||||
This sample uses the philosopher sample with two additional tasks to show the
|
||||
profiling data on different system's states. The fork manager task controls the
|
||||
fork's availibilty. The worker task performs intermitently heavy processing,
|
||||
allowing or preventing the system to go idle.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -26,6 +29,12 @@ or
|
|||
make pristine # discard results of previous builds
|
||||
# and restore pre-defined configuration info
|
||||
|
||||
|
||||
Problems with QEMU on ARM:
|
||||
Qemu v2.1 for ARM platform do not support tickless idle. If run the sample
|
||||
project in QEMU with the CONFIG_TICKLESS_IDLE option enabled, the project
|
||||
could present an erratic behaviour.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Sample Output:
|
24
samples/nanokernel/apps/kernel_event_logger_sample/prj.mdef
Normal file
24
samples/nanokernel/apps/kernel_event_logger_sample/prj.mdef
Normal file
|
@ -0,0 +1,24 @@
|
|||
% Application : DiningPhilosophers
|
||||
|
||||
% TASKGROUP NAME
|
||||
% ==============
|
||||
TASKGROUP PHI
|
||||
|
||||
% TASK NAME PRIO ENTRY STACK GROUPS
|
||||
% ======================================================
|
||||
TASK k_logger 5 k_event_logger_demo 1024 [EXE]
|
||||
TASK phi1Task0 6 philEntry 1024 [PHI]
|
||||
TASK philTask1 6 philEntry 1024 [PHI]
|
||||
TASK philTask2 6 philEntry 1024 [PHI]
|
||||
TASK philTask3 6 philEntry 1024 [PHI]
|
||||
TASK philTask4 6 philEntry 1024 [PHI]
|
||||
TASK philTask5 6 philEntry 1024 [PHI]
|
||||
|
||||
% MUTEX NAME
|
||||
% ================
|
||||
MUTEX forkMutex0
|
||||
MUTEX forkMutex1
|
||||
MUTEX forkMutex2
|
||||
MUTEX forkMutex3
|
||||
MUTEX forkMutex4
|
||||
MUTEX forkMutex5
|
|
@ -0,0 +1,6 @@
|
|||
CONFIG_COMPILER_OPT="-O0"
|
||||
CONFIG_NUM_IRQS=43
|
||||
CONFIG_NANO_TIMEOUTS=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE=16
|
||||
CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH=y
|
|
@ -0,0 +1,6 @@
|
|||
CONFIG_COMPILER_OPT="-O0"
|
||||
CONFIG_NUM_IRQS=43
|
||||
CONFIG_NANO_TIMEOUTS=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE=16
|
||||
CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH=y
|
|
@ -1,6 +1,6 @@
|
|||
# Let stack canaries use non-random number generator.
|
||||
# This option is NOT to be used in production code.
|
||||
CONFIG_KERNEL_PROFILER=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER=y
|
||||
CONFIG_NANO_TIMEOUTS=y
|
||||
CONFIG_PROFILER_BUFFER_SIZE=16
|
||||
CONFIG_PROFILER_CONTEXT_SWITCH=y
|
||||
CONFIG_KERNEL_EVENT_LOGGER_BUFFER_SIZE=16
|
||||
CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH=y
|
|
@ -1,24 +0,0 @@
|
|||
% Application : DiningPhilosophers
|
||||
|
||||
% TASKGROUP NAME
|
||||
% ==============
|
||||
TASKGROUP PHI
|
||||
|
||||
% TASK NAME PRIO ENTRY STACK GROUPS
|
||||
% ==================================================
|
||||
TASK profiler 5 profiler_demo 1024 [EXE]
|
||||
TASK phi1Task0 6 philEntry 1024 [PHI]
|
||||
TASK philTask1 6 philEntry 1024 [PHI]
|
||||
TASK philTask2 6 philEntry 1024 [PHI]
|
||||
TASK philTask3 6 philEntry 1024 [PHI]
|
||||
TASK philTask4 6 philEntry 1024 [PHI]
|
||||
TASK philTask5 6 philEntry 1024 [PHI]
|
||||
|
||||
% MUTEX NAME
|
||||
% ================
|
||||
MUTEX forkMutex0
|
||||
MUTEX forkMutex1
|
||||
MUTEX forkMutex2
|
||||
MUTEX forkMutex3
|
||||
MUTEX forkMutex4
|
||||
MUTEX forkMutex5
|
|
@ -1,6 +0,0 @@
|
|||
CONFIG_COMPILER_OPT="-O0"
|
||||
CONFIG_NUM_IRQS=43
|
||||
CONFIG_NANO_TIMEOUTS=y
|
||||
CONFIG_KERNEL_PROFILER=y
|
||||
CONFIG_PROFILER_BUFFER_SIZE=16
|
||||
CONFIG_PROFILER_CONTEXT_SWITCH=y
|
|
@ -1,6 +0,0 @@
|
|||
CONFIG_COMPILER_OPT="-O0"
|
||||
CONFIG_NUM_IRQS=43
|
||||
CONFIG_NANO_TIMEOUTS=y
|
||||
CONFIG_KERNEL_PROFILER=y
|
||||
CONFIG_PROFILER_BUFFER_SIZE=16
|
||||
CONFIG_PROFILER_CONTEXT_SWITCH=y
|
Loading…
Add table
Add a link
Reference in a new issue