Commit graph

400 commits

Author SHA1 Message Date
mage1
fc3920904e mm: Add dmalloc wrapper layer and enable dmalloc module.
Change-Id: I83fe5e275215946d5962379fc7aad882724741f2
2021-07-10 05:04:56 -07:00
Xiang Xiao
0961be771a mm: Simplify the semaphore handling
1.Move all special process to mm_takesemaphore
2.Remove the support of recurive lock
3.Remove mm_trysemaphore function

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ie216a6294ab67c5d427f31b089beb15c532f08fe
2021-07-10 05:02:33 -07:00
Xiang Xiao
9166ffe83c mm/tlfs: Report the number of used block correctly
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I0457b3843e9e62b47b1600d627909533aab8986d
2021-07-08 22:56:10 +08:00
Xiang Xiao
0fe1c85ba4 mm: Remove mm_heap_impl_s struct
it's more simple to make mm_heap_s opaque outside of mm

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I5c8e435f6baba6d22b10c5f7e8d9191104fb5af2
2021-07-07 02:14:53 -07:00
Xiang Xiao
8cea82708a mm/tlsf: don't do mm_checkcorruption in IRQ
because this not safe in SMP mode, port from:
commit 34f63bdc13

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I288f373e10aa4a68034fc9d9a0f87a0dc3f36cd5
2021-07-04 10:36:58 -07:00
Xiang Xiao
4adf7ad09d mm/tlsf: Register mem procfs in mm_initialize
follow up this change:
commit 268d66173d
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date:   Sat Jul 3 21:25:14 2021 +0800

    mm: Move procfs_register_meminfo into common place

    to avoid the code duplication and ensure the consistent behaviour

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ifd9f6ff67f0cb6de54d733f929474154830dc46b
2021-07-04 00:56:24 -07:00
Xiang Xiao
69cb1d7086 mm: Move the real implementation of mm_sbrk to sbrk
and remove mm_sbrk and kmm_sbrk since it's wrong to expose
sbrk to other heaps except the default userspace heap.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I78fdf34c271585ec8fdb81eacedda9fc9f2431fb
2021-07-04 00:53:07 -07:00
Xiang Xiao
9cd1252109 mm: Call memalign in malloc if ARCH_ADDRENV and BUILD_KERNEL are defined
to reuse the sbrk logic inside memalign

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-07-04 15:35:13 +08:00
Xiang Xiao
268d66173d mm: Move procfs_register_meminfo into common place
to avoid the code duplication and ensure the consistent behaviour

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I3fa9ba13d3f8abf882907782708f52c788d0c813
2021-07-04 15:33:19 +08:00
liuhaitao
b072d4709a mm: correct typo error to fix build break
Change-Id: Ieb053b4e58e127121fa5e9a93cb7da6ec7b0474a
Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2021-07-01 21:16:30 +08:00
ligd
dcea2afd7e mm: fix memory corruption when loop create/exit thread in SMP mode
Root casue:
when do thread exit, need add free stack operation to mm_delaylist,
but in SMP mode, CPU0 thread1 exit, at this time, CPU1 call malloc
and free mm_delaylist.

Fix:
Divide mm_delaylist for per CPU in SMP mode.

Change-Id: Ibf7d04614ea2f99fb5b506356b7346a0d94f0590
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-07-01 18:26:20 +08:00
ligd
34f63bdc13 mm: don't do mm_checkcorruption in IRQ
because this not safe in SMP mode

