qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
	qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Christian Schoenebeck <qemu_oss@crudebyte.com>,
	Fam Zheng <fam@euphon.net>, Greg Kurz <groug@kaod.org>,
	Richard Henderson <richard.henderson@linaro.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Alex Williamson <alex.williamson@redhat.com>
Subject: Re: [PATCH 5/6] hw/vfio/common: Use RCU_READ macros
Date: Fri, 16 Feb 2024 10:13:13 +0100	[thread overview]
Message-ID: <2fbf0024-3a2c-4656-8407-fa271a8bb7ec@redhat.com> (raw)
In-Reply-To: <a55d793c-3d61-4bda-8213-12a1de65c85f@linaro.org>

On 2/16/24 09:49, Philippe Mathieu-Daudé wrote:
> On 24/1/24 15:09, Philippe Mathieu-Daudé wrote:
>> On 24/1/24 10:25, Manos Pitsidianakis wrote:
>>> On Wed, 24 Jan 2024 09:42, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>>> Replace the manual rcu_read_(un)lock calls by the
>>>> *RCU_READ_LOCK_GUARD macros (See commit ef46ae67ba
>>>> "docs/style: call out the use of GUARD macros").
>>>>
>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>> ---
>>>> hw/vfio/common.c | 34 ++++++++++++++++------------------
>>>> 1 file changed, 16 insertions(+), 18 deletions(-)
>>>>
>>>> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
>>>> index 4aa86f563c..09878a3603 100644
>>>> --- a/hw/vfio/common.c
>>>> +++ b/hw/vfio/common.c
>>>> @@ -308,13 +308,13 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
>>>>         return;
>>>>     }
>>>>
>>>> -    rcu_read_lock();
>>>> +    RCU_READ_LOCK_GUARD();
>>>>
>>>>     if ((iotlb->perm & IOMMU_RW) != IOMMU_NONE) {
>>>>         bool read_only;
>>>>
>>>>         if (!vfio_get_xlat_addr(iotlb, &vaddr, NULL, &read_only)) {
>>>> -            goto out;
>>>> +            return;
>>>
>>> Since this is the only early return, we could alternatively do:
>>>
>>> -         if (!vfio_get_xlat_addr(iotlb, &vaddr, NULL, &read_only)) {
>>> +         if (vfio_get_xlat_addr(iotlb, &vaddr, NULL, &read_only)) {
>>>
>>> remove the goto/return, and wrap the rest of the codeflow in this if's brackets. And then we could use WITH_RCU_READ_LOCK_GUARD instead. That'd increase the code indentation however.
>>
>> If the maintainer agrees with the style & code churn, I don't
>> mind respining.
> 
> Alex, Cédric, any preference?

my choice would be to keep the 'goto' statement and protect
the vfio_get_xlat_addr() call with :

+        WITH_RCU_READ_LOCK_GUARD() {
+            if (vfio_get_xlat_addr(iotlb, NULL, &translated_addr, NULL)) {
+                ret = vfio_get_dirty_bitmap(bcontainer, iova,
+                                            iotlb->addr_mask + 1,
+                                            translated_addr);
+                if (ret) {
+                    error_report("vfio_iommu_map_dirty_notify(%p,"
+                                 " 0x%"HWADDR_PRIx
+                                 ", 0x%"HWADDR_PRIx") = %d (%s)",
+                                 bcontainer, iova, iotlb->addr_mask + 1, ret,
+                                 strerror(-ret));
+                }
+            }
          }



Thanks,

C.





  reply	other threads:[~2024-02-16  9:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24  7:41 [PATCH 0/6] hw/accel: Use RCU_READ macros Philippe Mathieu-Daudé
2024-01-24  7:41 ` [PATCH 1/6] accel/tcg/cpu-exec: Use RCU_READ macro Philippe Mathieu-Daudé
2024-01-24  9:34   ` Manos Pitsidianakis
2024-01-24 21:14   ` Richard Henderson
2024-01-28  1:07   ` Richard Henderson
2024-01-24  7:41 ` [PATCH 2/6] hw/9pfs/9p-synth: " Philippe Mathieu-Daudé
2024-01-24  7:49   ` Greg Kurz
2024-01-24 13:15   ` Christian Schoenebeck
2024-01-24  7:41 ` [PATCH 3/6] hw/display/virtio-gpu-udmabuf: " Philippe Mathieu-Daudé
2024-01-24  9:13   ` Manos Pitsidianakis
2024-01-24  7:41 ` [PATCH 4/6] hw/scsi/virtio-scsi: " Philippe Mathieu-Daudé
2024-01-24  9:17   ` Manos Pitsidianakis
2024-01-24 10:26     ` Philippe Mathieu-Daudé
2024-01-24  7:42 ` [PATCH 5/6] hw/vfio/common: Use RCU_READ macros Philippe Mathieu-Daudé
2024-01-24  9:25   ` Manos Pitsidianakis
2024-01-24 14:09     ` Philippe Mathieu-Daudé
2024-02-16  8:49       ` Philippe Mathieu-Daudé
2024-02-16  9:13         ` Cédric Le Goater [this message]
2024-01-24  7:42 ` [PATCH 6/6] hw/virtio/vhost: Use RCU_READ macro Philippe Mathieu-Daudé
2024-01-24  9:15   ` Manos Pitsidianakis

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=2fbf0024-3a2c-4656-8407-fa271a8bb7ec@redhat.com \
    --to=clg@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=fam@euphon.net \
    --cc=groug@kaod.org \
    --cc=kraxel@redhat.com \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    --cc=richard.henderson@linaro.org \
    /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).