mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 06:42:32 +08:00
procfs: add heap info for every task
cat /proc/2/heap AllocSize: 512 AllocBlks: 10 Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
@@ -50,4 +50,23 @@ struct mallinfo kmm_mallinfo(void)
|
||||
return info;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: kmm_mallinfo_task
|
||||
*
|
||||
* Description:
|
||||
* kmm_mallinfo_task returns a copy of updated current heap information of
|
||||
* task with specified pid for the user heap.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_MM
|
||||
struct mallinfo_task kmm_mallinfo_task(pid_t pid)
|
||||
{
|
||||
struct mallinfo_task info;
|
||||
|
||||
info.pid = pid;
|
||||
mm_mallinfo_task(g_kmmheap, &info);
|
||||
return info;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_MM_KERNEL_HEAP */
|
||||
|
||||
@@ -75,6 +75,26 @@ static void mallinfo_handler(FAR struct mm_allocnode_s *node, FAR void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_MM
|
||||
static void mallinfo_task_handler(FAR struct mm_allocnode_s *node,
|
||||
FAR void *arg)
|
||||
{
|
||||
FAR struct mallinfo_task *info = arg;
|
||||
|
||||
/* Check if the node corresponds to an allocated memory chunk */
|
||||
|
||||
if ((node->preceding & MM_ALLOC_BIT) != 0)
|
||||
{
|
||||
DEBUGASSERT(node->size >= SIZEOF_MM_ALLOCNODE);
|
||||
if (node->pid == info->pid)
|
||||
{
|
||||
info->aordblks++;
|
||||
info->uordblks += node->size;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -107,3 +127,25 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info)
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mm_mallinfo_task
|
||||
*
|
||||
* Description:
|
||||
* mallinfo returns a copy of updated current heap information for task
|
||||
* with pid.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_MM
|
||||
int mm_mallinfo_task(FAR struct mm_heap_s *heap,
|
||||
FAR struct mallinfo_task *info)
|
||||
{
|
||||
DEBUGASSERT(info);
|
||||
|
||||
info->uordblks = 0;
|
||||
info->aordblks = 0;
|
||||
mm_foreach(heap, mallinfo_task_handler, info);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -49,3 +49,23 @@ struct mallinfo mallinfo(void)
|
||||
mm_mallinfo(USR_HEAP, &info);
|
||||
return info;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mallinfo_task
|
||||
*
|
||||
* Description:
|
||||
* mallinfo_task returns a copy of updated current heap information of
|
||||
* task with specified pid for the user heap.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_MM
|
||||
struct mallinfo_task mallinfo_task(pid_t pid)
|
||||
{
|
||||
struct mallinfo_task info;
|
||||
|
||||
info.pid = pid;
|
||||
mm_mallinfo_task(USR_HEAP, &info);
|
||||
return info;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user