Commit Graph

68 Commits

Author SHA1 Message Date
Xu Xingliang 3d8b504779 mm: fix kasan report error when delay free is enabled
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
2024-10-16 10:23:10 +08:00
xuxingliang bc9d6549e9 mm: call sched_note within mm lock
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-16 10:23:10 +08:00
liwenxiang1 015a45517e mempool: add the minimum size configuration of mempool
The minimum size of mempool can be configured through CONFIG_MM_MPOOL_MINISIZE

Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
2024-10-13 02:46:57 +08:00
buxiasen 8def44b65a mm/dump: pretty the log and thin dump call
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-08 23:55:59 +08:00
buxiasen fd9a9f67cc memdump: add biggest allocated node dump
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-08 23:55:59 +08:00
buxiasen fd6634ecb5 mm/dump: make macro more common, fix help prompt
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-08 23:55:59 +08:00
xuxingliang 18d5ae20f5 drivers/segger: add heap data plot
Add heap current used to note.
Plot it in segger sysview data plot.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-07 17:34:59 +08:00
xuxingliang eac6a8597f sched/note: add note when mm add new region
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-07 17:34:59 +08:00
xuxingliang 0663ac1483 sched/note: specify note event for heap instrumentation
1. Add NOTE_HEAP_ prefix for heap note event.
2. Use note type as heap instrumentation parameter.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-07 17:34:59 +08:00
yinshengkai 8fecd0385b mm: fix memory statistics error
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-07 17:34:59 +08:00
yinshengkai 79eab8783f note: add memory tracing event support
Record all memory allocation and release, save to ram, used to analyze memory allocation rate and memory usage
Its absolute value is not trustworthy because the memory will be allocated in thread A and released in thread B

 netinit-5   [0]   0.105984392: tracing_mark_write: C|5|Heap Usage|96|free: heap: 0x606000000020 size:24, address: 0x603000000370
 netinit-5   [0]   0.105996874: tracing_mark_write: C|5|Heap Usage|24|free: heap: 0x606000000020 size:72, address: 0x6070000008e0
nsh_main-4   [0]   3.825169408: tracing_mark_write: C|4|Heap Usage|2177665|free: heap: 0x606000000020 size:424, address: 0x614000000840
nsh_main-4   [0]   3.825228525: tracing_mark_write: C|4|Heap Usage|14977|free: heap: 0x606000000020 size:2162688, address: 0x7f80a639f800
nsh_main-4   [0]   3.825298789: tracing_mark_write: C|4|Heap Usage|15189|malloc: heap: 0x606000000020 size:20, address: 0x6030000003a0

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-07 17:34:59 +08:00
yinshengkai 5ee7c563a5 mm: add kasan_unregister implementaion
In mm_uninitialize should unregister kasan

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-09-19 03:15:29 +08:00
wangmingrong ae3facda53 kasan: Implementation of Kasan based on software tags.
Currently, only aarch64 is supported

Signed-off-by: wangmingrong <wangmingrong@xiaomi.com>
2024-09-19 03:15:29 +08:00
Xiang Xiao 9c6bed4b00 mm: Move kasan.h from mm/kasan to include/nuttx/mm
so other parts of the system can use it.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-09-19 03:15:29 +08:00
Alin Jerpelea 339457dda3 mm: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-09-13 08:49:05 +08:00
yinshengkai 84333881d7 mm: add mm_largest api to get the current largest available memory block
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-25 23:09:28 +08:00
yinshengkai 49d1b4198f mm: add memory pressure notification support
Add mm_heap_free interface to pass remaining memory to memory pressure

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-25 23:09:28 +08:00
Yanfeng Liu cafee0e086 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 <yfliu2008@qq.com>
2024-08-03 01:30:04 +08:00
fangpeina 242b50f921 libc/execinfo: extract a common backtrace format function
Add a common method to format backtrace to buffer, so it can be used by both mm, fs and other possoble modules.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2024-06-29 22:44:39 +08:00
buxiasen 756d9508bc mm: mm_threshold perfer from init
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-06-26 00:20:44 +08:00
buxiasen cf574fa466 mm: add mm_initialize_pool, make pool more flexible
now allow enable pool for extra heap, and disable umm/kmm pool.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-06-25 16:42:06 +08:00
buxiasen 870d989d6c mm: seperate mm_pool and mm_pool init
make possible enable pool, but disabled in system heap.
also compatible for further extra heap use/not use pool.
Now use MM_HEAP_MEMPOOL_THRESHOLD -1 to indicate pool disabled.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-06-23 11:09:39 +08:00
chao an feb6ede434 sched/cpu: replace up_cpu_index() to this_cpu()
In SMP mode, up_cpu_index()/this_cpu() are the same, both return the index of the physical core.
In AMP mode, up_cpu_index() will return the index of the physical core, and this_cpu() will always return 0

