All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] hw/virtio/virtio-access.h: remove target specific code
@ 2026-02-12 23:45 Pierrick Bouvier
  2026-02-12 23:46 ` [PATCH 1/3] hw/virtio: add virtio_vdev_is_{modern, legacy} Pierrick Bouvier
                   ` (4 more replies)
  0 siblings, 5 replies; 23+ messages in thread
From: Pierrick Bouvier @ 2026-02-12 23:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, Pierrick Bouvier, Harsh Prateek Bora,
	Stefano Garzarella, Jason Wang, Nicholas Piggin, stefanha,
	richard.henderson, Michael S. Tsirkin,
	Philippe Mathieu-Daudé

This series eliminates some target specifics in hw/virtio and replace them with
runtime functions where needed, to be able to link virtio code in single-binary.
After a first try on a series [0] doing this change and making all virtio files
common, Richard asked to refactor this part, thus this independent series.

By diving into virtio initialization, I noticed that device_endian is always
storing endianness of cpu associated on device reset. The root issue, is when
dealing with target who dynamically change their endianness during execution.
ppc64 is the main use case, as cpu always boot in BE and most of OS use LE. arm
use case is more limited, as big endian systems are mostly dead nowadays.

Because of this, initialization is tricky, and goes through different hoops to
have the expected value. My first approach has been to try to change this, by
simply setting endianness on the first access. However, it fell flat, because
current_cpu is not always available at this time.
A second approach was to set endianness to LE by default, and change it only
when setting device features, and potentially discovering it's a legacy virtio
device. It brought other issues, that showed that current initialization code,
even though it's complex, does the right thing.
Thus, I focused on refactoring virtio_access_is_big_endian, and noticed that it
was not even needed at this point.

Patches 1 and 2 are refactoring names to clear some confusion.
Patch 3 eliminates virtio_access_is_big_endian, with a lenghty commit message
explaining the change. By doing this, we remove target specifics from
hw/virtio/virtio-access.h.

Of course, performance has been tested, and it is on par with upstream/master.

Results are on 20 runs and expressed in kIOPS:
reference: mean=239.2 std_dev=3.48
with_series: mean=238.1 std_dev=3.56

---

Performance has been measured with this automated fio benchmark [1], with
original instructions from Stefan [2].

Download artifacts and run benchmark with:
$ wget https://github.com/pbo-linaro/qemu-linux-stack/releases/download/build/x86_64_io_benchmark-a55f2d6.tar.xz
$ tar xvf x86_64_io_benchmark-a55f2d6.tar.xz
$ ./run.sh /path/to/qemu-system-x86_64

[0] https://lore.kernel.org/qemu-devel/20260206221908.1451528-1-pierrick.bouvier@linaro.org/
[1] https://github.com/pbo-linaro/qemu-linux-stack/tree/x86_64_io_benchmark
[2] https://lore.kernel.org/qemu-devel/20260202185233.GC405548@fedora/

Pierrick Bouvier (3):
  hw/virtio: add virtio_vdev_is_{modern, legacy}
  hw/virtio: rename virtio_is_big_endian to virtio_vdev_is_big_endian
  hw/virtio: remove virtio_access_is_big_endian

 include/hw/virtio/virtio-access.h | 43 +++++++++----------------------
 include/hw/virtio/virtio.h        | 14 ++++++++--
 hw/net/virtio-net.c               |  6 ++---
 hw/virtio/vhost.c                 |  6 ++---
 hw/virtio/virtio-pci.c            | 10 +++----
 hw/virtio/virtio.c                | 20 +++++++-------
 6 files changed, 45 insertions(+), 54 deletions(-)

-- 
2.47.3



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2026-02-25  0:25 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-12 23:45 [PATCH 0/3] hw/virtio/virtio-access.h: remove target specific code Pierrick Bouvier
2026-02-12 23:46 ` [PATCH 1/3] hw/virtio: add virtio_vdev_is_{modern, legacy} Pierrick Bouvier
2026-02-13  1:19   ` BALATON Zoltan
2026-02-13  1:33     ` Pierrick Bouvier
2026-02-18 21:00   ` Philippe Mathieu-Daudé
2026-02-18 22:17     ` Pierrick Bouvier
2026-02-18 22:20       ` Pierrick Bouvier
2026-02-18 22:28         ` BALATON Zoltan
2026-02-18 22:33           ` Pierrick Bouvier
2026-02-18 23:46             ` BALATON Zoltan
2026-02-19  0:13               ` Pierrick Bouvier
2026-02-19 14:13                 ` BALATON Zoltan
2026-02-12 23:46 ` [PATCH 2/3] hw/virtio: rename virtio_is_big_endian to virtio_vdev_is_big_endian Pierrick Bouvier
2026-02-18 21:01   ` Philippe Mathieu-Daudé
2026-02-12 23:46 ` [PATCH 3/3] hw/virtio: remove virtio_access_is_big_endian Pierrick Bouvier
2026-02-18 21:02   ` Philippe Mathieu-Daudé
2026-02-18 16:53 ` [PATCH 0/3] hw/virtio/virtio-access.h: remove target specific code Pierrick Bouvier
2026-02-24 18:33 ` Philippe Mathieu-Daudé
2026-02-24 19:07   ` Michael S. Tsirkin
2026-02-24 19:21     ` Pierrick Bouvier
2026-02-24 19:36       ` Philippe Mathieu-Daudé
2026-02-25  0:25         ` Stefan Hajnoczi
2026-02-25  0:21       ` Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.