Commit graph

2772 commits

Author SHA1 Message Date
chenxiaoyi
72f1315189 sched: add header irq.h to exit.c
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-11-04 11:07:40 -03:00
Kian Karas
92f001ee0c sched/wqueue: improve comments 2024-11-04 18:18:04 +08:00
Kian Karas
fa841237dc sched/wqueue: fix work_notifier_setup() false failure
Be consistent with the datatype used for the 'key'. As the API in
in the .h file uses int, I chose to replace uint32_t with int
everywhere.

This change ensures that work_notifier_setup() will not return a
negative value indicating error to the caller, when in fact the
notifier was correctly setup. This would happen when
work_notifier_setup() had been called 0x8000000 times, and that
many keys allocated.
2024-11-04 18:18:04 +08:00
hujun5
76d2a9443b sched/sched: change [FIRST|LAST]_ASSIGNED_STATE to [FIRST|LAST]_READY_TO_RUN_STATE in nxsched_set_affinity
reason:
In smp, It's possible that in a scenario where CONFIG_SMP_DEFAULT_CPUSET is set to 1,
when taskA is created with a relatively low priority,
it gets added to the g_readytorun queue with an affinity of 0x1.
Meanwhile, CPUs 1~n are in an idle state.
Subsequently, when we attempt to change the affinity property of taskA using nxsched_set_affinity,
the scheduling mechanism might not be triggered due to the lack of a proper condition check.
This can result in taskA remaining unscheduled and therefore unable to run.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-04 17:19:59 +08:00
hujun5
fa25b2ea4a fix regression caused by remove sync pause
reason:
If we need to handle a tcb that is running on another CPU,
we need to process it through the smpcall method.

This commit fixes the regression from https://github.com/apache/nuttx/pull/13863
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-04 11:05:20 +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
hujun5
2c0e5e872b pthread_cond 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-02 09:40:19 -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
cuiziwei
d1e5b38b9b nuttx/semaphore: Move define CONFIG_SEM_PREALLOCHOLDERS to include/semaphore.h.
Move CONFIG_SEM_PREALLOCHOLDERS to include/semaphore.h to avoid undefined issues from occurring in other places as well.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-10-31 18:37:53 +08:00
chenrun1
9a75519edc timer_create:Checks whether the signo provided by the user is valid
Summary:
  When the user sets an illegal signo, the error will only be known when timer_signotify is triggered during timeout.
By intercepting timer_create, we can directly locate the problem

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-10-31 17:16:12 +08:00
wangmingrong1
e3d7d23618 gcov: Fix typographical errors
1. CONFIG_ARCH_COVERAGE has been replaced by CONFIG_SCHED_GCOV
2. Delete the SIM-specific GCOV_ALL configuration and change it to a universal configuration for all architectures

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-30 14:45:23 +08:00
zhangyuan29
befe29801f sem: change sem wait to atomic operation
Add sem_wait fast operations, use atomic to ensure
atomicity of semcount operations, and do not depend
on critical section.

Test with robot:
before modify:
nxmutex_lock cost: 78 ns
nxmutex_unlock cost: 82 ns

after modify:
nxmutex_lock cost: 28 ns
nxmutex_unlock cost: 14 ns

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2024-10-30 01:38:45 +08:00
ligd
4541132035 Revert "shced:sem: replace mutex with spinlock"
Cause we can't do sem_post/wait within spinlock

This reverts commit 23d65cb97f.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-29 23:01:39 +08:00
chao an
9c97f7adaa sched/cpuload: move g_cpuload_wdog to private chapter
coding style

Signed-off-by: chao an <anchao@lixiang.com>
2024-10-25 13:28:51 +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
Ville Juven
134ecf380b task_exit.c: Add missing sched_note_stop()
A regression from #13728 ; sched_note_stop() is never called for tasks
that exit normally via exit().
2024-10-23 12:08:18 -03:00
Ville Juven
112b8cf470 sched/task_exit.c: Refresh current CPU instead of relying on stale value
The comment about the CPU index remaining stable is incorrect. There is no
guarantee the task does not yield during the exit process, meaning the CPU
can most definitely change. Also, there is no reason why it should not be
allowed to change.

This fixes a full system crash during process exit when the CPU changes
and we query the current task from the old CPU.
2024-10-22 23:28:52 +08:00
ouyangxiangzhen
8ecca52b27 sched/timer: Simplify setitimer implementation.
This commit simplified setitmer implementation by eliminating a redundant conditional branch.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-10-18 23:58:07 +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
yinshengkai
43d483efc0 sched: remove duplicate functions
nxsched_critmon_cpuload has two identical implementations

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-16 13:58:59 +08:00
hujun5
a46eb84334 sched: Use spinlock repalce sched_[un]lock in some place
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-16 13:53:51 +08:00
Xiang Xiao
5397a58731 libc/modlib: Make modlib selectable from defconfig
since bootloader may call modlib functions directly
to load elf firmware without binfmt, dlfcn or module.

