Commit graph

125 commits

Author SHA1 Message Date
Huang Qi
cfd0cc0d1a Remove duplicate includes across multiple files
This commit cleans up redundant header file includes throughout the codebase.
 The changes include:

 - Removing duplicate #include directives that were present in the same file
 - Consolidating includes that were split across multiple lines unnecessarily
 - Removing unused includes that were no longer needed
 - Fixing some formatting issues with includes

 The changes improve code organization and maintainability by:
 - Reducing unnecessary dependencies
 - Making include dependencies more explicit
 - Following consistent include patterns
 - Removing dead code

 No functional changes are made - this is purely a code cleanup commit.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-09 23:30:23 +08:00
wangmingrong1
2aaf6641a2 Fix compile error
'ret' may be used uninitialized

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-12-02 11:32:48 +08:00
buxiasen
7a4fac0df6 coredump: add BOARD_CRASHDUMP_CUSTOM support
For only board specific crashdump and no syslog/blk/mtd coredump

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-30 03:08:35 +08:00
buxiasen
ddf428d66c coredump: support mtdoutstream
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-30 03:08:35 +08:00
wanggang26
3add14714e coredump: fit sostream, mtdoutstream use alloc, info use stack
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-30 03:08:35 +08:00
buxiasen
88aaba29ba coredump: update coredump method to choice, default NONE
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-30 03:08:35 +08:00
hujun5
d226170292 assert: in assert we use small spinlock replace enter_critical_section
reason:
Since assert may synchronously wait to stop another CPU, potentially
leading to a deadlock, we replace enter_critical_section with a
small spinlock to avoid such a situation.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-20 12:22:58 -03:00
Xiang Xiao
1b77fd1df6 sched/misc: Remove the dup inclusion of nuttx/irq.h in assert.c
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-11-17 08:31:08 -03:00
raiden00pl
fa9bf63faf sched/misc/assert.c: don't compile dump_assert_info logic if CONFIG_DEBUG_ALERT=n
Don't compile dump_assert_info logic if CONFIG_DEBUG_ALERT=n

With _alert() disabled this logic does nothing, but the compiler
is not smart enough to optimize this code.

on minimal stm32f3 configuration it saves 220B of flash.
2024-11-16 22:51:54 +08:00
hujun5
19b4911d7f arch: remove up_current_regs in common code
reason:

When entering an exception or interrupt, there are two sets of registers:
one is the "running regs", which we need to save,
and the other is the "ready to running regs", which we may soon use.
For consistency in logic, we can always store the "running regs" in the regs field of g_running_tasks,
otherwise it may lead to errors in the storage location of the "running regs."

When we need to access the "running regs," we should uniformly retrieve them from the regs field of g_running_tasks.

As the next step, we will rename the set_current_regs/up_current_regs functions
for each architecture to more appropriate names, solely for the purpose of identifying interrupts.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-15 18:25:35 +08:00
hujun5
c498991ba4 smpcall: add nxsched_smp_call_async and nxsched_smp_call_single_async
reason:
The old implementation of the SMP call, even when using the "no wait" parameter,
could still result in waiting, if invoking it within a critical section
may lead to deadlocks. Therefore, in order to implement a truly asynchronous SMP
call strategy, we have added nxsched_smp_call_async.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-06 09:53:28 +08:00
raiden00pl
cd4e53c28a sched/misc/assert.c: don't compile dump_task logic if CONFIG_DEBUG_ALERT=n
Don't compile dump_task logic if CONFIG_DEBUG_ALERT=n.
With _alert() disabled this logic does nothing, but the compiler
is not smart enough to optimize this code.

on minimal stm32f3 configuration it saves 396B of flash.
2024-11-03 19:35:36 +08: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
anjiahao
b33226d76e coredump: coredump_add_memory_region need use flags
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-24 08:46:01 +08:00
wanggang26
848b596a12 coredump: measure the system's running time in milliseconds unit
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-10-16 15:35:21 +08:00
anjiahao
d347da10ca coredump:need close block device when finish coredump
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-16 15:35:21 +08:00
wanggang26
2414fc91ff coredump: fix issue that calculated dump region range is
smaller than it should be.

0x21000000    0x210105e8    0x210105f8      0x21044000
  |----------------|-------------|--------------|

