mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 09:49:21 +08:00
mm: Rename PID_MM_INVALID to PID_MM_LEAK
to express the intent more clear Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
b00237ac01
commit
9b6cd96671
6 changed files with 40 additions and 51 deletions
|
@ -35,7 +35,7 @@
|
|||
|
||||
#define PID_MM_FREE ((pid_t)-4)
|
||||
#define PID_MM_ALLOC ((pid_t)-3)
|
||||
#define PID_MM_INVALID ((pid_t)-2)
|
||||
#define PID_MM_LEAK ((pid_t)-2)
|
||||
#define PID_MM_MEMPOOL ((pid_t)-1)
|
||||
|
||||
/* For Linux and MacOS compatibility */
|
||||
|
|
|
@ -412,10 +412,8 @@ mempool_info_task(FAR struct mempool_s *pool,
|
|||
#if CONFIG_MM_BACKTRACE < 0
|
||||
else if (task->pid == PID_MM_ALLOC)
|
||||
{
|
||||
size_t count = pool->nalloc;
|
||||
|
||||
info.aordblks += count;
|
||||
info.uordblks += count * pool->blocksize;
|
||||
info.aordblks += pool->nalloc;
|
||||
info.uordblks += pool->nalloc * pool->blocksize;
|
||||
}
|
||||
#else
|
||||
else
|
||||
|
@ -425,15 +423,12 @@ mempool_info_task(FAR struct mempool_s *pool,
|
|||
list_for_every_entry(&pool->alist, buf, struct mempool_backtrace_s,
|
||||
node)
|
||||
{
|
||||
if (task->pid == buf->pid || task->pid == PID_MM_ALLOC ||
|
||||
(task->pid == PID_MM_INVALID &&
|
||||
nxsched_get_tcb(buf->pid) == NULL))
|
||||
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)
|
||||
{
|
||||
if (buf->seqno >= task->seqmin && buf->seqno <= task->seqmax)
|
||||
{
|
||||
info.aordblks++;
|
||||
info.uordblks += pool->blocksize;
|
||||
}
|
||||
info.aordblks++;
|
||||
info.uordblks += pool->blocksize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -491,7 +486,7 @@ void mempool_memdump(FAR struct mempool_s *pool,
|
|||
list_for_every_entry(&pool->alist, buf, struct mempool_backtrace_s,
|
||||
node)
|
||||
{
|
||||
if ((buf->pid == dump->pid || dump->pid == PID_MM_ALLOC) &&
|
||||
if ((dump->pid == PID_MM_ALLOC || dump->pid == buf->pid) &&
|
||||
buf->seqno >= dump->seqmin && buf->seqno <= dump->seqmax)
|
||||
{
|
||||
# if CONFIG_MM_BACKTRACE > 0
|
||||
|
|
|
@ -87,7 +87,9 @@ static void mallinfo_handler(FAR struct mm_allocnode_s *node, FAR void *arg)
|
|||
static void mallinfo_task_handler(FAR struct mm_allocnode_s *node,
|
||||
FAR void *arg)
|
||||
{
|
||||
FAR struct mm_mallinfo_handler_s *handle = arg;
|
||||
FAR struct mm_mallinfo_handler_s *handler = arg;
|
||||
FAR const struct malltask *task = handler->task;
|
||||
FAR struct mallinfo_task *info = handler->info;
|
||||
size_t nodesize = SIZEOF_MM_NODE(node);
|
||||
|
||||
/* Check if the node corresponds to an allocated memory chunk */
|
||||
|
@ -96,30 +98,25 @@ static void mallinfo_task_handler(FAR struct mm_allocnode_s *node,
|
|||
{
|
||||
DEBUGASSERT(nodesize >= SIZEOF_MM_ALLOCNODE);
|
||||
#if CONFIG_MM_BACKTRACE < 0
|
||||
if (handle->task->pid == PID_MM_ALLOC)
|
||||
if (task->pid == PID_MM_ALLOC)
|
||||
{
|
||||
handle->info->aordblks++;
|
||||
handle->info->uordblks += nodesize;
|
||||
info->aordblks++;
|
||||
info->uordblks += nodesize;
|
||||
}
|
||||
#else
|
||||
if (handle->task->pid == PID_MM_ALLOC ||
|
||||
handle->task->pid == node->pid ||
|
||||
(handle->task->pid == PID_MM_INVALID &&
|
||||
nxsched_get_tcb(node->pid) == NULL))
|
||||
if ((task->pid == PID_MM_ALLOC || task->pid == node->pid ||
|
||||
(task->pid == PID_MM_LEAK && !!nxsched_get_tcb(node->pid))) &&
|
||||
node->seqno >= task->seqmin && node->seqno <= task->seqmax)
|
||||
{
|
||||
if (node->seqno >= handle->task->seqmin &&
|
||||
node->seqno <= handle->task->seqmax)
|
||||
{
|
||||
handle->info->aordblks++;
|
||||
handle->info->uordblks += nodesize;
|
||||
}
|
||||
info->aordblks++;
|
||||
info->uordblks += nodesize;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (handle->task->pid == PID_MM_FREE)
|
||||
else if (task->pid == PID_MM_FREE)
|
||||
{
|
||||
handle->info->aordblks++;
|
||||
handle->info->uordblks += nodesize;
|
||||
info->aordblks++;
|
||||
info->uordblks += nodesize;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ void mm_dump_handler(FAR struct tcb_s *tcb, FAR void *arg)
|
|||
struct mallinfo_task info;
|
||||
struct malltask task;
|
||||
|
||||
task.pid = tcb ? tcb->pid : PID_MM_INVALID;
|
||||
task.pid = tcb ? tcb->pid : PID_MM_LEAK;
|
||||
task.seqmin = 0;
|
||||
task.seqmax = ULONG_MAX;
|
||||
info = mm_mallinfo_task(arg, &task);
|
||||
|
|
|
@ -61,7 +61,7 @@ static void memdump_handler(FAR struct mm_allocnode_s *node, FAR void *arg)
|
|||
#if CONFIG_MM_BACKTRACE < 0
|
||||
if (dump->pid == PID_MM_ALLOC)
|
||||
#else
|
||||
if ((dump->pid == PID_MM_ALLOC || node->pid == dump->pid) &&
|
||||
if ((dump->pid == PID_MM_ALLOC || dump->pid == node->pid) &&
|
||||
node->seqno >= dump->seqmin && node->seqno <= dump->seqmax)
|
||||
#endif
|
||||
{
|
||||
|
|
|
@ -284,6 +284,8 @@ static void mallinfo_task_handler(FAR void *ptr, size_t size, int used,
|
|||
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);
|
||||
|
@ -292,30 +294,25 @@ static void mallinfo_task_handler(FAR void *ptr, size_t size, int used,
|
|||
if (used)
|
||||
{
|
||||
#if CONFIG_MM_BACKTRACE < 0
|
||||
if (handler->task->pid == PID_MM_ALLOC)
|
||||
if (task->pid == PID_MM_ALLOC)
|
||||
{
|
||||
handler->info->aordblks++;
|
||||
handler->info->uordblks += size;
|
||||
info->aordblks++;
|
||||
info->uordblks += size;
|
||||
}
|
||||
#else
|
||||
if (handler->task->pid == PID_MM_ALLOC ||
|
||||
handler->task->pid == buf->pid ||
|
||||
(handler->task->pid == PID_MM_INVALID &&
|
||||
nxsched_get_tcb(buf->pid) == NULL))
|
||||
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)
|
||||
{
|
||||
if (buf->seqno >= handler->task->seqmin &&
|
||||
buf->seqno <= handler->task->seqmax)
|
||||
{
|
||||
handler->info->aordblks++;
|
||||
handler->info->uordblks += size;
|
||||
}
|
||||
info->aordblks++;
|
||||
info->uordblks += size;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (handler->task->pid == PID_MM_FREE)
|
||||
else if (task->pid == PID_MM_FREE)
|
||||
{
|
||||
handler->info->aordblks++;
|
||||
handler->info->uordblks += size;
|
||||
info->aordblks++;
|
||||
info->uordblks += size;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -417,9 +414,9 @@ static void memdump_handler(FAR void *ptr, size_t size, int used,
|
|||
if (used)
|
||||
{
|
||||
#if CONFIG_MM_BACKTRACE < 0
|
||||
if (pid == PID_MM_ALLOC)
|
||||
if (dump->pid == PID_MM_ALLOC)
|
||||
#else
|
||||
if ((dump->pid == PID_MM_ALLOC || buf->pid == dump->pid) &&
|
||||
if ((dump->pid == PID_MM_ALLOC || dump->pid == buf->pid) &&
|
||||
buf->seqno >= dump->seqmin && buf->seqno <= dump->seqmax)
|
||||
#endif
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue