Commit Graph

2632 Commits

Author SHA1 Message Date
dongjiuzhu1
79b4b39994 libc/modlib: free memory resource when rmmod elf
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-08 23:51:33 +08:00
dongjiuzhu1
3b0e2be058 binfmt/modlib: support loading each sections to different memory for Relocate object
The feature depends on ARCH_USE_SEPARATED_SECTION
the different memory area has different access speed and cache
capability, so the arch can custom allocate them based on
section names to achieve performance optimization

test:
sim:elf
sim:sotest

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-08 23:51:33 +08:00
ouyangxiangzhen
db88754822 sched/signal: Simplify the implementation of SIGEV_THREAD_TID.
This commit simplified thread ID dispatching logic by integrating it into the `nxsig_dispatch` function.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-09-23 12:29:36 +08:00
ouyangxiangzhen
0373ba0fab sched/signal: Simplified Implementation for SIGEV_THREAD_TID.
This commit simplified the implementation for SIGEV_THREAD_TID.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-09-23 12:29:36 +08:00
ouyangxiangzhen
9f36509c0b signal: Add siginfo initializer
This patch is to make Coverity happy.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-09-23 12:29:36 +08:00
anjiahao
112cc083d3 pthread_mutex:add deadlock assert
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-09-20 22:05:29 +08:00
yinshengkai
f326f15b40 sched: move DUMP_ON_EXIT to sched
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-09-19 03:49:12 +08:00
buxiasen
b33e20a586 critmon: fix context switch critmon pause err.
Elapsed time statistic up to now when sched happen

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-09-19 03:16:14 +08:00
ligd
90dcd5edd3 critmonitor: add caller support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-19 03:16:14 +08:00
yinshengkai
e28b311b78 Make each function of SCHED_CRITMONITOR independent
There will be a large performance loss after SCHED_CRITMONITOR is enabled.
By isolating thread running time-related functions, CPU load can be run with less overhead.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-09-19 03:16:14 +08:00
yinshengkai
6b07284c61 sched/cpuload: fix SMP situation CPULOAD statistics are inaccurate
When statistics when sched_cpuload_critMonitor, thread switching only
calculates the current CPU's running time. Other CPU running threads
are updated for updates

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-09-19 03:16:14 +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
simbit18
583f025422 Fix Kconfig style
Remove spaces from Kconfig files
Add TABs
Replace help => ---help---
2024-09-17 22:16:41 +08:00
hujun5
a2c704a84a Revert "irq: add [enter|leave]_critical_section_nonirq"
This reverts commit 1c5a0bf6cc.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-17 20:12:59 +08:00
ouyangxiangzhen
5a01f0f7f6 POSIX timer: Optimize overrun check by replacing loop with division.
Converted the timer overrun check from a loop-based approach to a division-based method. This change ensures a deterministic worst-case execution time (WCET), even if it might not outperform the loop in average scenarios.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-09-17 12:15:14 +08:00
ligd
578ecef975 wdog: add new API wd_start_realtime() support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-17 12:15:14 +08:00
ligd
9c423ee5fa wdog: rename wd_start_absolute() to wd_start_abstick()
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-17 12:15:14 +08:00
yangguangcai
81b97b676b timer_settime:fix set time when flag is TIMER_ABSTIME.
Signed-off-by: yangguangcai <yangguangcai@xiaomi.com>
2024-09-17 12:15:14 +08:00
ouyangxiangzhen
213d5538fc signal: Add support for SIGEV_THREAD_ID and sigev_notify_thread_id
This patch added support for SIGEV_THREAD_ID and sigev_notify_thread_id.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-17 12:15:14 +08:00
ouyangxiangzhen
a483c884ce sched/timer: Fix timer accuracy problems
This commit fixed timer accuracy problems when repetitive timer is set.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-09-17 12:15:14 +08:00
Shoukui Zhang
43223124ec vfs/file: add reference counting to prevent accidental close during reading writing...
Signed-off-by: Shoukui Zhang <zhangshoukui@xiaomi.com>
2024-09-17 12:01:53 +08:00
Zhe Weng
f8bd93575c sched/wqueue: Fix unexpected dq entry status
When we do not drop notifier from g_notifier_pending, we need an
isolated dq entry for this queue, otherwise the queued work_s's dq entry
may be modified by the work queue and breaks the chain of
g_notifier_pending.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-09-17 02:56:39 +08:00
ligd
4d6203d4c6 wqueue: teardown should cancel the work already in wqueue
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-17 02:56:39 +08:00
ligd
42b6dd0ff1 wqueue: extend the work_cancel_sync() return value
Return 1 to indicate the work was not cancelled.
Because it is currently being processed by work thread,
but wait for it to finish.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-17 02:56:39 +08:00
ligd
f3ada4b666 wqueue: workaound g_notifier_pending list unsafe
Situation:

thread1                             thread2
work_notifier_signal
enter_critical_section
dq_peek(&g_notifier_pending)
    dq_rem(&g_notifier_pending)
    work_queue()
      // switch -->                 work_notifier_teardown
                                    enter_critical_section
                                    dq_rem(&g_notifier_pending)
                                    leave_critical_section
                                    <--- switch back
    error occured
leave_critical_section

Workaound:
used sched_lock() to prevent the switch

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-17 02:56:39 +08:00
Masayuki Ishikawa
df298c186f Revert "build depend:Revert Make.dep intermediate ddc file"
This reverts commit ddc3119c4e.
2024-09-15 19:29:47 +08:00
ligd
fc50e57a26 pthread_mutx: remove unused critical_secton lock
Caused the 'nlocks' are remove from mutex, so
here don't need do critical_secton lock like nxmutex_lock

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-15 17:32:33 +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
xuxin19
ddc3119c4e build depend:Revert Make.dep intermediate ddc file
Revert "Parallelize depend file generation"
This reverts commit d5b6ec450f.

