Commit Graph

364 Commits

Author SHA1 Message Date
ligd aa43a0215d 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-02 04:55:46 -05:00
Xiang Xiao 187538c0b9 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 11:44:38 -07:00
YAMAMOTO Takashi 314237588e Add iob_tailroom
I plan to use this for tcp.
2021-06-30 06:40:13 -05:00
YAMAMOTO Takashi 7599ca4e95 Kconfig: mention that IOB_NCHAINS is not used by TCP anymore 2021-06-30 06:40:13 -05:00
chao.an 2c51c29768 mm/iob: add an interface to support dequeue an iob from the queue
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-10 10:45:30 -05:00
Xiang Xiao 5b2a17b892 Include assert.h in necessary place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-08 13:06:08 -07:00
Xiang Xiao 2e54df0f35 Don't include assert.h from public header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-03 08:36:03 -07:00
Alin Jerpelea 3744eb8b5f mm: update licenses to Apache
Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-05-27 08:07:25 +09:00
Jiuzhu Dong fea1da2f53 cmd/free: add nused/nfree field in command free
Change-Id: I74aa4b1e7394a17c3b117322a4cc24aa52aac3b8
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-05-25 01:01:38 -07:00
David Sidrane 85f0bc591e mm:initialize ensure alignment.
Broken by 635cfa.

   On an stm32 the heap is formed from
   const uintptr_t g_idle_topstack = HEAP_BASE;
   where HEAP_BASE is &_bss + CONFIG_IDLE_STACKSIZE.

   Both these values are not deterministic. One
   comes from the compiler, the other the system
   configurator.

   a 3 byte bss and 250 byte stack would lead to
   and unaligned address used as the heap to be.

   The compiler used clever `strd r1,r3,[r5,#8]` to
   store 2 values in one memory cycle into the
   heap_impl struct. Resulting in a hardfault.

   Change the amount of bss or the CONFIG_IDLE_STACKSIZE
   could lead to a non-functional NuttX system.
2021-05-19 21:25:08 -05: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
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
Gustavo Henrique Nihei 330eff36d7 sourcefiles: Fix relative path in file header 2021-03-09 23:18:28 +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
Jiuzhu Dong fecc68d1bb mm/umm_heap: move memory-related api from libc/stdlib to umm
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-02-26 11:47:11 -08:00
Jiuzhu Dong 355956fb57 umm_heap/valloc: support valloc (LEGACY)
Reference:
https://pubs.opengroup.org/onlinepubs/7908799/xsh/valloc.html

Change-Id: Ieb425a77b0a8d758956996d201223a0050ae4920
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-02-26 11:47:11 -08:00
Gustavo Henrique Nihei 76acb32e29 Fix typos reported by codespell 2021-02-25 11:31:49 -08:00
YAMAMOTO Takashi 929e438052 procfs: Use procfs_register_meminfo for "Kmem" 2021-02-12 03:16:03 -08:00
YAMAMOTO Takashi c25f4233aa procfs: Use procfs_register_meminfo for "Umem" 2021-02-12 03:16:03 -08:00
Alin Jerpelea acb8ad4c7b mm: nxstyle fixes
Nxstyle fixes to pass CI

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-09 01:21:53 -08:00
Alin Jerpelea bcee9c391c mm: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can mograte the licenses
to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-09 01:21:53 -08:00
Xiang Xiao 0defe43282 OS internal function should indicate the error by return negative value
instead to change errno value by calling set_errno

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-12-31 09:37:29 +01:00
dongjiuzhu 642718709d mm/circbuf: fix the problem of dividing by zero.
N/A

Change-Id: I78a5cae0f782bc2c09848ebda9589dc53809e089
Signed-off-by: dongjiuzhu <dongjiuzhu1@xiaomi.com>
2020-12-01 00:02:39 -06:00
Matias N 88f1cdb915 build system: add missing --obj-path to MKDEP 2020-11-28 09:59:56 -06:00
chao.an c56785bd0d style/Makefile: remove unnecessary trailing whitespace
N/A

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-28 12:20:30 +01:00
Matias N d5b6ec450f Parallelize depend file generation 2020-11-22 09:02:59 -03:00
YAMAMOTO Takashi 8da52c82b4 mm/mm_heap/mm_malloc.c: Fix syslog format errors 2020-11-20 22:22:53 -08:00
YAMAMOTO Takashi 7f61256b32 mm/mm_heap/mm_initialize.c: Fix syslog format errors 2020-11-20 22:22:53 -08:00
dongjiuzhu 23ddeaf3be mm/circbuf: support circular buffer managerment
N/A

Change-Id: Ib1fc009b9ce3af5815920f22221fe8a7262299ef
Signed-off-by: dongjiuzhu <dongjiuzhu1@xiaomi.com>
2020-11-20 05:33:03 -08:00
Matias N 166242c171 use "export" to expose TOPDIR to all child make instead of passing it around every time 2020-09-15 21:11:33 -07:00
ligd 6b7dd62bad mm/mm_heap/mm_initialize.c: add sem lock to mm_addregion()
Change-Id: I4a72e36fcd4504c0d8e671fe2243b14764db3b35
2020-09-15 08:50:01 +09:00
Xiang Xiao 3ea8d574fe mm: Implement malloc_usable_size
defined here:
https://man7.org/linux/man-pages/man3/malloc_usable_size.3.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I5988bb28375626188312bd0a0ba3fc12db66f644
2020-08-24 03:36:44 -07:00
SPRESENSE e249a2f82f Makefile: Fix Make.dep not updated by config changes
Make.dep file should be updated by .config changed after first make.
There are 2 cases affected for this problem:

 1) Add source files by config symbol
 2) Include header files in #ifdef directive

These 2 cases may not be included in Make.dep and this may prevent the
differential build from working correctly.
2020-07-28 03:59:45 -05:00
Brennan Ashton e87617f9fa nxstyle: fixup style issues in mm_realloc.c
Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
2020-06-29 14:56:26 -07:00
Brennan Ashton fcd6e1c7eb mm: Do not memcopy more than oldsize when realloc
When realloc up from a mem area to a larger one where a new node
is needed. The the larger memory region is copied from the source
this can both leak data as well as cause memory faults accesssing
invalid data.

This was first reported by Kwonsk

Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
2020-06-29 14:56:26 -07:00
YAMAMOTO Takashi 875828b698 Add a missing stdlib.h -> malloc.h change for mallinfo 2020-06-15 09:06:28 -06:00
YAMAMOTO Takashi a607e6257f Include malloc.h instead of stdlib.h for mallinfo()
This change also removes the malloc.h inclusion in stdlib.h
to break the build if there are still users of mallinfo() with stdlib.h.
2020-06-15 07:21:19 -06:00
Xiang Xiao 7e5b0f81e9 build: Replace -I with INCDIR
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-24 20:20:12 +01:00
Xiang Xiao 23668a4b9b build: Remove the empty variable assignment
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-24 08:24:13 -06:00
Xiang Xiao dd61d3d9f9 build: Remve the unnecessary .gitignore
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-23 18:00:40 +01:00
Xiang Xiao 1a95cce1a3 build: Move .config check to the top Makefile
remove the workaround to handle the inexistence of .config/Make.defs

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-20 17:57:34 +01:00