Skip to content

rv-virt/citest: Increase init task stack size to 3072#15165

Merged
xiaoxiang781216 merged 1 commit intoapache:masterfrom
tmedicci:bugfix/rv-virt_citest_ps
Dec 12, 2024
Merged

rv-virt/citest: Increase init task stack size to 3072#15165
xiaoxiang781216 merged 1 commit intoapache:masterfrom
tmedicci:bugfix/rv-virt_citest_ps

Conversation

@tmedicci
Copy link
Copy Markdown
Contributor

@tmedicci tmedicci commented Dec 12, 2024

Summary

After #15075, the size of the stack size has decreased 8 bytes and the init stack size for the rv-virt:citest defconfig was near its full capacity, which led to crashing the ps command. The init stack size for this defconfig was increased from 2048 to 3072 to avoid stack overflow.

Impact

Avoid ps from crashing after #15075

Testing

Build and run the rv-virt:citest with the following command:

make distclean
./tools/configure.sh rv-virt:citest
make EXTRAFLAGS="-Wno-cpp -Werror" -j$(nproc)
qemu-system-riscv32 -semihosting -M virt,aclint=on -cpu rv32 -smp 1 -bios none -kernel nuttx -nographic

Testing the commit just before #15075:

nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK    USED FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 0001952 0000940  48.1%  Idle_Task
    1     0 224 RR       Kthread   - Waiting  Semaphore 0000000000000000 0001896 0000508  26.7%  hpwork 0x8014b2f8 0x8014b31c
    2     0 100 RR       Kthread   - Waiting  Semaphore 0000000000000000 0001896 0000508  26.7%  lpwork 0x8014b2c0 0x8014b2e4
    3     3 100 RR       Task      - Running            0000000000000000 0001920 0001920 100.0%! nsh_main

Note that the nsh_main task is using the full capacity of its stack, but the firmware didn't crash. Stack size is 1920.

Testing the commit just after #15075:

nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK    USED FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 0001952 0000764  39.1%  Idle_Task
    1     0 224 RR       Kthread   - Waiting  Semaphore 0000000000000000 0001904 0000524  27.5%  hpwork 0x8014b2f4 0x8014b320
    2     0 100 RR       Kthread   - Waiting  Semaphore 0000000000000000 0001896 0000508  26.7%  lpwork 0x8014b2b0 0x8014b2dc
