procfs: Use procfs_register_meminfo for "Kmem"

This commit is contained in:
YAMAMOTO Takashi 2021-02-12 14:10:07 +09:00 committed by David Sidrane
parent c25f4233aa
commit 929e438052
2 changed files with 11 additions and 24 deletions

View File

@ -319,29 +319,6 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
}
}
#ifdef CONFIG_MM_KERNEL_HEAP
if (totalsize < buflen)
{
struct mallinfo mem;
buffer += copysize;
buflen -= copysize;
/* Show kernel heap information */
mem = kmm_mallinfo();
linesize = snprintf(procfile->line, MEMINFO_LINELEN,
"Kmem: %11lu%11lu%11lu%11lu\n",
(unsigned long)mem.arena,
(unsigned long)mem.uordblks,
(unsigned long)mem.fordblks,
(unsigned long)mem.mxordblk);
copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen,
&offset);
totalsize += copysize;
}
#endif
#ifdef CONFIG_MM_PGALLOC
if (totalsize < buflen)
{

View File

@ -24,6 +24,7 @@
#include <nuttx/config.h>
#include <nuttx/fs/procfs.h>
#include <nuttx/mm/mm.h>
#ifdef CONFIG_MM_KERNEL_HEAP
@ -58,7 +59,16 @@ struct mm_heap_s g_kmmheap;
void kmm_initialize(FAR void *heap_start, size_t heap_size)
{
return mm_initialize(&g_kmmheap, heap_start, heap_size);
mm_initialize(&g_kmmheap, heap_start, heap_size);
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
static struct procfs_meminfo_entry_s g_kmm_procfs;
g_kmm_procfs.name = "Kmem";
g_kmm_procfs.mallinfo = (void *)mm_mallinfo;
g_kmm_procfs.user_data = &g_kmmheap;
procfs_register_meminfo(&g_kmm_procfs);
#endif
}
#endif /* CONFIG_MM_KERNEL_HEAP */