note: Move the instrument register to note_initialize

avoid the instrument doesn't get registered in some case

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
cuiziwei
2023-12-05 20:15:48 +08:00
committed by Xiang Xiao
parent 7246533aeb
commit 19851c0979
2 changed files with 50 additions and 40 deletions
+50
View File
@@ -24,6 +24,7 @@
#include <debug.h>
#include <nuttx/instrument.h>
#include <nuttx/note/note_driver.h>
#include <nuttx/note/noteram_driver.h>
#include <nuttx/note/notectl_driver.h>
@@ -34,6 +35,51 @@
#include "noterpmsg.h"
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION
static void note_driver_instrument_enter(FAR void *this_fn,
FAR void *call_site, FAR void *arg) noinstrument_function;
static void note_driver_instrument_leave(FAR void *this_fn,
FAR void *call_site, FAR void *arg) noinstrument_function;
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION
static void note_driver_instrument_enter(FAR void *this_fn,
FAR void *call_site,
FAR void *arg)
{
sched_note_event_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn,
NOTE_DUMP_BEGIN, NULL, 0);
}
static void note_driver_instrument_leave(FAR void *this_fn,
FAR void *call_site,
FAR void *arg)
{
sched_note_event_ip(NOTE_TAG_ALWAYS, (uintptr_t)this_fn,
NOTE_DUMP_END, NULL, 0);
}
#endif
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION
static struct instrument_s g_note_instrument =
{
.enter = note_driver_instrument_enter,
.leave = note_driver_instrument_leave,
};
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -97,6 +143,10 @@ int note_initialize(void)
{
int ret = 0;
#ifdef CONFIG_SCHED_INSTRUMENTATION_FUNCTION
instrument_register(&g_note_instrument);
#endif
#ifdef CONFIG_DRIVERS_NOTERAM
ret = noteram_register();
if (ret < 0)