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

   ## Summary
   
   Add a diagnostic ping device to the virtio and vhost frameworks, to
   measure the bare virtqueue round trip between two cores.
   
   rpmsg ping measures the endpoint, name service, dispatch and vring cost
   as one total, so the share of the vring and notification path cannot be
   told apart. The ping device (vendor-local device id 63, chosen at the top
   of what the modern PCI transport can express) has two virtqueues, one per
   direction, because only the driver side can post to an available ring.
   The initiator sends a request carrying its semaphore as a cookie, the peer
   answers on the other queue, and the initiator prints the average, minimum
   and maximum round trip time and the throughput to syslog. Either side can
   initiate.
   
   - `drivers/virtio: add virtio_foreach_device()` and
     `drivers/vhost: add vhost_foreach_device()`: walk the claimed devices
     with a given id under the bus lock. `/dev/virtio` and `/dev/vhost` are
     single global nodes, so an ioctl aimed at one device needs this to find
     it.
   - `drivers/virtio: add a ping device for virtqueue benchmarking`: the
     driver side, `CONFIG_DRIVERS_VIRTIO_PING`, started with
     `VIRTIOIOC_PING` on `/dev/virtio`. The argument, `struct virtio_ping_s`
     in `include/nuttx/virtio/virtio.h`, names the instance (from the
     device's config space, or `all`), the number of round trips, the
     request length and the interval. The wire format is in
     `include/nuttx/virtio/virtio-ping.h`.
   - `drivers/vhost: add the vhost-ping backend`: the device side,
     `CONFIG_DRIVERS_VHOST_PING`; `VHOSTIOC_PING` has the same value and
     argument as `VIRTIOIOC_PING`.
   
   The nsh `virtio ping` / `vhost ping` subcommand is in
   apache/nuttx-apps#{apps_pr}.
   
   ## Impact
   
   - New Kconfig `DRIVERS_VIRTIO_PING`, `DRIVERS_VHOST_PING`, default n.
   - New ioctl `VIRTIOIOC_PING` / `VHOSTIOC_PING` (`_VIRTIOIOC(2)`), new
     `struct virtio_ping_s`, new `virtio_foreach_device()` /
     `vhost_foreach_device()`.
   - No change for existing devices; no in-tree resource table exposes a
     ping device yet (the rptun tables get one in a follow-up).
   
   ## 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 (+`DRIVERS_VIRTIO_PING`), sim:rpproxy
   (+`DRIVERS_VHOST_PING`), qemu-armv8a:netnsh (+`DRIVERS_VIRTIO_PING`) and
   qemu-armv8a:rpproxy (+`DRIVERS_VHOST_PING`) with 0 warnings.
   
   **Ping over ivshmem.** qemu-armv8a:rpserver (+`DRIVERS_VIRTIO_PING`) and
   qemu-armv8a:rpproxy (+`DRIVERS_VHOST_PING`), with a test-only patch (not
   in this PR) adding a ping vdev named `ping0` to the
   `drivers/rptun/rptun_ivshmem.c` resource table, plus the nsh subcommand
   from the apps PR. Three runs (the third on the final head), 100 round
   trips each, period 0:
   
   | command | node | avg | min (runs 1/2) | max (runs 1/2) | rate |
   |---|---|---|---|---|---|
   | `virtio ping all 100 64 0` | server | 114 / 207 / 125 us | 87 / 97 us | 
1554 / 1364 us | 5.4 / 3.0 / 4.9 Mbit/s |
   | `virtio ping all 100 1024 0` | server | 97 / 197 / 102 us | 84 / 172 us | 
265 / 246 us | 85 / 42 / 81 Mbit/s |
   | `vhost ping all 100 64 0` | proxy | 186 / 108 / 197 us | 85 / 71 us | 447 
/ 545 us | 3.3 / 5.7 / 3.1 Mbit/s |
   | `rpmsg ping all 100 64 1 0` (same link, for comparison) | server | 212 / 
211 / 212 us | 125 / 176 us | 1497 / 1242 us | 2.4 / 2.4 / 2.4 Mbit/s |
   
   `virtio dump all` / `vhost dump all` list the device as
   `ping: name=ping0`. A ping to a name that does not exist fails with
   `ENODEV`.
   
   The same on sim:rpserver + sim:rpproxy, with the ping vdev added to
   `arch/sim/src/sim/sim_rptun.c` (test-only): both directions complete
   100/100 round trips; latency there is bounded by the 10 ms sim tick.
   
   <details><summary>qemu-armv8a log</summary>
   
   ```
   server> virtio ping all 100 1024 0
   [server] ping device: ping0
   [server] ping times: 100, send_len: 1024
   [server] avg: 0 s, 97493 ns
   [server] min: 0 s, 83815 ns
   [server] max: 0 s, 264979 ns
   [server] rate: 85.093288 Mbits/sec
   proxy> vhost ping all 100 64 0
   [proxy] ping device: ping0
   [proxy] ping times: 100, send_len: 64
   [proxy] avg: 0 s, 186211 ns
   [proxy] min: 0 s, 85348 ns
   [proxy] max: 0 s, 446686 ns
   [proxy] rate: 3.308075 Mbits/sec
   ```
   </details>
   
   Not tested: the virtio-mmio and virtio-pci transports (QEMU has no ping
   device).
   
   No regression in rpmsg: sim:rpserver/rpproxy and 
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping, 
rpmsgfs; 15/15). No regression in virtio: qemu-armv8a:netnsh boot and pass the 
fixed virtio cases (rng, blk on mmio and pci, net, 9p; 24/24). 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