mirror of
https://github.com/apache/nuttx.git
synced 2026-05-10 23:40:21 +08:00
note:support filter for each note channel
Signed-off-by: zhangwenjian <zhangwenjian@xiaomi.com>
This commit is contained in:
+259
-179
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg);
|
||||
static int notectl_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@@ -62,7 +62,7 @@ static const struct file_operations g_notectl_fops =
|
||||
* Name: notectl_ioctl
|
||||
****************************************************************************/
|
||||
|
||||
static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
static int notectl_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
int ret = -ENOSYS;
|
||||
|
||||
@@ -77,7 +77,8 @@ static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
case NOTECTL_GETMODE:
|
||||
{
|
||||
struct note_filter_mode_s *mode = (struct note_filter_mode_s *)arg;
|
||||
FAR struct note_filter_named_mode_s *mode =
|
||||
(FAR struct note_filter_named_mode_s *)arg;
|
||||
|
||||
if (mode == NULL)
|
||||
{
|
||||
@@ -98,7 +99,8 @@ static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
case NOTECTL_SETMODE:
|
||||
{
|
||||
struct note_filter_mode_s *mode = (struct note_filter_mode_s *)arg;
|
||||
FAR struct note_filter_named_mode_s *mode =
|
||||
(FAR struct note_filter_named_mode_s *)arg;
|
||||
|
||||
if (mode == NULL)
|
||||
{
|
||||
@@ -120,8 +122,8 @@ static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
case NOTECTL_GETSYSCALLFILTER:
|
||||
{
|
||||
struct note_filter_syscall_s *filter;
|
||||
filter = (struct note_filter_syscall_s *)arg;
|
||||
FAR struct note_filter_named_syscall_s *filter;
|
||||
filter = (FAR struct note_filter_named_syscall_s *)arg;
|
||||
|
||||
if (filter == NULL)
|
||||
{
|
||||
@@ -142,8 +144,8 @@ static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
case NOTECTL_SETSYSCALLFILTER:
|
||||
{
|
||||
struct note_filter_syscall_s *filter;
|
||||
filter = (struct note_filter_syscall_s *)arg;
|
||||
FAR struct note_filter_named_syscall_s *filter;
|
||||
filter = (FAR struct note_filter_named_syscall_s *)arg;
|
||||
|
||||
if (filter == NULL)
|
||||
{
|
||||
@@ -166,8 +168,8 @@ static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
case NOTECTL_GETIRQFILTER:
|
||||
{
|
||||
struct note_filter_irq_s *filter;
|
||||
filter = (struct note_filter_irq_s *)arg;
|
||||
FAR struct note_filter_named_irq_s *filter;
|
||||
filter = (FAR struct note_filter_named_irq_s *)arg;
|
||||
|
||||
if (filter == NULL)
|
||||
{
|
||||
@@ -189,8 +191,8 @@ static int notectl_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
case NOTECTL_SETIRQFILTER:
|
||||
{
|
||||
struct note_filter_irq_s *filter;
|
||||
filter = (struct note_filter_irq_s *)arg;
|
||||
FAR struct note_filter_named_irq_s *filter;
|
||||
filter = (FAR struct note_filter_named_irq_s *)arg;
|
||||
|
||||
if (filter == NULL)
|
||||
{
|
||||
|
||||
@@ -124,6 +124,17 @@ static const struct note_driver_ops_s g_notelog_ops =
|
||||
|
||||
struct note_driver_s g_notelog_driver =
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
"log",
|
||||
{
|
||||
{
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
|
||||
# ifdef CONFIG_SMP
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET
|
||||
# endif
|
||||
},
|
||||
},
|
||||
#endif
|
||||
&g_notelog_ops,
|
||||
};
|
||||
|
||||
|
||||
@@ -146,7 +146,20 @@ static const struct note_driver_ops_s g_noteram_ops =
|
||||
|
||||
struct noteram_driver_s g_noteram_driver =
|
||||
{
|
||||
{&g_noteram_ops},
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
"ram",
|
||||
{
|
||||
{
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
|
||||
# ifdef CONFIG_SMP
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET
|
||||
# endif
|
||||
},
|
||||
},
|
||||
#endif
|
||||
&g_noteram_ops
|
||||
},
|
||||
g_ramnote_buffer,
|
||||
CONFIG_DRIVERS_NOTERAM_BUFSIZE,
|
||||
#ifdef CONFIG_DRIVERS_NOTERAM_DEFAULT_NOOVERWRITE
|
||||
@@ -1339,17 +1352,35 @@ FAR struct note_driver_s *
|
||||
noteram_initialize(FAR const char *devpath, size_t bufsize, bool overwrite)
|
||||
{
|
||||
FAR struct noteram_driver_s *drv;
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
size_t len = strlen(devpath) + 1;
|
||||
#else
|
||||
size_t len = 0;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
drv = kmm_malloc(sizeof(*drv) + bufsize);
|
||||
drv = kmm_malloc(sizeof(*drv) + len + bufsize);
|
||||
if (drv == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
|
||||
memcpy(drv + 1, devpath, len);
|
||||
drv->driver.name = (FAR const char *)(drv + 1);
|
||||
drv->driver.filter.mode.flag =
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE;
|
||||
|
||||
# ifdef CONFIG_SMP
|
||||
drv->driver.filter.mode.cpuset =
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
drv->driver.ops = &g_noteram_ops;
|
||||
drv->ni_bufsize = bufsize;
|
||||
drv->ni_buffer = (FAR uint8_t *)(drv + 1);
|
||||
drv->ni_buffer = (FAR uint8_t *)(drv + 1) + len;
|
||||
drv->ni_overwrite = overwrite;
|
||||
drv->ni_head = 0;
|
||||
drv->ni_tail = 0;
|
||||
|
||||
@@ -67,7 +67,20 @@ static const struct note_driver_ops_s g_noterpmsg_ops =
|
||||
|
||||
struct noterpmsg_driver_s g_noterpmsg_driver =
|
||||
{
|
||||
{&g_noterpmsg_ops},
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
"rpmsg",
|
||||
{
|
||||
{
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
|
||||
# ifdef CONFIG_SMP
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET
|
||||
# endif
|
||||
},
|
||||
},
|
||||
#endif
|
||||
&g_noterpmsg_ops
|
||||
},
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -150,7 +150,20 @@ static const struct note_driver_ops_s g_notesnap_ops =
|
||||
|
||||
static struct notesnap_s g_notesnap =
|
||||
{
|
||||
{&g_notesnap_ops}
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
"snap",
|
||||
{
|
||||
{
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
|
||||
# ifdef CONFIG_SMP
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET
|
||||
# endif
|
||||
},
|
||||
},
|
||||
#endif
|
||||
&g_notesnap_ops
|
||||
}
|
||||
};
|
||||
|
||||
static FAR const char *g_notesnap_type[] =
|
||||
|
||||
@@ -65,6 +65,17 @@ static const struct note_driver_ops_s g_notestream_ops =
|
||||
struct notestream_driver_s g_notestream_lowerout =
|
||||
{
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
"lowerout",
|
||||
{
|
||||
{
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
|
||||
# ifdef CONFIG_SMP
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET
|
||||
# endif
|
||||
},
|
||||
},
|
||||
#endif
|
||||
&g_notestream_ops
|
||||
},
|
||||
&g_lowoutstream
|
||||
@@ -91,14 +102,32 @@ static void notestream_add(FAR struct note_driver_s *drv,
|
||||
int notefile_register(FAR const char *filename)
|
||||
{
|
||||
FAR struct notestream_file_s *notefile;
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
size_t len = strlen(filename) + 1;
|
||||
#else
|
||||
size_t len = 0;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
notefile = kmm_zalloc(sizeof(struct notestream_file_s));
|
||||
notefile = kmm_zalloc(sizeof(struct notestream_file_s) + len);
|
||||
if (notefile == NULL)
|
||||
{
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
memcpy(notefile + 1, filename, len);
|
||||
notefile->driver.driver.name = (FAR const char *)(notefile + 1);
|
||||
notefile->driver.driver.filter.mode.flag =
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE;
|
||||
|
||||
# ifdef CONFIG_SMP
|
||||
notefile->driver.driver.filter.mode.cpuset =
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
notefile->driver.stream = ¬efile->filestream.common;
|
||||
ret = file_open(¬efile->file, filename, O_WRONLY);
|
||||
if (ret < 0)
|
||||
|
||||
@@ -55,6 +55,17 @@ static const struct note_driver_ops_s g_notertt_ops =
|
||||
struct notertt_s g_notertt =
|
||||
{
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
"rtt",
|
||||
{
|
||||
{
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
|
||||
# ifdef CONFIG_SMP
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET
|
||||
# endif
|
||||
},
|
||||
},
|
||||
#endif
|
||||
&g_notertt_ops
|
||||
}
|
||||
};
|
||||
|
||||
@@ -45,9 +45,6 @@ struct note_sysview_driver_s
|
||||
{
|
||||
struct note_driver_s driver;
|
||||
unsigned int irq[CONFIG_SMP_NCPUS];
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
|
||||
struct note_filter_syscall_s syscall_marker;
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -144,6 +141,17 @@ static const struct note_driver_ops_s g_note_sysview_ops =
|
||||
static struct note_sysview_driver_s g_note_sysview_driver =
|
||||
{
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
"sysview",
|
||||
{
|
||||
{
|
||||
CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE,
|
||||
# ifdef CONFIG_SMP
|
||||
CONFIG_SCHED_INSTRUMENTATION_CPUSET
|
||||
# endif
|
||||
},
|
||||
},
|
||||
#endif
|
||||
&g_note_sysview_ops
|
||||
}
|
||||
};
|
||||
@@ -307,7 +315,8 @@ static void note_sysview_syscall_enter(FAR struct note_driver_s *drv, int nr,
|
||||
|
||||
/* Set the name marker if the current syscall nr is not active */
|
||||
|
||||
if (NOTE_FILTER_SYSCALLMASK_ISSET(nr, &driver->syscall_marker) == 0)
|
||||
if (NOTE_FILTER_SYSCALLMASK_ISSET(nr,
|
||||
&driver->driver.filter.syscall_mask) == 0)
|
||||
{
|
||||
/* Set the name marker */
|
||||
|
||||
@@ -315,16 +324,18 @@ static void note_sysview_syscall_enter(FAR struct note_driver_s *drv, int nr,
|
||||
|
||||
/* Mark the syscall active */
|
||||
|
||||
NOTE_FILTER_SYSCALLMASK_SET(nr, &driver->syscall_marker);
|
||||
NOTE_FILTER_SYSCALLMASK_SET(nr, &driver->driver.filter.syscall_mask);
|
||||
|
||||
/* Use the Syscall "0" to identify whether the syscall is enabled,
|
||||
* if the host tool is closed abnormally, use this bit to clear
|
||||
* the active set.
|
||||
*/
|
||||
|
||||
if (NOTE_FILTER_SYSCALLMASK_ISSET(0, &driver->syscall_marker) == 0)
|
||||
if (NOTE_FILTER_SYSCALLMASK_ISSET(0,
|
||||
&driver->driver.filter.syscall_mask) == 0)
|
||||
{
|
||||
NOTE_FILTER_SYSCALLMASK_SET(0, &driver->syscall_marker);
|
||||
NOTE_FILTER_SYSCALLMASK_SET(0,
|
||||
&driver->driver.filter.syscall_mask);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,7 +349,7 @@ static void note_sysview_syscall_leave(FAR struct note_driver_s *drv,
|
||||
(FAR struct note_sysview_driver_s *)drv;
|
||||
nr -= CONFIG_SYS_RESERVED;
|
||||
|
||||
if (NOTE_FILTER_SYSCALLMASK_ISSET(nr, &driver->syscall_marker) != 0)
|
||||
if (NOTE_FILTER_SYSCALLMASK_ISSET(nr, &driver->driver.filter.syscall_mask))
|
||||
{
|
||||
SEGGER_SYSVIEW_MarkStop(nr);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/sched_note.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@@ -108,8 +109,28 @@ struct note_driver_ops_s
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
struct note_filter_s
|
||||
{
|
||||
struct note_filter_mode_s mode;
|
||||
# ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP
|
||||
struct note_filter_tag_s tag_mask;
|
||||
# endif
|
||||
# ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
|
||||
struct note_filter_irq_s irq_mask;
|
||||
# endif
|
||||
# ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
|
||||
struct note_filter_syscall_s syscall_mask;
|
||||
# endif
|
||||
};
|
||||
#endif
|
||||
|
||||
struct note_driver_s
|
||||
{
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
FAR const char *name;
|
||||
struct note_filter_s filter;
|
||||
#endif
|
||||
FAR const struct note_driver_ops_s *ops;
|
||||
};
|
||||
|
||||
|
||||
@@ -517,6 +517,12 @@ struct note_filter_mode_s
|
||||
#endif
|
||||
};
|
||||
|
||||
struct note_filter_named_mode_s
|
||||
{
|
||||
char name[NAME_MAX];
|
||||
struct note_filter_mode_s mode;
|
||||
};
|
||||
|
||||
/* This is the type of the argument passed to the NOTECTL_GETSYSCALLFILTER
|
||||
* and NOTECTL_SETSYSCALLFILTER ioctls
|
||||
*/
|
||||
@@ -526,6 +532,12 @@ struct note_filter_syscall_s
|
||||
{
|
||||
uint8_t syscall_mask[(SYS_nsyscalls + 7) / 8];
|
||||
};
|
||||
|
||||
struct note_filter_named_syscall_s
|
||||
{
|
||||
char name[NAME_MAX];
|
||||
struct note_filter_syscall_s syscall_mask;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* This is the type of the argument passed to the NOTECTL_GETIRQFILTER and
|
||||
@@ -537,11 +549,23 @@ struct note_filter_irq_s
|
||||
uint8_t irq_mask[(NR_IRQS + 7) / 8];
|
||||
};
|
||||
|
||||
struct note_filter_named_irq_s
|
||||
{
|
||||
char name[NAME_MAX];
|
||||
struct note_filter_irq_s irq_mask;
|
||||
};
|
||||
|
||||
struct note_filter_tag_s
|
||||
{
|
||||
uint8_t tag_mask[(NOTE_TAG_MAX + 7) / 8];
|
||||
};
|
||||
|
||||
struct note_filter_named_tag_s
|
||||
{
|
||||
char name[NAME_MAX];
|
||||
struct note_filter_tag_s tag_mask;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
@@ -682,8 +706,8 @@ void sched_note_printf_ip(uint32_t tag, uintptr_t ip, FAR const char *fmt,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||
void sched_note_filter_mode(FAR struct note_filter_mode_s *oldm,
|
||||
FAR struct note_filter_mode_s *newm);
|
||||
void sched_note_filter_mode(FAR struct note_filter_named_mode_s *oldm,
|
||||
FAR struct note_filter_named_mode_s *newm);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@@ -708,8 +732,8 @@ void sched_note_filter_mode(FAR struct note_filter_mode_s *oldm,
|
||||
|
||||
#if defined(CONFIG_SCHED_INSTRUMENTATION_FILTER) && \
|
||||
defined(CONFIG_SCHED_INSTRUMENTATION_SYSCALL)
|
||||
void sched_note_filter_syscall(FAR struct note_filter_syscall_s *oldf,
|
||||
FAR struct note_filter_syscall_s *newf);
|
||||
void sched_note_filter_syscall(FAR struct note_filter_named_syscall_s *oldf,
|
||||
FAR struct note_filter_named_syscall_s *newf);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@@ -734,14 +758,14 @@ void sched_note_filter_syscall(FAR struct note_filter_syscall_s *oldf,
|
||||
|
||||
#if defined(CONFIG_SCHED_INSTRUMENTATION_FILTER) && \
|
||||
defined(CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER)
|
||||
void sched_note_filter_irq(FAR struct note_filter_irq_s *oldf,
|
||||
FAR struct note_filter_irq_s *newf);
|
||||
void sched_note_filter_irq(FAR struct note_filter_named_irq_s *oldf,
|
||||
FAR struct note_filter_named_irq_s *newf);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SCHED_INSTRUMENTATION_FILTER) && \
|
||||
defined(CONFIG_SCHED_INSTRUMENTATION_DUMP)
|
||||
void sched_note_filter_tag(FAR struct note_filter_tag_s *oldf,
|
||||
FAR struct note_filter_tag_s *newf);
|
||||
void sched_note_filter_tag(FAR struct note_filter_named_tag_s *oldf,
|
||||
FAR struct note_filter_named_tag_s *newf);
|
||||
#endif
|
||||
|
||||
#endif /* defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT) */
|
||||
|
||||
Reference in New Issue
Block a user