| #ifdef CONFIG_SMP
| #  define this_cpu()             up_cpu_index()
| #elif defined(CONFIG_AMP)
| #  define this_cpu()             (0)
| #else
| #  define this_cpu()             (0)
| #endif

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-21 18:52:35 +08:00
wangmingrong d2fd043575 mm: Using Macros Instead of Memory to Fill Labels
Signed-off-by: wangmingrong <wangmingrong@xiaomi.com>
2024-03-14 22:48:19 +08:00
Xu Xingliang 6e7115ca09 mm: free delay list when exceeding specified count
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
2023-11-15 12:05:20 +01:00
Xiang Xiao 0fbeea64d5 mm: Remove mm_spinlock
since it's enough to protect per cpu delay list by disabling interrupt

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-11-12 11:27:38 +08:00
yinshengkai bb5b5420ae mm: record the maximum system memory usage
Add the usmblks field to mallinfo to record the maximum space allocated historically in the system

https://man7.org/linux/man-pages/man3/mallinfo.3.html#:~:text=mmap(2).-,usmblks,-This%20field%20is

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-11-09 09:08:49 +08:00
Xiang Xiao 0c805ca0a9 mm: Change global spinlock to per heap
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-30 11:18:34 +02:00
Xiang Xiao 08bae13624 mm/tlfs: Replace the critical section with spin lock
Base on discusion: https://github.com/apache/nuttx/issues/10981

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-30 11:18:34 +02:00
ligd 13f0051747 mm: rewrite the memdump code for more readable
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-09-24 10:39:18 +08:00
dongjiuzhu1 36e3d32740 mm/heap: add coloration after free to detect use after free issue
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-09-11 15:28:34 -04:00
wangbowen6 b0ab41beee memdump: support dump the leak memory (malloced but task exit)
1. command "memdump leak" can dump the leacked memory node;
2. fix the leak memory stat bug in memory manager;

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2023-07-31 05:48:33 -07:00
wangbowen6 2dedaa449b mm: use shced_backtrace and skip the first numbers in mm backatrace
beacause the first numbers backtrace in mm node is same, skip them to
show more useful backtrace.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2023-07-31 05:46:37 -07:00
anjiahao 79c0fafc06 mm:Fix the problem that the memdump statistics of blkcont are inconsistent
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-06-25 18:17:30 +08:00
Xiang Xiao a8e0a5faa4 sched: Remove the unnecessary cast from pid_t to int
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-19 11:37:34 +03:00
Xiang Xiao 07b0cd1cba mm: Simplify memdump_handler logic a little bit
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-19 11:37:34 +03:00
Xiang Xiao 590e968c5f mm/tlfs: Count the backtrace overhead in mm_mallinfo_task
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-19 11:37:34 +03:00
Xiang Xiao 9b6cd96671 mm: Rename PID_MM_INVALID to PID_MM_LEAK
to express the intent more clear

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-18 14:26:07 +03:00
Xiang Xiao b00237ac01 mm: Move PID_MM_MEMPOOL after PID_MM_ALLOC
so the allocation from mempool could be dumped correctly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-18 09:12:14 +03:00
Xiang Xiao f01deff80f mm: Rename MM_BACKTRACE_XXX_PID to PID_MM_XXX
and move the definition to malloc.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-18 09:12:14 +03:00
Xiang Xiao ddbe9eb6ab mm: Rename mm_memdump_s to malltask
align with the naming of mallinfo_task

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-18 09:12:14 +03:00
Xiang Xiao d920bfba10 mm: include malloc.h in mm/mm.h
to remove the forward declaration of mallinfo and mallinfo_task

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-11 19:37:04 +03:00
anjiahao 7732791cd6 mempool:Add mail_info support for multiple pools
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-06-08 23:56:40 +08:00
anjiahao 6572081e07 mempool:Allocate a chunk for multiple mempool avoid memory fragmentation
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-06-08 23:56:40 +08:00
Xiang Xiao dfe583e1de Fix tlsf/mm_tlsf.c:151:28: error: ‘TCB_FLAG_HEAPDUMP’ undeclared
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-01 08:19:04 +03:00
Xiang Xiao 3edff9d323 mm/tlsf: Change "memdump_backtrace_s *dump" to memdump_backtrace_s *buf"
avoid the conflict with "mm_memdump_s *dump"

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-01 08:19:04 +03:00
ligd 1a927a6cf3 mm: add invalid pid dump when malloc failed
We can dump the memory that has exited but
has not been released

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-05-30 02:19:59 +08:00
anjiahao c60dd72a2a Support memdump to realize incremental dump function
Add a new field to record the global on the basis of mm_backtrace.
When using alloc, the field is incremented by 1,
so that the memory usage can be dumped within the range
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-05-22 12:31:32 +08:00
anjiahao 97e652aed1 tlsf:fix bug invalid reference & mm_backtace need tid
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-05-22 12:31:32 +08:00
Xiang Xiao 7990f90915 Indent the define statement by two spaces
follow the code style convention

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-21 09:52:08 -03:00