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
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
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
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
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
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
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
wangbowen6
3e971d2e6d
mm_heap: double malloced memory default alignment (4 -> 8, 8 -> 16)
...
Base on the gnu libc standard:
https://www.gnu.org/software/libc/manual/html_node/Aligned-Memory-Blocks.html
Change the default memory aligment to 8 bytes for 32-bit system and
16 bytes for 64-bit system.
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2023-03-06 11:27:43 +01:00
wangbowen6
70083168f1
mm: support custom the mm alignment and default to be 8
...
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2023-03-06 11:10:36 +08:00
chao an
4c8d244fae
sched/getpid: replace syscall getpid/tid/ppid() to kernel version
...
NuttX kernel should not use the syscall functions, especially after
enabling CONFIG_SCHED_INSTRUMENTATION_SYSCALL, all system functions
will be traced to backend, which will impact system performance.
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-02 10:33:01 +08:00
wangbowen6
b1948a1631
mm: move preceding to previous free node to reduce the overhead
...
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2023-02-01 11:14:02 +08:00
wangbowen6
723c6e52e2
mm: reorder the preceding and size and move MM_ALLOC_BIT to size
...
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2023-02-01 11:14:02 +08:00
anjiahao
632ed0d3a4
Optimize multipe mempool memory space usage
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-01-18 14:12:45 +08:00
anjiahao
6b530fceae
mempool:change mempool_multiple way of initialization
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-01-18 14:12:45 +08:00
Xiang Xiao
154bb93c45
mm: Terminate the backtrace array with one NULL pointer
...
since one entry is enough to identify the end of back trace
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-17 16:48:30 +08:00
anjiahao
bdcb1f6a25
fix:mmsize_t need support 64bit
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-01-16 20:32:17 +08:00
dongjiuzhu1
c82f44c4f3
mm/mm_heap: add mempool to optimize small block performance
...
There are many small memory block in NuttX system, eg: struct tcb_s,
struct inode, etc, and several disadvantages about them:
1.Their frequent allocate and free cause the system memory fragmentation.
2.Since each memory block has an overhead, the utilization of small memory
blocks is relatively low, which will cause memory waste.
So we can use mempool to alloc smallo block, to improve alloc speed
and utilization, to reduce fragmentation.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-01-16 20:32:17 +08:00
dongjiuzhu1
7cd325f3be
mm/mm_heap: remove kasan in MM_ADD_BACKTRACE
...
do simple copy to instead of memset and memcpy operation because
they have been instrumented, if you access the posion area,
the system will crash.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-01-16 20:32:17 +08:00
Xiang Xiao
54de894e52
mm/heap: Skip memset backtrace buffer
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-08 01:25:18 +02:00
Xiang Xiao
70ecb4ef26
mm/heap: Changee mmchunk_handler_t to mm_node_handler_t
...
to unify the term usage(chunk v.s. node and mm v.s. mm_)
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-08 01:25:18 +02:00
anjiahao
f403118647
mm:fix typos
...
./mm_heap/mm.h:86:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
86 | FAR strcut tcb_s *tcb; \
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-12-22 20:19:05 +08:00
anjiahao
70791af8e2
procmeminfo:support memdump can show specific task
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-12-19 20:43:33 +08:00
qinwei1
8021dfece6
sched/task/task_getpid: getpid should return process id not thread id
...
Summary:
implement the right semantics:
1. getpid should return the main thread id
2. gettid should return the current thread id
Refer to:
https://github.com/apache/incubator-nuttx/issues/2499
https://github.com/apache/incubator-nuttx/pull/2518
Signed-off-by: qinwei1 <qinwei1@xiaomi.com>
2022-11-17 17:58:08 +08:00
Xiang Xiao
7dcf35cf64
mm: Remove the unused macro MM_IS_ALLOCATED
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-08 14:57:48 +09:00
Xiang Xiao
b567e09c3c
mm: Restore the return type of mm_lock from bool to int
...
Fix the issue reported here better:
https://github.com/apache/incubator-nuttx/pull/6995
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-07 10:01:52 +01:00
Xiang Xiao
e08c296a8e
Change the type of tg_joinlock, mm_lock and md_lock from sem_t to mutex_t
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-31 10:35:53 +01:00
dongjiuzhu1
579e47347e
mm/mm_heap: define MM_MASK_BIT as significant bits mask
...
using MM_MASK_BIT to expand different bits of preceding field to store the
block status.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-10-29 00:12:02 +08:00
dongjiuzhu1
5982cafbe0
mm/mm_heap: using LOG2_CEIL to generate MM_MIN_SHIFT at compile time
...
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-10-29 00:12:02 +08:00
anjiahao
d1d46335df
Replace nxsem API when used as a lock with nxmutex API
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
chao.an
87cb224b1c
mm/kasan: node header should updated from unpoisoning memory
...
| (gdb) bt
| #0 up_assert (filename=0x7fffffffdc6c "\001", lineno=0) at sim/up_assert.c:75
| #1 0x00005555555e636b in _assert (filename=0x555555627225 "kasan/kasan.c", linenum=104) at assert/lib_assert.c:36
| #2 0x00005555555a388e in kasan_report (addr=140737284458088, size=1, is_write=true) at kasan/kasan.c:104
| #3 0x00005555555a40a1 in __asan_storeN_noabort (addr=140737284458088, size=1) at kasan/kasan.c:297
| #4 0x00005555555a4519 in __asan_store1_noabort (addr=140737284458088) at kasan/kasan.c:348
| #5 0x00005555555a26d7 in memset (s=0x7ffff3d8c668, c=0, n=63) at string/lib_memset.c:169
| #6 0x00005555555a46a4 in mm_addregion (heap=0x7ffff3d8c000, heapstart=0x7ffff3d8c648, heapsize=66058656) at mm_heap/mm_initialize.c:131
| #7 0x00005555555a4a00 in mm_initialize (name=0x555555627068 "Umem", heapstart=0x7ffff3d8c648, heapsize=67107256) at mm_heap/mm_initialize.c:231
| #8 0x00005555555a33b1 in umm_initialize (heap_start=0x7ffff3d8c000, heap_size=67108864) at umm_heap/umm_initialize.c:84
| #9 0x000055555558f17c in nx_start () at init/nx_start.c:469
| #10 0x0000555555589559 in main (argc=1, argv=0x7fffffffdf58, envp=0x7fffffffdf68) at sim/up_head.c:131
| (gdb)
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-02 01:44:48 +08:00
Jiuzhu Dong
9899dd0ec0
mm/mm_heap: change CONFIG_MM_BACKTRACE to int type
...
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-07-26 23:45:31 +08:00
Xiang Xiao
53c6789bef
mm: Add mm_uninitialize to release the resource
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-12 19:41:14 +09:00
YAMAMOTO Takashi
b05320cac2
mm: Move backtrace stuff into a separate option
...
The functionality has too much overhead for CONFIG_DEBUG_MM.
2022-05-21 14:28:41 +08:00
wangbowen6
1a4ccd2d70
Revert "mm_heap: heapsize align with MM_MIN_CHUNK."
...
This reverts commit 69e69740b5
.
2022-04-11 12:46:17 +08:00
wangbowen6
69e69740b5
mm_heap: heapsize align with MM_MIN_CHUNK.
...
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-03-31 19:50:25 +08:00
wangbowen6
a0bde21f0f
mm/mm_heap: place alloc-bit at the LSB of node->preceeding.
...
Heap always allocate the memory at least 2bytes alignment.
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-03-31 14:43:56 +03:00
Jiuzhu Dong
709207b8d3
mm/memdump: dynamic turn on backtrace in heap when enable DEBUG_MM
...
default turn off.
turn on: echo on > /proc/memdump
turn off: echo off > proc/memdump
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-03-27 13:21:48 +08:00
Petro Karashchenko
68902d8732
pid_t: unify usage of special task IDs
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-03-22 21:22:32 +08:00
Jiuzhu Dong
2dcc4a359d
mm/dump: add pid and backtrace for every memory node
...
usage:
echo <pid/used/free> trace > /proc/memdump
echo used > /proc/memdump //output all used memory info with backtrace
echo free > /proc/memdump //output all free memory info
echo 22 > /proc/memdump //output used memory info for task pid is 22 with backtrace
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-02-26 14:32:42 +08:00
Jiuzhu Dong
39eaeefb78
mm/mm_heap: remove the unnecessary check for memory node size
...
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-02-26 14:32:42 +08:00
Jiuzhu Dong
eba0323eae
mm/mm_heap: add mm_foreach to run handler for every memory node
...
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-02-13 03:20:31 +08:00
Xiang Xiao
77792a1598
sched: Define CONFIG_SMP_NCPUS to 1 in no SMP case
...
to simplify the SMP related code logic
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-20 23:21:21 +08:00
ligd
5b369c5cec
libs/lbc: remove CHAR_BIT = 16 support
...
For CEVA platform CHAR_BIT is 16, and will do lots of extra work
when use IPC.
We will not support this platform anymore, so remove all the b2c operations.
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-13 11:08:28 -06:00