Commit graph

809 commits

Author SHA1 Message Date
Zhe Weng
035fdb4951 net: Refresh config dependency of NET_READAHEAD
ICMP(v6) uses IOB queue as readahead, but TCP/UDP don't now.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-12-20 20:01:19 +08:00
Ville Juven
95d1e52535 mm/kmap: Provide the user tcb as parameter to map_user()
This allows mapping pages from others than the running task. Obiously
this can only be done with proper preparations (the task in question
cannot exit before the mapping is released).
2024-12-18 08:57:01 +08:00
wangmingrong1
ee20aa888b kasan/lto: Turn off lto by default anyway
Of course, there is an error here, that is, the conditional judgment of
  ifeq ($(CONFIG_LTO_NONE),n)
    CFLAGS += -fno-lto
  endif
 is wrong, it should be judged as "ifneq ($(CONFIG_LTO_NONE),)"

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-12-05 20:36:37 +08:00
Ville Juven
fed3da9f03 mm_grantable.c: Fix infinite loop due to memory fragmentation
The search algorithm does not work with the ctz approach at all, if there
is a free range of granules that does not fit a specific allocation (i.e.
the granule allocation is fragmented) it will cause an infinite loop as
the algorithm will try to find free space from the same (free) starting
granule, causing an infinite loop.

The clz approach works for all cases, it will find the last used granule
and the search will continue from the next free granule.

Also, offsetting a full GAT must be sizeof(gat[0] - 1), which is 31 in
this case. The reason is that the upper level search function increments
the value by +1.
2024-12-05 20:36:04 +08:00
xuxingliang
1f2435641d nuttxgdb: fix memdump busyloop when nodesize is 0
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-12-02 13:43:52 +08:00
hujun5
34e79f9618 spinlock: use spin_lock_init replace spin_initialize
reason:
1: spin_lock_init and spin_initialize have similar functionalities.
2: spin_lock and spin_unlock should be called in matching pairs.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-26 00:02:44 +08:00
xuxingliang
6d2ebfdec6 mm: dump node overheadp during memdump
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-25 00:42:34 +08:00
Ville Juven
1abcb6a090 mm/gran: Speed optimize gran_match
The original code did the speedup only from the other direction (from end
to start). If the starting GAT index has reservations, they are not skipped
as a bunch, but instead the GAT is iterated bit-by-bit, causing a massive
performance issue.

Fix this by:
- Skipping full GATs right away
- Skipping all of the reserved bits from the starting GAT as a bunch
2024-11-20 01:07:01 +08:00
hujun5
9f835f63bd mm/iob: fix some comment in https://github.com/apache/nuttx/pull/14764
reason:
Since we decoupled counting and sem count,
we changed the meanings of three key global variables:

g_iob_count: A positive number indicates the available number
  of IOBs, while a negative number indicates the number of waiters in iob_alloc (when throttle == false).
g_throttle_wait: Represents the number of waiters in
  iob_alloc (when throttle == true), and it will not be negative.
g_qentry_wait: Represents the number of waiters for
  qentry, and it will not be negative.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-19 15:39:00 +08:00
hujun5
961767b2a4 mm/iob: remove csection
reason:
We decouple semcount from business logic
by using an independent counting variable,
which allows us to remove critical sections in many cases.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-16 12:37:14 -03:00
wangmingrong1
6dd313939f makefile/build: Delete unnecessary bin and kbin folders
1. Calling CLEAN on these folders did not have any effect
2. bin,kbin will be created during the context construction process

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-10 01:18:26 +08:00
xuxingliang
5609c3d416 mm/mm_gran: fix compile warnings
mm_gran/mm_grantable.c:187:6: error: 'r.sidx' may be used uninitialized

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-07 18:14:53 +08:00
yinshengkai
e04853536d mm: fix tlsf compiler error
error: ‘nodesize’ undeclared (first use in this function)
  518 |       memset(mem, MM_FREE_MAGIC, nodesize);
tlsf/mm_tlsf.c:1288:10: warning: unused variable ‘newsize’ [-Wunused-variable]
 1288 |   size_t newsize;

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-11-01 11:44:14 -03:00
ouyangxiangzhen
17c51c0667 userspace: Exclude nuttx/arch.h
This patch fixed userspace headers conflict. Architecture-related definition and API should not be exposed to users.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-11-01 16:59:37 +08:00
wangmingrong1
2b2f530e7c mm: Complete remaining unused macros instead of memory to fill tags
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-31 15:35:26 +08:00
Yanfeng Liu
f6facf7602 mm/mm_memalign: add debugging log
This adds debugging log support for mm_memalign to help track memory
issues via logs.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-10-30 08:40:32 +08:00
chao an
052ea5b20d mm/kasan: extern kasan API only MM_KASAN is enabled
this PR will fix g_region_init is incorrectly linked to the image if MM_KASAN is not enabled.

