logger: include task monitor in kernel event logger
Zephyr includes a Task Monitor feature that allows to track events on the microkernel server scheduler. Task monitor is integrated as a profiler point for the Kernel Event Logger feature. Change-Id: I7b8be5872439a333f976eada1aa3511d93b46388 Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
This commit is contained in:
parent
e7cf19bf1e
commit
65ec185f79
|
@ -43,6 +43,12 @@ extern "C" {
|
|||
#define KERNEL_EVENT_LOGGER_SLEEP_EVENT_ID 0x0003
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TASK_MONITOR
|
||||
#define KERNEL_EVENT_LOGGER_TASK_MON_TASK_STATE_CHANGE_EVENT_ID 0x0004
|
||||
#define KERNEL_EVENT_LOGGER_TASK_MON_CMD_PACKET_EVENT_ID 0x0005
|
||||
#define KERNEL_EVENT_LOGGER_TASK_MON_KEVENT_EVENT_ID 0x0006
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Kernel Event Logger
|
||||
* @defgroup nanokernel_event_logger Kernel Event Logger
|
||||
|
|
|
@ -148,7 +148,7 @@ config TASK_MONITOR
|
|||
bool
|
||||
prompt "Task monitoring [EXPERIMENTAL]"
|
||||
default n
|
||||
depends on MICROKERNEL
|
||||
depends on MICROKERNEL && KERNEL_EVENT_LOGGER
|
||||
help
|
||||
This option instructs the kernel to record significant task
|
||||
activities. These can include: task switches, task state changes,
|
||||
|
|
|
@ -17,20 +17,10 @@
|
|||
*/
|
||||
|
||||
#include <micro_private.h>
|
||||
#include <microkernel/ticks.h>
|
||||
#include <drivers/system_timer.h>
|
||||
#include <toolchain.h>
|
||||
#include <sections.h>
|
||||
#include <misc/kernel_event_logger.h>
|
||||
|
||||
static struct k_mrec __noinit k_monitor_buff[CONFIG_TASK_MONITOR_CAPACITY];
|
||||
|
||||
static const int k_monitor_capacity = CONFIG_TASK_MONITOR_CAPACITY;
|
||||
const int _k_monitor_mask = CONFIG_TASK_MONITOR_MASK;
|
||||
|
||||
static struct k_mrec *k_monitor_wptr = k_monitor_buff;
|
||||
static int k_monitor_nrec;
|
||||
static int K_monitor_wind;
|
||||
|
||||
k_task_monitor_hook_t _k_task_switch_callback;
|
||||
|
||||
void task_monitor_hook_set(k_task_monitor_hook_t func)
|
||||
|
@ -40,22 +30,17 @@ void task_monitor_hook_set(k_task_monitor_hook_t func)
|
|||
|
||||
void _k_task_monitor(struct k_task *X, uint32_t D)
|
||||
{
|
||||
uint32_t data[3];
|
||||
#ifdef CONFIG_TASK_DEBUG
|
||||
if (!_k_debug_halt)
|
||||
#endif
|
||||
{
|
||||
k_monitor_wptr->time = sys_cycle_get_32();
|
||||
k_monitor_wptr->data1 = X->id;
|
||||
k_monitor_wptr->data2 = D;
|
||||
if (++K_monitor_wind == k_monitor_capacity) {
|
||||
K_monitor_wind = 0;
|
||||
k_monitor_wptr = k_monitor_buff;
|
||||
} else {
|
||||
++k_monitor_wptr;
|
||||
}
|
||||
if (k_monitor_nrec < k_monitor_capacity) {
|
||||
k_monitor_nrec++;
|
||||
}
|
||||
data[0] = sys_cycle_get_32();
|
||||
data[1] = X->id;
|
||||
data[2] = D;
|
||||
sys_k_event_logger_put(
|
||||
KERNEL_EVENT_LOGGER_TASK_MON_TASK_STATE_CHANGE_EVENT_ID,
|
||||
data, ARRAY_SIZE(data));
|
||||
}
|
||||
if ((_k_task_switch_callback != NULL) && (D == 0)) {
|
||||
(_k_task_switch_callback)(X->id, sys_cycle_get_32());
|
||||
|
@ -69,41 +54,25 @@ void _k_task_monitor_args(struct k_args *A)
|
|||
#endif
|
||||
{
|
||||
int cmd_type;
|
||||
|
||||
k_monitor_wptr->time = sys_cycle_get_32();
|
||||
cmd_type = (int)A & KERNEL_CMD_TYPE_MASK;
|
||||
|
||||
if (cmd_type == KERNEL_CMD_EVENT_TYPE) {
|
||||
k_monitor_wptr->data2 = MO_EVENT | (uint32_t)A;
|
||||
k_monitor_wptr->ptr = (void *)0;
|
||||
} else {
|
||||
k_monitor_wptr->data1 = _k_current_task->id;
|
||||
k_monitor_wptr->data2 = MO_LCOMM;
|
||||
k_monitor_wptr->ptr = A->Comm;
|
||||
}
|
||||
uint32_t data[2];
|
||||
|
||||
if (++K_monitor_wind == k_monitor_capacity) {
|
||||
K_monitor_wind = 0;
|
||||
k_monitor_wptr = k_monitor_buff;
|
||||
data[0] = sys_cycle_get_32();
|
||||
data[1] = MO_EVENT | (uint32_t)A;
|
||||
sys_k_event_logger_put(
|
||||
KERNEL_EVENT_LOGGER_TASK_MON_KEVENT_EVENT_ID,
|
||||
data, ARRAY_SIZE(data));
|
||||
} else {
|
||||
++k_monitor_wptr;
|
||||
}
|
||||
uint32_t data[3];
|
||||
|
||||
if (k_monitor_nrec < k_monitor_capacity) {
|
||||
k_monitor_nrec++;
|
||||
data[0] = sys_cycle_get_32();
|
||||
data[1] = _k_current_task->id;
|
||||
data[2] = (uint32_t)A->Comm;
|
||||
sys_k_event_logger_put(
|
||||
KERNEL_EVENT_LOGGER_TASK_MON_CMD_PACKET_EVENT_ID,
|
||||
data, ARRAY_SIZE(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _k_task_monitor_read(struct k_args *A)
|
||||
{
|
||||
A->args.z4.nrec = k_monitor_nrec;
|
||||
if (A->args.z4.rind < k_monitor_nrec) {
|
||||
int i = K_monitor_wind - k_monitor_nrec + A->args.z4.rind;
|
||||
|
||||
if (i < 0) {
|
||||
i += k_monitor_capacity;
|
||||
}
|
||||
A->args.z4.mrec = k_monitor_buff[i];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue