From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 80A4B43214 for ; Fri, 27 Oct 2023 11:23:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7B5AE410FA; Fri, 27 Oct 2023 11:23:10 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 284FC402DF for ; Fri, 27 Oct 2023 11:23:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698398588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FEPxsc+wmAzOz+vZaBwBrH6qzo/QuuWx9oXuaNn9IoE=; b=PJslTmxLZ3M2dNqMkPGPB0Tk/GTlAx9pDju6SVYrwwxToCeWcKGKpwxe3lG99XuOSopnis GanHdFRxiqMbvFghGyccDukwjwYk0wNKIxIAW1DnA5GuNFeTUAvfHPmfhLsrvJrw4/ivNI q4IntnskaZ8KEBURkpRDQNK+p/DYY4E= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-487-s9DO8IYZNzChRn0dtWAdGQ-1; Fri, 27 Oct 2023 05:23:07 -0400 X-MC-Unique: s9DO8IYZNzChRn0dtWAdGQ-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-507d2e150c2so2165149e87.3 for ; Fri, 27 Oct 2023 02:23:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698398585; x=1699003385; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FEPxsc+wmAzOz+vZaBwBrH6qzo/QuuWx9oXuaNn9IoE=; b=NYXXxhuEzmoUnzmqSUKmyE+2BCB9+jrarQn6eFzCWVa1+84BmnBeDCp9cROf3FAPwk 32KQyECGC7tx2MxgvXJMlEab2cZic8uxJjvQC5jBpGwU9ZqA5f/GmihQUrEQZNSoioEL 0CBWQTJs/p4bsmcvCAOPbdZzMw5EHRz/WVFhilvL16vzbR41KE2p/2tkwk8IvAIYQDVh bYXsuktffIJbLzKbhQ8BAmMw+l7ZFA/Wgo3Hd3EgNEZ3kX8zQWs1z3MZ+gaHjEda2CmO 5N/4whBSbixPQ6Kj8QDYy127m/n2f8hWGEqFU5DhzNKJwanxYWCmnciyOqKMpa1DdxDY aNNA== X-Gm-Message-State: AOJu0YwofN7j8TlJVPlDdt9IzqBmHfY3WYlZUor81InMuQNP5earp1yb b8Ye2Sr4e0tKGvGtknYXIz1jRMyprW5gI58BMDMwiLD/byJINMMI3m+wZzWQ/DXFwTJgMRFh+iB ezgCJ1Wxeci12w4ycXo/4/RI= X-Received: by 2002:a05:6512:3e9:b0:507:c7cc:12c7 with SMTP id n9-20020a05651203e900b00507c7cc12c7mr1305162lfq.47.1698398585530; Fri, 27 Oct 2023 02:23:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSetzihTEwFVVR/rt2f93PggsEPEy3zgfEscr0Fh4ZE/tE1xiRLSSGD9yfeJQxElPTmAFI5NmhRbV5H+Hb/HU= X-Received: by 2002:a05:6512:3e9:b0:507:c7cc:12c7 with SMTP id n9-20020a05651203e900b00507c7cc12c7mr1305147lfq.47.1698398585161; Fri, 27 Oct 2023 02:23:05 -0700 (PDT) MIME-Version: 1.0 References: <20231023095520.2864868-1-david.marchand@redhat.com> <20231023095520.2864868-2-david.marchand@redhat.com> <76029D4A-DA8B-4CE9-ACFC-0B7D5BFF8512@redhat.com> In-Reply-To: <76029D4A-DA8B-4CE9-ACFC-0B7D5BFF8512@redhat.com> From: David Marchand Date: Fri, 27 Oct 2023 11:22:53 +0200 Message-ID: Subject: Re: [PATCH 2/3] vhost: fix virtqueue access lock in datapath To: Eelco Chaudron Cc: dev@dpdk.org, stable@dpdk.org, Maxime Coquelin , Chenbo Xia X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Fri, Oct 27, 2023 at 11:05=E2=80=AFAM Eelco Chaudron wrote: > > diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c > > index 759a78e3e3..4116f79d4f 100644 > > --- a/lib/vhost/virtio_net.c > > +++ b/lib/vhost/virtio_net.c > > @@ -1694,6 +1694,17 @@ virtio_dev_rx_packed(struct virtio_net *dev, > > return pkt_idx; > > } > > > > +static void > > +virtio_dev_vring_translate(struct virtio_net *dev, struct vhost_virtqu= eue *vq) > > +{ > > Would it be an idea to annotate this function that it needs to be called = with the =E2=80=9Cread locks=E2=80=9D (and that it will free them) to avoid= the duplicate: > > + vhost_user_iotlb_rd_unlock(vq); > + rte_rwlock_read_unlock(&vq->access_lock); The "unlock" annotations do not express read/write concerns for locks. So that would make the code less readable and potentially hide some issues. I prefer to keep as is, with clear calls to rd_lock / rd_unlock in those functions. > > > + rte_rwlock_write_lock(&vq->access_lock); > > + vhost_user_iotlb_rd_lock(vq); > > + if (!vq->access_ok) > > + vring_translate(dev, vq); > > + vhost_user_iotlb_rd_unlock(vq); > > + rte_rwlock_write_unlock(&vq->access_lock); > > +} > > + --=20 David Marchand