1
0
Fork 0
forked from nuttx/nuttx-update
Commit graph

2812 commits

Author SHA1 Message Date
Ville Juven
ea020a4eae sem_holder.c: Replace addrenv_select with kmm_map for holder sem access
The holder list can be modified via interrupt so using addrenv_select is
not safe. Access the semaphore by mapping it into kernel virtual memory
instead.
2024-12-18 08:57:01 +08:00
Ville Juven
510d9659b4 sem_waitirq: Use kmap interface to access the semaphore
The temporary mappings via addrenv_select() and addrenv_restore() simply
do not work from interrupt, so remove its usage and replace with kmap
which is safe.
2024-12-18 08:57:01 +08:00
hujun5
f301524cb9 sem: remove the additional assignment.
reason:
running tcb->waitobj should be NULL

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-12-12 22:01:50 +08:00
chao an
cafdcb1eb0 sched/clock: cleanup g_system_ticks reference if arch timer is enabled
continue work of: https://github.com/apache/nuttx/pull/15139

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-12 09:52:07 +01:00
ligd
4a51c21afc sched/clock: call up_timer_gettime() to get higher resolution
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-12-12 14:47:02 +08:00
zhangyuan29
b74a50775f 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-12-10 22:00:42 +08:00
hujun5
bc844509e2 addrenv: Ensure that the transmission parameter of addrenv_switch is not NULL
reason:
avoid obtaining this_task multiple times.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-12-04 14:20:12 +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
chao an
401e8eb062 sched/lockcount: replace all lockcount check to nxsched_islocked_tcb()
replace all lockcount check to nxsched_islocked_tcb()

Signed-off-by: chao an <anchao@lixiang.com>
2024-11-26 16:35:20 +08:00
hujun5
f5136b2afa spinlock: remove recursive locks with write_lock_irqsave/read_lock_irqsave
reason:
1 There is a similar PR, https://github.com/apache/nuttx/pull/14079,
2 Currently, no one is using recursive locks with write_lock_irqsave/read_lock_irqsave.
3 Nested spinlock is harmful, prone to abuse and leading to a decline in code quality and performance
4 Nested spinlock is also not available in Linux.
5 In our future plans, nested usage of enter_critical_section and spin_lock_irqsave will also be removed.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-26 10:21:04 +08:00
hujun5
33226a9bb7 use spin_lock_wo_note replace spin_lock in csection
reason:
spin_lock_wo_note/spin_unlock_wo_note  should be called in matching pairs.
This commit fixes the regression from https://github.com/apache/nuttx/pull/13933

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-26 10:17:18 +08:00
chao an
24add5eeaf spelling: fix spelling typo premp -> preemp
Signed-off-by: chao an <anchao@lixiang.com>
2024-11-25 22:05:05 +08:00
chao an
6ffb001fdf spelling: fix spelling typo premption -> preemption
Signed-off-by: chao an <anchao@lixiang.com>
2024-11-25 22:05:05 +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
YAMAMOTO Takashi
b4d8ac862e sched_unlock: remove redundant/stale logic and comment 2024-11-20 20:41:27 +08:00
YAMAMOTO Takashi
4c3ae2ed4f Revert "sem: change sem wait to atomic operation"
This reverts commit befe29801f.

Because a few regressions have been reported and
it likely will take some time to fix them:

* for some configurations, semaphore can be used on the special
  memory region, where atomic access is not available.
  cf. https://github.com/apache/nuttx/pull/14625

* include/nuttx/lib/stdatomic.h is not compatible with
  the C11 semantics, which the change in question relies on.
  cf. https://github.com/apache/nuttx/pull/14755
