mm:change special pid to macro
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
parent
f2257ffd80
commit
49cd7a795a
|
@ -516,11 +516,11 @@ static ssize_t memdump_write(FAR struct file *filep, FAR const char *buffer,
|
|||
switch (buffer[0])
|
||||
{
|
||||
case 'u':
|
||||
pid = (pid_t)-1;
|
||||
pid = MM_BACKTRACE_ALLOC_PID;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
pid = (pid_t)-2;
|
||||
pid = MM_BACKTRACE_FREE_PID;
|
||||
break;
|
||||
#if CONFIG_MM_BACKTRACE >= 0
|
||||
default:
|
||||
|
|
|
@ -98,6 +98,9 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#define MM_BACKTRACE_FREE_PID ((pid_t)-2)
|
||||
#define MM_BACKTRACE_ALLOC_PID ((pid_t)-1)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
|
|
@ -398,7 +398,7 @@ int mempool_info_task(FAR struct mempool_s *pool,
|
|||
irqstate_t flags = spin_lock_irqsave(&pool->lock);
|
||||
|
||||
DEBUGASSERT(info);
|
||||
if (info->pid == -2)
|
||||
if (info->pid == MM_BACKTRACE_FREE_PID)
|
||||
{
|
||||
size_t count = mempool_queue_lenth(&pool->queue) +
|
||||
mempool_queue_lenth(&pool->iqueue);
|
||||
|
@ -411,7 +411,7 @@ int mempool_info_task(FAR struct mempool_s *pool,
|
|||
info->uordblks -= pool->totalsize;
|
||||
}
|
||||
}
|
||||
else if (info->pid == -1)
|
||||
else if (info->pid == MM_BACKTRACE_ALLOC_PID)
|
||||
{
|
||||
#if CONFIG_MM_BACKTRACE >= 0
|
||||
size_t count = list_length(&pool->alist);
|
||||
|
@ -466,7 +466,7 @@ int mempool_info_task(FAR struct mempool_s *pool,
|
|||
|
||||
void mempool_memdump(FAR struct mempool_s *pool, pid_t pid)
|
||||
{
|
||||
if (pid == -2)
|
||||
if (pid == MM_BACKTRACE_FREE_PID)
|
||||
{
|
||||
FAR sq_entry_t *entry;
|
||||
|
||||
|
@ -492,7 +492,7 @@ void mempool_memdump(FAR struct mempool_s *pool, pid_t pid)
|
|||
list_for_every_entry(&pool->alist, buf, struct mempool_backtrace_s,
|
||||
node)
|
||||
{
|
||||
if (buf->pid == pid || pid == -1)
|
||||
if (buf->pid == pid || pid == MM_BACKTRACE_ALLOC_PID)
|
||||
{
|
||||
# if CONFIG_MM_BACKTRACE > 0
|
||||
int i;
|
||||
|
|
|
@ -87,16 +87,16 @@ static void mallinfo_task_handler(FAR struct mm_allocnode_s *node,
|
|||
{
|
||||
DEBUGASSERT(nodesize >= SIZEOF_MM_ALLOCNODE);
|
||||
#if CONFIG_MM_BACKTRACE < 0
|
||||
if (info->pid == -1)
|
||||
if (info->pid == MM_BACKTRACE_ALLOC_PID)
|
||||
#else
|
||||
if (info->pid == -1 || node->pid == info->pid)
|
||||
if (info->pid == MM_BACKTRACE_ALLOC_PID || node->pid == info->pid)
|
||||
#endif
|
||||
{
|
||||
info->aordblks++;
|
||||
info->uordblks += nodesize;
|
||||
}
|
||||
}
|
||||
else if (info->pid == -2)
|
||||
else if (info->pid == MM_BACKTRACE_FREE_PID)
|
||||
{
|
||||
info->aordblks++;
|
||||
info->uordblks += nodesize;
|
||||
|
|
|
@ -60,9 +60,9 @@ static void memdump_handler(FAR struct mm_allocnode_s *node, FAR void *arg)
|
|||
{
|
||||
DEBUGASSERT(nodesize >= SIZEOF_MM_ALLOCNODE);
|
||||
#if CONFIG_MM_BACKTRACE < 0
|
||||
if (pid == -1)
|
||||
if (pid == MM_BACKTRACE_ALLOC_PID)
|
||||
#else
|
||||
if (pid == -1 || node->pid == pid)
|
||||
if (pid == MM_BACKTRACE_ALLOC_PID || node->pid == pid)
|
||||
#endif
|
||||
{
|
||||
#if CONFIG_MM_BACKTRACE < 0
|
||||
|
@ -104,7 +104,7 @@ static void memdump_handler(FAR struct mm_allocnode_s *node, FAR void *arg)
|
|||
SIZEOF_MM_NODE(fnode->flink) == 0 ||
|
||||
SIZEOF_MM_NODE(fnode->flink) >= nodesize);
|
||||
|
||||
if (pid <= -2)
|
||||
if (pid <= MM_BACKTRACE_FREE_PID)
|
||||
{
|
||||
syslog(LOG_INFO, "%12zu%*p\n",
|
||||
nodesize, MM_PTR_FMT_WIDTH,
|
||||
|
|
|
@ -263,16 +263,16 @@ static void mallinfo_task_handler(FAR void *ptr, size_t size, int used,
|
|||
if (used)
|
||||
{
|
||||
#if CONFIG_MM_BACKTRACE < 0
|
||||
if (info->pid = -1)
|
||||
if (info->pid = MM_BACKTRACE_ALLOC_PID)
|
||||
#else
|
||||
if (info->pid == -1 || info->pid == dump->pid)
|
||||
if (info->pid == MM_BACKTRACE_ALLOC_PID || info->pid == dump->pid)
|
||||
#endif
|
||||
{
|
||||
info->aordblks++;
|
||||
info->uordblks += size;
|
||||
}
|
||||
}
|
||||
else if (info->pid == -2)
|
||||
else if (info->pid == MM_BACKTRACE_FREE_PID)
|
||||
{
|
||||
info->aordblks++;
|
||||
info->uordblks += size;
|
||||
|
@ -377,9 +377,9 @@ static void memdump_handler(FAR void *ptr, size_t size, int used,
|
|||
if (used)
|
||||
{
|
||||
#if CONFIG_MM_BACKTRACE < 0
|
||||
if (pid == -1)
|
||||
if (pid == MM_BACKTRACE_ALLOC_PID)
|
||||
#else
|
||||
if (pid == -1 || dump->pid == pid)
|
||||
if (pid == MM_BACKTRACE_ALLOC_PID || dump->pid == pid)
|
||||
#endif
|
||||
{
|
||||
#if CONFIG_MM_BACKTRACE < 0
|
||||
|
@ -406,7 +406,7 @@ static void memdump_handler(FAR void *ptr, size_t size, int used,
|
|||
#endif
|
||||
}
|
||||
}
|
||||
else if (pid <= -2)
|
||||
else if (pid <= MM_BACKTRACE_FREE_PID)
|
||||
{
|
||||
syslog(LOG_INFO, "%12zu%*p\n", size, MM_PTR_FMT_WIDTH, ptr);
|
||||
}
|
||||
|
@ -904,7 +904,7 @@ void mm_memdump(FAR struct mm_heap_s *heap, pid_t pid)
|
|||
#endif
|
||||
struct memdump_info_s info;
|
||||
|
||||
if (pid >= -1)
|
||||
if (pid >= MM_BACKTRACE_ALLOC_PID)
|
||||
{
|
||||
syslog(LOG_INFO, "Dump all used memory node info:\n");
|
||||
#if CONFIG_MM_BACKTRACE < 0
|
||||
|
|
Loading…
Reference in New Issue