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 B99EE43214; Fri, 27 Oct 2023 11:23:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A5A8F40F16; Fri, 27 Oct 2023 11:23:11 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 2693C4025E for ; Fri, 27 Oct 2023 11:23:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698398589; 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=H9uT4jgoEckq4cGhRzgorRgZknLjZASXdfoApA/IsJwiclhZnLTr3epM7uDyxFkw1jcYoe G6lh5DT26ouTDRqPES2aRAIrlIud840NN/vBP3HfFC+169yqS6+oqezrWWiN6SAXDLZM8E 5twZ/hrpOG2Vd7TeKC0TzLNuqzkBnMA= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-QA3JYe96MOSpQXaUna0OoQ-1; Fri, 27 Oct 2023 05:23:08 -0400 X-MC-Unique: QA3JYe96MOSpQXaUna0OoQ-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-507b8ac8007so2184355e87.0 for ; Fri, 27 Oct 2023 02:23:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698398587; x=1699003387; 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=UtWyx2ucFcBoBOxnwrr9xaI7dLyumaS4Rpb3ECnNOLRKf6eAesYsvEZ/6fgA+qY50b 21d45rQLMwD5mMYP1syoowVf22wFO1rudoCX7lQLm+Y+zeV/yfHjqcaIhYtT/7MdXBBX zqgr6dk1mhpW3HTUz6s+AbTDcgxJtXQY/vlBXxA9uRJQR5pmMrW2Wa7KJt7RqenhFe1+ LbzSOmTpTXxtU6Cg4bvF31SbiDcbyGNtCKnDjs+okkEI4wgCVEM6KWGmzfrZ4DLNdzga DRvmCXpWo0xCraiMj59bEZXS+yAddgRFR4yQECKDvmI04zsr9IJwy5ZOm4AeaxwjzvGS DizQ== X-Gm-Message-State: AOJu0YwB2deAOif4IduzzMI03sG8jl3oF2iORls5ZKchuKZigXB5byzD teLrWqLmDZI8JZo1fvEaZHO5oFIYoGAhyC8tujPe22/e2yNOae6fg90vkgzn0v4fR+2YOelm00W 7Dezuv9++uuv2ouuZNhs= X-Received: by 2002:a05:6512:3e9:b0:507:c7cc:12c7 with SMTP id n9-20020a05651203e900b00507c7cc12c7mr1305159lfq.47.1698398585497; 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: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-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