mm: Rename mm_memdump_s to malltask

align with the naming of mallinfo_task

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2023-05-28 19:23:56 +08:00 committed by Petro Karashchenko
parent c76f9f9349
commit ddbe9eb6ab
13 changed files with 66 additions and 68 deletions

View File

@ -397,8 +397,8 @@ struct mallinfo mm_mallinfo(struct mm_heap_s *heap)
*
****************************************************************************/
struct mallinfo_task mm_mallinfo_task(FAR struct mm_heap_s *heap,
FAR const struct mm_memdump_s *dump)
struct mallinfo_task mm_mallinfo_task(struct mm_heap_s *heap,
const struct malltask *task)
{
struct mallinfo_task info =
{

View File

@ -444,8 +444,9 @@ static ssize_t memdump_read(FAR struct file *filep, FAR char *buffer,
#if CONFIG_MM_BACKTRACE >= 0
buffer += copysize;
buflen -= copysize;
linesize = procfs_snprintf(procfile->line, MEMINFO_LINELEN,
"The current sequence number %lu\n", g_mm_seqno);
linesize = procfs_snprintf(procfile->line, MEMINFO_LINELEN,
"The current sequence number %lu\n",
g_mm_seqno);
totalsize += procfs_memcpy(procfile->line, linesize, buffer, buflen,
&offset);

View File

@ -886,20 +886,20 @@ static ssize_t proc_heap(FAR struct proc_file_s *procfile,
size_t copysize;
size_t totalsize = 0;
struct mallinfo_task info;
struct mm_memdump_s dump;
struct malltask task;
dump.pid = tcb->pid;
dump.seqmin = 0;
dump.seqmax = ULONG_MAX;
task.pid = tcb->pid;
task.seqmin = 0;
task.seqmax = ULONG_MAX;
#ifdef CONFIG_MM_KERNEL_HEAP
if ((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
{
info = kmm_mallinfo_task(&dump);
info = kmm_mallinfo_task(&task);
}
else
#endif
{
info = mallinfo_task(&dump);
info = mallinfo_task(&task);
}
/* Show the heap alloc size */

View File

@ -52,7 +52,7 @@ struct mallinfo
* by free (not in use) chunks. */
};
struct mm_memdump_s
struct malltask
{
pid_t pid; /* Process id */
#if CONFIG_MM_BACKTRACE >= 0
@ -67,14 +67,6 @@ struct mallinfo_task
int uordblks; /* This is the total size of memory occupied for task */
};
/****************************************************************************
* Public data
****************************************************************************/
#if CONFIG_MM_BACKTRACE >= 0
extern unsigned long g_mm_seqno;
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
@ -86,7 +78,7 @@ extern "C"
struct mallinfo mallinfo(void);
size_t malloc_size(FAR void *ptr);
struct mallinfo_task mallinfo_task(FAR const struct mm_memdump_s *dump);
struct mallinfo_task mallinfo_task(FAR const struct malltask *task);
#if defined(__cplusplus)
}

View File

@ -25,11 +25,11 @@
* Included Files
****************************************************************************/
#include <malloc.h>
#include <sys/types.h>
#include <nuttx/list.h>
#include <nuttx/queue.h>
#include <nuttx/mm/mm.h>
#include <nuttx/fs/procfs.h>
#include <nuttx/spinlock.h>
#include <nuttx/semaphore.h>
@ -260,7 +260,7 @@ int mempool_deinit(FAR struct mempool_s *pool);
*
* Input Parameters:
* pool - Address of the memory pool to be used.
* dump - The information of what need dump.
* task - The information of what need retrieve.
*
* Returned Value:
* Statistics of memory information based on dump.
@ -268,7 +268,7 @@ int mempool_deinit(FAR struct mempool_s *pool);
struct mallinfo_task
mempool_info_task(FAR struct mempool_s *pool,
FAR const struct mm_memdump_s *dump);
FAR const struct malltask *task);
/****************************************************************************
* Name: mempool_procfs_register
@ -510,7 +510,7 @@ mempool_multiple_mallinfo(FAR struct mempool_multiple_s *mpool);
*
* Input Parameters:
* mpool - The handle of multiple memory pool to be used.
* dump - The information of what need dump.
* task - The information of what need retrieve.
*
* Returned Value:
* Statistics of memory information based on dump.
@ -518,7 +518,7 @@ mempool_multiple_mallinfo(FAR struct mempool_multiple_s *mpool);
struct mallinfo_task
mempool_multiple_info_task(FAR struct mempool_multiple_s *mpool,
FAR const struct mm_memdump_s *dump);
FAR const struct malltask *task);
#undef EXTERN
#if defined(__cplusplus)

View File

@ -99,6 +99,8 @@
# endif
#endif
#define mm_memdump_s malltask
#define MM_BACKTRACE_INVALID_PID ((pid_t)-4)
#define MM_BACKTRACE_MEMPOOL_PID ((pid_t)-3)
#define MM_BACKTRACE_FREE_PID ((pid_t)-2)
@ -123,6 +125,10 @@ extern "C"
#define EXTERN extern
#endif
#if CONFIG_MM_BACKTRACE >= 0
extern unsigned long g_mm_seqno;
#endif
/* User heap structure:
*
* - Flat build: In the FLAT build, the user heap structure is a globally
@ -316,14 +322,14 @@ void kmm_extend(FAR void *mem, size_t size, int region);
struct mallinfo mm_mallinfo(FAR struct mm_heap_s *heap);
struct mallinfo_task mm_mallinfo_task(FAR struct mm_heap_s *heap,
FAR const struct mm_memdump_s *dump);
FAR const struct malltask *task);
/* Functions contained in kmm_mallinfo.c ************************************/
#ifdef CONFIG_MM_KERNEL_HEAP
struct mallinfo kmm_mallinfo(void);
# if CONFIG_MM_BACKTRACE >= 0
struct mallinfo_task kmm_mallinfo_task(FAR const struct mm_memdump_s *dump);
struct mallinfo_task kmm_mallinfo_task(FAR const struct malltask *task);
# endif
#endif

View File

@ -55,8 +55,8 @@ struct mallinfo kmm_mallinfo(void)
*
****************************************************************************/
struct mallinfo_task kmm_mallinfo_task(FAR const struct mm_memdump_s *dump)
struct mallinfo_task kmm_mallinfo_task(FAR const struct malltask *task)
{
return mm_mallinfo_task(g_kmmheap, dump);
return mm_mallinfo_task(g_kmmheap, task);
}
#endif /* CONFIG_MM_KERNEL_HEAP */

View File

@ -393,7 +393,7 @@ int mempool_info(FAR struct mempool_s *pool, FAR struct mempoolinfo_s *info)
struct mallinfo_task
mempool_info_task(FAR struct mempool_s *pool,
FAR const struct mm_memdump_s *dump)
FAR const struct malltask *task)
{
irqstate_t flags = spin_lock_irqsave(&pool->lock);
struct mallinfo_task info =
@ -401,7 +401,7 @@ mempool_info_task(FAR struct mempool_s *pool,
0, 0
};
if (dump->pid == MM_BACKTRACE_FREE_PID)
if (task->pid == MM_BACKTRACE_FREE_PID)
{
size_t count = mempool_queue_lenth(&pool->queue) +
mempool_queue_lenth(&pool->iqueue);
@ -410,7 +410,7 @@ mempool_info_task(FAR struct mempool_s *pool,
info.uordblks += count * pool->blocksize;
}
#if CONFIG_MM_BACKTRACE < 0
else if (dump->pid == MM_BACKTRACE_ALLOC_PID)
else if (task->pid == MM_BACKTRACE_ALLOC_PID)
{
size_t count = pool->nalloc;
@ -425,11 +425,11 @@ mempool_info_task(FAR struct mempool_s *pool,
list_for_every_entry(&pool->alist, buf, struct mempool_backtrace_s,
node)
{
if (dump->pid == buf->pid || dump->pid == MM_BACKTRACE_ALLOC_PID ||
(dump->pid == MM_BACKTRACE_INVALID_PID &&
if (task->pid == buf->pid || task->pid == MM_BACKTRACE_ALLOC_PID ||
(task->pid == MM_BACKTRACE_INVALID_PID &&
nxsched_get_tcb(buf->pid) == NULL))
{
if (buf->seqno >= dump->seqmin && buf->seqno <= dump->seqmax)
if (buf->seqno >= task->seqmin && buf->seqno <= task->seqmax)
{
info.aordblks++;
info.uordblks += pool->blocksize;

View File

@ -768,7 +768,7 @@ mempool_multiple_mallinfo(FAR struct mempool_multiple_s *mpool)
struct mallinfo_task
mempool_multiple_info_task(FAR struct mempool_multiple_s *mpool,
FAR const struct mm_memdump_s *dump)
FAR const struct malltask *task)
{
int i;
struct mallinfo_task info;
@ -779,7 +779,7 @@ mempool_multiple_info_task(FAR struct mempool_multiple_s *mpool,
for (i = 0; i < mpool->npools; i++)
{
info = mempool_info_task(mpool->pools + i, dump);
info = mempool_info_task(mpool->pools + i, task);
ret.aordblks += info.aordblks;
ret.uordblks += info.uordblks;
}

View File

@ -37,7 +37,7 @@
struct mm_mallinfo_handler_s
{
FAR const struct mm_memdump_s *dump;
FAR const struct malltask *task;
FAR struct mallinfo_task *info;
};
@ -96,19 +96,19 @@ static void mallinfo_task_handler(FAR struct mm_allocnode_s *node,
{
DEBUGASSERT(nodesize >= SIZEOF_MM_ALLOCNODE);
#if CONFIG_MM_BACKTRACE < 0
if (handle->dump->pid == MM_BACKTRACE_ALLOC_PID)
if (handle->task->pid == MM_BACKTRACE_ALLOC_PID)
{
handle->info->aordblks++;
handle->info->uordblks += nodesize;
}
#else
if (handle->dump->pid == MM_BACKTRACE_ALLOC_PID ||
handle->dump->pid == node->pid ||
(handle->dump->pid == MM_BACKTRACE_INVALID_PID &&
if (handle->task->pid == MM_BACKTRACE_ALLOC_PID ||
handle->task->pid == node->pid ||
(handle->task->pid == MM_BACKTRACE_INVALID_PID &&
nxsched_get_tcb(node->pid) == NULL))
{
if (node->seqno >= handle->dump->seqmin &&
node->seqno <= handle->dump->seqmax)
if (node->seqno >= handle->task->seqmin &&
node->seqno <= handle->task->seqmax)
{
handle->info->aordblks++;
handle->info->uordblks += nodesize;
@ -116,7 +116,7 @@ static void mallinfo_task_handler(FAR struct mm_allocnode_s *node,
}
#endif
}
else if (handle->dump->pid == MM_BACKTRACE_FREE_PID)
else if (handle->task->pid == MM_BACKTRACE_FREE_PID)
{
handle->info->aordblks++;
handle->info->uordblks += nodesize;
@ -170,7 +170,7 @@ struct mallinfo mm_mallinfo(FAR struct mm_heap_s *heap)
****************************************************************************/
struct mallinfo_task mm_mallinfo_task(FAR struct mm_heap_s *heap,
FAR const struct mm_memdump_s *dump)
FAR const struct malltask *task)
{
struct mm_mallinfo_handler_s handle;
struct mallinfo_task info =
@ -179,11 +179,10 @@ struct mallinfo_task mm_mallinfo_task(FAR struct mm_heap_s *heap,
};
#if CONFIG_MM_HEAP_MEMPOOL_THRESHOLD != 0
info = mempool_multiple_info_task(heap->mm_mpool, dump);
info = mempool_multiple_info_task(heap->mm_mpool, task);
#endif
handle.dump = dump;
handle.task = task;
handle.info = &info;
mm_foreach(heap, mallinfo_task_handler, &handle);

View File

@ -78,14 +78,14 @@ static void free_delaylist(FAR struct mm_heap_s *heap)
void mm_dump_handler(FAR struct tcb_s *tcb, FAR void *arg)
{
struct mallinfo_task info;
struct mm_memdump_s dump;
struct malltask task;
dump.pid = tcb ? tcb->pid : MM_BACKTRACE_INVALID_PID;
dump.seqmin = 0;
dump.seqmax = ULONG_MAX;
info = mm_mallinfo_task(arg, &dump);
task.pid = tcb ? tcb->pid : MM_BACKTRACE_INVALID_PID;
task.seqmin = 0;
task.seqmax = ULONG_MAX;
info = mm_mallinfo_task(arg, &task);
mwarn("pid:%5d, used:%10d, nused:%10d\n",
dump.pid, info.uordblks, info.aordblks);
task.pid, info.uordblks, info.aordblks);
}
#endif

View File

@ -122,7 +122,7 @@ struct memdump_backtrace_s
struct mm_mallinfo_handler_s
{
FAR const struct mm_memdump_s *dump;
FAR const struct malltask *task;
FAR struct mallinfo_task *info;
};
@ -292,19 +292,19 @@ static void mallinfo_task_handler(FAR void *ptr, size_t size, int used,
if (used)
{
#if CONFIG_MM_BACKTRACE < 0
if (handler->dump->pid = MM_BACKTRACE_ALLOC_PID)
if (handler->task->pid = MM_BACKTRACE_ALLOC_PID)
{
handler->info->aordblks++;
handler->info->uordblks += size;
}
#else
if (handler->dump->pid == MM_BACKTRACE_ALLOC_PID ||
handler->dump->pid == buf->pid ||
(handler->dump->pid == MM_BACKTRACE_INVALID_PID &&
if (handler->task->pid == MM_BACKTRACE_ALLOC_PID ||
handler->task->pid == buf->pid ||
(handler->task->pid == MM_BACKTRACE_INVALID_PID &&
nxsched_get_tcb(buf->pid) == NULL))
{
if (buf->seqno >= handler->dump->seqmin &&
buf->seqno <= handler->dump->seqmax)
if (buf->seqno >= handler->task->seqmin &&
buf->seqno <= handler->task->seqmax)
{
handler->info->aordblks++;
handler->info->uordblks += size;
@ -312,7 +312,7 @@ static void mallinfo_task_handler(FAR void *ptr, size_t size, int used,
}
#endif
}
else if (handler->dump->pid == MM_BACKTRACE_FREE_PID)
else if (handler->task->pid == MM_BACKTRACE_FREE_PID)
{
handler->info->aordblks++;
handler->info->uordblks += size;
@ -905,7 +905,7 @@ struct mallinfo mm_mallinfo(FAR struct mm_heap_s *heap)
}
struct mallinfo_task mm_mallinfo_task(FAR struct mm_heap_s *heap,
FAR const struct mm_memdump_s *dump)
FAR const struct malltask *task)
{
struct mm_mallinfo_handler_s handle;
struct mallinfo_task info =
@ -920,10 +920,10 @@ struct mallinfo_task mm_mallinfo_task(FAR struct mm_heap_s *heap,
#endif
#if CONFIG_MM_HEAP_MEMPOOL_THRESHOLD != 0
info = mempool_multiple_info_task(heap->mm_mpool, dump);
info = mempool_multiple_info_task(heap->mm_mpool, task);
#endif
handle.dump = dump;
handle.task = task;
handle.info = &info;
#if CONFIG_MM_REGIONS > 1
for (region = 0; region < heap->mm_nregions; region++)

View File

@ -57,7 +57,7 @@ struct mallinfo mallinfo(void)
*
****************************************************************************/
struct mallinfo_task mallinfo_task(FAR const struct mm_memdump_s *dump)
struct mallinfo_task mallinfo_task(FAR const struct malltask *task)
{
return mm_mallinfo_task(USR_HEAP, dump);
return mm_mallinfo_task(USR_HEAP, task);
}