2024-11-20 17:52:00 +08:00
Ville Juven
244a560be9 sched/addrenv.c: Fix usage of atomic_fetch_sub
addrenv_give should return the new reference counter (after subtraction)
instead of the old one.
2024-11-20 18:28:26 +09:00
Ville Juven
97ed62b797 irq/irq.h: Remove extern of non-existent global 2024-11-20 01:04:47 +08:00
Ville Juven
e2616e7866 addrenv/addrenv.c: Use atomic_ functions to handle the reference counter
The performance penalty in SMP mode is too big for taking the big kernel
lock simply to bump the address environment reference counter; fix this
by using the compiler provided atomic macros.
2024-11-20 01:04:31 +08:00
YAMAMOTO Takashi
ab3b128805 group_signal_handler: Remove a redundant check
We know tcb is not NULL here as we have a DIAGASSERT on it
immediately above.
2024-11-18 19:10:02 +08:00
ligd
dfa24a056e sched: add some DEBUGASSERT when nxsched_release_tcb()
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-11-17 08:31:08 -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
hujun5
2714f1b605 remove sched_lock in pthread_cond_broadcast
reason:
Since pthread_cond_broadcast is already protected by a mutex,
even if sem_post causes a context switch, it will not affect the count of wait_count.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-16 22:52:21 +08: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
88b4aebedc in smp_call handle we only change TCB_FLAG_CPU_LOCKED bit of tcb->flag
reason:
change unrelated changes to tcb->flag fields, may cause error

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-16 01:58:59 +08:00
hujun5
dcc75048be Revert "system: pthread_barrierwait should be moved to kernel space"
reason:
new implementation does not requires the use of enter_critical_section,
so the source code needs to be moved to user space

This reverts commit d189a86a35.
2024-11-15 22:07:25 +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
7ba0f11d70 pthread: remove enter_critical_section in pthread_barrier_wait
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-15 14:03:03 +08:00
wangmingrong1
17ce9b86c1 gcov: Correct existing gcov configuration
1. add CONFIG_COVERAGE_ALL to replace CONFIG_SCHED_GCOV_ALL
2. Correct all SCHED_GCOV, SCHED_GCOV_ALL

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-15 01:05:16 +08:00
hujun5
ea20ae588a pthread_cond_broadcast use wait_count for judement
This commit fixes the comment from https://github.com/apache/nuttx/pull/14581

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-14 23:22:52 +08:00
wangmingrong1
bf93c7840a gprof: move gprof function from sched to libbuiltin/libgcc
1. Enable interrupt gprof please config CONFIG_PROFILE_MINI
2. Enable instuction gprof please add compile opt "-pg" or config CONFIG_PROFILE_ALL

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-13 02:42:31 +08:00
wangmingrong1
7421e099ca gprof: Add a configuration dependency
arm-none-eabi-g++: error: -pg and -fomit-frame-pointer are incompatible

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-12 12:03:57 +08:00
hujun5
55dbf37017 fix compiler error
reason:
when CONFIG_CLOCK_TIMEKEEPING=y, compiler error may report

In file included from /home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/sched.h:42,
                 from /home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/arch.h:89,
                 from boardctl.c:33:
/home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/irq.h:261:12: error: conflicting types for 'enter_critical_section'; have 'irqstate_t(void)' {aka 'long unsigned int(void)'}
  261 | irqstate_t enter_critical_section(void) noinstrument_function;
      |            ^~~~~~~~~~~~~~~~~~~~~~
In file included from /home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/wqueue.h:37,
                 from /home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/addrenv.h:39,
                 from /home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/sched.h:40:
/home/hujun5/downloads1/vela_sim/nuttx/include/nuttx/wdog.h:267:11: note: previous implicit declaration of 'enter_critical_section' with type 'int()'
  267 |   flags = enter_critical_section();
      |           ^~~~~~~~~~~~~~~~~~~~~~
hujun5@hujun5-OptiPlex-7070:~/downloads1/vela_sim/nuttx$ make -j12
sched/sched_processtimer.c: In function 'nxsched_process_timer':
sched/sched_processtimer.c:178:3: error: implicit declaration of function 'clock_update_wall_time' [-Werror=implicit-function-declaration]
  178 |   clock_update_wall_time();

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-11 19:48:38 +08:00
hujun5
6611480904 isrthread: add configuring the stack of an isrthread as static
reason:
we configure the isr thread stack as static to allow for more flexible placement of the stack.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-08 01:49:14 +08:00
hujun5
7ec1894267 smpcall: we directly call the function to handle local smpcall
reason:
some arch do not support issuing interrupts to the local CPU.

This commit fixes the regression from https://github.com/apache/nuttx/pull/14663

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-07 09:25:11 +09: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
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