BTW, this patch also remove the duplicated selecttion

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-16 10:11:20 +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
ligd
f0e12a983d cpuload: add nxsched_update_critmon() to handle thread busyloop
Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-10-15 21:11:15 +08:00
chenzhijia
10d0526f3f nuttx/sched:Modify the comment error in sched_resumescheduler.c
Signed-off-by: chenzhijia <chenzhijia@xiaomi.com>
2024-10-15 21:05:36 +08:00
hujun5
a567148888 sched: add up_this_task and up_change_task macro stub
reason:
We can utilize percpu storage to hold information about the
current running task. If we intend to implement this feature, we would
need to define two macros that help us manage this percpu information
effectively.

up_this_task: This macro is designed to read the contents of the percpu
              register to retrieve information about the current
              running task.This allows us to quickly access
              task-specific data without having to disable interrupts,
              access global variables and obtain the current cpu index.

up_update_task: This macro is responsible for updating the contents of
                the percpu register.It is typically called during
                initialization or when a context switch occurs to ensure
                that the percpu register reflects the information of the
                newly running task.

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-15 15:25:55 +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
chao an
ce42a9affc Revert "sched/spinlock: remove nesting spinlock support"
This reverts commit 5aa13bc490.
2024-10-14 17:42:16 +08:00
hujun5
b964eeee18 Reapply "sched/spinlock: remove nesting spinlock support"
This reverts commit 9e81f5efac.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-13 18:31:35 +08:00
hujun5
fa8ccc0e85 sched: fix nxsched_suspend_scheduler regression
This commit fixes the regression from https://github.com/apache/nuttx/pull/13877

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-13 10:16:22 +08:00
chenrun1
9e81f5efac Revert "sched/spinlock: remove nesting spinlock support"
This reverts commit 5aa13bc490.
2024-10-13 09:41:59 +08:00
chenzhijia
505adfa277 nuttx:move "#define STRINGIFY(x)" to nuttx/macro.h
Franklin requirement, "#define STRINGIFY(x)" conflicts with https://github.com/mborgerding/kissfft define

Signed-off-by: chenzhijia <chenzhijia@xiaomi.com>
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-10-13 03:16:25 +08:00
Xiang Xiao
a074a572af sched/pthread: Remove unused pthread_sem_xxx functions
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-13 02:47:44 +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
Xiang Xiao
17cb6ed63d sched/instrument: rename stack_record.c to stack_monitor.c
to align with gprof naming convention.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-13 02:10:41 +08:00
yinshengkai
0132d98e41 sched: delete the dump file list when the thread exits
Accessing the filelist of other tasks when the thread exits may cause a crash

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-13 02:06:38 +08:00
hujun5
7ab27ec1c8 sched: replace sync pause with async pause for sched_backtrace
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-13 01:54:14 +08:00
buxiasen
4b7493901e sched_backtrace: fix when dump running thread in other-core
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-13 01:54:14 +08:00
zhangyuan29
ed8007ac40 sched/signal: exit sig action when tcb group is null
nxsig_action will use tcb group when group release,
so check tcb group when do sig action.

[ap] dump_assert_info: Assertion failed : at file: signal/sig_action.c:205 task: ofonod process: Kernel 0xec89d5
[ap] sched_dumpstack: backtrace:
[ap] sched_dumpstack: [29] [<0x66e2e2>] backtrace_unwind+0x105/0x108
[ap] sched_dumpstack: [29] [<0x660272>] sched_backtrace+0x41/0x48
[ap] sched_dumpstack: [29] [<0x61c4dc>] sched_dumpstack+0x33/0x80
[ap] sched_dumpstack: [29] [<0x6023e4>] _assert+0x19b/0x39c
[ap] sched_dumpstack: [29] [<0x61b7e4>] __assert+0x7/0x10
[ap] sched_dumpstack: [29] [<0x6071a2>] nxsig_action+0x119/0x248
[ap] sched_dumpstack: [29] [<0x6072d8>] sigaction+0x7/0x24
[ap] sched_dumpstack: [29] [<0x66a072>] signal+0x4d/0x80
[ap] sched_dumpstack: [29] [<0x100fd36>] signalfd_file_close+0x35/0x60
[ap] sched_dumpstack: [29] [<0x64a7d8>] file_close+0x1b/0x44
[ap] sched_dumpstack: [29] [<0x649ac0>] files_putlist+0x2b/0x70
[ap] sched_dumpstack: [29] [<0x60491a>] group_leave+0x99/0xe4
[ap] sched_dumpstack: [29] [<0x605df8>] nxtask_exithook+0x4f/0xf4
[ap] sched_dumpstack: [29] [<0x603ca0>] _exit+0x33/0x3c
[ap] sched_dumpstack: [29] [<0x61ecf0>] abort+0x7/0xc

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2024-10-12 13:39:21 +08:00
hujun5
4c1c05164a sched/signal: There is no need to use sched_[un]lock
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-12 13:28:23 +08:00
hujun5
794d362335 sched/pthread: There is no need to use sched_[un]lock
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-12 13:28:23 +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
chao an
5aa13bc490 sched/spinlock: remove nesting spinlock support
developers must be careful to hold spinlocks and ensure all
of protected code is under control, so remove support for nested
spinlocks to improve performance.

Signed-off-by: chao an <anchao@lixiang.com>
2024-10-12 11:18:10 +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