riscv_exception: EXCEPTION: Load access fault. MCAUSE: 00000005, EPC: 80008bfe, MTVAL: 01473e00
riscv_exception: PANIC!!! Exception = 00000005
dump_assert_info: Current Version: NuttX  10.4.0 fb4a246fcc Dec 12 2024 11:37:54 risc-v
dump_assert_info: Assertion failed panic: at file: common/riscv_exception.c:131 task: nsh_main process: nsh_main 0x8000a806
up_dump_register: EPC: 80008bfe
up_dump_register: A0: 01473e00 A1: 01473dff A2: 0000003f A3: 00000053
up_dump_register: A4: 00000000 A5: 01473e00 A6: 8016e5ec A7: 8016d3c4
up_dump_register: T0: 00000000 T1: 0000005d T2: 00000000 T3: 0000002d
up_dump_register: T4: 0000002d T5: 00000000 T6: 00000000
up_dump_register: S0: 8016d618 S1: 00000001 S2: 00000000 S3: 00000073
up_dump_register: S4: 01473e00 S5: 8016ce78 S6: 00000001 S7: 8016d650
up_dump_register: S8: 00000000 S9: 8011c4c7 S10: 00000000 S11: 00000000
up_dump_register: SP: 8016d5a0 FP: 8016d618 TP: 00000000 RA: 80007ea6
dump_stackinfo: User Stack:
dump_stackinfo:   base: 0x8016d4c8
dump_stackinfo:   size: 00001912
dump_stackinfo:     sp: 0x8016d5a0
stack_dump: 0x8016d580: 00000000 8016ce78 00000200 2016d5b8 00000000 0000000c 8016d618 80007c1e
stack_dump: 0x8016d5a0: 00000038 00000038 00000004 00000004 00000010 00002088 31383638 38303136
stack_dump: 0x8016d5c0: 00000010 00000010 8014b37c 800075d6 00000010 00000010 8014b338 8013a000
stack_dump: 0x8016d5e0: 8013a000 00000004 00000000 00002088 00000001 8016ce78 8011c000 8016e5ec
stack_dump: 0x8016d600: 8016d76b 00000000 8011c4c4 80007bc4 00000036 8016d64c 00000001 80008a78
stack_dump: 0x8016d620: 80008a2a 80008b26 8016e5ec 0000015d 00000036 8016e5ce 0000015e 800211b0
stack_dump: 0x8016d640: 8016d72c 80139f58 00000003 01473e00 00000000 8016d448 8016e5ec 8016d3c4
stack_dump: 0x8016d660: 00000401 80139d48 8016d3c4 00000008 0000015e 8016e5ec 8016e2e1 8001c8e6
stack_dump: 0x8016d680: 000001b6 8016e5c8 8016e5ce 8016e5d0 80139d48 8016cf20 00000000 8001b6d8
stack_dump: 0x8016d6a0: 8016d72c 8013a000 8013a000 0000000a 00000000 8016e5c8 00000000 8016e158
stack_dump: 0x8016d6c0: 8016d72c 00000401 00000000 800141a2 00000001 8016e5ce 8016e158 8013a000
stack_dump: 0x8016d6e0: 8013a000 00000004 00000000 8016e2d9 00000001 00000166 8016e158 00000000
stack_dump: 0x8016d700: 8016d778 8016d3c4 00000000 8001466a 800edc4c 00000166 00000167 8016e2d9
stack_dump: 0x8016d720: 8016d778 00000001 00000000 800146de 00000000 8016d3c4 8016d778 00000001
stack_dump: 0x8016d740: 00000004 8016e210 00000004 8001470e 80008a2a 80008b26 00000001 8016d778
stack_dump: 0x8016d760: 30303020 8016e210 0000000f 8001473e 8016e210 8016d830 8016e2d9 00000166
stack_dump: 0x8016d780: 00000167 00000099 00000053 8000b7f4 8016e210 8013a000 8013a000 0000000a
stack_dump: 0x8016d7a0: 00000778 00000003 8016e240 800ee000 8016e210 8016d830 0000000f 80010572
stack_dump: 0x8016d7c0: 8016e524 00000000 00000000 8016e5c8 8016e329 00000003 8016e240 0000000a
stack_dump: 0x8016d7e0: 8016e524 8016e210 8016e329 80010702 00000001 00000022 8014b4b8 00000000
stack_dump: 0x8016d800: 8016d3b0 8016e550 8016e524 80014fea 8016d888 8016d3b0 00000000 8001466a
stack_dump: 0x8016d820: 800ed504 800ed48c 00000022 800ed48c 8016e261 8016e272 8016e280 80101600
stack_dump: 0x8016d840: 8016e294 8016e2a2 8016e2b8 8016e2c7 80101600 00000003 00000778 0000074c
stack_dump: 0x8016d860: 000003d0 8016e240 00000200 00000099 20544e45 800ed48c 8016e524 00000000
stack_dump: 0x8016d880: 00000000 00000000 8014b000 800ed3bc 800ed504 8016d8fb 8001058e 800edc4c
stack_dump: 0x8016d8a0: 8016e520 800ed48c 8016e210 8000b8f4 00002080 00000000 00000001 8016da6c
stack_dump: 0x8016d8c0: 00000001 80139788 8016e210 80010a1e 800ee1ec 800ee1e4 800ee1dc 800ee1d4
stack_dump: 0x8016d8e0: 8010aee4 800ee1cc 800ee1c4 8000bff2 0000007f 8016dafc 0014b018 8016e4c8
stack_dump: 0x8016d900: 00000000 00003880 deadbeef 8016da54 8016e4c8 ffffffff 8016e210 8000d484
stack_dump: 0x8016d920: 800ed504 00000000 00000001 8016da6c 00000001 80139788 8016e210 8000da96
stack_dump: 0x8016d940: deadbeef deadbeef deadbeef 8016e4c8 deadbeef 800059e4 800059e0 00000001
stack_dump: 0x8016d960: 8016da6c 8016da54 8016e210 8000bd16 00000000 8000d106 8000cf50 8016db00
stack_dump: 0x8016d980: 00000000 00000000 00000000 00000020 00000000 00000000 8016e4c8 00000070
stack_dump: 0x8016d9a0: 8016da74 00002088 00000001 00000001 00000008 80169f00 8016d374 8014b338
stack_dump: 0x8016d9c0: 8014b338 00002080 0000008c 80006c74 0000007f 0000001b 00000004 00000000
stack_dump: 0x8016d9e0: 00000000 00000000 8014b000 800ed3bc 800ed504 00000000 00000000 00000001
stack_dump: 0x8016da00: 00000004 8016e4c8 8016e210 8000cd5e 00000000 8014b39c 8014b358 00000001
stack_dump: 0x8016da20: 00000003 00002088 8014b338 8016e4cb 00000000 ffffffff ffffffff 00000000
stack_dump: 0x8016da40: 00000000 00000001 8016b948 00000000 8016dac8 ffffffff ffffffff 00000000
stack_dump: 0x8016da60: 00000000 00000000 00000000 8016e4c8 00000000 00000000 00000000 00000000
stack_dump: 0x8016da80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
stack_dump: 0x8016daa0: 00000000 00000000 00000000 80013ce8 8016db4c 8016e4c8 8016db4c 00000001
stack_dump: 0x8016dac0: 00000050 00000101 00000000 80013e90 00000005 00000005 8016d374 8016daf8
stack_dump: 0x8016dae0: 00000005 00000003 00000000 00000001 00000050 00000102 00000000 00000000
stack_dump: 0x8016db00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
stack_dump: 0x8016db20: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
stack_dump: 0x8016db40: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
stack_dump: 0x8016db60: 00000100 00000005 00000001 00000000 00000000 00000000 00000000 00000000
stack_dump: 0x8016db80: 00000000 00000000 00000000 00000001 ffffffff 8016e4c8 8016e210 8000ac0a
stack_dump: 0x8016dba0: 8016e4c8 00000000 00000001 8014b42c ffffff83 8016b6c0 00000001 00000000
stack_dump: 0x8016dbc0: 00000000 8016d4a8 8016e210 8000a880 8016b6c0 8016d4a8 8016d4a8 00000001
stack_dump: 0x8016dbe0: 00000000 8016d4a8 00000001 8000a836 8016a000 800eb720 800eb71c 00000064
stack_dump: 0x8016dc00: 00000000 8016ce78 8000a806 8000791c 00000000 00000000 00000001 8016d4a8
stack_dump: 0x8016dc20: 00000000 8016ce78 00000000 800027b2 00000000 00000000 00000000 00000000
stack_dump: 0x8016dc40: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
dump_tasks:    PID GROUP PRI POLICY   TYPE    NPX STATE   EVENT      SIGMASK          STACKBASE  STACKSIZE      USED   FILLED    COMMAND
dump_tasks:   ----   --- --- -------- ------- --- ------- ---------- ---------------- 0x8014ddd0      2048       748    36.5%    irq
dump_task:       0     0   0 FIFO     Kthread -   Ready              0000000000000000 0x8016af20      1952       764    39.1%    Idle_Task
dump_task:       1     0 224 RR       Kthread -   Waiting Semaphore  0000000000000000 0x8016bbc0      1904       524    27.5%    hpwork 0x8014b2f4 0x8014b320
dump_task:       2     0 100 RR       Kthread -   Waiting Semaphore  0000000000000000 0x8016c498      1896       508    26.7%    lpwork 0x8014b2b0 0x8014b2dc
dump_task:       3     3 100 RR       Task    -   Running            0000000000000000 0x8016d4c8      1912      1868    97.6%!   nsh_main

