CV-Bowen opened a new pull request, #22140:
URL: https://github.com/apache/nuttx/pull/22140
## Summary
Small follow-ups to the rpmsg core (`drivers/rpmsg`), in the order they
were made:
- `add a signal for local buffer allocation`: add
`RPMSG_SIGNAL_ALLOC_LOCAL` and `rpmsg_alloc_local()`, so that a service
can tell whether `rpmsg_alloc_buf()` on a device allocates from shared
memory on the local side. rpmsg_virtio sets it on the virtio driver
side. `rpmsg_register()` now ORs `RPMSG_SIGNAL_RUNNING` into the
signals instead of overwriting them, so a signal the transport set
before registration is kept.
- `make the recursive dispatch limit configurable`: the depth up to
which `rpmsg_tickwait()` runs pending works of its own work queue
while it waits was hard coded to 8. Add `CONFIG_RPMSG_RECURSIVE_LIMIT`
(default 8) so a configuration with a small worker stack can lower it.
- `inline the rx work helpers`: every frame on the rx path is paid once
per recursion level. Make `rpmsg_queue_rx_work()` and
`rpmsg_virtio_process_rx_buffer()` inline functions;
`struct rpmsg_work_s` and `rpmsg_queue_rx_work()` move to
`drivers/rpmsg/rpmsg.h`, `rpmsg_rx_worker()` becomes non-static.
- `skip comparing a work queue with itself`,
`drop the cleanup loop for a single work queue`: Coverity cleanups in
`rpmsg_queue_work()` and `rpmsg_create_wqueues()`, no functional
change.
- `scale recursion limit with work queue stack size`: derive the
default `RPMSG_RECURSIVE_LIMIT` from `RPMSG_WQUEUE_STACKSIZE`, one level
per 2 KB, from 2 up to 8. One nested dispatch costs about 528 B of
framework stack on AArch64 (336 B on ARM32) before the endpoint
callback, so a fixed 8 can overflow a small worker stack.
Depends on apache/nuttx#22098; this branch contains its 5 commits,
review the last 6.
## Impact
- New Kconfig `RPMSG_RECURSIVE_LIMIT`. Its default follows
`RPMSG_WQUEUE_STACKSIZE` (2 at <= 4 KB ... 8 above 14 KB), so boards with
a small worker stack nest less than before: sim:rp* (2 KB) get 2,
qemu-armv8a:rp* (8 KB) get 4; both pass the tests below.
- New `RPMSG_SIGNAL_ALLOC_LOCAL` / `rpmsg_alloc_local()` in
`include/nuttx/rpmsg/rpmsg.h`; no in-tree user yet. Bit 0 of the
rpmsg signals is now set on the virtio driver side;
`rpmsg_is_running()` and the other in-tree users only test
`RPMSG_SIGNAL_RUNNING`.
- Internal header and symbol moves in `drivers/rpmsg`; no API change
outside it.
## 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
Every commit builds sim:rpserver, sim:rpproxy, qemu-armv8a:rpserver and
qemu-armv8a:rpproxy with 0 warnings.
**Inlining.** qemu-armv8a:rpserver with `CONFIG_DEBUG_NOOPT` off and
`CONFIG_DEBUG_FULLOPT=y` (the rp configs build -O0, where
`inline_function` is plain `inline`), base = #22098 head:
| | base | this PR |
|---|---|---|
| `rpmsg_queue_rx_work` / `rpmsg_virtio_process_rx_buffer` symbols | present
| gone (inlined) |
| `rpmsg_virtio_rx_dispatch` frame | 96 B | 112 B |
| stack for deferred rx (dispatch + queue_rx_work) | 96 + 32 = 128 B | 112 B
|
| stack for RT rx (dispatch + process_rx_buffer) | 96 + 64 = 160 B | 112 B |
**Recursion limit.** sim:rpserver + sim:rpproxy, baseline cases with
`CONFIG_RPMSG_RECURSIVE_LIMIT` set to 3 and 2: all pass, same as the
default 8. With 1 or 0 the proxy never completes the name service
handshake (server endpoints stay unbound, proxy console unreachable),
presumably because some start-up waits are only satisfied by work queued
behind them on the same work queue, so at least two levels of nested
dispatch are needed; the stack size based default never goes below 2.
Not tested: `rpmsg_alloc_local()` has no in-tree caller; the
single-work-queue cleanup path needs a failing `work_queue_create()`.
No regression in rpmsg: sim:rpserver/rpproxy and
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping,
rpmsgfs; 22/22 with the stack size based defaults, 2 on sim and 4 on
qemu-armv8a, including 200 x 2048 byte ping in both directions and `rpmsg dump
all`). 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]