From patchwork Tue Feb 7 10:45:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 123217 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 236B541C2D; Tue, 7 Feb 2023 11:46:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1F06842D2C; Tue, 7 Feb 2023 11:46:02 +0100 (CET) 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 E533F40042 for ; Tue, 7 Feb 2023 11:46:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675766760; 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=eOwGbt9CcP0zjshpwMuNvLPvD9rBDmotHjwdvgUIrgs=; b=N/4B8su4n0AgYoFV/nq61NmNoT/lOvRNYXkAdtXbi7s8JoaPZFZuiUiUBZRyoYLqWEYyC6 NwVvp/YIP7JsWa64/HvpphGFkLSLzNVLYRHvZix40+4YXON5tv7a4R+TBlP10omaSdbieL wa/GWgR8vncEGoKg6H3BdsOrH1BHycI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-433-gH3638f8OjeV-31f4u2SAg-1; Tue, 07 Feb 2023 05:45:57 -0500 X-MC-Unique: gH3638f8OjeV-31f4u2SAg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BF678801779; Tue, 7 Feb 2023 10:45:56 +0000 (UTC) Received: from dmarchan.redhat.com (ovpn-195-46.brq.redhat.com [10.40.195.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 327E82166B29; Tue, 7 Feb 2023 10:45:55 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, stephen@networkplumber.org, chenbo.xia@intel.com, jiayu.hu@intel.com, yuanx.wang@intel.com, xuan.ding@intel.com, mb@smartsharesystems.com Subject: [PATCH v6 4/9] vhost: annotate virtqueue access lock Date: Tue, 7 Feb 2023 11:45:27 +0100 Message-Id: <20230207104532.2370869-5-david.marchand@redhat.com> In-Reply-To: <20230207104532.2370869-1-david.marchand@redhat.com> References: <20220328121758.26632-1-david.marchand@redhat.com> <20230207104532.2370869-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 vhost_user_lock/unlock_all_queue_pairs must be waived since clang annotations can't express taking a runtime number of locks. vhost_queue_stats_update() requirement can be expressed with a required tag. Signed-off-by: David Marchand Acked-by: Morten Brørup Reviewed-by: Maxime Coquelin Reviewed-by: Chenbo Xia --- Changes since RFC v3: - removed annotations needed for vhost async which went to the next patch, --- lib/vhost/vhost_user.c | 2 ++ lib/vhost/virtio_net.c | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index 60ec1bf5f6..70d221b9f6 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -2965,6 +2965,7 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev, static void vhost_user_lock_all_queue_pairs(struct virtio_net *dev) + __rte_no_thread_safety_analysis { unsigned int i = 0; unsigned int vq_num = 0; @@ -2982,6 +2983,7 @@ vhost_user_lock_all_queue_pairs(struct virtio_net *dev) static void vhost_user_unlock_all_queue_pairs(struct virtio_net *dev) + __rte_no_thread_safety_analysis { unsigned int i = 0; unsigned int vq_num = 0; diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index cc9675ebe5..f2ab6dba15 100644 --- a/lib/vhost/virtio_net.c +++ b/lib/vhost/virtio_net.c @@ -52,12 +52,10 @@ is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t nr_vring) return (is_tx ^ (idx & 1)) == 0 && idx < nr_vring; } -/* - * This function must be called with virtqueue's access_lock taken. - */ static inline void vhost_queue_stats_update(struct virtio_net *dev, struct vhost_virtqueue *vq, struct rte_mbuf **pkts, uint16_t count) + __rte_exclusive_locks_required(&vq->access_lock) { struct virtqueue_stats *stats = &vq->stats; int i;