Change-Id: Ifaf49818c51ee4283f0e280ae3e4e23cbd0dba08
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-07-01 18:26:20 +08:00
Xiang Xiao
82047fe3c4 mm: Add kmm_malloc_size and mm_malloc_size
make malloc_size implementation align with malloc

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I8d7781925f06e58a880437a16569dccbfd2ea035
2021-07-01 18:08:54 +08:00
Xiang Xiao
3dd31cba2c Move aligned_alloc, posix_memalign and valloc from mm/umm to libs/libc/stdlib
since the similar functions(e.g. strdup/strndup) put into libs/libc/string

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ifb2c0c51298b09014748e5ee8275db51213d6911
2021-07-01 18:08:54 +08:00
Xiang Xiao
4e3c1ed8af mm: Support malloc_size function
and rename malloc_usable_size to malloc_size

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I8d83e9148d70e752142af26d7dd9a291123fdd14
2021-06-28 21:26:09 +08:00
chao.an
2152a35662 net: fix build break
Change-Id: I662580ded8d1c98ddcfbcfae961978eb3512e3b9
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-09 22:07:45 +08:00
chao.an
2fd5872449 mm/iob: add iob_get_queue_size() helper
Change-Id: I117530f364cbef1e011638ff6d14087b7447bde7
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-08 11:57:52 +08:00
chao.an
dcc2db8d40 make/archive: replace the dependency to preprequisite list
Change-Id: Id63f3cd32906461a54cb016ef8078d4d922845e2
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-05-07 21:34:45 +08:00
liuhaitao
dc639b2b59 Merge remote-tracking branch 'mirtos/master' into dev-upmerge-nuttx-10.1-0507
Change-Id: I4bb3a61356be2b4a77ccfe45390b15e68a376dd6
Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2021-05-07 20:46:07 +08:00
liuhaitao
e3166ecac0 Revert "make/archive: replace the dependency to preprequisite list"
This reverts commit 9c946e2af6.

Change-Id: Ia8b7726d036c861d5eda51765d330e894e0d214a
2021-05-07 16:38:39 +08:00
Jiuzhu Dong
241dcfacd1 cmd/free: add nused field in command free
N/A

Change-Id: I74aa4b1e7394a17c3b117322a4cc24aa52aac3b8
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-04-28 11:34:26 +08:00
ligd
fcdb6444ad mm: idle check heap use mm_trysemaphore
Change-Id: I92e1df572fa6cd801b10e5b06e7b04d450b3e3fb
Signed-off-by: ligd <liguiding1@xiaomi.com>
(cherry picked from commit bc9a5d1ca9656f6effd3a419cc2488586dfb1489)
2021-04-16 20:56:44 +08:00
Xiang Xiao
037dd2acf4 mm/tlfs: Remove the critical section
follow the mm heap change

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ic9700e7ab3629d755723ad8b1c5b1c5cc896a518
2021-04-06 15:37:55 +08:00
Xiang Xiao
0d12e8bae5 libc/assert: Reference the expression in all case
to avoid the warning "defined but not used"

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I55b7c092d0f2e5882fc1784987657c10cdf2d90b
2021-04-06 14:47:51 +08:00
Brennan Ashton
3cdc0b7332 libc: Add additional checks to malloc realloc and memalign 2021-04-04 18:58:04 -07:00
Xiang Xiao
5f3a98b5a8 libc/assert: Reference the expression in all case
to avoid the warning "defined but not used"

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I55b7c092d0f2e5882fc1784987657c10cdf2d90b
2021-04-03 21:00:41 +01:00
Masayuki Ishikawa
f99f590751 mm: mm_heap: Remove critical section in mm_sem.c
Summary:
- This commit removes critical section in mm_sem.c which was
  added to stabilize the NuttX SMP kernel in Mar 2018.

Impact:
- SMP only

Testing:
- Tested with ostest with the following configs
 - maix-bit:smp (QEMU), esp32-devkitc:smp (QEMU)
 - sabre-6quad:smp (QEMU), spresense:smp, sim:smp
- Tested with nxplayer with the following configs
 - spresense:wifi_smp, spresense:rndis_smp

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-03-31 22:43:23 -05:00
ligd
29cdf66e1a mm/mm_heap: fix compile failed when open DEBUG_MM
Change-Id: Id21e9619e4800ec9f02f818ec86d80cdd99d9aae
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-03-30 01:14:37 -05:00
Xiang Xiao
e14c458747 mm/heap: Move semaphore related declaration to private header
since other subsystem doesn't need call these function anymore

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Idfb217c412db62d9f17f427310b75bb78785dc50
2021-03-22 15:35:32 +01:00
Xiang Xiao
473bacd7a2 mm/heap: Add FAR to the pointer type
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-03-21 10:11:43 +01:00
Xiang Xiao
10e3d28372 mm/heap: Change nxsem_init to _SEM_INIT
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I84ad710c3ebe92d31d6c8dc1ddf6b63c10494ce2
2021-03-21 10:11:43 +01:00
mage1
874ecbe2f3 mm: add kconfig option to control the memory manger strategy choice.
since will will porvide more the one  strategy in future.

