sched/note: add support of trace section mark
The implementation of this feature is based on android systrace: https://source.android.com/devices/tech/debug/ftrace Application developers are more concerned about the performance of the specified application section, added two APIs to implement performance measurement: void sched_note_begin(FAR const char *str); void sched_note_end(FAR const char *str); or SCHED_NOTE_BEGIN(); /* defined to sched_note_begin(__FUNCTION__) */ SCHED_NOTE_END(); /* defined to sched_note_end(__FUNCTION__) */ Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
f4a41c6ed4
commit
124c1328a6
@ -142,10 +142,22 @@ static int trace_cmd_start(int index, int argc, FAR char **argv,
|
|||||||
static int trace_cmd_dump(int index, int argc, FAR char **argv,
|
static int trace_cmd_dump(int index, int argc, FAR char **argv,
|
||||||
int notectlfd)
|
int notectlfd)
|
||||||
{
|
{
|
||||||
|
trace_dump_t type = TRACE_TYPE_LTTNG_KERNEL;
|
||||||
FAR FILE *out = stdout;
|
FAR FILE *out = stdout;
|
||||||
int ret;
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bool cont = false;
|
bool cont = false;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Usage: trace dump [-a] "Custom Format : Android SysTrace" */
|
||||||
|
|
||||||
|
if (index < argc)
|
||||||
|
{
|
||||||
|
if (strcmp(argv[index], "-a") == 0)
|
||||||
|
{
|
||||||
|
index++;
|
||||||
|
type = TRACE_TYPE_ANDROID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Usage: trace dump [-c][<filename>] */
|
/* Usage: trace dump [-c][<filename>] */
|
||||||
|
|
||||||
@ -189,7 +201,7 @@ static int trace_cmd_dump(int index, int argc, FAR char **argv,
|
|||||||
|
|
||||||
/* Dump the trace data */
|
/* Dump the trace data */
|
||||||
|
|
||||||
ret = trace_dump(out);
|
ret = trace_dump(type, out);
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
@ -788,8 +800,9 @@ static void show_usage(void)
|
|||||||
" Get the trace while running <command>\n"
|
" Get the trace while running <command>\n"
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_DRIVER_NOTERAM
|
#ifdef CONFIG_DRIVER_NOTERAM
|
||||||
" dump [-c][<filename>] :"
|
" dump [-a][-c][<filename>] :"
|
||||||
" Output the trace result\n"
|
" Output the trace result\n"
|
||||||
|
" [-a] <Android SysTrace>\n"
|
||||||
#endif
|
#endif
|
||||||
" mode [{+|-}{o|w|s|a|i|d}...] :"
|
" mode [{+|-}{o|w|s|a|i|d}...] :"
|
||||||
" Set task trace options\n"
|
" Set task trace options\n"
|
||||||
|
@ -37,6 +37,20 @@ extern "C"
|
|||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
TRACE_TYPE_LTTNG_KERNEL = 0, /* Common Trace Format : Linux Kernel Trace */
|
||||||
|
TRACE_TYPE_GENERIC_CTF = 1, /* Common Trace Format : Generic CTF Trace */
|
||||||
|
TRACE_TYPE_LTTNG_UST = 2, /* Common Trace Format : LTTng UST Trace */
|
||||||
|
TRACE_TYPE_CUSTOM_TEXT = 3, /* Custom Text : TmfGeneric */
|
||||||
|
TRACE_TYPE_CUSTOM_XML = 4, /* Custom XML : Custom XML Log */
|
||||||
|
TRACE_TYPE_ANDROID = 5, /* Custom Format : Android ATrace */
|
||||||
|
} trace_dump_t;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -51,7 +65,7 @@ extern "C"
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int trace_dump(FAR FILE *out);
|
int trace_dump(trace_dump_t type, FAR FILE *out);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: trace_dump_clear
|
* Name: trace_dump_clear
|
||||||
@ -85,7 +99,7 @@ void trace_dump_set_overwrite(bool mode);
|
|||||||
|
|
||||||
#else /* CONFIG_DRIVER_NOTERAM */
|
#else /* CONFIG_DRIVER_NOTERAM */
|
||||||
|
|
||||||
#define trace_dump(out)
|
#define trace_dump(type,out)
|
||||||
#define trace_dump_clear()
|
#define trace_dump_clear()
|
||||||
#define trace_dump_get_overwrite() 0
|
#define trace_dump_get_overwrite() 0
|
||||||
#define trace_dump_set_overwrite(mode) (void)(mode)
|
#define trace_dump_set_overwrite(mode) (void)(mode)
|
||||||
|
@ -381,8 +381,7 @@ static void trace_dump_sched_switch(FAR FILE *out,
|
|||||||
* Name: trace_dump_one
|
* Name: trace_dump_one
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int trace_dump_one(FAR FILE *out,
|
static int trace_dump_one(trace_dump_t type, FAR FILE *out, FAR uint8_t *p,
|
||||||
FAR uint8_t *p,
|
|
||||||
FAR struct trace_dump_context_s *ctx)
|
FAR struct trace_dump_context_s *ctx)
|
||||||
{
|
{
|
||||||
FAR struct note_common_s *note = (FAR struct note_common_s *)p;
|
FAR struct note_common_s *note = (FAR struct note_common_s *)p;
|
||||||
@ -520,8 +519,16 @@ static int trace_dump_one(FAR FILE *out,
|
|||||||
}
|
}
|
||||||
|
|
||||||
trace_dump_header(out, note, ctx);
|
trace_dump_header(out, note, ctx);
|
||||||
fprintf(out, "sys_%s(",
|
if (type == TRACE_TYPE_ANDROID)
|
||||||
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED]);
|
{
|
||||||
|
fprintf(out, "tracing_mark_write: B|%d|sys_%s(",
|
||||||
|
pid, g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(out, "sys_%s(",
|
||||||
|
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED]);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = j = 0; i < nsc->nsc_argc; i++)
|
for (i = j = 0; i < nsc->nsc_argc; i++)
|
||||||
{
|
{
|
||||||
@ -578,9 +585,20 @@ static int trace_dump_one(FAR FILE *out,
|
|||||||
|
|
||||||
trace_dump_header(out, note, ctx);
|
trace_dump_header(out, note, ctx);
|
||||||
trace_dump_unflatten(&result, nsc->nsc_result, sizeof(result));
|
trace_dump_unflatten(&result, nsc->nsc_result, sizeof(result));
|
||||||
fprintf(out, "sys_%s -> 0x%" PRIxPTR "\n",
|
|
||||||
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED],
|
if (type == TRACE_TYPE_ANDROID)
|
||||||
result);
|
{
|
||||||
|
fprintf(out, "tracing_mark_write: E|%d|"
|
||||||
|
"sys_%s -> 0x%" PRIxPTR "\n", pid,
|
||||||
|
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED],
|
||||||
|
result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(out, "sys_%s -> 0x%" PRIxPTR "\n",
|
||||||
|
g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED],
|
||||||
|
result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@ -632,7 +650,18 @@ static int trace_dump_one(FAR FILE *out,
|
|||||||
nst = (FAR struct note_string_s *)p;
|
nst = (FAR struct note_string_s *)p;
|
||||||
trace_dump_header(out, note, ctx);
|
trace_dump_header(out, note, ctx);
|
||||||
trace_dump_unflatten(&ip, nst->nst_ip, sizeof(ip));
|
trace_dump_unflatten(&ip, nst->nst_ip, sizeof(ip));
|
||||||
fprintf(out, "0x%" PRIdPTR ": %s\n", ip, nst->nst_data);
|
|
||||||
|
if (type == TRACE_TYPE_ANDROID &&
|
||||||
|
strlen(nst->nst_data) > 2 &&
|
||||||
|
(memcmp(nst->nst_data, "B|", 2) == 0 ||
|
||||||
|
memcmp(nst->nst_data, "E|", 2) == 0))
|
||||||
|
{
|
||||||
|
fprintf(out, "tracing_mark_write: %s\n", nst->nst_data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(out, "0x%" PRIdPTR ": %s\n", ip, nst->nst_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -684,7 +713,7 @@ static int trace_dump_one(FAR FILE *out,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int trace_dump(FAR FILE *out)
|
int trace_dump(trace_dump_t type, FAR FILE *out)
|
||||||
{
|
{
|
||||||
struct trace_dump_context_s ctx;
|
struct trace_dump_context_s ctx;
|
||||||
uint8_t tracedata[UCHAR_MAX];
|
uint8_t tracedata[UCHAR_MAX];
|
||||||
@ -718,7 +747,7 @@ int trace_dump(FAR FILE *out)
|
|||||||
p = tracedata;
|
p = tracedata;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
size = trace_dump_one(out, p, &ctx);
|
size = trace_dump_one(type, out, p, &ctx);
|
||||||
p += size;
|
p += size;
|
||||||
ret -= size;
|
ret -= size;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user