nuttx
nuttx copied to clipboard
sched/group: move task group into task_tcb_s to improve performance
Summary
sched/group: move task group into task_tcb_s to improve performance
move task group into task_tcb_s to avoid access allocator to improve performance
for Task Termination, the time consumption will be reduced ~2us (Tricore TC397 300MHZ): 15.97(us) -> 13.55(us)
In interval B:
Signed-off-by: chao an [email protected]
Impact
N/A
Testing
ci-check
@anchao please rebase again, the last master fix the ci broken.
@anchao
I noticed the following crash with this PR.
rv-virt:ksmp64
$ /home/ishikawa/opensource/QEMU/qemu-8.2.0/build/qemu-system-riscv64 -semihosting -nographic -cpu rv64 -smp 8 -M virt,aclint=on -bios none -kernel nuttx
NuttShell (NSH) NuttX-12.0.0
nsh>
nsh>
nsh> uname -a
NuttX 12.0.0 29e50ffa73 Mar 11 2024 04:27:16 risc-v rv-virt
nsh> ps
PID GROUP CPU PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK USED FILLED COMMAND
0 0 0 0 FIFO Kthread - Assigned 0000000000000000 003056 001624 53.1% CPU0 IDLE
1 1 1 0 FIFO Kthread - Running 0000000000000000 003056 001136 37.1% CPU1 IDLE
2 2 2 0 FIFO Kthread - Running 0000000000000000 003056 001136 37.1% CPU2 IDLE
3 3 3 0 FIFO Kthread - Running 0000000000000000 003056 001136 37.1% CPU3 IDLE
4 4 --- 100 RR Kthread - Waiting Semaphore 0000000000000000 001968 000704 35.7% lpwork 0x80205ca0 0x80205cc8
5 5 0 100 RR Task - Running 0000000000000000 003008 001416 47.0% /system/bin/init
nsh> free
total used free maxused maxfree nused nfree
Kmem: 2049024 15360 2033664 34384 2031824 32 3
Page: 4194304 602112 3592192 3592192
nsh> hello
Hello, World!!
[ 1.340000] [CPU1] riscv_exception: EXCEPTION: Load access fault. MCAUSE: 0000000000000005, EPC: 0000000080004bf6, MTVAL: 0000000000000008
[ 1.340000] [CPU1] riscv_exception: PANIC!!! Exception = 0000000000000005
sabre-6quad:netnsh_smp
$ /home/ishikawa/opensource/QEMU/qemu-8.2.0/build/qemu-system-arm -semihosting -M sabrelite -m 1024 -smp 4 -kernel nuttx -nographic -net nic -net user,hostfwd=tcp::20023-:23,hostfwd=tcp::20021-:21,hostfwd=tcp::25001-:5001,hostfwd=tcp::25555-:5555
telnetd [7:100]
NuttShell (NSH) NuttX-12.0.0
nsh> uname -a
NuttX 12.0.0 29e50ffa73 Mar 11 2024 04:11:35 arm sabre-6quad
nsh> ps
PID GROUP CPU PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK USED FILLED COMMAND
0 0 0 0 FIFO Kthread - Assigned 0000000000000000 002032 000568 27.9% CPU0 IDLE
1 1 1 0 FIFO Kthread - Running 0000000000000000 002032 000664 32.6% CPU1 IDLE
2 2 2 0 FIFO Kthread - Running 0000000000000000 002032 000664 32.6% CPU2 IDLE
3 3 3 0 FIFO Kthread - Running 0000000000000000 002032 000664 32.6% CPU3 IDLE
4 4 --- 224 RR Kthread - Waiting Semaphore 0000000000000000 001984 000432 21.7% hpwork 0x10843830 0x10843844
5 5 --- 100 RR Kthread - Waiting Semaphore 0000000000000000 001984 000432 21.7% lpwork 0x10843808 0x1084381c
6 6 0 100 RR Task - Running 0000000000000000 003032 001264 41.6% nsh_main
7 7 --- 100 RR Task - Waiting Semaphore 0000000000000000 002016 000760 37.6% telnetd
nsh> free
total used free maxused maxfree nused nfree
Umem: 1065033304 17520 1065015784 17616 1065015784 38 1
nsh> ifconfig
eth0 Link encap:Ethernet HWaddr 00:e0:de:ad:be:ef at UP mtu 1500
inet addr:10.0.2.15 DRaddr:10.0.2.2 Mask:255.255.255.0
IPv4 TCP UDP ICMP
Received 0000 0000 0000 0000
Dropped 0000 0000 0000 0000
IPv4 VHL: 0000 Frg: 0000
Checksum 0000 0000 0000 ----
TCP ACK: 0000 SYN: 0000
RST: 0000 0000
Type 0000 ---- ---- 0000
Sent 0000 0000 0000 0000
Rexmit ---- 0000 ---- ----
nsh> renew eth0
[ 1.010000] [CPU0] arm_prefetchabort: Prefetch abort. PC: 00100000 IFAR: 00100000 IFSR: 0000000d
Traceback (most recent call last):
esp32:wifi_smp (dev board)
nsh> uname -a
NuttX 12.0.0 29e50ffa73 Mar 11 2024 04:01:32 xtensa esp32-devkitc
nsh> help
help usage: help [-v] [<cmd>]
. cp exit kill printf true
[ cmp expr ls ps truncate
? dirname false md5 pwd uname
alias date fdinfo mkdir rm umount
unalias dd free mkrd rmdir unset
arp df help mount set uptime
basename dmesg hexdump mv sleep usleep
break echo ifconfig nfsmount source wget
cat env ifdown nslookup test xd
cd exec ifup pidof time
Builtin Apps:
telnetd ntpcstart ping taskset
wapi ostest getprime hello
webserver sh renew nsh
ntpcstatus ntpcstop iperf smp
nsh> ps
PID GROUP CPU PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK USED FILLED COMMAND
0 0 0 0 FIFO Kthread - Assigned 0000000000000000 002032 000720 35.4% CPU0 IDLE
1 1 1 0 FIFO Kthread - Running 0000000000000000 002024 000432 21.3% CPU1 IDLE
2 2 --- 100 RR Kthread - Waiting Semaphore 0000000000000000 001976 000680 34.4% lpwork 0x3ffb0c10 0x3ffb0c24
3 3 0 100 RR Task - Running 0000000000000000 003024 001696 56.0% nsh_main
4 4 --- 255 RR Kthread - Waiting Semaphore 0000000000000000 000696 000344 49.4% spiflash_op 0x3ffe0f00
5 5 --- 255 RR Kthread - Waiting Semaphore 0000000000000000 000696 000344 49.4% spiflash_op 0x3ffe0f00
6 6 --- 223 RR Kthread - Waiting Semaphore 0000000000000000 001992 000664 33.3% rt_timer
7 7 --- 253 RR Kthread - Waiting MQ empty 0000000000000000 006624 001184 17.8% wifi
8 8 --- 100 RR Task - Waiting Semaphore 0000000000000000 002008 001016 50.5% telnetd
nsh> free
total used free maxused maxfree nused nfree
Umem: 238756 63244 175512 63308 110000 117 2
nsh> hello
Hello, World!!
[ 3.830000] [CPU0] xtensa_panic: Unhandled Exception 2 task: hello
[ 3.830000] [CPU0] _assert: Current Version: NuttX 12.0.0 29e50ffa73 Mar 11 2024 04:01:32 xtensa
[ 3.830000] [CPU0] _assert: Assertion failed panic: at file: common/xtensa_assert.c:84 task(CPU0): hello process: Kernel 0x40104d00
[ 3.830000] [CPU0] up_dump_register: PC: 00000000 PS: 00000016
[ 3.830000] [CPU0] up_dump_register: A0: 00000000 A1: 60035cf8 A2: 00000001 A3: 60035d60
[ 3.830000] [CPU0] up_dump_register: A4: 3ffd08c0 A5: 3ffb0a92 A6: 00000002 A7: 00000000
[ 3.830000] [CPU0] up_dump_register: A8: 800d88a0 A9: 3ffd0880 A10: 00000000 A11: 00000000
[ 3.830000] [CPU0] up_dump_register: A12: 00000000 A13: 3f000000 A14: 00000000 A15: 3ffe0e80
[ 3.830000] [CPU0] up_dump_register: SAR: 0000002b CAUSE: 00000014 VADDR: 00000000
[ 3.830000] [CPU0] up_dump_register: LBEG: 3ffb0c7c LEND: 3ffcfda0 LCNT: 00060023
@anchao Let me revert this PR until the issues are resolved.
I noticed the following crash with this PR.
@masayuki2009 emm ... sorry for the regression, thanks for your verification again. I have a fix that verifying internally. I will send a PR later.