parallel depend ddc does not significantly speed up compilation,
intermediately generated .ddc files can cause problems if compilation is interrupted unexpectedly

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-09-15 10:01:58 +08:00
ligd
ff1b54bff3 pthread_cleanup: move clenup down to tls
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-14 20:15:12 +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
ligd
f0d3c8ab2b usleep: use div_const to optimize the usleep
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
ligd
fae6a00e02 clock: refactor clock_systime_timespec() & clock_systime_ticks()
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
ligd
76e807560e clock: take clock_abstime2ticks() as MACRO
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
ligd
07a4233d1d clock: refactor clock_gettime clock_settime
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
ligd
6a2c03732f clock: Replace all ts and tick conversion functions
Using the ts/tick conversion functions provided in clock.h

Do this caused we want speed up the time calculation, so change:
clock_time2ticks, clock_ticks2time, clock_timespec_add,
clock_timespec_compare, clock_timespec_subtract... to MACRO

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
ligd
a10c46d02e clock: use clock_timespec_add/subtract to optimize code
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
liaoao
45d6b5f8f2 clock: remove cast
Signed-off-by: liaoao <liaoao@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
ligd
f2a77bbcea clock: take clock_timespec_compare/add/subtract() as MACRO
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
hujun5
3619e61c31 sched: adjust the scheduling strategy
1 Only the idle task can have the flag TCB_FLAG_CPU_LOCKED.
  According to the code logic, btcb cannot be an idle task, so this check can be removed.
2 Optimized the preemption logic check and removed the call to nxsched_add_prioritized.
3 Speed up the scheduling time while avoiding the potential for
  tasks to be moved multiple times between g_assignedtasks and g_readytorun.

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-12 01:34:56 +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
hujun5
cd8db329de irq: simplify code by using OSINIT_TASK_READY
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-11 11:05:33 +08:00
ligd
7ff7f6ec21 wdog: optimize a bit speed in wd_start
After these wdog refactor:
We conducted a latency measurement using the rt-tests/cyclictest (commit cadd661) on an x86_64 NUC12 equipped with an i7-1255U processor and 16GB of LPDDR5 memory. The specific command used for this microbenchmark was cyclictest -q -l 100000 -h 30000, which is designed to assess the responsiveness of the cyclic timer.

The findings from our benchmark are summarized below, highlighting the minimum, median, and maximum latency values for each operating system tested:

Operating System	Minimum Latency (us)	Median Latency (us)	Maximum Latency (us)
Linux	            48	                    53	                410
PreemptRT	        6	                    57	                148
Xenomai	            53	                    53	                64
NuttX	            64	                    626	                1212
NuttX (refactor)	1	                    1	                3
In this table, "Min" indicates the shortest latency observed, "Median" represents the middle value of the latency distribution, and "Max" denotes the longest latency encountered.

The systems tested were as follows:

Linux: ACRN version 6.1.80 (commit f528146)
PreemptRT: Linux kernel 5.4.251 with the 5.4.254-rt85 patch applied
Xenomai: Linux kernel 5.4.251 patched with ipipe-core-5.4.239-x86-13
These results clearly demonstrate the varying performance of different operating systems in terms of timer latency, the refactored NuttX showing particularly low latency values.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-10 23:32:30 +08:00
ligd
cb5bab34f1 wdog: always ticks++ when wd_start
Now we have CONFIG_USEC_PER_TICK, and for our timer system, all the calculation used 'tick'.
And all the timespec should change to 'tick' before use wd_start(), so USEC2TICK() can NOT be avoided.

Then there must be an 'less then one tick' loss.

One resolution:
ticks++ anyway when wd_start(). But this will caused time expired more a tick.

Another resolution:
Change the testcase, and allow the following logic:

t1 = current_time();
sleep(3);
t2 = current_time();

allow: t2 - t1 >= 3;
(original test must be: t2- t1 > 3)

The original test think the time must be elapse-ing, and the (t2 - t1) must bigger then 3,
but in our system, we use 'tick' as the minimal wdog unit, then there must a precision loss.

Now we choose first resolution.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-10 23:32:30 +08:00
ligd
e334df6d9a wdog: add API wd_cancel_irq() support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-10 23:32:30 +08:00
ouyangxiangzhen
b7cd0ab796 sched/sched: Correct the elapsed time calculation.
This patch addresses an issue where the elapsed time was uncorrectly calculated.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-10 23:32:30 +08:00
ligd
bc1e1e1064 sched: add nxsched_get_next_expired() support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-10 23:32:30 +08:00
ligd
b010356b26 wdog: fix timer IRQ busy when timer list empty
when timer list empty, should return 0 to indicate
we are no longer set time

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-10 23:32:30 +08:00
ligd
f23fb7ec09 sched: disable interrupt in non-SMP case
For the nested interrupt, one thing should decleared:
We are in ISR context, but no meaning we are disabled the interrupts.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-10 23:32:30 +08:00
ouyangxiangzhen
35fcd9331f sched/sched: Remove g_sched_time and fix CONFIG_SCHED_SPORADIC compilation error
This patch removes unused variable g_sched_time while fixes
 compilation error if CONFIG_SCHED_SPORADIC enabled.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-10 23:32:30 +08:00