mm/tlfs: Count the backtrace overhead in mm_mallinfo_task

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2023-05-28 21:51:57 +08:00 committed by Petro Karashchenko
parent 313f79d55e
commit 590e968c5f

View file

@ -280,17 +280,10 @@ static void mallinfo_handler(FAR void *ptr, size_t size, int used,
static void mallinfo_task_handler(FAR void *ptr, size_t size, int used, static void mallinfo_task_handler(FAR void *ptr, size_t size, int used,
FAR void *user) FAR void *user)
{ {
#if CONFIG_MM_BACKTRACE >= 0
FAR struct memdump_backtrace_s *buf;
#endif
FAR struct mm_mallinfo_handler_s *handler = user; FAR struct mm_mallinfo_handler_s *handler = user;
FAR const struct malltask *task = handler->task; FAR const struct malltask *task = handler->task;
FAR struct mallinfo_task *info = handler->info; FAR struct mallinfo_task *info = handler->info;
#if CONFIG_MM_BACKTRACE >= 0
size -= sizeof(struct memdump_backtrace_s);
buf = ptr + size;
if (used) if (used)
{ {
#if CONFIG_MM_BACKTRACE < 0 #if CONFIG_MM_BACKTRACE < 0
@ -300,6 +293,9 @@ static void mallinfo_task_handler(FAR void *ptr, size_t size, int used,
info->uordblks += size; info->uordblks += size;
} }
#else #else
FAR struct memdump_backtrace_s *buf =
ptr + size - sizeof(struct memdump_backtrace_s);
if ((task->pid == PID_MM_ALLOC || task->pid == buf->pid || if ((task->pid == PID_MM_ALLOC || task->pid == buf->pid ||
(task->pid == PID_MM_LEAK && !!nxsched_get_tcb(buf->pid))) && (task->pid == PID_MM_LEAK && !!nxsched_get_tcb(buf->pid))) &&
buf->seqno >= task->seqmin && buf->seqno <= task->seqmax) buf->seqno >= task->seqmin && buf->seqno <= task->seqmax)
@ -314,7 +310,6 @@ static void mallinfo_task_handler(FAR void *ptr, size_t size, int used,
info->aordblks++; info->aordblks++;
info->uordblks += size; info->uordblks += size;
} }
#endif
} }
/**************************************************************************** /****************************************************************************
@ -404,18 +399,15 @@ static void memdump_handler(FAR void *ptr, size_t size, int used,
FAR void *user) FAR void *user)
{ {
FAR const struct mm_memdump_s *dump = user; FAR const struct mm_memdump_s *dump = user;
#if CONFIG_MM_BACKTRACE >= 0
FAR struct memdump_backtrace_s *buf;
size -= sizeof(struct memdump_backtrace_s);
buf = ptr + size;
#endif
if (used) if (used)
{ {
#if CONFIG_MM_BACKTRACE < 0 #if CONFIG_MM_BACKTRACE < 0
if (dump->pid == PID_MM_ALLOC) if (dump->pid == PID_MM_ALLOC)
#else #else
FAR struct memdump_backtrace_s *buf =
ptr + size - sizeof(struct memdump_backtrace_s);
if ((dump->pid == PID_MM_ALLOC || dump->pid == buf->pid) && if ((dump->pid == PID_MM_ALLOC || dump->pid == buf->pid) &&
buf->seqno >= dump->seqmin && buf->seqno <= dump->seqmax) buf->seqno >= dump->seqmin && buf->seqno <= dump->seqmax)
#endif #endif