CV-Bowen opened a new pull request, #22290:
URL: https://github.com/apache/nuttx/pull/22290

   ## Summary
   
   `drivers/rptun: add a synchronous start mode without a worker thread`:
   every rptun start spawns a short lived "rptun" kernel thread that runs
   `rptun_do_start()` and then polls `rptun_create_devices()` until the
   peer has set up every device, so each start/stop cycle allocates and
   frees a TCB and a stack. The new `CONFIG_RPTUN_START_SYNC` (default n)
   runs that sequence in the caller instead: no thread and no allocation
   per cycle, at the cost of blocking the caller until the peer is ready.
   
   No pid is recorded in this mode: `rptun_dev_stop()` SIGKILLs the
   recorded pid, which would otherwise be the task that started the link
   (for example the shell after `rptun start`, or the task that ran the
   board bring-up).
   
   ## Impact
   
   - New Kconfig `RPTUN_START_SYNC`, default n; no change otherwise.
   - With the option, `rptun_initialize()` (autostart) and `RPTUNIOC_START`
     return only after the peer has driven every virtio device in the
     resource table. A device the peer has no driver for blocks the caller
     for good; the Kconfig help says so. In the default mode the same
     situation only leaves the short lived thread polling.
   
   ## Testing
   
   Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU 
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
   
   The commit builds sim:rpserver, sim:rpproxy, qemu-armv8a:rpserver and
   qemu-armv8a:rpproxy with and without `CONFIG_RPTUN_START_SYNC=y`, with
   0 warnings.
   
   **Runtime with `CONFIG_RPTUN_START_SYNC=y` on both sides.** The server
   now finishes its bring-up only once the proxy is up, so both are started
   together; then, on the server console, `rpmsg ping all 10 64 1 0`, `ps`,
   `rptun stop /dev/rptun/proxy`, `ps`, `echo alive`. Three boots each:
   
   | | qemu-armv8a:rpserver + rpproxy | sim:rpserver + rpproxy (*) |
   |---|---|---|
   | boot, ping in both directions | 3/3 | 3/3 |
   | no "rptun" thread in `ps` | yes | yes |
   | `rptun stop` | returns, `sh` keeps pid 8 | returns, `sh` keeps pid 8 |
   
   (*) On sim this needs apache/nuttx#P146, which enables a driver for the
   virtio serial vdev in the sim resource table. Without it the proxy's
   bring-up waits for that vdev forever with this option, while the default
   mode only leaves the short lived thread polling. The sim runs above are
   on top of that PR, without other config changes. This PR builds and
   works without it otherwise.
   
   Recording the caller's pid, as a first version of this change did, made
   `rptun stop` kill the shell on qemu-armv8a (`sh` pid 8 is gone after the
   stop and init starts a new `sh` as pid 9):
   
   ```
   server> ps
       8     8     7 100 FIFO     Task      - Running  ...  sh
   server> rptun stop /dev/rptun/proxy
   server> ps
       9     9     7 100 FIFO     Task      - Running  ...  sh
   ```
   
   No regression in rpmsg: sim:rpserver/rpproxy and 
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping, 
rpmsgfs; 15/15). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC 
disabled, which current master needs for nxinit to start nsh there; unrelated 
to this change.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to