Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#
# CONFIG_ARCH_FPU is not set
# CONFIG_DRIVERS_NOTERAM is not set
# CONFIG_SERIAL_RTT_CONSOLE is not set
# CONFIG_STANDARD_SERIAL is not set
# CONFIG_STM32_FLASH_PREFETCH is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="stm32f429i-disco"
Expand Down Expand Up @@ -41,6 +43,7 @@ CONFIG_SCHED_INSTRUMENTATION=y
CONFIG_SCHED_INSTRUMENTATION_HEAP=y
CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER=y
CONFIG_SCHED_INSTRUMENTATION_SWITCH=y
CONFIG_SCHED_INSTRUMENTATION_WDOG=y
CONFIG_SEGGER_SYSVIEW=y
CONFIG_SERIAL_RTT0=y
CONFIG_SPI=y
Expand All @@ -52,8 +55,10 @@ CONFIG_STM32_EXTERNAL_RAM=y
CONFIG_STM32_FMC=y
CONFIG_STM32_JTAG_SW_ENABLE=y
CONFIG_STM32_PWR=y
CONFIG_STM32_USART1=y
CONFIG_SYSLOG_CHAR=y
CONFIG_SYSLOG_RTT=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_SYSTEM=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART1_SERIAL_CONSOLE=y
39 changes: 38 additions & 1 deletion drivers/note/note_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
((drv)->ops->irqhandler(drv, irq, handler, enter), true))
#define note_heap(drv, event, data, mem, size, used) \
((drv)->ops->heap && ((drv)->ops->heap(drv, event, data, mem, size, used), true))
#define note_wdog(drv, event, handler, arg) \
((drv)->ops->wdog && ((drv)->ops->wdog(drv, event, handler, arg), true))
#define note_string(drv, ip, buf) \
((drv)->ops->string && ((drv)->ops->string(drv, ip, buf), true))
#define note_event(drv, ip, event, buf, len) \
Expand Down Expand Up @@ -1358,6 +1360,41 @@ void sched_note_irqhandler(int irq, FAR void *handler, bool enter)
}
#endif

#ifdef CONFIG_SCHED_INSTRUMENTATION_WDOG
void sched_note_wdog(uint8_t event, FAR void *handler, FAR const void *arg)
{
FAR struct note_driver_s **driver;
struct note_wdog_s note;
bool formatted = false;
FAR struct tcb_s *tcb = this_task();

for (driver = g_note_drivers; *driver; driver++)
{
if (note_wdog(*driver, event, handler, arg))
{
continue;
}

if ((*driver)->ops->add == NULL)
{
continue;
}

if (!formatted)
{
formatted = true;
note_common(tcb, &note.nwd_cmn, sizeof(note), event);
note.handler = (uintptr_t)handler;
note.arg = (uintptr_t)arg;
}

/* Add the note to circular buffer */

note_add(*driver, &note, sizeof(note));
}
}
#endif