Change-Id: I73b900c6571f9b71b8239dd72006bdd0a68ee64d
2021-03-19 09:56:39 -07:00
mage1
635cfadc25 mm: Move mm_heap_s related stuff to private header file
since it will improve the modularity and reduce the inforamtion explosion

Change-Id: I085b36adb38993a979625a1f4c252d364a15afa1
2021-03-19 09:56:39 -07:00
ligd
90a75dfedf mm/tlsf: fix mm_checkcorruption failed, caused by mm_takesemaphore() param error
Change-Id: Id3fc81754f623c53151ba2ae02c0271008d5f3e3
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-03-16 20:45:56 +08:00
YAMAMOTO Takashi
f8d56b9da2 iob_trimhead.c: Fix a comment typo 2021-03-16 02:07:34 -07:00
YAMAMOTO Takashi
6b9d2fef00 mm/iob/Kconfig: Fix a typo (other other -> other) 2021-03-16 02:07:34 -07:00
liuhaitao
0883499e39 Add dmalloc .gitignore file
Change-Id: I8d712d314c81bdb86c9aa74c8c5e7e21aa043f9d
Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2021-03-11 16:32:49 +08:00
Xiang Xiao
777a99ea00 mm: Integrate TLSF manager
can be enabled by CONFIG_MM_TLSF_MANAGER=y

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Id3cb6549b6dd881a9549f3202ab4b3ebdceb3ca4
2021-03-10 21:14:34 +08:00
Xiang Xiao
05abfac89b mm/heap: Move semaphore related declaration to private header
since other subsystem doesn't need call these function anymore

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Idfb217c412db62d9f17f427310b75bb78785dc50
2021-03-10 21:13:56 +08:00
Xiang Xiao
cbeb35c646 mm/heap: Replace _SEM_GETERROR with _SEM_ERRVAL
and change nxsem_init to _SEM_INIT

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I84ad710c3ebe92d31d6c8dc1ddf6b63c10494ce2
2021-03-10 21:13:56 +08:00
Gustavo Henrique Nihei
330eff36d7 sourcefiles: Fix relative path in file header 2021-03-09 23:18:28 +08:00
chao.an
92b0b1d0f2 mm/iob: iob_get_queue_count() should return the iob count
Change-Id: Ief7b98589613c59754f1a4d265aaa4760ad3d209
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-03-08 13:59:12 +08:00
ligd
1d66d5c297 debug tools: add heap & stack check in idle thread
N/A

Change-Id: Iba6f5cdffb1336697096c71fca86c9ece584225f
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-03-04 18:38:05 -08:00
dongjiuzhu1
4438681a51 mm/umm_heap: move memory-related api from libc/stdlib to umm
N/A

Change-Id: I4cf7f2586c8b476336e7d32e518b2c774e6ce746
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-03-03 22:24:49 +08:00
ligd
49389e2695 mm/net/sched: fix warnings
Change-Id: I92db0e2cb7ff9e63eef8086a7cc084f67045d69c
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-03-03 19:26:43 +08:00
mage1
15fc1cb23f mm: add kconfig option to control the memory manger strategy choice.
since will will porvide more the one  strategy in future.

Change-Id: I73b900c6571f9b71b8239dd72006bdd0a68ee64d
2021-03-03 15:04:27 +08:00
mage1
465f98384b mm: Move mm_heap_s related stuff to private header file
since it will improve the modularity and reduce the inforamtion explosion

Change-Id: I085b36adb38993a979625a1f4c252d364a15afa1
2021-03-02 22:21:46 +08:00
chao.an
800421e231 net/tcp: cache the drop packet to avoid retransmit
Change-Id: Ia27ed17a7708df8481ac96d9a3a870b6ccef4d24
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-03-02 10:12:56 +08:00
chao.an
9c946e2af6 make/archive: replace the dependency to preprequisite list
Change-Id: Id63f3cd32906461a54cb016ef8078d4d922845e2
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-03-01 21:10:15 +08:00
chao.an
3a658ee32c mm/circbuf: fix compile warning
circbuf/circbuf.c:133:14: warning: 'len' may be used uninitialized in this function [-Wmaybe-uninitialized]
  133 |   circ->head = len;
      |   ~~~~~~~~~~~^~~~~
circbuf/circbuf.c:106:10: note: 'len' was declared here
  106 |   size_t len;
      |          ^~~

Change-Id: I60e42b88e98838f5654d84b70f109a4df5a7ff26
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-03-01 16:14:25 +08:00