From 590e968c5ff80c3d05a4009d377521201cbab253 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 28 May 2023 21:51:57 +0800 Subject: [PATCH] mm/tlfs: Count the backtrace overhead in mm_mallinfo_task Signed-off-by: Xiang Xiao --- mm/tlsf/mm_tlsf.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/mm/tlsf/mm_tlsf.c b/mm/tlsf/mm_tlsf.c index 5c66f26dea..a978027326 100644 --- a/mm/tlsf/mm_tlsf.c +++ b/mm/tlsf/mm_tlsf.c @@ -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, FAR void *user) { -#if CONFIG_MM_BACKTRACE >= 0 - FAR struct memdump_backtrace_s *buf; -#endif FAR struct mm_mallinfo_handler_s *handler = user; FAR const struct malltask *task = handler->task; FAR struct mallinfo_task *info = handler->info; -#if CONFIG_MM_BACKTRACE >= 0 - size -= sizeof(struct memdump_backtrace_s); - buf = ptr + size; - if (used) { #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; } #else + FAR struct memdump_backtrace_s *buf = + ptr + size - sizeof(struct memdump_backtrace_s); + if ((task->pid == PID_MM_ALLOC || task->pid == buf->pid || (task->pid == PID_MM_LEAK && !!nxsched_get_tcb(buf->pid))) && 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->uordblks += size; } -#endif } /**************************************************************************** @@ -404,18 +399,15 @@ static void memdump_handler(FAR void *ptr, size_t size, int used, FAR void *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 CONFIG_MM_BACKTRACE < 0 if (dump->pid == PID_MM_ALLOC) #else + FAR struct memdump_backtrace_s *buf = + ptr + size - sizeof(struct memdump_backtrace_s); + if ((dump->pid == PID_MM_ALLOC || dump->pid == buf->pid) && buf->seqno >= dump->seqmin && buf->seqno <= dump->seqmax) #endif