mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
Add note_syscall args support
This commit is contained in:
committed by
Xiang Xiao
parent
897b61b057
commit
87a7c0317e
@@ -69,6 +69,9 @@
|
|||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
|
||||||
#define NOTE_FILTER_MODE_FLAG_IRQ (1 << 2) /* Enable IRQ instrumentaiton */
|
#define NOTE_FILTER_MODE_FLAG_IRQ (1 << 2) /* Enable IRQ instrumentaiton */
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
|
||||||
|
#define NOTE_FILTER_MODE_FLAG_SYSCALL_ARGS (1 << 3) /* Enable collecting syscall arguments */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Helper macros for syscall instrumentation filter */
|
/* Helper macros for syscall instrumentation filter */
|
||||||
|
|
||||||
@@ -278,10 +281,17 @@ struct note_spinlock_s
|
|||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
|
||||||
/* This is the specific form of the NOTE_SYSCALL_ENTER/LEAVE notes */
|
/* This is the specific form of the NOTE_SYSCALL_ENTER/LEAVE notes */
|
||||||
|
|
||||||
|
#define MAX_SYSCALL_ARGS 6
|
||||||
|
#define SIZEOF_NOTE_SYSCALL_ENTER(n) (sizeof(struct note_common_s) + \
|
||||||
|
sizeof(uint8_t) + sizeof(uint8_t) + \
|
||||||
|
(sizeof(uintptr_t) * (n)))
|
||||||
|
|
||||||
struct note_syscall_enter_s
|
struct note_syscall_enter_s
|
||||||
{
|
{
|
||||||
struct note_common_s nsc_cmn; /* Common note parameters */
|
struct note_common_s nsc_cmn; /* Common note parameters */
|
||||||
uint8_t nsc_nr; /* System call number */
|
uint8_t nsc_nr; /* System call number */
|
||||||
|
uint8_t nsc_argc; /* Number of system call arguments */
|
||||||
|
uint8_t nsc_args[sizeof(uintptr_t) * MAX_SYSCALL_ARGS]; /* System call arguments */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct note_syscall_leave_s
|
struct note_syscall_leave_s
|
||||||
|
|||||||
+2
-1
@@ -1003,12 +1003,13 @@ config SCHED_INSTRUMENTATION_FILTER
|
|||||||
config SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE
|
config SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE
|
||||||
hex "Default instrumentation filter mode"
|
hex "Default instrumentation filter mode"
|
||||||
depends on SCHED_INSTRUMENTATION_FILTER
|
depends on SCHED_INSTRUMENTATION_FILTER
|
||||||
default 0x7
|
default 0xf
|
||||||
---help---
|
---help---
|
||||||
Default mode of the instrumentation filter logic.
|
Default mode of the instrumentation filter logic.
|
||||||
Bit 0 = Enable instrumentation
|
Bit 0 = Enable instrumentation
|
||||||
Bit 1 = Enable syscall instrumentation
|
Bit 1 = Enable syscall instrumentation
|
||||||
Bit 2 = Enable IRQ instrumentation
|
Bit 2 = Enable IRQ instrumentation
|
||||||
|
Bit 3 = Enable collecting syscall arguments
|
||||||
|
|
||||||
endif # SCHED_INSTRUMENTATION
|
endif # SCHED_INSTRUMENTATION
|
||||||
endmenu # Performance Monitoring
|
endmenu # Performance Monitoring
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -651,22 +652,60 @@ void sched_note_syscall_enter(int nr, int argc, ...)
|
|||||||
{
|
{
|
||||||
struct note_syscall_enter_s note;
|
struct note_syscall_enter_s note;
|
||||||
FAR struct tcb_s *tcb = this_task();
|
FAR struct tcb_s *tcb = this_task();
|
||||||
|
unsigned int length;
|
||||||
|
va_list ap;
|
||||||
|
uintptr_t arg;
|
||||||
|
int i;
|
||||||
|
uint8_t *args;
|
||||||
|
|
||||||
if (!note_isenabled_syscall(nr))
|
if (!note_isenabled_syscall(nr))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_FILTER
|
||||||
|
if (!(g_note_filter.mode.flag & NOTE_FILTER_MODE_FLAG_SYSCALL_ARGS))
|
||||||
|
{
|
||||||
|
argc = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Format the note */
|
/* Format the note */
|
||||||
|
|
||||||
note_common(tcb, ¬e.nsc_cmn, sizeof(struct note_syscall_enter_s),
|
length = SIZEOF_NOTE_SYSCALL_ENTER(argc);
|
||||||
NOTE_SYSCALL_ENTER);
|
note_common(tcb, ¬e.nsc_cmn, length, NOTE_SYSCALL_ENTER);
|
||||||
DEBUGASSERT(nr <= UCHAR_MAX);
|
DEBUGASSERT(nr <= UCHAR_MAX);
|
||||||
note.nsc_nr = nr;
|
note.nsc_nr = nr;
|
||||||
|
DEBUGASSERT(argc <= MAX_SYSCALL_ARGS);
|
||||||
|
note.nsc_argc = argc;
|
||||||
|
|
||||||
|
/* If needed, retrieve the given syscall arguments */
|
||||||
|
|
||||||
|
va_start(ap, argc);
|
||||||
|
|
||||||
|
args = note.nsc_args;
|
||||||
|
for (i = 0; i < argc; i++)
|
||||||
|
{
|
||||||
|
arg = (uintptr_t)va_arg(ap, uintptr_t);
|
||||||
|
*args++ = (uint8_t)(arg & 0xff);
|
||||||
|
*args++ = (uint8_t)((arg >> 8) & 0xff);
|
||||||
|
#if UINTPTR_MAX > UINT16_MAX
|
||||||
|
*args++ = (uint8_t)((arg >> 16) & 0xff);
|
||||||
|
*args++ = (uint8_t)((arg >> 24) & 0xff);
|
||||||
|
#if UINTPTR_MAX > UINT32_MAX
|
||||||
|
*args++ = (uint8_t)((arg >> 32) & 0xff);
|
||||||
|
*args++ = (uint8_t)((arg >> 40) & 0xff);
|
||||||
|
*args++ = (uint8_t)((arg >> 48) & 0xff);
|
||||||
|
*args++ = (uint8_t)((arg >> 56) & 0xff);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
/* Add the note to circular buffer */
|
/* Add the note to circular buffer */
|
||||||
|
|
||||||
sched_note_add(¬e, sizeof(struct note_syscall_enter_s));
|
sched_note_add((FAR const uint8_t *)¬e, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sched_note_syscall_leave(int nr, uintptr_t result)
|
void sched_note_syscall_leave(int nr, uintptr_t result)
|
||||||
|
|||||||
Reference in New Issue
Block a user