Commit Graph

2694 Commits

Author SHA1 Message Date
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
fangxinyong 76508d42a9 sched: export sched_getcpu API in AMP mode
Some app with same code runs on different cores in AMP mode,
need known physical core id on which the function is called.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2024-10-09 15:21:25 +08:00
ligd 86869e96c9 sem: use wd_start_realtime/abstime to replace wd_start
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-09 13:54:29 +08:00
ligd 4196433888 nxsig_clockwait: fix time error when clockid is CLOCK_REALTIME
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-09 13:54:29 +08:00
yangguangcai 475bbfc165 nxsig_clockwait: add Parameter Check.
Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-10-09 13:54:29 +08:00
ligd fc73dfd368 sleep: optimize sleep logic, to reduce the disable IRQ time
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-09 13:54:29 +08:00
hujun5 e01d6b26cc sched/group: There is no need to use sched_[un]lock
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-09 13:46:33 +08:00
xuxingliang bc5a337a58 sched/note: add note for wdog module
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-09 08:39:58 +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
ouyangxiangzhen c0ae6525c4 sched/signal: Fix compilation errors for MSVC.
This commit removed empty struct to fix compilation errors for the MSVC compiler.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-10-09 01:36:39 +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
zhangyuan29 651a5e6afa sched/signal: change pthread_exit to nx_pthread_exit
In protected build, kernel cannot call usersapce interface.

1. change pthread_exit to nx_pthread_exit.
2. add kernel tls cleanup.

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2024-10-08 16:53:21 +08:00
buxiasen 0b3859521a arch: fix the sched parameter update when exiting
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-08 13:53:06 +08:00
ligd 07b27cd199 sched: swap setting for g_npidhash
in case of crash in kmm_zalloc, and crash dump use
nxsched_foreach()

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-08 08:59:39 +08:00
hujun5 31a3cea64a arch: rename xxxx_pause.c to xxxx_smpcall.c
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-08 08:13:22 +08:00
hujun5 d8cb7759b6 arch: remove up_cpu_pause up_cpu_resume up_cpu_paused up_cpu_pausereq
reason:
  To remove the "sync pause" and decouple the critical section from the dependency on enabling interrupts,
  after that we need to further implement "schedlock + spinlock".
changelist
  1 Modify the implementation of critical sections to no longer involve enabling interrupts or handling synchronous pause events.
  2 GIC_SMP_CPUCALL attach to pause handler to remove arch interface up_cpu_paused_restore up_cpu_paused_save
  3 Completely remove up_cpu_pause, up_cpu_resume, up_cpu_paused, and up_cpu_pausereq
  4 change up_cpu_pause_async to up_send_cpu_sgi

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-08 08:13:22 +08:00
zhangyuan29 82eca2607a mq: change mqueue msg mail to dynamic array
Change mqueue_msg_s to a dynamic array so that
mqueue msg can be malloc based on the msg size
of the current data when applied dynamically.

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2024-10-07 20:20:13 +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 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 79eab8783f note: add memory tracing event support
Record all memory allocation and release, save to ram, used to analyze memory allocation rate and memory usage
Its absolute value is not trustworthy because the memory will be allocated in thread A and released in thread B

 netinit-5   [0]   0.105984392: tracing_mark_write: C|5|Heap Usage|96|free: heap: 0x606000000020 size:24, address: 0x603000000370
 netinit-5   [0]   0.105996874: tracing_mark_write: C|5|Heap Usage|24|free: heap: 0x606000000020 size:72, address: 0x6070000008e0
