You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/08/02 17:30:10 UTC
(nuttx) branch master updated (e9d20bd611 -> 160ca004ac)
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
from e9d20bd611 Add mkfsdata.py
new cafee0e086 mm/mm.h: add mm_free_delaylist interface
new 160ca004ac procfs/meminfo: free delaylist for PROTECTED
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
arch/sim/src/sim/sim_heap.c | 26 +++++++++++++++++++++-----
fs/procfs/fs_procfsmeminfo.c | 7 +++++++
include/nuttx/mm/mm.h | 2 ++
mm/mm_heap/mm_malloc.c | 16 ++++++++++++++++
mm/tlsf/mm_tlsf.c | 16 ++++++++++++++++
5 files changed, 62 insertions(+), 5 deletions(-)
(nuttx) 02/02: procfs/meminfo: free delaylist for PROTECTED
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 160ca004ac3d649f6a6fb0db4bf95843e2f29086
Author: Yanfeng Liu <yf...@qq.com>
AuthorDate: Mon Jul 1 19:05:57 2024 +0800
procfs/meminfo: free delaylist for PROTECTED
This triggers `mm_free_delaylist()` before dumping status in PROTECTED
build, otherwise the `free` command still shows delaylist as `used`.
Signed-off-by: Yanfeng Liu <yf...@qq.com>
---
fs/procfs/fs_procfsmeminfo.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/procfs/fs_procfsmeminfo.c b/fs/procfs/fs_procfsmeminfo.c
index 0e145d2545..eeb0889ded 100644
--- a/fs/procfs/fs_procfsmeminfo.c
+++ b/fs/procfs/fs_procfsmeminfo.c
@@ -314,6 +314,13 @@ static ssize_t meminfo_read(FAR struct file *filep, FAR char *buffer,
buffer += copysize;
buflen -= copysize;
+ /* Trigger reclamation of delay list otherwise they will be
+ * counted as used, which often confuses people like memory
+ * leakages. see pull/12817 for more information.
+ */
+
+ mm_free_delaylist(entry->heap);
+
/* Show heap information */
info = mm_mallinfo(entry->heap);
(nuttx) 01/02: mm/mm.h: add mm_free_delaylist interface
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit cafee0e086f2d87a134648f20bb26b7646fd82ab
Author: Yanfeng Liu <yf...@qq.com>
AuthorDate: Fri Aug 2 12:00:07 2024 +0800
mm/mm.h: add mm_free_delaylist interface
This adds explicit `void mm_free_delaylist(heap)` interface so that
to force freeing the heap's delaylist.
Signed-off-by: Yanfeng Liu <yf...@qq.com>
---
arch/sim/src/sim/sim_heap.c | 26 +++++++++++++++++++++-----
include/nuttx/mm/mm.h | 2 ++
mm/mm_heap/mm_malloc.c | 16 ++++++++++++++++
mm/tlsf/mm_tlsf.c | 16 ++++++++++++++++
4 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/arch/sim/src/sim/sim_heap.c b/arch/sim/src/sim/sim_heap.c
index ac1828dcd8..5095bb5654 100644
--- a/arch/sim/src/sim/sim_heap.c
+++ b/arch/sim/src/sim/sim_heap.c
@@ -97,7 +97,7 @@ static void mm_add_delaylist(struct mm_heap_s *heap, void *mem)
#endif
}
-static bool mm_free_delaylist(struct mm_heap_s *heap, bool force)
+static bool free_delaylist(struct mm_heap_s *heap, bool force)
{
bool ret = false;
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
@@ -293,6 +293,22 @@ void mm_free(struct mm_heap_s *heap, void *mem)
mm_delayfree(heap, mem, CONFIG_MM_FREE_DELAYCOUNT_MAX > 0);
}
+/****************************************************************************
+ * Name: mm_free_delaylist
+ *
+ * Description:
+ * force freeing the delaylist of this heap.
+ *
+ ****************************************************************************/
+
+void mm_free_delaylist(FAR struct mm_heap_s *heap)
+{
+ if (heap)
+ {
+ free_delaylist(heap, true);
+ }
+}
+
/****************************************************************************
* Name: mm_realloc
*
@@ -324,7 +340,7 @@ void *mm_realloc(struct mm_heap_s *heap, void *oldmem,
int usmblks;
int newsize;
- mm_free_delaylist(heap, false);
+ free_delaylist(heap, false);
if (size == 0)
{
@@ -351,7 +367,7 @@ void *mm_realloc(struct mm_heap_s *heap, void *oldmem,
while (atomic_compare_exchange_weak(&heap->usmblks, &usmblks, uordblks));
#if CONFIG_MM_FREE_DELAYCOUNT_MAX > 0
- if (mem == NULL && mm_free_delaylist(heap, true))
+ if (mem == NULL && free_delaylist(heap, true))
{
return mm_realloc(heap, oldmem, size);
}
@@ -420,7 +436,7 @@ void *mm_memalign(struct mm_heap_s *heap, size_t alignment, size_t size)
int uordblks;
int usmblks;
- mm_free_delaylist(heap, false);
+ free_delaylist(heap, false);
mem = host_memalign(alignment, size);
if (mem == NULL)
@@ -444,7 +460,7 @@ void *mm_memalign(struct mm_heap_s *heap, size_t alignment, size_t size)
while (atomic_compare_exchange_weak(&heap->usmblks, &usmblks, uordblks));
#if CONFIG_MM_FREE_DELAYCOUNT_MAX > 0
- if (mem == NULL && mm_free_delaylist(heap, true))
+ if (mem == NULL && free_delaylist(heap, true))
{
return mm_memalign(heap, alignment, size);
}
diff --git a/include/nuttx/mm/mm.h b/include/nuttx/mm/mm.h
index 63fd379adf..6ba6891176 100644
--- a/include/nuttx/mm/mm.h
+++ b/include/nuttx/mm/mm.h
@@ -263,6 +263,8 @@ void kmm_addregion(FAR void *heapstart, size_t heapsize);
FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) malloc_like1(2);
+void mm_free_delaylist(FAR struct mm_heap_s *heap);
+
/* Functions contained in kmm_malloc.c **************************************/
#ifdef CONFIG_MM_KERNEL_HEAP
diff --git a/mm/mm_heap/mm_malloc.c b/mm/mm_heap/mm_malloc.c
index fa980021ea..c6cde651eb 100644
--- a/mm/mm_heap/mm_malloc.c
+++ b/mm/mm_heap/mm_malloc.c
@@ -137,6 +137,22 @@ void mm_mempool_dump_handle(FAR struct mempool_s *pool, FAR void *arg)
* Public Functions
****************************************************************************/
+/****************************************************************************
+ * Name: mm_free_delaylist
+ *
+ * Description:
+ * force freeing the delaylist of this heap.
+ *
+ ****************************************************************************/
+
+void mm_free_delaylist(FAR struct mm_heap_s *heap)
+{
+ if (heap)
+ {
+ free_delaylist(heap, true);
+ }
+}
+
/****************************************************************************
* Name: mm_malloc
*
diff --git a/mm/tlsf/mm_tlsf.c b/mm/tlsf/mm_tlsf.c
index 8e8d74dee9..98f2566bf9 100644
--- a/mm/tlsf/mm_tlsf.c
+++ b/mm/tlsf/mm_tlsf.c
@@ -1447,3 +1447,19 @@ FAR void *mm_zalloc(FAR struct mm_heap_s *heap, size_t size)
return alloc;
}
+
+/****************************************************************************
+ * Name: mm_free_delaylist
+ *
+ * Description:
+ * force freeing the delaylist of this heap.
+ *
+ ****************************************************************************/
+
+void mm_free_delaylist(FAR struct mm_heap_s *heap)
+{
+ if (heap)
+ {
+ free_delaylist(heap, true);
+ }
+}