Signed-off-by: chao an <anchao@lixiang.com>
2024-10-25 19:04:14 +08:00
yinshengkai
5aa48061c9 mm: fix mempool default recording backtrace
Need to initialize procfs.backtrace to false if it's disabled.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-17 09:05:11 +08:00
Neo Xu
9c6c56c255 mempool: use backtrace_format
There's no need to manually format the backtrace any more.

Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-17 09:05:11 +08:00
anjiahao
62850f3163 mempool:when deinit mempool,need mark dict NULL before free
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-17 09:05:11 +08:00
hanqiyuan
ff4b654be0 memdump: fix warnings.
mm_heap/mm_malloc.c: In function 'mm_malloc':
mm_heap/mm_malloc.c:281:33: warning: excess elements in struct initializer
  281 |         MM_BACKTRACE_ALLOC_PID, 0, ULONG_MAX
      |                                 ^
mm_heap/mm_malloc.c:281:33: note: (near initialization for 'dump')
mm_heap/mm_malloc.c:281:36: warning: excess elements in struct initializer
  281 |         MM_BACKTRACE_ALLOC_PID, 0, ULONG_MAX
      |                                    ^~~~~~~~~
mm_heap/mm_malloc.c:281:36: note: (near initialization for 'dump')

Signed-off-by: hanqiyuan <hanqiyuan@xiaomi.com>
2024-10-16 10:23:10 +08:00
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
Neo Xu
7466237b14 mm/Kconfig: adjust config options order and fix typos
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-16 08:09:43 +08:00
liguiding1
b4def16ac3 Revert "mm/iob: Replace the critical section with spin lock"
`g_iob_sem.semcount` is both manually changed in iob source code and api
nxsem_xxx.

nxsem related API uses critical_section to ensure sem value is modified
correctly. If iob using spin lock and modify sem value in the same time,
it's not safe.

This PR revert the spin lock change and uses critical section to align
with what nxsem uses.
2024-10-15 22:45:02 +08:00
liwenxiang1
7541311ac0 mm/mm_heap: Optimizing heap performance, changing the mm_size2ndx and mm-addfreechunk functions to inline functions can improve by about 7%
Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
2024-10-15 22:29:17 +08:00
xuxingliang
a8b7d26db5 Use BACKTRACE_BUFFER_SIZE to declare backtrace buffer
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-15 01:07:21 +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
xuxin19
351781d601 cmake:refine nuttx cmake build system fix CMake build missing part
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-10-13 02:25:06 +08:00
wangmingrong1
a5c0dbe772 mm/sw_tags: add config for no longer checking for tags 0
1. When dynamically loading, the read-only data of arm64 architecture is accessed through PC offset. When opening the tag kasan, because the PC value does not have a tag, accessing the read-only data will be detected with a tag mismatch error.
2. uninitial heap use 0xff poison, initial heap use 1-254 unpoison.

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-12 09:52:27 +08:00
buxiasen
4b315b3606 mm: dump more information when failed dump detail
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-12 09:32:44 +08:00
anjiahao
c0d416584f malloc:if malloc filed need print leak memory detatls
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-12 09:32:44 +08:00
wangmingrong1
de1701c235 mm/kconfig: Remove unnecessary dependencies
If MM_KASAN judgment already exists

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-11 20:01:46 +08:00
Bowen Wang
8eabad52fd mm/Kconfig: fix build error when MM_BACKTRACE > 0 and disable mempool
mempool is always be compiled, so when enable BACKTRACE but not enable
memdpool, the MM_HEAP_MEMPOOL_BACKTRACE_SKIP is not defined
mempool_add_backtrace() will compiled failed.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-11 19:59:26 +08:00
Bowen Wang
313d6df787 include/nuttx.h: replace all the align macros to nuttx version
1. add IS_ALIGNED()  definitions for NuttX;
2. replace all the ALIGN_UP() and ALIGN_DOWN() to use common
   align implementation;

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-11 16:55:43 +08:00
yinshengkai
c158ed2c32 mm/heap: memory alignment before executing kasan_register
The unaligned address is used in kasan_register, but the aligned address is used in kasan_unregister.
The mismatch between the addr value and mm_heapstart will result in a crash due to the inability to unregister correctly.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-10 23:11:37 +08:00
wangmingrong1
5c3025e2fb mm/mempool: Merge two memory requests
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-09 18:15:13 +08:00
wangmingrong1
dd57400e7b mm/mempool: Fix mempool tag kasan error
The address needs to be reset only when comparing addition, subtraction, multiplication and division addresses. Otherwise, the original address is always returned or saved.

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-09 18:15:13 +08:00
ligd
183ff9b6cc mm/mempool: fix mempool crash when use KASAN SW_TAG
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-09 18:15:13 +08:00
ligd
5258e48be6 mm/heap: fix heap crash when use KASAN SW_TAG
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-09 18:15:13 +08:00
Xiang Xiao
b068e2357a circbuf: Move from mm/circbuf to libs/libc/misc
so that it can be used by userspace program.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-09 08:41:49 +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
9f2b08a91a memdump: add dump for the orphan nodes(neighbor of free node)
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
wangmingrong1
55c9697efe mm/kconfig: The default alignment of global variable out-of-bounds detection is 1
It is recommended to use 1 on qemu and 16 or even 32 on the device.

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-08 19:53:38 +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