procfs: Use procfs_register_meminfo for "Umem"

This commit is contained in:
YAMAMOTO Takashi 2021-02-12 14:07:33 +09:00 committed by David Sidrane
parent f305cefe82
commit c25f4233aa
2 changed files with 15 additions and 22 deletions

View File

@ -265,7 +265,6 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
size_t buflen)
{
FAR struct meminfo_file_s *procfile;
struct mallinfo mem;
size_t linesize;
size_t copysize;
size_t totalsize;
@ -323,6 +322,8 @@ 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;
@ -341,27 +342,6 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
}
#endif
#if !defined(CONFIG_BUILD_KERNEL)
if (totalsize < buflen)
{
buffer += copysize;
buflen -= copysize;
/* Show user heap information */
mem = kumm_mallinfo();
linesize = snprintf(procfile->line, MEMINFO_LINELEN,
"Umem: %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

@ -26,6 +26,7 @@
#include <assert.h>
#include <nuttx/fs/procfs.h>
#include <nuttx/mm/mm.h>
#include "umm_heap/umm_heap.h"
@ -82,4 +83,16 @@
void umm_initialize(FAR void *heap_start, size_t heap_size)
{
mm_initialize(USR_HEAP, heap_start, heap_size);
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \
defined(CONFIG_BUILD_FLAT)
static struct procfs_meminfo_entry_s g_umm_procfs;
g_umm_procfs.name = "Umem";
g_umm_procfs.mallinfo = (void *)mm_mallinfo;
g_umm_procfs.user_data = USR_HEAP;
procfs_register_meminfo(&g_umm_procfs);
#endif
#endif
}