#ifdef CONFIG_SCHED_INSTRUMENTATION_HEAP
void sched_note_heap(uint8_t event, FAR void *heap, FAR void *mem,
size_t size, size_t used)
Expand Down Expand Up @@ -1389,7 +1426,7 @@ void sched_note_heap(uint8_t event, FAR void *heap, FAR void *mem,
if (!formatted)
{
formatted = true;
note_common(tcb, &note.nmm_cmn, sizeof(note), event);
note_common(tcb, &note.nhp_cmn, sizeof(note), event);
note.heap = heap;
note.mem = mem;
note.size = size;
Expand Down
23 changes: 22 additions & 1 deletion drivers/note/noteram_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,27 @@ static int noteram_dump_one(FAR uint8_t *p, FAR struct lib_outstream_s *s,
break;
#endif

#ifdef CONFIG_SCHED_INSTRUMENTATION_WDOG
case NOTE_WDOG_START:
case NOTE_WDOG_CANCEL:
case NOTE_WDOG_ENTER:
case NOTE_WDOG_LEAVE:
{
FAR struct note_wdog_s *nw;
FAR const char *name[] =
{
"start", "cancel", "enter", "leave",
};

nw = (FAR struct note_wdog_s *)p;
ret += noteram_dump_header(s, note, ctx);
ret += lib_sprintf(s, "tracing_mark_write: I|%d|wdog: %s-%pS %p\n",
pid, name[note->nc_type - NOTE_WDOG_START],
(FAR void *)nw->handler, (FAR void *)nw->arg);
}
break;
#endif

#ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION
case NOTE_CSECTION_ENTER:
case NOTE_CSECTION_LEAVE:
Expand Down Expand Up @@ -1031,7 +1052,7 @@ static int noteram_dump_one(FAR uint8_t *p, FAR struct lib_outstream_s *s,
"add", "remove", "malloc", "free"
};

ret += noteram_dump_header(s, &nmm->nmm_cmn, ctx);
ret += noteram_dump_header(s, &nmm->nhp_cmn, ctx);
ret += lib_sprintf(s, "tracing_mark_write: C|%d|Heap Usage|%d|%s"
": heap: %p size:%" PRIiPTR ", address: %p\n",
pid, nmm->used,
Expand Down
22 changes: 22 additions & 0 deletions drivers/segger/note_sysview.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ static void note_sysview_heap(FAR struct note_driver_s *drv,
uint8_t event, FAR void *heap, FAR void *mem,
size_t size, size_t curused);
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_WDOG
static void note_sysview_wdog(FAR struct note_driver_s *drv, uint8_t event,
FAR void *handler, FAR const void *arg);
#endif

/****************************************************************************
* Private Data
Expand Down Expand Up @@ -119,6 +123,9 @@ static const struct note_driver_ops_s g_note_sysview_ops =
#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
note_sysview_irqhandler, /* irqhandler */
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_WDOG
note_sysview_wdog, /* wdog */
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_HEAP
note_sysview_heap, /* heap */
#endif
Expand Down Expand Up @@ -386,6 +393,21 @@ static void note_sysview_heap(FAR struct note_driver_s *drv,
}
#endif

#ifdef CONFIG_SCHED_INSTRUMENTATION_WDOG
static void note_sysview_wdog(FAR struct note_driver_s *drv, uint8_t event,
FAR void *handler, FAR const void *arg)
{
if (event == NOTE_WDOG_ENTER)
{
SEGGER_SYSVIEW_RecordEnterTimer((uintptr_t)handler);
}
else if (event == NOTE_WDOG_LEAVE)
{
SEGGER_SYSVIEW_RecordExitTimer();
}
}
#endif

/****************************************************************************
* Public Functions
****************************************************************************/
Expand Down
4 changes: 4 additions & 0 deletions include/nuttx/note/note_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ struct note_driver_ops_s
CODE void (*irqhandler)(FAR struct note_driver_s *drv, int irq,
FAR void *handler, bool enter);
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_WDOG
CODE void (*wdog)(FAR struct note_driver_s *drv, uint8_t event,
FAR void *handler, FAR const void *arg);
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION_HEAP
CODE void (*heap)(FAR struct note_driver_s *drv, uint8_t event,
FAR void *heap, FAR void *mem, size_t size,
Expand Down
19 changes: 18 additions & 1 deletion include/nuttx/sched_note.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ enum note_type_e
NOTE_SYSCALL_LEAVE,
NOTE_IRQ_ENTER,
NOTE_IRQ_LEAVE,
NOTE_WDOG_START,
NOTE_WDOG_CANCEL,
NOTE_WDOG_ENTER,
NOTE_WDOG_LEAVE,
NOTE_HEAP_ADD,
NOTE_HEAP_REMOVE,
NOTE_HEAP_ALLOC,
Expand Down Expand Up @@ -386,9 +390,16 @@ struct note_irqhandler_s
uint8_t nih_irq; /* IRQ number */
};

struct note_wdog_s
{
struct note_common_s nwd_cmn; /* Common note parameters */
uintptr_t handler;
uintptr_t arg;
};

struct note_heap_s
{
struct note_common_s nmm_cmn; /* Common note parameters */
struct note_common_s nhp_cmn; /* Common note parameters */
FAR void *heap;
FAR void *mem;
size_t size;
Expand Down Expand Up @@ -557,6 +568,12 @@ void sched_note_irqhandler(int irq, FAR void *handler, bool enter);
# define sched_note_irqhandler(i,h,e)
#endif

#ifdef CONFIG_SCHED_INSTRUMENTATION_WDOG
void sched_note_wdog(uint8_t event, FAR void *handler, FAR const void *arg);
#else
# define sched_note_wdog(e,h,a)
#endif

#ifdef CONFIG_SCHED_INSTRUMENTATION_HEAP
void sched_note_heap(uint8_t event, FAR void *heap, FAR void *mem,
size_t size, size_t used);
Expand Down
8 changes: 8 additions & 0 deletions sched/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,14 @@ config SCHED_INSTRUMENTATION_HEAP

void sched_note_heap(uint8_t event, FAR void* heap, FAR void *mem, size_t size, size_t curused);

config SCHED_INSTRUMENTATION_WDOG
bool "Watchdog timer monitor hooks"
default n
---help---
Enables additional hooks for watchdog timer.

void sched_note_wdog(uint8_t event, FAR void *handler, FAR const void *arg);

config SCHED_INSTRUMENTATION_DUMP
bool "Use note dump for instrumentation"
default n
Expand Down
4 changes: 4 additions & 0 deletions sched/wdog/wd_cancel.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/wdog.h>
#include <nuttx/sched_note.h>

#include "sched/sched.h"
#include "wdog/wdog.h"
Expand Down Expand Up @@ -95,6 +96,9 @@ int wd_cancel_irq(FAR struct wdog_s *wdog)
return -EINVAL;
}

sched_note_wdog(NOTE_WDOG_CANCEL, (FAR void *)wdog->func,
(FAR void *)(uintptr_t)wdog->expired);

/* Prohibit timer interactions with the timer queue until the
* cancellation is complete
*/
Expand Down
15 changes: 14 additions & 1 deletion sched/wdog/wd_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/wdog.h>
#include <nuttx/sched_note.h>

#include "sched/sched.h"
#include "wdog/wdog.h"
Expand All @@ -56,9 +57,11 @@
{ \
clock_t start; \
clock_t elapsed; \
sched_note_wdog(NOTE_WDOG_ENTER, func, (FAR void *)arg); \
start = perf_gettime(); \
func(arg); \
elapsed = perf_gettime() - start; \
sched_note_wdog(NOTE_WDOG_LEAVE, func, (FAR void *)arg); \
if (elapsed > CONFIG_SCHED_CRITMONITOR_MAXTIME_WDOG) \
{ \
CRITMONITOR_PANIC("WDOG %p, %s IRQ, execute too long %ju\n", \
Expand All @@ -68,7 +71,15 @@
} \
while (0)
#else
# define CALL_FUNC(func, arg) func(arg)
# define CALL_FUNC(func, arg) \
do \
{ \
sched_note_wdog(NOTE_WDOG_ENTER, func, (FAR void *)arg); \
func(arg); \
sched_note_wdog(NOTE_WDOG_LEAVE, func, (FAR void *)arg); \
} \
while (0)

#endif

/****************************************************************************
Expand Down Expand Up @@ -319,6 +330,8 @@ int wd_start_abstick(FAR struct wdog_s *wdog, clock_t ticks,
wd_insert(wdog, ticks, wdentry, arg);
#endif
leave_critical_section(flags);

sched_note_wdog(NOTE_WDOG_START, wdentry, (FAR void *)(uintptr_t)ticks);
return OK;
}

Expand Down