If there is already a range of 0x210105e8 - 0x210105f8, adding another
range of 0x21000000 - 0x21044000 would result in an incorrect range of
0x210105e8 - 0x21044000.

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-10-16 15:35:21 +08:00
wangmingrong1
533c11eee2 coredump.c: Delete the judgment of continue
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-16 08:07:09 +08:00
wangmingrong1
2beef702cc coredump.c: del multiple behavior
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-16 08:07:09 +08:00
yinshengkai
ef62c70e5f sched: modify CONFIG_DUMP_ON_EXIT to CONFIG_SCHED_DUMP_ON_EXIT
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-15 01:50:55 +08:00
wanggang26
7a352d2b83 coredump: fix bug that memsegs got invalid value
for (; cinfo.regions[memsegs].start <
       cinfo.regions[memsegs].end; memsegs++);

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-10-15 01:07:45 +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
anjiahao
52126aede1 coredump:Move coredump to sched/misc
1. move coredump form libelf to sched/misc
2. rename core_dump to coredump

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-12 12:29:06 +08:00
anjiahao
9e868cadfb coredump:Move private functions to internal header files
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-12 12:29:06 +08:00
buxiasen
ca45ad69bd misc: flush syslog before possible long time cost coredump
When coredump to mtd, it maybe cost lots of time, do flush syslog can
make user access all log when coredump processing, should be better.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-12 09:32:44 +08:00
Neo Xu
d598da80e4 Rename group_argvstr to nxtask_argvstr
Now argument vector is stored to TLS, task_argvstr fits better.

Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-10 23:13:37 +08:00
anjiahao
fa59adde40 Simplify BOARD_MEMORY_RANGE initialization logic
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-09 15:41:48 +08:00
anjiahao
e0bcad3a1d gdbstub:support gdbstub memory access control
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-09 15:41:48 +08:00
fangpeina
b5145c528e misc/assert: add backtrace dump support for mutex hold task
Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2024-10-09 08:37:01 +08:00
wangmingrong1
ba05a36eed board_reset: flush cache before reset
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-09 02:30:21 +08:00
xuxingliang
b7824264f6 sched: optimize deadlock detection readability
Use meaningful variable names.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-08 23:35:01 +08:00
anjiahao
97425687cf deadlock:fix find deadlock bug
bug:
  thread 1: get mutexA
            wait a sem

  thread 2: wait mutexA

  This situation will be mistakenly judged as a deadlock.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-08 23:35:01 +08:00
anjiahao
3d69dbe1c8 deadlock:fix bug,When holder is -1 need stop search next
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-08 23:35:01 +08:00
Xu Xingliang
4ed506d6ab board/coredump: add option to use base64 stream
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
2024-10-08 22:33:19 +08:00
anjiahao
f2bdfa43e1 coredump:Add a coreudmp api to watch custom variables
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-01 20:40:28 +08:00
anjiahao
60796a7063 coredump:add const to memory region struct ptr
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-01 20:40:28 +08:00
xuxingliang
7044b10c88 task: use get_task_name where possible
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-01 20:38:06 +08:00
xuxingliang
2b8a4a361d assert: dump all CPU registers and stack
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-09-30 18:43:35 +08:00
xuxingliang
6d0180f12e assert: cleanup assert handler
1. extract dump from assert main flow
2. use OSINIT_PANIC for fatal error.
3. fix the method to judge kernel thread.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-09-30 18:43:35 +08:00
Xu Xingliang
2749736638 assert: disable kasan in assert
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
2024-09-30 18:43:35 +08:00
chao an
3cce16dd0c fs/dump: correct SCHED_DUMP_ON_EXIT to DUMP_ON_EXIT
1. correct SCHED_DUMP_ON_EXIT to DUMP_ON_EXIT
2. dump file list only if DUMP_ON_EXIT enabled

Signed-off-by: chao an <anchao@lixiang.com>
2024-09-18 23:48:31 +08:00
wanggang26
f07a1868ce coredump: just save latest core file
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-15 17:31:40 +08:00
hujun5
908df725ad arch: use up_current_regs/up_set_current_regs replace CURRENT_REGS
reason:
1 On different architectures, we can utilize more optimized strategies
  to implement up_current_regs/up_set_current_regs.
eg. use interrupt registersor percpu registers.

code size
before
    text    data     bss     dec     hex filename
 262848   49985   63893  376726   5bf96 nuttx

after
       text    data     bss     dec     hex filename
 262844   49985   63893  376722   5bf92 nuttx

size change -4

Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic \
   -machine virt,virtualization=on,gic-version=3 \
   -net none -chardev stdio,id=con,mux=on -serial chardev:con \
   -mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-13 23:18:58 +08:00
Alin Jerpelea
eb9030c891 sched: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-09-12 01:10:14 +08:00
fangxinyong
7b05a550dc sched: replace up_cpu_index with this_cpu
Make this_cpu is arch independent and up_cpu_index do that.
In AMP mode, up_cpu_index() may return the index of the physical core.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2024-09-05 12:09:24 +08:00
chao an
39e873f269 sched/policy: move g_policy from data to rodata
Signed-off-by: chao an <anchao@lixiang.com>
2024-09-02 18:23:57 +08:00
YAMAMOTO Takashi
52baca0a89 Increase the chance for _assert to work early in the boot 2024-08-30 01:12:45 +08:00
yinshengkai
624fc5a9b8 sched: support dumping all file information during assert
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-23 16:12:31 -03:00
yinshengkai
20b357abde assert: pause all other CPUs when assert
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-23 16:12:31 -03:00
yinshengkai
b3794c8af7 assert: Avoid recursive calls of Assert
After the structure of the kernel core is wrong, dump_stack, dumpstack is easy to appear crash

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-08-23 16:12:31 -03:00