The firmware crashes and the stack size is 1912.

Now, with the changes introduced by this PR:

nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK            STACK    USED FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 0001952 0000908  46.5%  Idle_Task
    1     0 224 RR       Kthread   - Waiting  Semaphore 0000000000000000 0001904 0000508  26.6%  hpwork 0x8014b374 0x8014b3a0
    2     0 100 RR       Kthread   - Waiting  Semaphore 0000000000000000 0001896 0000508  26.7%  lpwork 0x8014b330 0x8014b35c
    3     3 100 RR       Task      - Running            0000000000000000 0002936 0002076  70.7%  nsh_main
nsh> 

After apache#15075, the size of the
stack size has decreased 8 bytes and the init stack size for the
rv-virt:citest defconfig was near its full capacity, which lead to
crashing the `ps` command. The init stack size for this defconfig
was increased from 2048 to 3072 to avoid stack overflow.
@github-actions github-actions bot added Board: risc-v Size: XS The size of the change in this PR is very small labels Dec 12, 2024
@tmedicci
Copy link
Copy Markdown
Contributor Author

@lupyuen , it seems that there are other issues regarding the rv-virt:citest. In fact, we had this problem regarding the init stack size, but test_ltp_interfaces_pthread_barrierattr_init_2_1 starts failing (and all subsequent tests fail too).

Let's merge this PR because it fixes a known issue (not necessarily the only one that broke our CI) and continue the investigation.

@xiaoxiang781216
Copy link
Copy Markdown
Contributor

but the ci still fail.

@tmedicci
Copy link
Copy Markdown
Contributor Author

but the ci still fail.

Yes, there are other issues (not related with the ps command and probably not related to the init stack size). I edited the description (and it doesn't close #14808 anymore), but it fixes the ps crash due to stack overflow. So, I think this can be merged and we continue investigating the other issues regarding the run test.

@xiaoxiang781216 xiaoxiang781216 merged commit 38b41e5 into apache:master Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Board: risc-v Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants