cmd/free: add nused/nfree field in command free
Change-Id: I74aa4b1e7394a17c3b117322a4cc24aa52aac3b8 Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
7a49fade03
commit
fea1da2f53
@ -495,8 +495,9 @@ Show Memory Manager Status (free)
|
||||
example::
|
||||
|
||||
nsh> free
|
||||
total used free largest
|
||||
Mem: 4194288 1591552 2602736 2601584
|
||||
total used free largest nused nfree
|
||||
Mem: 5583024 1614784 3968240 3967792 244 4
|
||||
|
||||
nsh>
|
||||
|
||||
**Where:**
|
||||
@ -506,6 +507,8 @@ total This is the total size of memory allocated for use by malloc in bytes.
|
||||
used This is the total size of memory occupied by chunks handed out by malloc.
|
||||
free This is the total size of memory occupied by free (not in use) chunks.
|
||||
largest Size of the largest free (not in use) chunk.
|
||||
nused This is the number of allocated chunks
|
||||
nfree This is the number of free chunks
|
||||
======= ======================================
|
||||
|
||||
.. _cmdget:
|
||||
|
@ -54,7 +54,7 @@
|
||||
* to handle the longest line generated by this logic.
|
||||
*/
|
||||
|
||||
#define MEMINFO_LINELEN 62
|
||||
#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. */
|
||||
@ -147,6 +148,8 @@ static void meminfo_progmem(FAR struct progmem_info_s *progmem)
|
||||
ssize_t status;
|
||||
|
||||
progmem->arena = 0;
|
||||
progmem->ordblks = 0;
|
||||
progmem->aordblks = 0;
|
||||
progmem->fordblks = 0;
|
||||
progmem->uordblks = 0;
|
||||
progmem->mxordblk = 0;
|
||||
@ -171,6 +174,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 +289,7 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
|
||||
linesize =
|
||||
snprintf(procfile->line, MEMINFO_LINELEN,
|
||||
" "
|
||||
"total used free largest\n");
|
||||
"total used free largest nused nfree\n");
|
||||
|
||||
copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen,
|
||||
&offset);
|
||||
@ -308,12 +312,14 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
|
||||
|
||||
entry->mallinfo(entry->user_data, &minfo);
|
||||
linesize = snprintf(procfile->line, MEMINFO_LINELEN,
|
||||
"%12s: %11lu%11lu%11lu%11lu\n",
|
||||
"%12s: %11lu%11lu%11lu%11lu%7lu%7lu\n",
|
||||
entry->name,
|
||||
(unsigned long)minfo.arena,
|
||||
(unsigned long)minfo.uordblks,
|
||||
(unsigned long)minfo.fordblks,
|
||||
(unsigned long)minfo.mxordblk);
|
||||
(unsigned long)minfo.mxordblk,
|
||||
(unsigned long)minfo.aordblks,
|
||||
(unsigned long)minfo.ordblks);
|
||||
copysize = procfs_memcpy(procfile->line, linesize, buffer,
|
||||
buflen, &offset);
|
||||
totalsize += copysize;
|
||||
@ -364,11 +370,13 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
|
||||
meminfo_progmem(&progmem);
|
||||
|
||||
linesize = snprintf(procfile->line, MEMINFO_LINELEN,
|
||||
"Prog: %11lu%11lu%11lu%11lu\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.mxordblk,
|
||||
(unsigned long)progmem.aordblks,
|
||||
(unsigned long)progmem.ordblks);
|
||||
copysize = procfs_memcpy(procfile->line, linesize, buffer, buflen,
|
||||
&offset);
|
||||
totalsize += copysize;
|
||||
|
@ -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. */
|
||||
|
@ -51,6 +51,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
|
||||
@ -92,6 +93,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
|
||||
@ -133,6 +135,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;
|
||||
|
Loading…
Reference in New Issue
Block a user