qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: "Laurent Vivier" <lvivier@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@de.ibm.com>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"David Gibson" <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v2] Avoid address_space_rw() with a constant is_write argument
Date: Thu, 20 Feb 2020 10:27:14 +0100	[thread overview]
Message-ID: <31660c9b-ad1c-5d3f-b6db-fba69ee5e563@redhat.com> (raw)
In-Reply-To: <f87dbeeb-2259-9eb9-45c7-a30819eec2ee@redhat.com>

On 2/18/20 1:56 PM, Philippe Mathieu-Daudé wrote:
> On 2/18/20 12:24 PM, Peter Maydell 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.

Script is "scripts/coccinelle/as_rw_const.cocci".

I plan to respin this patch (fixed) in a larger series.

>>
>> 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 <peter.maydell@linaro.org>
>> ---
>> 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 ++---
>>   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



  parent reply	other threads:[~2020-02-20  9:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18 11:24 [PATCH v2] Avoid address_space_rw() with a constant is_write argument Peter Maydell
2020-02-16 17:24 ` Edgar E. Iglesias
2020-02-18 12:56 ` Philippe Mathieu-Daudé
2020-02-18 13:33   ` Eric Blake
2020-02-18 13:41     ` Peter Maydell
2020-02-20  9:27   ` Philippe Mathieu-Daudé [this message]
2020-02-18 13:13 ` Laurent Vivier
2020-02-18 13:20   ` Peter Maydell
2020-02-20 11:28   ` Paolo Bonzini
2020-02-18 13:30 ` Cédric Le Goater
2020-02-18 14:54 ` Christian Borntraeger
2020-02-18 17:34 ` Cornelia Huck
2020-02-18 22:30 ` Alistair Francis
2020-02-18 23:00 ` David Gibson

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=31660c9b-ad1c-5d3f-b6db-fba69ee5e563@redhat.com \
    --to=philmd@redhat.com \
    --cc=alistair@alistair23.me \
    --cc=borntraeger@de.ibm.com \
    --cc=clg@kaod.org \
    --cc=cohuck@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=edgar.iglesias@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).