procfs: Use procfs_register_meminfo for "Umem"
This commit is contained in:
parent
f305cefe82
commit
c25f4233aa
@ -265,7 +265,6 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
size_t buflen)
|
size_t buflen)
|
||||||
{
|
{
|
||||||
FAR struct meminfo_file_s *procfile;
|
FAR struct meminfo_file_s *procfile;
|
||||||
struct mallinfo mem;
|
|
||||||
size_t linesize;
|
size_t linesize;
|
||||||
size_t copysize;
|
size_t copysize;
|
||||||
size_t totalsize;
|
size_t totalsize;
|
||||||
@ -323,6 +322,8 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
#ifdef CONFIG_MM_KERNEL_HEAP
|
#ifdef CONFIG_MM_KERNEL_HEAP
|
||||||
if (totalsize < buflen)
|
if (totalsize < buflen)
|
||||||
{
|
{
|
||||||
|
struct mallinfo mem;
|
||||||
|
|
||||||
buffer += copysize;
|
buffer += copysize;
|
||||||
buflen -= copysize;
|
buflen -= copysize;
|
||||||
|
|
||||||
@ -341,27 +342,6 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
#ifdef CONFIG_MM_PGALLOC
|
||||||
if (totalsize < buflen)
|
if (totalsize < buflen)
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <nuttx/fs/procfs.h>
|
||||||
#include <nuttx/mm/mm.h>
|
#include <nuttx/mm/mm.h>
|
||||||
|
|
||||||
#include "umm_heap/umm_heap.h"
|
#include "umm_heap/umm_heap.h"
|
||||||
@ -82,4 +83,16 @@
|
|||||||
void umm_initialize(FAR void *heap_start, size_t heap_size)
|
void umm_initialize(FAR void *heap_start, size_t heap_size)
|
||||||
{
|
{
|
||||||
mm_initialize(USR_HEAP, heap_start, 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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user