nsh_main-4   [0]   3.825169408: tracing_mark_write: C|4|Heap Usage|2177665|free: heap: 0x606000000020 size:424, address: 0x614000000840
nsh_main-4   [0]   3.825228525: tracing_mark_write: C|4|Heap Usage|14977|free: heap: 0x606000000020 size:2162688, address: 0x7f80a639f800
nsh_main-4   [0]   3.825298789: tracing_mark_write: C|4|Heap Usage|15189|malloc: heap: 0x606000000020 size:20, address: 0x6030000003a0

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-07 17:34:59 +08:00
ligd 86a1cc30a5 task: merge nxtask_setup_name() before create_stack
After this patch up_create_stack() can do some
judgement with thread name

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-07 15:47:13 +08:00
hujun5 f12996c851 sched: replace sync pause with async pause for nxsig_process
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-07 13:32:57 +08:00
hujun5 f132ed2edb signal: adjust the signal processing logic to remove the judgment
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-07 13:32:57 +08:00
hujun5 eae57cb0e6 sched: replace sync pause with async pause for nxtask_terminate
reason:
In the kernel, we are planning to remove all occurrences of up_cpu_pause as one of the steps to
simplify the implementation of critical sections. The goal is to enable spin_lock_irqsave to encapsulate critical sections,
thereby facilitating the replacement of critical sections(big lock) with smaller spin_lock_irqsave(small lock)

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-06 09:26:56 +08:00
anjiahao a9cb28cd23 modlib:Standardized module loading method
1. use '__attribute__((constructor))' mark initialize function
2. use '__attribute__((destructor))' mark uninitialize function
3. compile module with -fvisibility=hidden. use `__attribute__((visibility("default")))`
mark is need export symbol.so not need module_initialize to initialize export symbol.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-05 15:22:02 +08:00
hujun5 5df3625b62 sched: replace sync pause with async pause for nxtask_restart
reason:
In the kernel, we are planning to remove all occurrences of up_cpu_pause as one of the steps to
simplify the implementation of critical sections. The goal is to enable spin_lock_irqsave to encapsulate critical sections,
thereby facilitating the replacement of critical sections(big lock) with smaller spin_lock_irqsave(small lock)

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-10-05 14:23:25 +08:00
hujun5 0b0f535c66 sched: replace sync pause with async pause for setpriority
reason:
In the kernel, we are planning to remove all occurrences of up_cpu_pause as one of the steps to
simplify the implementation of critical sections. The goal is to enable spin_lock_irqsave to encapsulate critical sections,
thereby facilitating the replacement of critical sections(big lock) with smaller spin_lock_irqsave(small lock)

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-10-05 14:00:59 +08:00
hujun5 8e89984360 sched: replace sync pause with async pause for nxsched_suspend
reason:
In the kernel, we are planning to remove all occurrences of up_cpu_pause as one of the steps to
simplify the implementation of critical sections. The goal is to enable spin_lock_irqsave to encapsulate critical sections,
thereby facilitating the replacement of critical sections(big lock) with smaller spin_lock_irqsave(small lock)

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-10-05 13:59:35 +08:00
hujun5 6a13e4a6f6 sched/sched: next pointer value is definitely not null
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-05 13:49:55 +08:00
hujun5 b4cc9fb11b sched: change nxsched_islocked_global to nxsched_islocked_tcb
reason:
1 To improve efficiency, we mimic Linux's behavior where preemption disabling is only applicable to the current CPU and does not affect other CPUs.
2 In the future, we will implement "spinlock+sched_lock", and use it extensively. Under such circumstances, if preemption is still globally disabled, it will seriously impact the scheduling efficiency.
3 We have removed g_cpu_lockset and used irqcount in order to eliminate the dependency of schedlock on critical sections in the future, simplify the logic, and further enhance the performance of sched_lock.
4 We set lockcount to 1 in order to lock scheduling on all CPUs during startup, without the need to provide additional functions to disable scheduling on other CPUs.
5 Cpu1~n must wait for cpu0 to enter the idle state before enabling scheduling because it prevents CPUs1~n from competing with cpu0 for the memory manager mutex, which could cause the cpu0 idle task to enter a wait state and trigger an assert.

size nuttx
before:
   text    data     bss     dec     hex filename
 265396   51057   63646  380099   5ccc3 nuttx
after:
   text    data     bss     dec     hex filename
 265184   51057   63642  379883   5cbeb nuttx

size -216

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-10-05 13:49:55 +08:00
zhangyuan29 34d247fb5f group: change pthread_kill to tkill in kernel mode
Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2024-10-03 09:39:33 +08:00
zhangyuan29 dcae65f504 sched: Disable the scheduling when send SIGCHLD signal
Disable the scheduling to prevent other tasks from being
deleted after they are awakened

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2024-10-02 20:59:01 +08:00
zhangyuan29 38ddf7d59f sched: process scheduler before wd_timer handler
wd_timer handler will change current task, so need process
scheduler before wd timer handler, Ensure that the current
task is not updated before the RR process

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2024-10-02 10:30:48 +02:00
dongjiuzhu1 a367657d2d sched/semaphore: support recursive write for same process in sem_rw lock
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-02 01:56:46 +08:00
dongjiuzhu1 0de9d4ba6a sched/semaphore: add sem_rw source file to CMakeLists
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-02 01:56:46 +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
Jukka Laitinen 07d5bc2c50 sched/semaphore/sem_tickwait.c: Fix nxsem_tickwait_uninterruptible end condition
nxsem_tickwait correctly sleeps more than 1 tick. But nxsem_tickwait_uninterruptible
may wake up to a signal (with -EINTR), in which case the tick + 1 must also
be taken into account. Otherwise the nxsem_tickwait_uninterruptible may
wake up 1 tick too early.

Also fix the nxsem_tickwait to return with -ETIMEDOUT if called with delay 0.
This is similar to e.g.  posix sem_timedwait.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-09-30 19:23:01 +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
xuxingliang a9b8681a9f sched: handle sched lock in interrupt
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-09-30 16:22:44 +08:00
dulibo1 1d135dbfd9 sched_smp:adjust the unlock order
1.nxsem_post wake up  nxsched_smp_call;
2.stack smp_call_data_s may return;
3.nxsched_smp_call_handler access call_data->lock is not safety;
so adjust the unlock order

Signed-off-by: dulibo1 <dulibo1@xiaomi.com>
2024-09-30 16:22:44 +08:00
ligd 1e7631e695 mqueue: refactor of mqueue
1. mainly for long time within critical_section
2. move out memcpy buffer from enter_critical_section()
3. let mq_send() return fail when mq buffer full in ISR

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-29 18:18:01 +08:00