[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] Avoid address_space_rw() with a constant is_write argumen
From: |
Cornelia Huck |
Subject: |
Re: [PATCH v2] Avoid address_space_rw() with a constant is_write argument |
Date: |
Tue, 18 Feb 2020 18:34:41 +0100 |
On Tue, 18 Feb 2020 11:24:57 +0000
Peter Maydell <address@hidden> wrote:
> The address_space_rw() function allows either reads or writes
> depending on the is_write argument passed to it; this is useful
> when the direction of the access is determined programmatically
> (as for instance when handling the KVM_EXIT_MMIO exit reason).
> Under the hood it just calls either address_space_write() or
> address_space_read_full().
>
> We also use it a lot with a constant is_write argument, though,
> which has two issues:
> * when reading "address_space_rw(..., 1)" this is less
> immediately clear to the reader as being a write than
> "address_space_write(...)"
> * calling address_space_rw() bypasses the optimization
> in address_space_read() that fast-paths reads of a
> fixed length
>
> This commit was produced with the included Coccinelle script
> scripts/coccinelle/as-rw-const.patch.
>
> Two lines in hw/net/dp8393x.c that Coccinelle produced that
> were over 80 characters were re-wrapped by hand.
>
> Signed-off-by: Peter Maydell <address@hidden>
> ---
> I could break this down into separate patches by submaintainer,
> but the patch is not that large and I would argue that it's
> better for the project if we can try to avoid introducing too
> much friction into the process of doing 'safe' tree-wide
> minor refactorings.
>
> v1->v2: put the coccinelle script in scripts/coccinelle rather
> than just in the commit message.
> ---
> accel/kvm/kvm-all.c | 6 +--
> dma-helpers.c | 4 +-
> exec.c | 4 +-
> hw/dma/xlnx-zdma.c | 11 ++---
> hw/net/dp8393x.c | 68 ++++++++++++++--------------
> hw/net/i82596.c | 25 +++++-----
> hw/net/lasi_i82596.c | 5 +-
> hw/ppc/pnv_lpc.c | 8 ++--
> hw/s390x/css.c | 12 ++---
s390 part:
Reviewed-by: Cornelia Huck <address@hidden>
> qtest.c | 52 ++++++++++-----------
> target/i386/hvf/x86_mmu.c | 12 ++---
> scripts/coccinelle/as_rw_const.cocci | 30 ++++++++++++
> 12 files changed, 133 insertions(+), 104 deletions(-)
> create mode 100644 scripts/coccinelle/as_rw_const.cocci
- [PATCH v2] Avoid address_space_rw() with a constant is_write argument, Peter Maydell, 2020/02/18
- Re: [PATCH v2] Avoid address_space_rw() with a constant is_write argument, Philippe Mathieu-Daudé, 2020/02/18
- Re: [PATCH v2] Avoid address_space_rw() with a constant is_write argument, Laurent Vivier, 2020/02/18
- Re: [PATCH v2] Avoid address_space_rw() with a constant is_write argument, Cédric Le Goater, 2020/02/18
- Re: [PATCH v2] Avoid address_space_rw() with a constant is_write argument, Christian Borntraeger, 2020/02/18
- Re: [PATCH v2] Avoid address_space_rw() with a constant is_write argument,
Cornelia Huck <=
- Re: [PATCH v2] Avoid address_space_rw() with a constant is_write argument, Alistair Francis, 2020/02/18
- Re: [PATCH v2] Avoid address_space_rw() with a constant is_write argument, David Gibson, 2020/02/18
- Re: [PATCH v2] Avoid address_space_rw() with a constant is_write argument, Edgar E. Iglesias, 2020/02/18