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
buxiasen
bdcda24a68
mm: fix mm_curused calculate err
...
before fix, the maxused shown in free command is not accurate.
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-06-07 03:29:02 +08:00
Xu Xingliang
b5f8498142
mm: check double free before adding to delaylist
...
If free memory is delayed, check case of double free in the first
place.
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
2024-06-04 17:42:28 -03:00
yinshengkai
20ebe0e64c
Replace all asserts in kernel code with ASSERT
...
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-05-17 10:18:16 -03: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
Yanfeng Liu
813f67f93b
mm_heap/mm.h: revising comments
...
Revising comments to be in line with code
Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-03-12 19:44:48 +08:00
Yanfeng Liu
5ac401d941
mm/kconfig: fix typo in MM_DEFAULT_ALIGNMENT
...
This fixes minor typo in MM_DEFAULT_ALIGNMENT
Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-03-11 13:12:34 +08:00
Masayuki Ishikawa
e67d32a5ba
Revert "fix variable set but not used"
...
This reverts commit d2d93ba58c
.
2024-02-21 21:29:48 -08:00
yinshengkai
d2d93ba58c
fix variable set but not used
...
These variables will trigger variable 'ret' set but not used warnings due to different configurations.
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-02-21 13:28:20 -03:00
Nathan Hartman
3ed629274e
mm: Fix some typos
2023-11-24 09:57:10 -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
ligd
fe03ce5fbe
mm: both use spin_lock_irqxx() when operated delaylist
...
align with free_delaylist()
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-10-27 22:27:15 +08:00
TaiJuWu
51eaa59cc0
Replace enter_critical_section with spin_irqsave
...
Base on discusion: https://github.com/apache/nuttx/issues/10981
Signed-off-by: TaiJuWu <tjwu1217@gmail.com>
2023-10-21 11:00:07 +08:00
anjiahao
5d6f6f2d47
mm:fix warning
...
mm_heap/mm_initialize.c:69:11: warning: array subscript -1 is outside array bounds of 'void[2147483647]' [-Warray-bounds]
69 | node->pid = MM_BACKTRACE_MEMPOOL_PID;
| ^~
mm_heap/mm_initialize.c:64:9: note: at offset -16 into object of size [0, 2147483647] allocated by 'mm_memalign'
64 | ret = mm_memalign(arg, alignment, size);
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-09-26 14:12:59 +08: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
Petro Karashchenko
1c2931222c
mm/mm_heap: add parenthesis in macro definition
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-09-16 14:17:47 +08:00
Xuxingliang
b9e59ad0a7
mm: add macro to judge if node/prenode is free
...
Signed-off-by: Xuxingliang <xuxingliang@xiaomi.com>
2023-09-12 22:09:36 +08:00
Xuxingliang
c9f33b7ee5
mm: use unified naming style for macros
...
Make all macro name starts with prefix MM_
Signed-off-by: Xuxingliang <xuxingliang@xiaomi.com>
2023-09-12 22:09:36 +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
xuxin19
5b6488f09f
cmake:complete missing changes during cmake reforming for mm
...
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2023-09-08 21:20:16 +03:00
pengyiqiang
8c19fc547d
mm_heap: check heap member in advance
...
Block wrong address in advance before entering mempool.
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
2023-08-07 01:06:05 -07:00
Bowen Wang
477602e657
mm_heap: mm dump and panic only valid for the heap own by OS
...
When other code use nuttx memory manager by call mm_xx api directly,
it better to let other code to control weather dump or panic when
malloc failed.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2023-08-02 06:11:59 -07: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
chao an
6ee9ec7656
build: add initial cmake build system
...
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)
------------------
How to test
From within nuttx/. Configure:
cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja
(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja
This uses ninja generator (install with sudo apt install ninja-build). To build:
$ cmake --build build
menuconfig:
$ cmake --build build -t menuconfig
--------------------------
2. cmake/build: reformat the cmake style by cmake-format
https://github.com/cheshirekow/cmake_format
$ pip install cmakelang
$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done
Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:48 +08: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
tjwu1217
42914040de
mm_lock.c: reformat preprocessor format
2023-06-24 10:54:19 -03: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
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
c76f9f9349
mm/heap: Count mm_heap_s overhead in mm_mallinfo
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-17 19:11:07 -03:00
wangbowen6
372fba70bb
mm_heap: dump and stat the mm_heapend node also
...
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2023-06-17 19:37:14 +08: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
e98a153cb2
mm/mempool: Remove nexpend and totalsize from mempool_s
...
forget in the commit(https://github.com/apache/nuttx/pull/9052 ):
commit 781a34da94
Author: anjiahao <anjiahao@xiaomi.com>
Date: Tue Apr 18 11:18:43 2023 +0800
memepool:fix memory consumption double counting issue
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-04 11:47:51 -03:00
yinshengkai
aad2f97587
mm: Dump all memory blocks on allocation failure
...
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-05-31 15:24:25 +08:00
anjiahao
045b9ffd54
mempool:fix bug read out of bounds when realloc
...
fix kasan report
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-05-30 23:12:07 +08:00
chao an
fb9b41221d
semantic/parser: fix compile warning found by sparse
...
Reference:
https://linux.die.net/man/1/sparse
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-30 23:00:00 +08:00