All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Cc: "Stefan Hajnoczi" <stefanha@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-devel@nongnu.org,
	"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
	"Stefano Garzarella" <sgarzare@redhat.com>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	qemu-ppc@nongnu.org
Subject: Re: [PATCH v3 04/11] hw/virtio: Use VirtIODevice::access_is_big_endian field
Date: Tue, 3 Feb 2026 06:07:43 -0500	[thread overview]
Message-ID: <20260203055247-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1804511f-a048-4eb8-9cf3-1c75bdf4b277@linaro.org>

On Mon, Feb 02, 2026 at 07:22:16PM -0800, Pierrick Bouvier wrote:
> On 2/2/26 11:25 AM, Pierrick Bouvier wrote:
> > On 2/2/26 10:52 AM, Stefan Hajnoczi wrote:
> > > 
> > > This command-line lets you benchmark virtio-blk without actual I/O
> > > slowing down the request processing:
> > > 
> > >     qemu-system-x86_64 \
> > >         -M accel=kvm \
> > >         -cpu host \
> > >         -m 4G \
> > >         --blockdev file,node-name=drive0,filename=boot.img,cache.direct=on,aio=native \
> > >         --blockdev null-co,node-name=drive1,size=$((10 * 1024 * 1024 * 1024)) \
> > >         --object iothread,id=iothread0 \
> > >         --device virtio-blk-pci,drive=drive0,iothread=iothread0 \
> > >         --device virtio-blk-pci,drive=drive1,iothread=iothread0
> > > 
> > > Here is a fio command-line for 4 KiB random reads:
> > > 
> > >     fio \
> > >         --ioengine=libaio \
> > >         --direct=1 \
> > >         --runtime=30 \
> > >         --ramp_time=10 \
> > >         --rw=randread \
> > >         --bs=4k \
> > >         --iodepth=128 \
> > >         --filename=/dev/vdb \
> > >         --name=randread
> > > 
> > > This is just a single vCPU, but it should be enough to see if there is
> > > any difference in I/O Operations Per Second (IOPS) or efficiency
> > > (IOPS/CPU utilization).
> > > 
> > Thanks very much for the info Stefan. I didn't even know null-co
> > blockdev, so it definitely would have taken some time to find all this.
> > 
> > For what it's worth, I automated the benchmark here (need podman for
> > build), so it can be reused for future changes:
> > https://github.com/pbo-linaro/qemu-linux-stack/tree/x86_64_io_benchmark
> > 
> > ./build.sh && ./run.sh path/to/qemu-system-x86_64
> > 
> > My initial testing showed a 50% slow down, which was more than
> > surprising. After profiling, the extra time is spent here:
> > https://github.com/qemu/qemu/blob/587f4a1805c83a4e1d59dd43cb14e0a834843d1d/target-info.c#L30
> > 
> > When we merged target-info, there have been several versions over a long
> > time, and I was 100% sure we were updating the target_info structure,
> > instead of reparsing the target_name every time. Unfortunately, that's
> > not the case. I'll fix that.
> > 
> > With that fix, there is no difference in performance (<1%).
> > 
> > I'll respin a v4 with the target info fix, initial v1 changes and
> > benchmark results.
> > 
> > Thanks for pointing the performance issue, there was one for sure.
> > 
> > Regards,
> > Pierrick
> 
> After proper benchmarking, I get those results (in kIOPS) over 20 runs, all
> including target_arch fix I mentioned.
> 
> reference: mean=239.2 var=12.16
> v1: mean=232.2 var=37.06
> v4-wip (optimized virtio_access_is_big_endian): mean=235.05 var=18.64
> 
> So basically, we have a 1.7% performance hit on a torture benchmark.
> Is that acceptable for you, or should we dig more?
> 
> Regards,
> Pierrick

Could we use some kind of linker trick?
Split just the ring manipulation code from
virtio.c and keep it target specific.


