diff --git a/arch/sim/src/sim/up_hostmemory.c b/arch/sim/src/sim/up_hostmemory.c index 7d306c88e8a..e596de6c37e 100644 --- a/arch/sim/src/sim/up_hostmemory.c +++ b/arch/sim/src/sim/up_hostmemory.c @@ -150,6 +150,7 @@ void host_mallinfo(struct host_mallinfo *info) tmp = mallinfo(); info->arena = tmp.arena; info->ordblks = tmp.ordblks; + info->aordblks = tmp.hblks; info->mxordblk = tmp.usmblks; info->uordblks = tmp.uordblks; info->fordblks = tmp.fordblks; diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h index 1af2c7daec5..7520cedb329 100644 --- a/arch/sim/src/sim/up_internal.h +++ b/arch/sim/src/sim/up_internal.h @@ -176,6 +176,7 @@ struct host_mallinfo int arena; /* This is the total size of memory allocated * for use by malloc in bytes. */ int ordblks; /* This is the number of free (not in use) chunks */ + int aordblks; /* This is the number of allocated (in use) chunks */ int mxordblk; /* Size of the largest free (not in use) chunk */ int uordblks; /* This is the total size of memory occupied by * chunks handed out by malloc. */ diff --git a/fs/procfs/fs_procfsmeminfo.c b/fs/procfs/fs_procfsmeminfo.c index b51fe2ebd21..25eb86cabf7 100644 --- a/fs/procfs/fs_procfsmeminfo.c +++ b/fs/procfs/fs_procfsmeminfo.c @@ -54,7 +54,7 @@ * to handle the longest line generated by this logic. */ -#define MEMINFO_LINELEN 64 +#define MEMINFO_LINELEN 80 /**************************************************************************** * Private Types @@ -74,6 +74,7 @@ struct progmem_info_s { int arena; /* Total size of available progmem. */ int ordblks; /* This is the number of free chunks */ + int aordblks; /* This is the number of allocated chunks */ int mxordblk; /* Size of the largest free chunk */ int uordblks; /* Total size of memory for allocated chunks */ int fordblks; /* Total size of memory for free chunks. */ @@ -146,6 +147,7 @@ static void meminfo_progmem(FAR struct progmem_info_s *progmem) progmem->arena = 0; progmem->ordblks = 0; + progmem->aordblks = 0; progmem->fordblks = 0; progmem->uordblks = 0; progmem->mxordblk = 0; @@ -171,6 +173,7 @@ static void meminfo_progmem(FAR struct progmem_info_s *progmem) } else if (status != 0) { + progmem->aordblks++; progmem->uordblks += pagesize; if (stpage != 0xffff && up_progmem_isuniform()) @@ -285,7 +288,7 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer, linesize = procfs_snprintf(procfile->line, MEMINFO_LINELEN, - " total used free largest nfree\n"); + " total used free largest nused nfree\n"); copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen, &offset); @@ -303,11 +306,12 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer, mem = kmm_mallinfo(); linesize = procfs_snprintf(procfile->line, MEMINFO_LINELEN, - "Kmem: %11lu%11lu%11lu%11lu%7lu\n", + "Kmem: %11lu%11lu%11lu%11lu%7lu%7lu\n", (unsigned long)mem.arena, (unsigned long)mem.uordblks, (unsigned long)mem.fordblks, (unsigned long)mem.mxordblk, + (unsigned long)mem.aordblks, (unsigned long)mem.ordblks); copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen, &offset); @@ -325,11 +329,12 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer, mem = kumm_mallinfo(); linesize = procfs_snprintf(procfile->line, MEMINFO_LINELEN, - "Umem: %11lu%11lu%11lu%11lu%7lu\n", + "Umem: %11lu%11lu%11lu%11lu%7lu%7lu\n", (unsigned long)mem.arena, (unsigned long)mem.uordblks, (unsigned long)mem.fordblks, (unsigned long)mem.mxordblk, + (unsigned long)mem.aordblks, (unsigned long)mem.ordblks); copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen, &offset); @@ -381,11 +386,12 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer, meminfo_progmem(&progmem); linesize = procfs_snprintf(procfile->line, MEMINFO_LINELEN, - "Prog: %11lu%11lu%11lu%11lu%7lu\n", + "Prog: %11lu%11lu%11lu%11lu%7lu%7lu\n", (unsigned long)progmem.arena, (unsigned long)progmem.uordblks, (unsigned long)progmem.fordblks, (unsigned long)progmem.mxordblk, + (unsigned long)progmem.aordblks, (unsigned long)progmem.ordblks); copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen, &offset); diff --git a/include/malloc.h b/include/malloc.h index 0d993b933da..a4bc6c4f43c 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -40,6 +40,7 @@ struct mallinfo int arena; /* This is the total size of memory allocated * for use by malloc in bytes. */ int ordblks; /* This is the number of free (not in use) chunks */ + int aordblks; /* This is the number of allocated (in use) chunks */ int mxordblk; /* Size of the largest free (not in use) chunk */ int uordblks; /* This is the total size of memory occupied by * chunks handed out by malloc. */ diff --git a/mm/mm_heap/mm_mallinfo.c b/mm/mm_heap/mm_mallinfo.c index 2e398a18b28..bbb719b80f0 100644 --- a/mm/mm_heap/mm_mallinfo.c +++ b/mm/mm_heap/mm_mallinfo.c @@ -66,6 +66,7 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info) FAR struct mm_allocnode_s *prev; size_t mxordblk = 0; int ordblks = 0; /* Number of non-inuse chunks */ + int aordblks = 0; /* Number of inuse chunks */ size_t uordblks = 0; /* Total allocated space */ size_t fordblks = 0; /* Total non-inuse space */ #if CONFIG_MM_REGIONS > 1 @@ -107,6 +108,7 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info) if ((node->preceding & MM_ALLOC_BIT) != 0) { DEBUGASSERT(node->size >= SIZEOF_MM_ALLOCNODE); + aordblks ++; uordblks += node->size; } else @@ -148,6 +150,7 @@ int mm_mallinfo(FAR struct mm_heap_s *heap, FAR struct mallinfo *info) info->arena = heap_impl->mm_heapsize; info->ordblks = ordblks; + info->aordblks = aordblks; info->mxordblk = mxordblk; info->uordblks = uordblks; info->fordblks = fordblks;