Or it could be that even just these two would be enough:

static inline uint16_t virtio_lduw_phys_cached(VirtIODevice *vdev,
                                               MemoryRegionCache *cache,
                                               hwaddr pa)
{
    if (virtio_access_is_big_endian(vdev)) {
        return lduw_be_phys_cached(cache, pa);
    }
    return lduw_le_phys_cached(cache, pa);
}

static inline void virtio_stw_phys_cached(VirtIODevice *vdev,
                                          MemoryRegionCache *cache,
                                          hwaddr pa, uint16_t value)
{
    if (virtio_access_is_big_endian(vdev)) {
        stw_be_phys_cached(cache, pa, value);
    } else {
        stw_le_phys_cached(cache, pa, value);
    }
}






-- 
MST



  reply	other threads:[~2026-02-03 11:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-01 23:29 [PATCH v3 00/11] single-binary: hw/virtio Philippe Mathieu-Daudé
2026-02-01 23:29 ` [PATCH v3 01/11] target-info: add target_base_ppc, target_ppc and target_ppc64 Philippe Mathieu-Daudé
2026-02-01 23:29 ` [PATCH v3 02/11] hw/virtio: Constify virtio_is_big_endian() argument Philippe Mathieu-Daudé
2026-02-01 23:29 ` [PATCH v3 03/11] hw/virtio: Introduce VirtIODevice::access_is_big_endian boolean field Philippe Mathieu-Daudé
2026-02-01 23:50   ` Philippe Mathieu-Daudé
2026-02-01 23:29 ` [PATCH v3 04/11] hw/virtio: Use VirtIODevice::access_is_big_endian field Philippe Mathieu-Daudé
2026-02-02  7:45   ` Michael S. Tsirkin
2026-02-02 13:08     ` Alex Bennée
2026-02-02 16:04       ` Michael S. Tsirkin
2026-02-02 18:52         ` Stefan Hajnoczi
2026-02-02 19:25           ` Pierrick Bouvier
2026-02-03  3:22             ` Pierrick Bouvier
2026-02-03 11:07               ` Michael S. Tsirkin [this message]
2026-02-03 17:31                 ` Pierrick Bouvier
2026-02-03 19:06                   ` Michael S. Tsirkin
2026-02-03 19:10                     ` Pierrick Bouvier
2026-02-03 19:37                       ` Pierrick Bouvier
2026-02-03 10:44             ` Philippe Mathieu-Daudé
2026-02-01 23:29 ` [PATCH v3 05/11] hw/virtio: Reduce virtio_access_is_big_endian() scope Philippe Mathieu-Daudé
2026-02-01 23:29 ` [PATCH v3 06/11] hw/virtio: Check target supports legacy bi-endianness at runtime Philippe Mathieu-Daudé
2026-02-01 23:29 ` [PATCH v3 07/11] hw/virtio: Replace TARGET_BIG_ENDIAN -> target_big_endian() Philippe Mathieu-Daudé
2026-02-01 23:29 ` [PATCH v3 08/11] hw/ppc/spapr: extract SPAPR_MAX_RAM_SLOTS in a new header Philippe Mathieu-Daudé
2026-02-01 23:29 ` [PATCH v3 09/11] hw/virtio/vhost-user: make compilation unit common Philippe Mathieu-Daudé
2026-02-01 23:29 ` [PATCH v3 10/11] hw/virtio/virtio-qmp: " Philippe Mathieu-Daudé
2026-02-01 23:29 ` [PATCH v3 11/11] hw/virtio: make all compilation units common Philippe Mathieu-Daudé
2026-02-02  7:47 ` [PATCH v3 00/11] single-binary: hw/virtio Michael S. Tsirkin
2026-02-02 11:16 ` Philippe Mathieu-Daudé
2026-02-02 18:13   ` Pierrick Bouvier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260203055247-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=harshpb@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=philmd@linaro.org \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.