From patchwork Tue Apr 4 12:48:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125753 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 5E459428CD; Tue, 4 Apr 2023 14:49:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4FC7041153; Tue, 4 Apr 2023 14:49:01 +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 F1E7740A7E for ; Tue, 4 Apr 2023 14:48:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612539; 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=EhaIhl6hmC2b4yZVgLXGE3K/rq2mYCRoyh2/amsVFZQ=; b=DGxj+jjM4Tv+my6BI2AsbUysNdJf+F8RnbSjSepG+JXh9UNL3AbX08kFl8Gfwy633+VAk0 ik2RHhYs9559Rta9fbYEEeggsuy5r5hORdinBfR72zTp3FTAeDvwuMl0enYV+2+RhP9CAm BBODwxCWlsVOfQwPYov5pXVxxpCgMlw= 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-550-Pnbpgy5PNruxm9GgEJhgzA-1; Tue, 04 Apr 2023 08:48:56 -0400 X-MC-Unique: Pnbpgy5PNruxm9GgEJhgzA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE268101A54F; Tue, 4 Apr 2023 12:48:55 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 183722027061; Tue, 4 Apr 2023 12:48:54 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Anatoly Burakov Subject: [PATCH v3 01/16] malloc: rework heap destroy Date: Tue, 4 Apr 2023 14:48:25 +0200 Message-Id: <20230404124840.1898-2-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 The destroy helper has been reworked to zero all the heap object but leave the lock untouched. The heap lock is then released through the standard API. Signed-off-by: David Marchand --- Changes since v2: - shrinked the change to the required part, --- lib/eal/common/malloc_heap.c | 6 ++++-- lib/eal/common/rte_malloc.c | 5 +---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index d7c410b786..d3c474d79c 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -1385,8 +1385,10 @@ malloc_heap_destroy(struct malloc_heap *heap) if (heap->total_size != 0) RTE_LOG(ERR, EAL, "Total size not zero, heap is likely corrupt\n"); - /* after this, the lock will be dropped */ - memset(heap, 0, sizeof(*heap)); + /* Reset all of the heap but the (hold) lock so caller can release it. */ + RTE_BUILD_BUG_ON(offsetof(struct malloc_heap, lock) != 0); + memset(RTE_PTR_ADD(heap, sizeof(heap->lock)), 0, + sizeof(*heap) - sizeof(heap->lock)); return 0; } diff --git a/lib/eal/common/rte_malloc.c b/lib/eal/common/rte_malloc.c index d39870bf3c..ebafef3f6c 100644 --- a/lib/eal/common/rte_malloc.c +++ b/lib/eal/common/rte_malloc.c @@ -657,10 +657,7 @@ rte_malloc_heap_destroy(const char *heap_name) /* sanity checks done, now we can destroy the heap */ rte_spinlock_lock(&heap->lock); ret = malloc_heap_destroy(heap); - - /* if we failed, lock is still active */ - if (ret < 0) - rte_spinlock_unlock(&heap->lock); + rte_spinlock_unlock(&heap->lock); unlock: rte_mcfg_mem_write_unlock(); From patchwork Tue Apr 4 12:48:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125754 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 925A7428CD; Tue, 4 Apr 2023 14:49:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8091E42B71; Tue, 4 Apr 2023 14:49:07 +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 6E39242B7E for ; Tue, 4 Apr 2023 14:49:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612546; 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=SZJ7ulxFx35Sp5nqIxL3N/qdf1XC23Q5HQIhtCFL3uQ=; b=PawD7f1aCrhmj21HhuMMFciKvC4TH8UJqcEOez6TO6P5RmDgaQ7zRtEDMfSzUD1fyu5lOF AgmWmCt7LnG1/CVKV69Oqq8Bj97QBzlJbxjH7i9re0p3fvKdMK+nasI7mm3ptr4cq6qy+z Dhi7civJ5OEuZGi2cvbZ8OMl/lOkAbw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-160-CaDGn5-8NbiK2q5Padce8g-1; Tue, 04 Apr 2023 08:49:00 -0400 X-MC-Unique: CaDGn5-8NbiK2q5Padce8g-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 860D72807D6E; Tue, 4 Apr 2023 12:48:59 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id F138F492C13; Tue, 4 Apr 2023 12:48:57 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Anatoly Burakov , Bruce Richardson , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Subject: [PATCH v3 02/16] mem: rework malloc heap init Date: Tue, 4 Apr 2023 14:48:26 +0200 Message-Id: <20230404124840.1898-3-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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 rte_eal_memory_init() and rte_eal_malloc_heap_init() must be called in a common section taking rte_mcfg_mem_read_lock(). Split rte_eal_malloc_heap_init() in two so that the mem lock is taken in rte_eal_init() making lock checks trivial (once annotated in the next patch). Signed-off-by: David Marchand --- lib/eal/common/eal_common_memory.c | 10 +--------- lib/eal/common/malloc_heap.c | 10 ++++++---- lib/eal/common/malloc_heap.h | 3 +++ lib/eal/freebsd/eal.c | 13 +++++++++++++ lib/eal/linux/eal.c | 13 +++++++++++++ lib/eal/windows/eal.c | 13 +++++++++++++ 6 files changed, 49 insertions(+), 13 deletions(-) diff --git a/lib/eal/common/eal_common_memory.c b/lib/eal/common/eal_common_memory.c index c2a4c8f9e7..e21fc7cfae 100644 --- a/lib/eal/common/eal_common_memory.c +++ b/lib/eal/common/eal_common_memory.c @@ -1078,18 +1078,11 @@ rte_eal_memory_detach(void) int rte_eal_memory_init(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; const struct internal_config *internal_conf = eal_get_internal_configuration(); - int retval; - RTE_LOG(DEBUG, EAL, "Setting up physically contiguous memory...\n"); - - if (!mcfg) - return -1; - /* lock mem hotplug here, to prevent races while we init */ - rte_mcfg_mem_read_lock(); + RTE_LOG(DEBUG, EAL, "Setting up physically contiguous memory...\n"); if (rte_eal_memseg_init() < 0) goto fail; @@ -1108,7 +1101,6 @@ rte_eal_memory_init(void) return 0; fail: - rte_mcfg_mem_read_unlock(); return -1; } diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index d3c474d79c..d25bdc98f9 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -1421,18 +1421,20 @@ rte_eal_malloc_heap_init(void) } } - if (register_mp_requests()) { RTE_LOG(ERR, EAL, "Couldn't register malloc multiprocess actions\n"); - rte_mcfg_mem_read_unlock(); return -1; } - /* unlock mem hotplug here. it's safe for primary as no requests can + return 0; +} + +int rte_eal_malloc_heap_populate(void) +{ + /* mem hotplug is unlocked here. it's safe for primary as no requests can * even come before primary itself is fully initialized, and secondaries * do not need to initialize the heap. */ - rte_mcfg_mem_read_unlock(); /* secondary process does not need to initialize anything */ if (rte_eal_process_type() != RTE_PROC_PRIMARY) diff --git a/lib/eal/common/malloc_heap.h b/lib/eal/common/malloc_heap.h index 3b2fbc0aa0..8f3ab57154 100644 --- a/lib/eal/common/malloc_heap.h +++ b/lib/eal/common/malloc_heap.h @@ -85,6 +85,9 @@ malloc_socket_to_heap_id(unsigned int socket_id); int rte_eal_malloc_heap_init(void); +int +rte_eal_malloc_heap_populate(void); + void rte_eal_malloc_heap_cleanup(void); diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 7db4239c51..7daf22e314 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -754,13 +755,25 @@ rte_eal_init(int argc, char **argv) return -1; } + rte_mcfg_mem_read_lock(); + if (rte_eal_memory_init() < 0) { + rte_mcfg_mem_read_unlock(); rte_eal_init_alert("Cannot init memory"); rte_errno = ENOMEM; return -1; } if (rte_eal_malloc_heap_init() < 0) { + rte_mcfg_mem_read_unlock(); + rte_eal_init_alert("Cannot init malloc heap"); + rte_errno = ENODEV; + return -1; + } + + rte_mcfg_mem_read_unlock(); + + if (rte_eal_malloc_heap_populate() < 0) { rte_eal_init_alert("Cannot init malloc heap"); rte_errno = ENODEV; return -1; diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index c37868b7f0..ae323cd492 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -1193,7 +1194,10 @@ rte_eal_init(int argc, char **argv) return -1; } + rte_mcfg_mem_read_lock(); + if (rte_eal_memory_init() < 0) { + rte_mcfg_mem_read_unlock(); rte_eal_init_alert("Cannot init memory"); rte_errno = ENOMEM; return -1; @@ -1203,6 +1207,15 @@ rte_eal_init(int argc, char **argv) eal_hugedirs_unlock(); if (rte_eal_malloc_heap_init() < 0) { + rte_mcfg_mem_read_unlock(); + rte_eal_init_alert("Cannot init malloc heap"); + rte_errno = ENODEV; + return -1; + } + + rte_mcfg_mem_read_unlock(); + + if (rte_eal_malloc_heap_populate() < 0) { rte_eal_init_alert("Cannot init malloc heap"); rte_errno = ENODEV; return -1; diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c index e7d405b91c..033825c14c 100644 --- a/lib/eal/windows/eal.c +++ b/lib/eal/windows/eal.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -387,13 +388,25 @@ rte_eal_init(int argc, char **argv) return -1; } + rte_mcfg_mem_read_lock(); + if (rte_eal_memory_init() < 0) { + rte_mcfg_mem_read_unlock(); rte_eal_init_alert("Cannot init memory"); rte_errno = ENOMEM; return -1; } if (rte_eal_malloc_heap_init() < 0) { + rte_mcfg_mem_read_unlock(); + rte_eal_init_alert("Cannot init malloc heap"); + rte_errno = ENODEV; + return -1; + } + + rte_mcfg_mem_read_unlock(); + + if (rte_eal_malloc_heap_populate() < 0) { rte_eal_init_alert("Cannot init malloc heap"); rte_errno = ENODEV; return -1; From patchwork Tue Apr 4 12:48:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125755 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 82739428CD; Tue, 4 Apr 2023 14:49:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 953A842C76; Tue, 4 Apr 2023 14:49:08 +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 95A5342B8E for ; Tue, 4 Apr 2023 14:49:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612546; 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=gQ5HUTQpfDDrIZYwaCxEkd4HqKlqmxIwNPnv2uQQzBc=; b=e4S4rv9UBEU/T0VMfOnK6DnhVPyGvmqDdIxMWi59yYvsafX7E4eZVjm1IbxAyayQSdNTPi 8o7CYIe7SaVz3vj6qolFMn50vzNAvKZ/OHmmHI5fJljHDAfLL58DfEybyfjXx/ZyP+ydpy krf/nNkZebgOJt6MbhhLCgjm/a2ISDY= 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-648-eRLMzSffMzOV3I69wIsl3A-1; Tue, 04 Apr 2023 08:49:02 -0400 X-MC-Unique: eRLMzSffMzOV3I69wIsl3A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 213F7185A7A4; Tue, 4 Apr 2023 12:49:02 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7AF4C40C6EC4; Tue, 4 Apr 2023 12:49:01 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net Subject: [PATCH v3 03/16] mem: annotate shared memory config locks Date: Tue, 4 Apr 2023 14:48:27 +0200 Message-Id: <20230404124840.1898-4-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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 Expose internal locks via some internal accessors. Then annotate rte_mcfg_xxx_(read|write)_(|un)lock. Signed-off-by: David Marchand --- lib/eal/common/eal_common_mcfg.c | 66 +++++++++++++++++------------ lib/eal/include/rte_eal_memconfig.h | 63 +++++++++++++++++++++------ lib/eal/version.map | 4 ++ 3 files changed, 91 insertions(+), 42 deletions(-) diff --git a/lib/eal/common/eal_common_mcfg.c b/lib/eal/common/eal_common_mcfg.c index cf4a279905..b60d41f7b6 100644 --- a/lib/eal/common/eal_common_mcfg.c +++ b/lib/eal/common/eal_common_mcfg.c @@ -69,102 +69,112 @@ eal_mcfg_update_from_internal(void) mcfg->version = RTE_VERSION; } +rte_rwlock_t * +rte_mcfg_mem_get_lock(void) +{ + return &rte_eal_get_configuration()->mem_config->memory_hotplug_lock; +} + void rte_mcfg_mem_read_lock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_rwlock_read_lock(&mcfg->memory_hotplug_lock); + rte_rwlock_read_lock(rte_mcfg_mem_get_lock()); } void rte_mcfg_mem_read_unlock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_rwlock_read_unlock(&mcfg->memory_hotplug_lock); + rte_rwlock_read_unlock(rte_mcfg_mem_get_lock()); } void rte_mcfg_mem_write_lock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_rwlock_write_lock(&mcfg->memory_hotplug_lock); + rte_rwlock_write_lock(rte_mcfg_mem_get_lock()); } void rte_mcfg_mem_write_unlock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_rwlock_write_unlock(&mcfg->memory_hotplug_lock); + rte_rwlock_write_unlock(rte_mcfg_mem_get_lock()); +} + +rte_rwlock_t * +rte_mcfg_tailq_get_lock(void) +{ + return &rte_eal_get_configuration()->mem_config->qlock; } void rte_mcfg_tailq_read_lock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_rwlock_read_lock(&mcfg->qlock); + rte_rwlock_read_lock(rte_mcfg_tailq_get_lock()); } void rte_mcfg_tailq_read_unlock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_rwlock_read_unlock(&mcfg->qlock); + rte_rwlock_read_unlock(rte_mcfg_tailq_get_lock()); } void rte_mcfg_tailq_write_lock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_rwlock_write_lock(&mcfg->qlock); + rte_rwlock_write_lock(rte_mcfg_tailq_get_lock()); } void rte_mcfg_tailq_write_unlock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_rwlock_write_unlock(&mcfg->qlock); + rte_rwlock_write_unlock(rte_mcfg_tailq_get_lock()); +} + +rte_rwlock_t * +rte_mcfg_mempool_get_lock(void) +{ + return &rte_eal_get_configuration()->mem_config->mplock; } void rte_mcfg_mempool_read_lock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_rwlock_read_lock(&mcfg->mplock); + rte_rwlock_read_lock(rte_mcfg_mempool_get_lock()); } void rte_mcfg_mempool_read_unlock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_rwlock_read_unlock(&mcfg->mplock); + rte_rwlock_read_unlock(rte_mcfg_mempool_get_lock()); } void rte_mcfg_mempool_write_lock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_rwlock_write_lock(&mcfg->mplock); + rte_rwlock_write_lock(rte_mcfg_mempool_get_lock()); } void rte_mcfg_mempool_write_unlock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_rwlock_write_unlock(&mcfg->mplock); + rte_rwlock_write_unlock(rte_mcfg_mempool_get_lock()); +} + +rte_spinlock_t * +rte_mcfg_timer_get_lock(void) +{ + return &rte_eal_get_configuration()->mem_config->tlock; } void rte_mcfg_timer_lock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_spinlock_lock(&mcfg->tlock); + rte_spinlock_lock(rte_mcfg_timer_get_lock()); } void rte_mcfg_timer_unlock(void) { - struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; - rte_spinlock_unlock(&mcfg->tlock); + rte_spinlock_unlock(rte_mcfg_timer_get_lock()); } bool diff --git a/lib/eal/include/rte_eal_memconfig.h b/lib/eal/include/rte_eal_memconfig.h index e175564647..c527f9aa29 100644 --- a/lib/eal/include/rte_eal_memconfig.h +++ b/lib/eal/include/rte_eal_memconfig.h @@ -7,6 +7,8 @@ #include +#include +#include /** * @file @@ -18,89 +20,122 @@ extern "C" { #endif +/** + * Internal helpers used for lock annotations. + */ +__rte_internal +rte_rwlock_t * +rte_mcfg_mem_get_lock(void); + +__rte_internal +rte_rwlock_t * +rte_mcfg_tailq_get_lock(void); + +__rte_internal +rte_rwlock_t * +rte_mcfg_mempool_get_lock(void); + +__rte_internal +rte_spinlock_t * +rte_mcfg_timer_get_lock(void); + /** * Lock the internal EAL shared memory configuration for shared access. */ void -rte_mcfg_mem_read_lock(void); +rte_mcfg_mem_read_lock(void) + __rte_shared_lock_function(rte_mcfg_mem_get_lock()); /** * Unlock the internal EAL shared memory configuration for shared access. */ void -rte_mcfg_mem_read_unlock(void); +rte_mcfg_mem_read_unlock(void) + __rte_unlock_function(rte_mcfg_mem_get_lock()); /** * Lock the internal EAL shared memory configuration for exclusive access. */ void -rte_mcfg_mem_write_lock(void); +rte_mcfg_mem_write_lock(void) + __rte_exclusive_lock_function(rte_mcfg_mem_get_lock()); /** * Unlock the internal EAL shared memory configuration for exclusive access. */ void -rte_mcfg_mem_write_unlock(void); +rte_mcfg_mem_write_unlock(void) + __rte_unlock_function(rte_mcfg_mem_get_lock()); /** * Lock the internal EAL TAILQ list for shared access. */ void -rte_mcfg_tailq_read_lock(void); +rte_mcfg_tailq_read_lock(void) + __rte_shared_lock_function(rte_mcfg_tailq_get_lock()); /** * Unlock the internal EAL TAILQ list for shared access. */ void -rte_mcfg_tailq_read_unlock(void); +rte_mcfg_tailq_read_unlock(void) + __rte_unlock_function(rte_mcfg_tailq_get_lock()); /** * Lock the internal EAL TAILQ list for exclusive access. */ void -rte_mcfg_tailq_write_lock(void); +rte_mcfg_tailq_write_lock(void) + __rte_exclusive_lock_function(rte_mcfg_tailq_get_lock()); /** * Unlock the internal EAL TAILQ list for exclusive access. */ void -rte_mcfg_tailq_write_unlock(void); +rte_mcfg_tailq_write_unlock(void) + __rte_unlock_function(rte_mcfg_tailq_get_lock()); /** * Lock the internal EAL Mempool list for shared access. */ void -rte_mcfg_mempool_read_lock(void); +rte_mcfg_mempool_read_lock(void) + __rte_shared_lock_function(rte_mcfg_mempool_get_lock()); /** * Unlock the internal EAL Mempool list for shared access. */ void -rte_mcfg_mempool_read_unlock(void); +rte_mcfg_mempool_read_unlock(void) + __rte_unlock_function(rte_mcfg_mempool_get_lock()); /** * Lock the internal EAL Mempool list for exclusive access. */ void -rte_mcfg_mempool_write_lock(void); +rte_mcfg_mempool_write_lock(void) + __rte_exclusive_lock_function(rte_mcfg_mempool_get_lock()); /** * Unlock the internal EAL Mempool list for exclusive access. */ void -rte_mcfg_mempool_write_unlock(void); +rte_mcfg_mempool_write_unlock(void) + __rte_unlock_function(rte_mcfg_mempool_get_lock()); /** * Lock the internal EAL Timer Library lock for exclusive access. */ void -rte_mcfg_timer_lock(void); +rte_mcfg_timer_lock(void) + __rte_exclusive_lock_function(rte_mcfg_timer_get_lock()); /** * Unlock the internal EAL Timer Library lock for exclusive access. */ void -rte_mcfg_timer_unlock(void); +rte_mcfg_timer_unlock(void) + __rte_unlock_function(rte_mcfg_timer_get_lock()); /** * If true, pages are put in single files (per memseg list), diff --git a/lib/eal/version.map b/lib/eal/version.map index 6d6978f108..51a820d829 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -469,6 +469,10 @@ INTERNAL { rte_intr_vec_list_free; rte_intr_vec_list_index_get; rte_intr_vec_list_index_set; + rte_mcfg_mem_get_lock; + rte_mcfg_mempool_get_lock; + rte_mcfg_tailq_get_lock; + rte_mcfg_timer_get_lock; rte_mem_lock; rte_mem_map; rte_mem_page_size; From patchwork Tue Apr 4 12:48:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125756 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 BFB94428CD; Tue, 4 Apr 2023 14:49:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 283E742D1D; Tue, 4 Apr 2023 14:49: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 6074942B7E for ; Tue, 4 Apr 2023 14:49:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612546; 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=5IXdKEIbzNEn/czHJyiyto+op04BlCukyTQehteBcjw=; b=RauylB2zlqUaNousxvfFE36I4pghJqp/JNE9wSZIvCKnlIjsRUigi0QAaWd7L4s3kvBQmo GGtYd0lUcN1aXwPJ9x5yqbnT7HRnlvYQu7AZTJWxpqq8qu/A8qOqY0HS6L5JhI2t5Tpbkv 0dNQVKQg+XIoAg3YYIgMbiLY9ZPLfCM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-cPp5EjsJOLKNMZGZMW_BeA-1; Tue, 04 Apr 2023 08:49:05 -0400 X-MC-Unique: cPp5EjsJOLKNMZGZMW_BeA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5756F2807D63; Tue, 4 Apr 2023 12:49:05 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27BC9202701F; Tue, 4 Apr 2023 12:49:04 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH v3 04/16] hash: annotate cuckoo hash lock Date: Tue, 4 Apr 2023 14:48:28 +0200 Message-Id: <20230404124840.1898-5-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 __hash_rw_(reader|writer)_(|un)lock helpers take locks depending on conditions that are fixed at the rte_hash object initialisation. So we can tell clang that those helpers unconditionally take/release those locks (and waive the lock check on their implementation). Signed-off-by: David Marchand --- lib/hash/rte_cuckoo_hash.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 829b79c89a..d92a903bb3 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -575,6 +575,8 @@ rte_hash_count(const struct rte_hash *h) /* Read write locks implemented using rte_rwlock */ static inline void __hash_rw_writer_lock(const struct rte_hash *h) + __rte_exclusive_lock_function(&h->readwrite_lock) + __rte_no_thread_safety_analysis { if (h->writer_takes_lock && h->hw_trans_mem_support) rte_rwlock_write_lock_tm(h->readwrite_lock); @@ -584,6 +586,8 @@ __hash_rw_writer_lock(const struct rte_hash *h) static inline void __hash_rw_reader_lock(const struct rte_hash *h) + __rte_shared_lock_function(&h->readwrite_lock) + __rte_no_thread_safety_analysis { if (h->readwrite_concur_support && h->hw_trans_mem_support) rte_rwlock_read_lock_tm(h->readwrite_lock); @@ -593,6 +597,8 @@ __hash_rw_reader_lock(const struct rte_hash *h) static inline void __hash_rw_writer_unlock(const struct rte_hash *h) + __rte_unlock_function(&h->readwrite_lock) + __rte_no_thread_safety_analysis { if (h->writer_takes_lock && h->hw_trans_mem_support) rte_rwlock_write_unlock_tm(h->readwrite_lock); @@ -602,6 +608,8 @@ __hash_rw_writer_unlock(const struct rte_hash *h) static inline void __hash_rw_reader_unlock(const struct rte_hash *h) + __rte_unlock_function(&h->readwrite_lock) + __rte_no_thread_safety_analysis { if (h->readwrite_concur_support && h->hw_trans_mem_support) rte_rwlock_read_unlock_tm(h->readwrite_lock); From patchwork Tue Apr 4 12:48:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125757 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 70EA0428CD; Tue, 4 Apr 2023 14:49:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B041F42D29; Tue, 4 Apr 2023 14:49:13 +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 6C09242C54 for ; Tue, 4 Apr 2023 14:49:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612551; 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=X1M/43rTTW/W5AHsm4ogjA9bjbH/hJuhWVzpR+6qmLM=; b=EKtZwIxNLPIqaFp22neEI0rGu72FVAXmx0beChCTXbGA2eAxriaIim17aNifwn5Dgi6kxT k/erPqr9hHoV78B8hdxW1SFZk0MQR044D3TN+u2J1WTdLx2JUM+9ovdtAmcSMjMz3ba9DL rolO7KuEcbMT64KmG9Fqa/umUzREhIY= 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-29-gZU-JEs4M5awdzzQm_u7tQ-1; Tue, 04 Apr 2023 08:49:08 -0400 X-MC-Unique: gZU-JEs4M5awdzzQm_u7tQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 63C7C858F09; Tue, 4 Apr 2023 12:49:08 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DD372027061; Tue, 4 Apr 2023 12:49:07 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram Subject: [PATCH v3 05/16] graph: annotate graph lock Date: Tue, 4 Apr 2023 14:48:29 +0200 Message-Id: <20230404124840.1898-6-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 Export internal lock and annotate associated helper. Signed-off-by: David Marchand --- lib/graph/graph.c | 10 ++++++++-- lib/graph/graph_private.h | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/graph/graph.c b/lib/graph/graph.c index a839a2803b..5582631b53 100644 --- a/lib/graph/graph.c +++ b/lib/graph/graph.c @@ -30,16 +30,22 @@ graph_list_head_get(void) return &graph_list; } +rte_spinlock_t * +graph_spinlock_get(void) +{ + return &graph_lock; +} + void graph_spinlock_lock(void) { - rte_spinlock_lock(&graph_lock); + rte_spinlock_lock(graph_spinlock_get()); } void graph_spinlock_unlock(void) { - rte_spinlock_unlock(&graph_lock); + rte_spinlock_unlock(graph_spinlock_get()); } static int diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index 7d1b30b8ac..eacdef45f0 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -10,6 +10,7 @@ #include #include +#include #include "rte_graph.h" #include "rte_graph_worker.h" @@ -148,20 +149,25 @@ STAILQ_HEAD(graph_head, graph); */ struct graph_head *graph_list_head_get(void); +rte_spinlock_t * +graph_spinlock_get(void); + /* Lock functions */ /** * @internal * * Take a lock on the graph internal spin lock. */ -void graph_spinlock_lock(void); +void graph_spinlock_lock(void) + __rte_exclusive_lock_function(graph_spinlock_get()); /** * @internal * * Release a lock on the graph internal spin lock. */ -void graph_spinlock_unlock(void); +void graph_spinlock_unlock(void) + __rte_unlock_function(graph_spinlock_get()); /* Graph operations */ /** From patchwork Tue Apr 4 12:48:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125768 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 6253B428CD; Tue, 4 Apr 2023 14:50:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F37D441153; Tue, 4 Apr 2023 14:50:15 +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 6E36741133 for ; Tue, 4 Apr 2023 14:50:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612614; 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=HdVrLjVPr/DR3SFnrgUCXgC5w4hVnZ45qJuwfZ6Wcgs=; b=ZaVs8/t03FWtnc0HhF+BVFdKKzoH3sLdt3cF9rxRX+2hwFR6hW23J5Zo1MekA2XYImSXPx MRcGQaJCoCQsVWlz5pY5BoPEMSpXWkl9zFDYXKokpXyP54EUw/+fkdTyeJJOObMyx4kEso gKCf51ZSax63CBLUgT4b1Zo3drc1eos= 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-79-xMHFgsHgPEWDmrZMTMKalQ-1; Tue, 04 Apr 2023 08:49:41 -0400 X-MC-Unique: xMHFgsHgPEWDmrZMTMKalQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC495886067; Tue, 4 Apr 2023 12:49:11 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80FAF440BC; Tue, 4 Apr 2023 12:49:10 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Jingjing Wu , Beilei Xing , Yuying Zhang , Qiming Yang , Qi Zhang Subject: [PATCH v3 06/16] drivers: inherit lock annotations for Intel drivers Date: Tue, 4 Apr 2023 14:48:30 +0200 Message-Id: <20230404124840.1898-7-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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 Due to clang limitation, inline helpers don't inherit lock annotations from the EAL lock API. Replace them with macros. Signed-off-by: David Marchand --- drivers/common/iavf/iavf_osdep.h | 39 ++++++-------------------- drivers/common/iavf/iavf_prototype.h | 6 ---- drivers/common/idpf/base/idpf_osdep.h | 26 +++-------------- drivers/net/i40e/base/i40e_osdep.h | 8 +++--- drivers/net/i40e/base/i40e_prototype.h | 5 ---- drivers/net/i40e/i40e_ethdev.c | 24 ---------------- drivers/net/ice/base/ice_osdep.h | 26 +++-------------- 7 files changed, 20 insertions(+), 114 deletions(-) diff --git a/drivers/common/iavf/iavf_osdep.h b/drivers/common/iavf/iavf_osdep.h index 31d3d809f9..263d92400c 100644 --- a/drivers/common/iavf/iavf_osdep.h +++ b/drivers/common/iavf/iavf_osdep.h @@ -170,11 +170,6 @@ struct iavf_virt_mem { u32 size; } __rte_packed; -/* SW spinlock */ -struct iavf_spinlock { - rte_spinlock_t spinlock; -}; - #define iavf_allocate_dma_mem(h, m, unused, s, a) \ iavf_allocate_dma_mem_d(h, m, s, a) #define iavf_free_dma_mem(h, m) iavf_free_dma_mem_d(h, m) @@ -182,32 +177,14 @@ struct iavf_spinlock { #define iavf_allocate_virt_mem(h, m, s) iavf_allocate_virt_mem_d(h, m, s) #define iavf_free_virt_mem(h, m) iavf_free_virt_mem_d(h, m) -static inline void -iavf_init_spinlock_d(struct iavf_spinlock *sp) -{ - rte_spinlock_init(&sp->spinlock); -} - -static inline void -iavf_acquire_spinlock_d(struct iavf_spinlock *sp) -{ - rte_spinlock_lock(&sp->spinlock); -} - -static inline void -iavf_release_spinlock_d(struct iavf_spinlock *sp) -{ - rte_spinlock_unlock(&sp->spinlock); -} - -static inline void -iavf_destroy_spinlock_d(__rte_unused struct iavf_spinlock *sp) -{ -} +/* SW spinlock */ +struct iavf_spinlock { + rte_spinlock_t spinlock; +}; -#define iavf_init_spinlock(_sp) iavf_init_spinlock_d(_sp) -#define iavf_acquire_spinlock(_sp) iavf_acquire_spinlock_d(_sp) -#define iavf_release_spinlock(_sp) iavf_release_spinlock_d(_sp) -#define iavf_destroy_spinlock(_sp) iavf_destroy_spinlock_d(_sp) +#define iavf_init_spinlock(sp) rte_spinlock_init(&(sp)->spinlock) +#define iavf_acquire_spinlock(sp) rte_spinlock_lock(&(sp)->spinlock) +#define iavf_release_spinlock(sp) rte_spinlock_unlock(&(sp)->spinlock) +#define iavf_destroy_spinlock(sp) RTE_SET_USED(sp) #endif /* _IAVF_OSDEP_H_ */ diff --git a/drivers/common/iavf/iavf_prototype.h b/drivers/common/iavf/iavf_prototype.h index b5124de5bf..ba78ec5169 100644 --- a/drivers/common/iavf/iavf_prototype.h +++ b/drivers/common/iavf/iavf_prototype.h @@ -76,12 +76,6 @@ STATIC INLINE struct iavf_rx_ptype_decoded decode_rx_desc_ptype(u8 ptype) return iavf_ptype_lookup[ptype]; } -/* prototype for functions used for SW spinlocks */ -void iavf_init_spinlock(struct iavf_spinlock *sp); -void iavf_acquire_spinlock(struct iavf_spinlock *sp); -void iavf_release_spinlock(struct iavf_spinlock *sp); -void iavf_destroy_spinlock(struct iavf_spinlock *sp); - __rte_internal void iavf_vf_parse_hw_config(struct iavf_hw *hw, struct virtchnl_vf_resource *msg); diff --git a/drivers/common/idpf/base/idpf_osdep.h b/drivers/common/idpf/base/idpf_osdep.h index 99ae9cf60a..49bd7c4b21 100644 --- a/drivers/common/idpf/base/idpf_osdep.h +++ b/drivers/common/idpf/base/idpf_osdep.h @@ -210,28 +210,10 @@ struct idpf_lock { rte_spinlock_t spinlock; }; -static inline void -idpf_init_lock(struct idpf_lock *sp) -{ - rte_spinlock_init(&sp->spinlock); -} - -static inline void -idpf_acquire_lock(struct idpf_lock *sp) -{ - rte_spinlock_lock(&sp->spinlock); -} - -static inline void -idpf_release_lock(struct idpf_lock *sp) -{ - rte_spinlock_unlock(&sp->spinlock); -} - -static inline void -idpf_destroy_lock(__rte_unused struct idpf_lock *sp) -{ -} +#define idpf_init_lock(sp) rte_spinlock_init(&(sp)->spinlock) +#define idpf_acquire_lock(sp) rte_spinlock_lock(&(sp)->spinlock) +#define idpf_release_lock(sp) rte_spinlock_unlock(&(sp)->spinlock) +#define idpf_destroy_lock(sp) RTE_SET_USED(sp) struct idpf_hw; diff --git a/drivers/net/i40e/base/i40e_osdep.h b/drivers/net/i40e/base/i40e_osdep.h index 51537c5cf3..aa5dc61841 100644 --- a/drivers/net/i40e/base/i40e_osdep.h +++ b/drivers/net/i40e/base/i40e_osdep.h @@ -215,10 +215,10 @@ struct i40e_spinlock { rte_spinlock_t spinlock; }; -#define i40e_init_spinlock(_sp) i40e_init_spinlock_d(_sp) -#define i40e_acquire_spinlock(_sp) i40e_acquire_spinlock_d(_sp) -#define i40e_release_spinlock(_sp) i40e_release_spinlock_d(_sp) -#define i40e_destroy_spinlock(_sp) i40e_destroy_spinlock_d(_sp) +#define i40e_init_spinlock(sp) rte_spinlock_init(&(sp)->spinlock) +#define i40e_acquire_spinlock(sp) rte_spinlock_lock(&(sp)->spinlock) +#define i40e_release_spinlock(sp) rte_spinlock_unlock(&(sp)->spinlock) +#define i40e_destroy_spinlock(sp) RTE_SET_USED(sp) #define I40E_NTOHS(a) rte_be_to_cpu_16(a) #define I40E_NTOHL(a) rte_be_to_cpu_32(a) diff --git a/drivers/net/i40e/base/i40e_prototype.h b/drivers/net/i40e/base/i40e_prototype.h index 29c86c7fe8..691c977172 100644 --- a/drivers/net/i40e/base/i40e_prototype.h +++ b/drivers/net/i40e/base/i40e_prototype.h @@ -546,11 +546,6 @@ i40e_virtchnl_link_speed(enum i40e_aq_link_speed link_speed) } } #endif /* PF_DRIVER */ -/* prototype for functions used for SW spinlocks */ -void i40e_init_spinlock(struct i40e_spinlock *sp); -void i40e_acquire_spinlock(struct i40e_spinlock *sp); -void i40e_release_spinlock(struct i40e_spinlock *sp); -void i40e_destroy_spinlock(struct i40e_spinlock *sp); /* i40e_common for VF drivers*/ void i40e_vf_parse_hw_config(struct i40e_hw *hw, diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index cb0070f94b..f9d8f9791f 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -4635,30 +4635,6 @@ i40e_free_virt_mem_d(__rte_unused struct i40e_hw *hw, return I40E_SUCCESS; } -void -i40e_init_spinlock_d(struct i40e_spinlock *sp) -{ - rte_spinlock_init(&sp->spinlock); -} - -void -i40e_acquire_spinlock_d(struct i40e_spinlock *sp) -{ - rte_spinlock_lock(&sp->spinlock); -} - -void -i40e_release_spinlock_d(struct i40e_spinlock *sp) -{ - rte_spinlock_unlock(&sp->spinlock); -} - -void -i40e_destroy_spinlock_d(__rte_unused struct i40e_spinlock *sp) -{ - return; -} - /** * Get the hardware capabilities, which will be parsed * and saved into struct i40e_hw. diff --git a/drivers/net/ice/base/ice_osdep.h b/drivers/net/ice/base/ice_osdep.h index 4b92057521..0e14b934c8 100644 --- a/drivers/net/ice/base/ice_osdep.h +++ b/drivers/net/ice/base/ice_osdep.h @@ -211,28 +211,10 @@ struct ice_lock { rte_spinlock_t spinlock; }; -static inline void -ice_init_lock(struct ice_lock *sp) -{ - rte_spinlock_init(&sp->spinlock); -} - -static inline void -ice_acquire_lock(struct ice_lock *sp) -{ - rte_spinlock_lock(&sp->spinlock); -} - -static inline void -ice_release_lock(struct ice_lock *sp) -{ - rte_spinlock_unlock(&sp->spinlock); -} - -static inline void -ice_destroy_lock(__rte_unused struct ice_lock *sp) -{ -} +#define ice_init_lock(sp) rte_spinlock_init(&(sp)->spinlock) +#define ice_acquire_lock(sp) rte_spinlock_lock(&(sp)->spinlock) +#define ice_release_lock(sp) rte_spinlock_unlock(&(sp)->spinlock) +#define ice_destroy_lock(sp) RTE_SET_USED(sp) struct ice_hw; From patchwork Tue Apr 4 12:48:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125758 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 D873F428CD; Tue, 4 Apr 2023 14:49:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 646B142D13; Tue, 4 Apr 2023 14:49:20 +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 D1B2840A7E for ; Tue, 4 Apr 2023 14:49:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612558; 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=+QC5N7fdw2YpcSZdVy5nwVTTnJpJG+iHrtpsW8GzoNI=; b=Nyf1Ps/pHjwLVS7h2bniO9KiapB/3eXOuzjlA6XcLglKpoTm7E0aL9SZC5bv7ZkR/7ViM4 4yxskpXMMt/OTAK7qZTz/f3aitgbTokfSg7BaDrE/hl8+DV6ZljNnjtmKThU9GDQUpC1J/ UUebOVSeYK/iUMLiNuOO7YKqifMFj3I= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-10-i4bl3ijCM7Gq1vrcVdOwMg-1; Tue, 04 Apr 2023 08:49:15 -0400 X-MC-Unique: i4bl3ijCM7Gq1vrcVdOwMg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A06A11C0879A; Tue, 4 Apr 2023 12:49:14 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id D15481121319; Tue, 4 Apr 2023 12:49:13 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Rahul Lakkireddy Subject: [PATCH v3 07/16] net/cxgbe: inherit lock annotations Date: Tue, 4 Apr 2023 14:48:31 +0200 Message-Id: <20230404124840.1898-8-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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 Due to clang limitation, inline helpers don't inherit lock annotations from the EAL lock API. Replace them with macros. Signed-off-by: David Marchand --- drivers/net/cxgbe/base/adapter.h | 35 +++++++------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/drivers/net/cxgbe/base/adapter.h b/drivers/net/cxgbe/base/adapter.h index 16cbc1a345..8f2ffa0eeb 100644 --- a/drivers/net/cxgbe/base/adapter.h +++ b/drivers/net/cxgbe/base/adapter.h @@ -351,28 +351,19 @@ struct adapter { * t4_os_rwlock_init - initialize rwlock * @lock: the rwlock */ -static inline void t4_os_rwlock_init(rte_rwlock_t *lock) -{ - rte_rwlock_init(lock); -} +#define t4_os_rwlock_init(lock) rte_rwlock_init(lock) /** * t4_os_write_lock - get a write lock * @lock: the rwlock */ -static inline void t4_os_write_lock(rte_rwlock_t *lock) -{ - rte_rwlock_write_lock(lock); -} +#define t4_os_write_lock(lock) rte_rwlock_write_lock(lock) /** * t4_os_write_unlock - unlock a write lock * @lock: the rwlock */ -static inline void t4_os_write_unlock(rte_rwlock_t *lock) -{ - rte_rwlock_write_unlock(lock); -} +#define t4_os_write_unlock(lock) rte_rwlock_write_unlock(lock) /** * ethdev2pinfo - return the port_info structure associated with a rte_eth_dev @@ -678,37 +669,25 @@ static inline void t4_os_set_hw_addr(struct adapter *adapter, int port_idx, * t4_os_lock_init - initialize spinlock * @lock: the spinlock */ -static inline void t4_os_lock_init(rte_spinlock_t *lock) -{ - rte_spinlock_init(lock); -} +#define t4_os_lock_init(lock) rte_spinlock_init(lock) /** * t4_os_lock - spin until lock is acquired * @lock: the spinlock */ -static inline void t4_os_lock(rte_spinlock_t *lock) -{ - rte_spinlock_lock(lock); -} +#define t4_os_lock(lock) rte_spinlock_lock(lock) /** * t4_os_unlock - unlock a spinlock * @lock: the spinlock */ -static inline void t4_os_unlock(rte_spinlock_t *lock) -{ - rte_spinlock_unlock(lock); -} +#define t4_os_unlock(lock) rte_spinlock_unlock(lock) /** * t4_os_trylock - try to get a lock * @lock: the spinlock */ -static inline int t4_os_trylock(rte_spinlock_t *lock) -{ - return rte_spinlock_trylock(lock); -} +#define t4_os_trylock(lock) rte_spinlock_trylock(lock) /** * t4_os_init_list_head - initialize From patchwork Tue Apr 4 12:48:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125759 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 986E5428CD; Tue, 4 Apr 2023 14:49:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7792342D35; Tue, 4 Apr 2023 14:49:21 +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 A1FAF42D33 for ; Tue, 4 Apr 2023 14:49:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612559; 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=UWJfb+3aQQrRzRxS4nxjHkV05O/I7utrsuNQe+4sVz8=; b=G+VcZMuHEatT698UzZ6dyskiuQ2bB+TLVQs4ZhQ5wZXSWEfUJ+r59+h8F2nyBF0EG9xLE+ lJT0vp57nSy8Kchviqi7TdsEChzs3pdWylC4eVszDTsj0+OkRyT4dsKfMch1SmdFGa21AJ JINynOyPyOkl6tEBvTht6KlMvhTBYhg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-73-_PKAz_lWOOeUWDYinVoh9A-1; Tue, 04 Apr 2023 08:49:18 -0400 X-MC-Unique: _PKAz_lWOOeUWDYinVoh9A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A00501C08799; Tue, 4 Apr 2023 12:49:17 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id B96D81121315; Tue, 4 Apr 2023 12:49:16 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Qi Zhang , Xiao Wang Subject: [PATCH v3 08/16] net/fm10k: annotate mailbox lock Date: Tue, 4 Apr 2023 14:48:32 +0200 Message-Id: <20230404124840.1898-9-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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 Expose requirements for helpers dealing with the FM10K_DEV_PRIVATE_TO_MBXLOCK(hw->back) lock. Signed-off-by: David Marchand --- drivers/net/fm10k/fm10k_ethdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 8b83063f0a..4d3c4c10cf 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -116,6 +116,7 @@ fm10k_mbx_initlock(struct fm10k_hw *hw) static void fm10k_mbx_lock(struct fm10k_hw *hw) + __rte_exclusive_lock_function(FM10K_DEV_PRIVATE_TO_MBXLOCK(hw->back)) { while (!rte_spinlock_trylock(FM10K_DEV_PRIVATE_TO_MBXLOCK(hw->back))) rte_delay_us(FM10K_MBXLOCK_DELAY_US); @@ -123,6 +124,7 @@ fm10k_mbx_lock(struct fm10k_hw *hw) static void fm10k_mbx_unlock(struct fm10k_hw *hw) + __rte_unlock_function(FM10K_DEV_PRIVATE_TO_MBXLOCK(hw->back)) { rte_spinlock_unlock(FM10K_DEV_PRIVATE_TO_MBXLOCK(hw->back)); } From patchwork Tue Apr 4 12:48:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125760 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 8672D428CD; Tue, 4 Apr 2023 14:49:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 13EE442D3B; Tue, 4 Apr 2023 14:49:25 +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 B238342D0B for ; Tue, 4 Apr 2023 14:49:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612563; 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=Zs3hxWmKhTOXWkESvyRvQItu4YlI3r4m21ZEPZCidSo=; b=U+BgbkwnXqSNbtLTj5LX6xYQkiI0AIGKXMLHSDt5GdZjn2HMhMAIBOM3NBV3eCpdO9KVSF 28cashD9C/LYDIRjgkkwk+ILyNW8qHX3fggyHmxh+ihAF8KYmRZFdy3GIMPeNu/bGkz5vk ig2YG2P+Ym8fYiXQwnvvvJrhiDzSsW4= 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-444-yMhnlYhNODyOJdfvGq80iA-1; Tue, 04 Apr 2023 08:49:20 -0400 X-MC-Unique: yMhnlYhNODyOJdfvGq80iA-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 91E51801779; Tue, 4 Apr 2023 12:49:20 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93CE22166B26; Tue, 4 Apr 2023 12:49:19 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Andrew Rybchenko Subject: [PATCH v3 09/16] net/sfc: rework locking in proxy code Date: Tue, 4 Apr 2023 14:48:33 +0200 Message-Id: <20230404124840.1898-10-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-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 Remove one extra layer for proxy code: sfc_get_adapter_by_pf_port_id() now only resolves the sa object. sfc_adapter_(|un)lock() are added were necessary. This will simplify lock checks later. Signed-off-by: David Marchand --- drivers/net/sfc/sfc_repr_proxy.c | 59 ++++++++++++++++---------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/drivers/net/sfc/sfc_repr_proxy.c b/drivers/net/sfc/sfc_repr_proxy.c index 4b958ced61..4ba7683370 100644 --- a/drivers/net/sfc/sfc_repr_proxy.c +++ b/drivers/net/sfc/sfc_repr_proxy.c @@ -51,17 +51,9 @@ sfc_get_adapter_by_pf_port_id(uint16_t pf_port_id) dev = &rte_eth_devices[pf_port_id]; sa = sfc_adapter_by_eth_dev(dev); - sfc_adapter_lock(sa); - return sa; } -static void -sfc_put_adapter(struct sfc_adapter *sa) -{ - sfc_adapter_unlock(sa); -} - static struct sfc_repr_proxy_port * sfc_repr_proxy_find_port(struct sfc_repr_proxy *rp, uint16_t repr_id) { @@ -1289,6 +1281,7 @@ sfc_repr_proxy_add_port(uint16_t pf_port_id, uint16_t repr_id, int rc; sa = sfc_get_adapter_by_pf_port_id(pf_port_id); + sfc_adapter_lock(sa); rp = sfc_repr_proxy_by_adapter(sa); sfc_log_init(sa, "entry"); @@ -1341,7 +1334,7 @@ sfc_repr_proxy_add_port(uint16_t pf_port_id, uint16_t repr_id, } sfc_log_init(sa, "done"); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return 0; @@ -1352,7 +1345,7 @@ sfc_repr_proxy_add_port(uint16_t pf_port_id, uint16_t repr_id, fail_alloc_port: fail_port_exists: sfc_log_init(sa, "failed: %s", rte_strerror(rc)); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return rc; } @@ -1366,6 +1359,7 @@ sfc_repr_proxy_del_port(uint16_t pf_port_id, uint16_t repr_id) int rc; sa = sfc_get_adapter_by_pf_port_id(pf_port_id); + sfc_adapter_lock(sa); rp = sfc_repr_proxy_by_adapter(sa); sfc_log_init(sa, "entry"); @@ -1393,14 +1387,14 @@ sfc_repr_proxy_del_port(uint16_t pf_port_id, uint16_t repr_id) sfc_log_init(sa, "done"); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return 0; fail_port_remove: fail_no_port: sfc_log_init(sa, "failed: %s", rte_strerror(rc)); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return rc; } @@ -1416,6 +1410,7 @@ sfc_repr_proxy_add_rxq(uint16_t pf_port_id, uint16_t repr_id, struct sfc_adapter *sa; sa = sfc_get_adapter_by_pf_port_id(pf_port_id); + sfc_adapter_lock(sa); rp = sfc_repr_proxy_by_adapter(sa); sfc_log_init(sa, "entry"); @@ -1423,14 +1418,14 @@ sfc_repr_proxy_add_rxq(uint16_t pf_port_id, uint16_t repr_id, port = sfc_repr_proxy_find_port(rp, repr_id); if (port == NULL) { sfc_err(sa, "%s() failed: no such port", __func__); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return ENOENT; } rxq = &port->rxq[queue_id]; if (rp->dp_rxq[queue_id].mp != NULL && rp->dp_rxq[queue_id].mp != mp) { sfc_err(sa, "multiple mempools per queue are not supported"); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return ENOTSUP; } @@ -1440,7 +1435,7 @@ sfc_repr_proxy_add_rxq(uint16_t pf_port_id, uint16_t repr_id, rp->dp_rxq[queue_id].ref_count++; sfc_log_init(sa, "done"); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return 0; } @@ -1455,6 +1450,7 @@ sfc_repr_proxy_del_rxq(uint16_t pf_port_id, uint16_t repr_id, struct sfc_adapter *sa; sa = sfc_get_adapter_by_pf_port_id(pf_port_id); + sfc_adapter_lock(sa); rp = sfc_repr_proxy_by_adapter(sa); sfc_log_init(sa, "entry"); @@ -1462,7 +1458,7 @@ sfc_repr_proxy_del_rxq(uint16_t pf_port_id, uint16_t repr_id, port = sfc_repr_proxy_find_port(rp, repr_id); if (port == NULL) { sfc_err(sa, "%s() failed: no such port", __func__); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return; } @@ -1475,7 +1471,7 @@ sfc_repr_proxy_del_rxq(uint16_t pf_port_id, uint16_t repr_id, rp->dp_rxq[queue_id].mp = NULL; sfc_log_init(sa, "done"); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); } int @@ -1489,6 +1485,7 @@ sfc_repr_proxy_add_txq(uint16_t pf_port_id, uint16_t repr_id, struct sfc_adapter *sa; sa = sfc_get_adapter_by_pf_port_id(pf_port_id); + sfc_adapter_lock(sa); rp = sfc_repr_proxy_by_adapter(sa); sfc_log_init(sa, "entry"); @@ -1496,7 +1493,7 @@ sfc_repr_proxy_add_txq(uint16_t pf_port_id, uint16_t repr_id, port = sfc_repr_proxy_find_port(rp, repr_id); if (port == NULL) { sfc_err(sa, "%s() failed: no such port", __func__); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return ENOENT; } @@ -1507,7 +1504,7 @@ sfc_repr_proxy_add_txq(uint16_t pf_port_id, uint16_t repr_id, *egress_mport = port->egress_mport; sfc_log_init(sa, "done"); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return 0; } @@ -1522,6 +1519,7 @@ sfc_repr_proxy_del_txq(uint16_t pf_port_id, uint16_t repr_id, struct sfc_adapter *sa; sa = sfc_get_adapter_by_pf_port_id(pf_port_id); + sfc_adapter_lock(sa); rp = sfc_repr_proxy_by_adapter(sa); sfc_log_init(sa, "entry"); @@ -1529,7 +1527,7 @@ sfc_repr_proxy_del_txq(uint16_t pf_port_id, uint16_t repr_id, port = sfc_repr_proxy_find_port(rp, repr_id); if (port == NULL) { sfc_err(sa, "%s() failed: no such port", __func__); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return; } @@ -1538,7 +1536,7 @@ sfc_repr_proxy_del_txq(uint16_t pf_port_id, uint16_t repr_id, txq->ring = NULL; sfc_log_init(sa, "done"); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); } int @@ -1551,6 +1549,7 @@ sfc_repr_proxy_start_repr(uint16_t pf_port_id, uint16_t repr_id) int rc; sa = sfc_get_adapter_by_pf_port_id(pf_port_id); + sfc_adapter_lock(sa); rp = sfc_repr_proxy_by_adapter(sa); sfc_log_init(sa, "entry"); @@ -1594,7 +1593,7 @@ sfc_repr_proxy_start_repr(uint16_t pf_port_id, uint16_t repr_id) } sfc_log_init(sa, "done"); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return 0; @@ -1606,7 +1605,7 @@ sfc_repr_proxy_start_repr(uint16_t pf_port_id, uint16_t repr_id) fail_not_found: sfc_err(sa, "failed to start repr %u proxy port: %s", repr_id, rte_strerror(rc)); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return rc; } @@ -1621,6 +1620,7 @@ sfc_repr_proxy_stop_repr(uint16_t pf_port_id, uint16_t repr_id) int rc; sa = sfc_get_adapter_by_pf_port_id(pf_port_id); + sfc_adapter_lock(sa); rp = sfc_repr_proxy_by_adapter(sa); sfc_log_init(sa, "entry"); @@ -1628,14 +1628,14 @@ sfc_repr_proxy_stop_repr(uint16_t pf_port_id, uint16_t repr_id) port = sfc_repr_proxy_find_port(rp, repr_id); if (port == NULL) { sfc_err(sa, "%s() failed: no such port", __func__); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return ENOENT; } if (!port->enabled) { sfc_log_init(sa, "repr %u proxy port is not started - skip", repr_id); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return 0; } @@ -1662,7 +1662,7 @@ sfc_repr_proxy_stop_repr(uint16_t pf_port_id, uint16_t repr_id) sfc_err(sa, "failed to stop representor proxy TxQ %u: %s", repr_id, rte_strerror(rc)); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return rc; } } @@ -1670,7 +1670,7 @@ sfc_repr_proxy_stop_repr(uint16_t pf_port_id, uint16_t repr_id) port->enabled = false; sfc_log_init(sa, "done"); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return 0; } @@ -1685,13 +1685,14 @@ sfc_repr_proxy_repr_entity_mac_addr_set(uint16_t pf_port_id, uint16_t repr_id, int rc; sa = sfc_get_adapter_by_pf_port_id(pf_port_id); + sfc_adapter_lock(sa); rp = sfc_repr_proxy_by_adapter(sa); port = sfc_repr_proxy_find_port(rp, repr_id); if (port == NULL) { sfc_err(sa, "%s() failed: no such port (repr_id=%u)", __func__, repr_id); - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return ENOENT; } @@ -1703,7 +1704,7 @@ sfc_repr_proxy_repr_entity_mac_addr_set(uint16_t pf_port_id, uint16_t repr_id, __func__, repr_id, rte_strerror(rc)); } - sfc_put_adapter(sa); + sfc_adapter_unlock(sa); return rc; } From patchwork Tue Apr 4 12:48:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125761 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 76F05428CD; Tue, 4 Apr 2023 14:49:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9C64742D43; Tue, 4 Apr 2023 14:49:28 +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 6E58440A7E for ; Tue, 4 Apr 2023 14:49:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612567; 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=1qc3+1DPrDMRNKtc5rxqr+4NJR2lVYVoyc4rYt37MMc=; b=IKe7Jb4XTJKMYbIjb8lQQNFsj8IRhp2KZqYXC18jp8wdZqKez0LxwUIPPjeDjTLRNZgXMj KgUujMwVXv8iEzxPQYGZLMXhw8ElwcA+Lnau7fbslX/5zuLUSs09118cZP+C3odXHBEvY9 pSLRRMQXiMgWL5mX2hmJTDbP+BME7qw= 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-512-MPzBS4m2PACJ-7YRqm0YHQ-1; Tue, 04 Apr 2023 08:49:23 -0400 X-MC-Unique: MPzBS4m2PACJ-7YRqm0YHQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B3FC886065; Tue, 4 Apr 2023 12:49:23 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8D492027061; Tue, 4 Apr 2023 12:49:22 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Andrew Rybchenko Subject: [PATCH v3 10/16] net/sfc: inherit lock annotations Date: Tue, 4 Apr 2023 14:48:34 +0200 Message-Id: <20230404124840.1898-11-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 Due to clang limitation, inline helpers don't inherit lock annotations from the EAL lock API. Replace them with macros. One additional change is required in sfc_ev_qpoll() so that clang does see the same lock is being manipulated. Signed-off-by: David Marchand --- drivers/net/sfc/sfc.h | 41 ++++++-------------------------------- drivers/net/sfc/sfc_ev.c | 6 ++++-- drivers/net/sfc/sfc_repr.c | 38 +++++------------------------------ 3 files changed, 15 insertions(+), 70 deletions(-) diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 0a1e224fa2..730d054aea 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -333,41 +333,12 @@ sfc_sa2shared(struct sfc_adapter *sa) * change the lock in one place. */ -static inline void -sfc_adapter_lock_init(struct sfc_adapter *sa) -{ - rte_spinlock_init(&sa->lock); -} - -static inline int -sfc_adapter_is_locked(struct sfc_adapter *sa) -{ - return rte_spinlock_is_locked(&sa->lock); -} - -static inline void -sfc_adapter_lock(struct sfc_adapter *sa) -{ - rte_spinlock_lock(&sa->lock); -} - -static inline int -sfc_adapter_trylock(struct sfc_adapter *sa) -{ - return rte_spinlock_trylock(&sa->lock); -} - -static inline void -sfc_adapter_unlock(struct sfc_adapter *sa) -{ - rte_spinlock_unlock(&sa->lock); -} - -static inline void -sfc_adapter_lock_fini(__rte_unused struct sfc_adapter *sa) -{ - /* Just for symmetry of the API */ -} +#define sfc_adapter_lock_init(sa) rte_spinlock_init(&(sa)->lock) +#define sfc_adapter_is_locked(sa) rte_spinlock_is_locked(&(sa)->lock) +#define sfc_adapter_lock(sa) rte_spinlock_lock(&(sa)->lock) +#define sfc_adapter_trylock(sa) rte_spinlock_trylock(&(sa)->lock) +#define sfc_adapter_unlock(sa) rte_spinlock_unlock(&(sa)->lock) +#define sfc_adapter_lock_fini(sa) RTE_SET_USED(sa) static inline unsigned int sfc_nb_counter_rxq(const struct sfc_adapter_shared *sas) diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c index f949abbfc3..c0d58c9554 100644 --- a/drivers/net/sfc/sfc_ev.c +++ b/drivers/net/sfc/sfc_ev.c @@ -570,6 +570,8 @@ static const efx_ev_callbacks_t sfc_ev_callbacks_dp_tx = { void sfc_ev_qpoll(struct sfc_evq *evq) { + struct sfc_adapter *sa; + SFC_ASSERT(evq->init_state == SFC_EVQ_STARTED || evq->init_state == SFC_EVQ_STARTING); @@ -577,8 +579,8 @@ sfc_ev_qpoll(struct sfc_evq *evq) efx_ev_qpoll(evq->common, &evq->read_ptr, evq->callbacks, evq); - if (unlikely(evq->exception) && sfc_adapter_trylock(evq->sa)) { - struct sfc_adapter *sa = evq->sa; + sa = evq->sa; + if (unlikely(evq->exception) && sfc_adapter_trylock(sa)) { int rc; if (evq->dp_rxq != NULL) { diff --git a/drivers/net/sfc/sfc_repr.c b/drivers/net/sfc/sfc_repr.c index 919048e278..d4134ec91b 100644 --- a/drivers/net/sfc/sfc_repr.c +++ b/drivers/net/sfc/sfc_repr.c @@ -112,39 +112,11 @@ sfc_repr_by_eth_dev(struct rte_eth_dev *eth_dev) * change the lock in one place. */ -static inline void -sfc_repr_lock_init(struct sfc_repr *sr) -{ - rte_spinlock_init(&sr->lock); -} - -#if defined(RTE_LIBRTE_SFC_EFX_DEBUG) || defined(RTE_ENABLE_ASSERT) - -static inline int -sfc_repr_lock_is_locked(struct sfc_repr *sr) -{ - return rte_spinlock_is_locked(&sr->lock); -} - -#endif - -static inline void -sfc_repr_lock(struct sfc_repr *sr) -{ - rte_spinlock_lock(&sr->lock); -} - -static inline void -sfc_repr_unlock(struct sfc_repr *sr) -{ - rte_spinlock_unlock(&sr->lock); -} - -static inline void -sfc_repr_lock_fini(__rte_unused struct sfc_repr *sr) -{ - /* Just for symmetry of the API */ -} +#define sfc_repr_lock_init(sr) rte_spinlock_init(&(sr)->lock) +#define sfc_repr_lock_is_locked(sr) rte_spinlock_is_locked(&(sr)->lock) +#define sfc_repr_lock(sr) rte_spinlock_lock(&(sr)->lock) +#define sfc_repr_unlock(sr) rte_spinlock_unlock(&(sr)->lock) +#define sfc_repr_lock_fini(sr) RTE_SET_USED(sr) static void sfc_repr_rx_queue_stop(void *queue) From patchwork Tue Apr 4 12:48:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125762 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 DE44A428CD; Tue, 4 Apr 2023 14:49:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C011542D0B; Tue, 4 Apr 2023 14:49:30 +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 98E3440A7E for ; Tue, 4 Apr 2023 14:49:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612568; 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=va2krLS+m/LXbhgoAk3YpTOws40ec4c8LHDV2XRdyJk=; b=dGv+i+n9U+xSjZYhDAJKVUMW5RJ/mUbyTJ2yBbKfAEIytF26tzPJHF6mv/eXbJJ2BkwMj3 9r9/6d1wLJgyX9FJgxJ/IdCN9Kc3EPN8WvB1TCm39GcgCFIJ1Pzo4k5/M/YOFFVjcL5Vgg RKWZ9/BJSgW81FTJ0eD4B8JeQcjdtSQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-511-d1lkJyB9NKGWEOArd3_u9w-1; Tue, 04 Apr 2023 08:49:26 -0400 X-MC-Unique: d1lkJyB9NKGWEOArd3_u9w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 505EA3C0F367; Tue, 4 Apr 2023 12:49:26 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57F501121314; Tue, 4 Apr 2023 12:49:25 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Maxime Coquelin , Chenbo Xia Subject: [PATCH v3 11/16] net/virtio: rework guest announce notify helper Date: Tue, 4 Apr 2023 14:48:35 +0200 Message-Id: <20230404124840.1898-12-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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 Inline existing helpers virtio_dev_(pause|resume) into virtio_notify_peers(). This makes the lock check on hw->state_lock trivial. Signed-off-by: David Marchand --- drivers/net/virtio/virtio_ethdev.c | 75 ++++++++---------------------- drivers/net/virtio/virtio_ethdev.h | 4 -- 2 files changed, 19 insertions(+), 60 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index ae84d313be..07e53d2b97 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1144,57 +1144,6 @@ virtio_ethdev_negotiate_features(struct virtio_hw *hw, uint64_t req_features) return 0; } -int -virtio_dev_pause(struct rte_eth_dev *dev) -{ - struct virtio_hw *hw = dev->data->dev_private; - - rte_spinlock_lock(&hw->state_lock); - - if (hw->started == 0) { - /* Device is just stopped. */ - rte_spinlock_unlock(&hw->state_lock); - return -1; - } - hw->started = 0; - /* - * Prevent the worker threads from touching queues to avoid contention, - * 1 ms should be enough for the ongoing Tx function to finish. - */ - rte_delay_ms(1); - return 0; -} - -/* - * Recover hw state to let the worker threads continue. - */ -void -virtio_dev_resume(struct rte_eth_dev *dev) -{ - struct virtio_hw *hw = dev->data->dev_private; - - hw->started = 1; - rte_spinlock_unlock(&hw->state_lock); -} - -/* - * Should be called only after device is paused. - */ -int -virtio_inject_pkts(struct rte_eth_dev *dev, struct rte_mbuf **tx_pkts, - int nb_pkts) -{ - struct virtio_hw *hw = dev->data->dev_private; - struct virtnet_tx *txvq = dev->data->tx_queues[0]; - int ret; - - hw->inject_pkts = tx_pkts; - ret = dev->tx_pkt_burst(txvq, tx_pkts, nb_pkts); - hw->inject_pkts = NULL; - - return ret; -} - static void virtio_notify_peers(struct rte_eth_dev *dev) { @@ -1216,14 +1165,28 @@ virtio_notify_peers(struct rte_eth_dev *dev) return; } - /* If virtio port just stopped, no need to send RARP */ - if (virtio_dev_pause(dev) < 0) { + rte_spinlock_lock(&hw->state_lock); + if (hw->started == 0) { + /* If virtio port just stopped, no need to send RARP */ rte_pktmbuf_free(rarp_mbuf); - return; + goto out; } + hw->started = 0; - virtio_inject_pkts(dev, &rarp_mbuf, 1); - virtio_dev_resume(dev); + /* + * Prevent the worker threads from touching queues to avoid contention, + * 1 ms should be enough for the ongoing Tx function to finish. + */ + rte_delay_ms(1); + + hw->inject_pkts = &rarp_mbuf; + dev->tx_pkt_burst(dev->data->tx_queues[0], &rarp_mbuf, 1); + hw->inject_pkts = NULL; + + hw->started = 1; + +out: + rte_spinlock_unlock(&hw->state_lock); } static void diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h index c08f382791..7be1c9acd0 100644 --- a/drivers/net/virtio/virtio_ethdev.h +++ b/drivers/net/virtio/virtio_ethdev.h @@ -112,12 +112,8 @@ int eth_virtio_dev_init(struct rte_eth_dev *eth_dev); void virtio_interrupt_handler(void *param); -int virtio_dev_pause(struct rte_eth_dev *dev); -void virtio_dev_resume(struct rte_eth_dev *dev); int virtio_dev_stop(struct rte_eth_dev *dev); int virtio_dev_close(struct rte_eth_dev *dev); -int virtio_inject_pkts(struct rte_eth_dev *dev, struct rte_mbuf **tx_pkts, - int nb_pkts); bool virtio_rx_check_scatter(uint16_t max_rx_pkt_len, uint16_t rx_buf_size, bool rx_scatter_enabled, const char **error); From patchwork Tue Apr 4 12:48:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125763 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 3D5C9428CD; Tue, 4 Apr 2023 14:50:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0AFDB42BAC; Tue, 4 Apr 2023 14:49:35 +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 846B742D17 for ; Tue, 4 Apr 2023 14:49:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612573; 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=IgYL7lUVc0hKT/jA6RO2c7ZpH5n0f3wkO9a8M0ueI6E=; b=cqvtYMMrMwnsSv13ux5VgIoALCB0U9Nu28TFwGn17GKboFLZs94NA5xWec4DmCz70we3TO kWvPWZarAYCRvClNfnhzhbJuSwTOON8r8ag9mpZdVmpGCFI3gwvJw1egUdWXbN7pEVpqHN rrengzl+HZMUMmCCX+bsGZAjzYj6dDs= 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-249-8L06CdBYNxmK4INNHs-ocA-1; Tue, 04 Apr 2023 08:49:29 -0400 X-MC-Unique: 8L06CdBYNxmK4INNHs-ocA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 72A571012BA1; Tue, 4 Apr 2023 12:49:29 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 642032027061; Tue, 4 Apr 2023 12:49:28 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Rosen Xu , Wei Huang , Tianfei Zhang Subject: [PATCH v3 12/16] raw/ifpga: inherit lock annotations Date: Tue, 4 Apr 2023 14:48:36 +0200 Message-Id: <20230404124840.1898-13-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 The checks in those helpers are useless: - all (start/stop/reset/test) callers ensure that dev != NULL, - dev->sd can't be NULL either as it would mean the application is calling those helpers for a dev pointer that did not pass initialisation, Once the checks are removed, the only thing that remains is calls to the rte_spinlock API, so simply use macros and inherit annotations from the lock API. Signed-off-by: David Marchand Reviewed-by: Rosen Xu Reviewed-by: Wei Huang --- drivers/raw/ifpga/afu_pmd_core.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/raw/ifpga/afu_pmd_core.c b/drivers/raw/ifpga/afu_pmd_core.c index ddf7a34f33..3ab1f47ac1 100644 --- a/drivers/raw/ifpga/afu_pmd_core.c +++ b/drivers/raw/ifpga/afu_pmd_core.c @@ -23,21 +23,8 @@ static struct rte_afu_uuid afu_pmd_uuid_map[AFU_RAWDEV_MAX_DRVS+1]; TAILQ_HEAD(afu_drv_list, afu_rawdev_drv); static struct afu_drv_list afu_pmd_list = TAILQ_HEAD_INITIALIZER(afu_pmd_list); -static inline int afu_rawdev_trylock(struct afu_rawdev *dev) -{ - if (!dev || !dev->sd) - return 0; - - return rte_spinlock_trylock(&dev->sd->lock); -} - -static inline void afu_rawdev_unlock(struct afu_rawdev *dev) -{ - if (!dev || !dev->sd) - return; - - rte_spinlock_unlock(&dev->sd->lock); -} +#define afu_rawdev_trylock(dev) rte_spinlock_trylock(&dev->sd->lock) +#define afu_rawdev_unlock(dev) rte_spinlock_unlock(&dev->sd->lock) static int afu_rawdev_configure(const struct rte_rawdev *rawdev, rte_rawdev_obj_t config, size_t config_size) From patchwork Tue Apr 4 12:48:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125764 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 0B1B0428CD; Tue, 4 Apr 2023 14:50:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6FFD242D47; Tue, 4 Apr 2023 14:49:38 +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 1E72842D20 for ; Tue, 4 Apr 2023 14:49:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612575; 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=5kEnMWkScyPuEhSTNjMbeZsZFkRgt1i8JuY0DeXRpeU=; b=A6fwBB8xer8bP6ZAPCoSP2uFo6MGkQv8fl31iSyy9w/WfH9SpllYJrVTaNLxxAqGiHbqkP zRszxrEze2VBrdIDLhkHXbcSd4tKGhzBGYbcguMPsQQdcG95pJFg67BPmltnPLHLJalk7a uo0sQDgBC7yStPOFJg8e5XTRI4bWh5I= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-hPZFuD3gO5Sh79EN4yQfng-1; Tue, 04 Apr 2023 08:49:32 -0400 X-MC-Unique: hPZFuD3gO5Sh79EN4yQfng-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 307CA2807D63; Tue, 4 Apr 2023 12:49:32 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 680A11121314; Tue, 4 Apr 2023 12:49:31 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Vijay Kumar Srivastava Subject: [PATCH v3 13/16] vdpa/sfc: inherit lock annotations Date: Tue, 4 Apr 2023 14:48:37 +0200 Message-Id: <20230404124840.1898-14-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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 Due to clang limitation, inline helpers don't inherit lock annotations from the EAL lock API. Replace them with macros. sfc_vdpa_ops.c was relying on an implicit cast of the dev_handle to a vdpa adapter object. Add an explicit conversion. Signed-off-by: David Marchand --- drivers/vdpa/sfc/sfc_vdpa.h | 41 +++++---------------------------- drivers/vdpa/sfc/sfc_vdpa_ops.c | 14 +++++------ 2 files changed, 13 insertions(+), 42 deletions(-) diff --git a/drivers/vdpa/sfc/sfc_vdpa.h b/drivers/vdpa/sfc/sfc_vdpa.h index b25eb3a5fe..2b843e563d 100644 --- a/drivers/vdpa/sfc/sfc_vdpa.h +++ b/drivers/vdpa/sfc/sfc_vdpa.h @@ -122,40 +122,11 @@ sfc_vdpa_adapter_by_dev_handle(void *dev_handle) * Add wrapper functions to acquire/release lock to be able to remove or * change the lock in one place. */ -static inline void -sfc_vdpa_adapter_lock_init(struct sfc_vdpa_adapter *sva) -{ - rte_spinlock_init(&sva->lock); -} - -static inline int -sfc_vdpa_adapter_is_locked(struct sfc_vdpa_adapter *sva) -{ - return rte_spinlock_is_locked(&sva->lock); -} - -static inline void -sfc_vdpa_adapter_lock(struct sfc_vdpa_adapter *sva) -{ - rte_spinlock_lock(&sva->lock); -} - -static inline int -sfc_vdpa_adapter_trylock(struct sfc_vdpa_adapter *sva) -{ - return rte_spinlock_trylock(&sva->lock); -} - -static inline void -sfc_vdpa_adapter_unlock(struct sfc_vdpa_adapter *sva) -{ - rte_spinlock_unlock(&sva->lock); -} - -static inline void -sfc_vdpa_adapter_lock_fini(__rte_unused struct sfc_vdpa_adapter *sva) -{ - /* Just for symmetry of the API */ -} +#define sfc_vdpa_adapter_lock_init(sva) rte_spinlock_init(&(sva)->lock) +#define sfc_vdpa_adapter_is_locked(sva) rte_spinlock_is_locked(&(sva)->lock) +#define sfc_vdpa_adapter_lock(sva) rte_spinlock_lock(&(sva)->lock) +#define sfc_vdpa_adapter_trylock(sva) rte_spinlock_trylock(&(sva)->lock) +#define sfc_vdpa_adapter_unlock(sva) rte_spinlock_unlock(&(sva)->lock) +#define sfc_vdpa_adapter_lock_fini(sva) RTE_SET_USED(sva) #endif /* _SFC_VDPA_H */ diff --git a/drivers/vdpa/sfc/sfc_vdpa_ops.c b/drivers/vdpa/sfc/sfc_vdpa_ops.c index e88c7eeaa6..f63af7d478 100644 --- a/drivers/vdpa/sfc/sfc_vdpa_ops.c +++ b/drivers/vdpa/sfc/sfc_vdpa_ops.c @@ -577,7 +577,7 @@ sfc_vdpa_notify_ctrl(void *arg) if (ops_data == NULL) return NULL; - sfc_vdpa_adapter_lock(ops_data->dev_handle); + sfc_vdpa_adapter_lock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); vid = ops_data->vid; @@ -586,7 +586,7 @@ sfc_vdpa_notify_ctrl(void *arg) "vDPA (%s): Notifier could not get configured", ops_data->vdpa_dev->device->name); - sfc_vdpa_adapter_unlock(ops_data->dev_handle); + sfc_vdpa_adapter_unlock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); return NULL; } @@ -637,7 +637,7 @@ sfc_vdpa_dev_config(int vid) ops_data->vid = vid; - sfc_vdpa_adapter_lock(ops_data->dev_handle); + sfc_vdpa_adapter_lock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); sfc_vdpa_log_init(ops_data->dev_handle, "configuring"); rc = sfc_vdpa_configure(ops_data); @@ -653,7 +653,7 @@ sfc_vdpa_dev_config(int vid) if (rc != 0) goto fail_vdpa_notify; - sfc_vdpa_adapter_unlock(ops_data->dev_handle); + sfc_vdpa_adapter_unlock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); sfc_vdpa_log_init(ops_data->dev_handle, "done"); @@ -666,7 +666,7 @@ sfc_vdpa_dev_config(int vid) sfc_vdpa_close(ops_data); fail_vdpa_config: - sfc_vdpa_adapter_unlock(ops_data->dev_handle); + sfc_vdpa_adapter_unlock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); return -1; } @@ -688,7 +688,7 @@ sfc_vdpa_dev_close(int vid) return -1; } - sfc_vdpa_adapter_lock(ops_data->dev_handle); + sfc_vdpa_adapter_lock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); if (ops_data->is_notify_thread_started == true) { void *status; ret = pthread_cancel(ops_data->notify_tid); @@ -710,7 +710,7 @@ sfc_vdpa_dev_close(int vid) sfc_vdpa_stop(ops_data); sfc_vdpa_close(ops_data); - sfc_vdpa_adapter_unlock(ops_data->dev_handle); + sfc_vdpa_adapter_unlock(sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)); return 0; } From patchwork Tue Apr 4 12:48:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125765 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 A2218428CD; Tue, 4 Apr 2023 14:50:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BD0C942D33; Tue, 4 Apr 2023 14:49:40 +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 513BD410FA for ; Tue, 4 Apr 2023 14:49:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612578; 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=LJ/g6N/31mwuTTA5/SfePizE03NX8X4SRQ0mT5w/3GU=; b=OB59tl1rrDauYnIZpNK/4Zx2BBw0dlk3STDuYNDAR+aHVHTCX+NTUG0iTSY3LlP+pXfg5u gvpmsILMHB1Qn8b7gkseKfSQSCCC2g1Z0nIPzt3QlXd4oFvSQynyFD2NjllpMmEhBfwWcW lbKNeEjdBnSvdBe9VzsNvTOWVTczjZk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-oUMfeGzaMqWipOGPcgxfBA-1; Tue, 04 Apr 2023 08:49:35 -0400 X-MC-Unique: oUMfeGzaMqWipOGPcgxfBA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D4FC2807D60; Tue, 4 Apr 2023 12:49:35 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E5362027061; Tue, 4 Apr 2023 12:49:34 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Gaetan Rivet Subject: [PATCH v3 14/16] net/failsafe: fix mutex locking Date: Tue, 4 Apr 2023 14:48:38 +0200 Message-Id: <20230404124840.1898-15-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 The pthread mutex API describes cases where locking might fail. Check fts_enter wrapper return code. Signed-off-by: David Marchand Acked-by: Gaetan Rivet --- drivers/net/failsafe/failsafe_ether.c | 3 +- drivers/net/failsafe/failsafe_flow.c | 23 +++-- drivers/net/failsafe/failsafe_ops.c | 142 +++++++++++++++++++------- 3 files changed, 123 insertions(+), 45 deletions(-) diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c index 10b90fd837..031f3eb13f 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -592,7 +592,8 @@ failsafe_eth_rmv_event_callback(uint16_t port_id __rte_unused, { struct sub_device *sdev = cb_arg; - fs_lock(fs_dev(sdev), 0); + if (fs_lock(fs_dev(sdev), 0) != 0) + return -1; /* Switch as soon as possible tx_dev. */ fs_switch_dev(fs_dev(sdev), sdev); /* Use safe bursts in any case. */ diff --git a/drivers/net/failsafe/failsafe_flow.c b/drivers/net/failsafe/failsafe_flow.c index 354f9fec20..707e6c63b5 100644 --- a/drivers/net/failsafe/failsafe_flow.c +++ b/drivers/net/failsafe/failsafe_flow.c @@ -72,7 +72,9 @@ fs_flow_validate(struct rte_eth_dev *dev, uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { DEBUG("Calling rte_flow_validate on sub_device %d", i); ret = rte_flow_validate(PORT_ID(sdev), @@ -99,7 +101,8 @@ fs_flow_create(struct rte_eth_dev *dev, struct rte_flow *flow; uint8_t i; - fs_lock(dev, 0); + if (fs_lock(dev, 0) != 0) + return NULL; flow = fs_flow_allocate(attr, patterns, actions); FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { flow->flows[i] = rte_flow_create(PORT_ID(sdev), @@ -137,8 +140,9 @@ fs_flow_destroy(struct rte_eth_dev *dev, ERROR("Invalid flow"); return -EINVAL; } - ret = 0; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { int local_ret; @@ -169,7 +173,9 @@ fs_flow_flush(struct rte_eth_dev *dev, uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { DEBUG("Calling rte_flow_flush on sub_device %d", i); ret = rte_flow_flush(PORT_ID(sdev), error); @@ -197,7 +203,8 @@ fs_flow_query(struct rte_eth_dev *dev, { struct sub_device *sdev; - fs_lock(dev, 0); + if (fs_lock(dev, 0) != 0) + return -1; sdev = TX_SUBDEV(dev); if (sdev != NULL) { int ret = rte_flow_query(PORT_ID(sdev), @@ -223,7 +230,9 @@ fs_flow_isolate(struct rte_eth_dev *dev, uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV(sdev, i, dev) { if (sdev->state < DEV_PROBED) continue; diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index d357e1bc83..35649b6244 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -28,7 +28,9 @@ fs_dev_configure(struct rte_eth_dev *dev) uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV(sdev, i, dev) { int rmv_interrupt = 0; int lsc_interrupt = 0; @@ -129,7 +131,9 @@ fs_dev_start(struct rte_eth_dev *dev) uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; ret = failsafe_rx_intr_install(dev); if (ret) { fs_unlock(dev, 0); @@ -189,7 +193,9 @@ fs_dev_stop(struct rte_eth_dev *dev) uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; PRIV(dev)->state = DEV_STARTED - 1; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_STARTED) { ret = rte_eth_dev_stop(PORT_ID(sdev)); @@ -217,7 +223,9 @@ fs_dev_set_link_up(struct rte_eth_dev *dev) uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { DEBUG("Calling rte_eth_dev_set_link_up on sub_device %d", i); ret = rte_eth_dev_set_link_up(PORT_ID(sdev)); @@ -239,7 +247,9 @@ fs_dev_set_link_down(struct rte_eth_dev *dev) uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { DEBUG("Calling rte_eth_dev_set_link_down on sub_device %d", i); ret = rte_eth_dev_set_link_down(PORT_ID(sdev)); @@ -263,7 +273,9 @@ fs_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) int err = 0; bool failure = true; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { uint16_t port_id = ETH(sdev)->data->port_id; @@ -289,7 +301,9 @@ fs_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { uint16_t port_id = ETH(sdev)->data->port_id; @@ -316,7 +330,9 @@ fs_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) int err = 0; bool failure = true; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { uint16_t port_id = ETH(sdev)->data->port_id; @@ -342,7 +358,9 @@ fs_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { uint16_t port_id = ETH(sdev)->data->port_id; @@ -369,7 +387,8 @@ fs_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid) if (rxq == NULL) return; - fs_lock(dev, 0); + if (fs_lock(dev, 0) != 0) + return; if (rxq->event_fd >= 0) close(rxq->event_fd); FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { @@ -395,7 +414,9 @@ fs_rx_queue_setup(struct rte_eth_dev *dev, uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; if (rx_conf->rx_deferred_start) { FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) { if (SUBOPS(sdev, rx_queue_start) == NULL) { @@ -466,7 +487,9 @@ fs_rx_intr_enable(struct rte_eth_dev *dev, uint16_t idx) int ret; int rc = 0; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; if (idx >= dev->data->nb_rx_queues) { rc = -EINVAL; goto unlock; @@ -506,7 +529,9 @@ fs_rx_intr_disable(struct rte_eth_dev *dev, uint16_t idx) int rc = 0; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; if (idx >= dev->data->nb_rx_queues) { rc = -EINVAL; goto unlock; @@ -542,7 +567,8 @@ fs_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid) if (txq == NULL) return; - fs_lock(dev, 0); + if (fs_lock(dev, 0) != 0) + return; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { if (ETH(sdev)->data->tx_queues != NULL && ETH(sdev)->data->tx_queues[txq->qid] != NULL) @@ -565,7 +591,9 @@ fs_tx_queue_setup(struct rte_eth_dev *dev, uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; if (tx_conf->tx_deferred_start) { FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_PROBED) { if (SUBOPS(sdev, tx_queue_start) == NULL) { @@ -639,7 +667,9 @@ failsafe_eth_dev_close(struct rte_eth_dev *dev) uint8_t i; int err, ret = 0; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; failsafe_hotplug_alarm_cancel(dev); if (PRIV(dev)->state == DEV_STARTED) { ret = dev->dev_ops->dev_stop(dev); @@ -693,7 +723,9 @@ fs_promiscuous_enable(struct rte_eth_dev *dev) uint8_t i; int ret = 0; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { ret = rte_eth_promiscuous_enable(PORT_ID(sdev)); ret = fs_err(sdev, ret); @@ -725,7 +757,9 @@ fs_promiscuous_disable(struct rte_eth_dev *dev) uint8_t i; int ret = 0; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { ret = rte_eth_promiscuous_disable(PORT_ID(sdev)); ret = fs_err(sdev, ret); @@ -757,7 +791,9 @@ fs_allmulticast_enable(struct rte_eth_dev *dev) uint8_t i; int ret = 0; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { ret = rte_eth_allmulticast_enable(PORT_ID(sdev)); ret = fs_err(sdev, ret); @@ -789,7 +825,9 @@ fs_allmulticast_disable(struct rte_eth_dev *dev) uint8_t i; int ret = 0; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { ret = rte_eth_allmulticast_disable(PORT_ID(sdev)); ret = fs_err(sdev, ret); @@ -822,7 +860,9 @@ fs_link_update(struct rte_eth_dev *dev, uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { DEBUG("Calling link_update on sub_device %d", i); ret = (SUBOPS(sdev, link_update))(ETH(sdev), wait_to_complete); @@ -859,7 +899,9 @@ fs_stats_get(struct rte_eth_dev *dev, uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; rte_memcpy(stats, &PRIV(dev)->stats_accumulator, sizeof(*stats)); FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { struct rte_eth_stats *snapshot = &sdev->stats_snapshot.stats; @@ -893,7 +935,9 @@ fs_stats_reset(struct rte_eth_dev *dev) uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { ret = rte_eth_stats_reset(PORT_ID(sdev)); if (ret) { @@ -983,7 +1027,9 @@ fs_xstats_get_names(struct rte_eth_dev *dev, { int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; ret = __fs_xstats_get_names(dev, xstats_names, limit); fs_unlock(dev, 0); return ret; @@ -1035,7 +1081,9 @@ fs_xstats_get(struct rte_eth_dev *dev, { int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; ret = __fs_xstats_get(dev, xstats, n); fs_unlock(dev, 0); @@ -1048,9 +1096,11 @@ fs_xstats_reset(struct rte_eth_dev *dev) { struct sub_device *sdev; uint8_t i; - int r = 0; + int r; - fs_lock(dev, 0); + r = fs_lock(dev, 0); + if (r != 0) + return r; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { r = rte_eth_xstats_reset(PORT_ID(sdev)); if (r < 0) @@ -1238,7 +1288,8 @@ fs_dev_supported_ptypes_get(struct rte_eth_dev *dev) struct rte_eth_dev *edev; const uint32_t *ret; - fs_lock(dev, 0); + if (fs_lock(dev, 0) != 0) + return NULL; sdev = TX_SUBDEV(dev); if (sdev == NULL) { ret = NULL; @@ -1270,7 +1321,9 @@ fs_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { DEBUG("Calling rte_eth_dev_set_mtu on sub_device %d", i); ret = rte_eth_dev_set_mtu(PORT_ID(sdev), mtu); @@ -1292,7 +1345,9 @@ fs_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { DEBUG("Calling rte_eth_dev_vlan_filter on sub_device %d", i); ret = rte_eth_dev_vlan_filter(PORT_ID(sdev), vlan_id, on); @@ -1314,7 +1369,9 @@ fs_flow_ctrl_get(struct rte_eth_dev *dev, struct sub_device *sdev; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; sdev = TX_SUBDEV(dev); if (sdev == NULL) { ret = 0; @@ -1338,7 +1395,9 @@ fs_flow_ctrl_set(struct rte_eth_dev *dev, uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { DEBUG("Calling rte_eth_dev_flow_ctrl_set on sub_device %d", i); ret = rte_eth_dev_flow_ctrl_set(PORT_ID(sdev), fc_conf); @@ -1359,7 +1418,8 @@ fs_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) struct sub_device *sdev; uint8_t i; - fs_lock(dev, 0); + if (fs_lock(dev, 0) != 0) + return; /* No check: already done within the rte_eth_dev_mac_addr_remove * call for the fail-safe device. */ @@ -1381,7 +1441,9 @@ fs_mac_addr_add(struct rte_eth_dev *dev, uint8_t i; RTE_ASSERT(index < FAILSAFE_MAX_ETHADDR); - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { ret = rte_eth_dev_mac_addr_add(PORT_ID(sdev), mac_addr, vmdq); if ((ret = fs_err(sdev, ret))) { @@ -1407,7 +1469,9 @@ fs_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr) uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { ret = rte_eth_dev_default_mac_addr_set(PORT_ID(sdev), mac_addr); ret = fs_err(sdev, ret); @@ -1432,7 +1496,9 @@ fs_set_mc_addr_list(struct rte_eth_dev *dev, int ret; void *mcast_addrs; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { ret = rte_eth_dev_set_mc_addr_list(PORT_ID(sdev), @@ -1480,7 +1546,9 @@ fs_rss_hash_update(struct rte_eth_dev *dev, uint8_t i; int ret; - fs_lock(dev, 0); + ret = fs_lock(dev, 0); + if (ret != 0) + return ret; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { ret = rte_eth_dev_rss_hash_update(PORT_ID(sdev), rss_conf); ret = fs_err(sdev, ret); From patchwork Tue Apr 4 12:48:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125766 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 BB704428CD; Tue, 4 Apr 2023 14:50:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B9D4441156; Tue, 4 Apr 2023 14:49:46 +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 9BD3742D50 for ; Tue, 4 Apr 2023 14:49:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612584; 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=Ua9bxdTCIzphsmVe/7/8wVpV3aAfodxM+TLmq0GxFIQ=; b=XXWoJQFInroAKueLH6zKzgGPs2PsMyGZjWx0LUR3NuKuzoKtI4lz8ZR5e3zI9LlqwGCgmh jqjQNc91IApQ/gO20ejPqwXpLIT8CxYjltpSowcyfNOKwB+1/kDGwI8StNPv/PB4dROYak yxBTullrn2RbQfKtqnpH6K/FZbQAO3o= 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-190-akPzZjAYP9yfrlN6jiCZ9w-1; Tue, 04 Apr 2023 08:49:38 -0400 X-MC-Unique: akPzZjAYP9yfrlN6jiCZ9w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 736638030D0; Tue, 4 Apr 2023 12:49:38 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 432EF492C13; Tue, 4 Apr 2023 12:49:37 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Subject: [PATCH v3 15/16] eal/windows: disable lock check on alarm code Date: Tue, 4 Apr 2023 14:48:39 +0200 Message-Id: <20230404124840.1898-16-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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 This code uses locks to implement synchronisation between two threads. There seems nothing wrong with it, just silence the clang lock check. Signed-off-by: David Marchand Acked-by: Tyler Retzlaff Acked-by: Dmitry Kozlyuk --- lib/eal/windows/eal_alarm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/eal/windows/eal_alarm.c b/lib/eal/windows/eal_alarm.c index 48203a2870..34b52380ce 100644 --- a/lib/eal/windows/eal_alarm.c +++ b/lib/eal/windows/eal_alarm.c @@ -224,6 +224,7 @@ struct intr_task { static void intr_thread_entry(void *arg) + __rte_no_thread_safety_analysis { struct intr_task *task = arg; task->func(task->arg); @@ -232,6 +233,7 @@ intr_thread_entry(void *arg) static int intr_thread_exec_sync(void (*func)(void *arg), void *arg) + __rte_no_thread_safety_analysis { struct intr_task task; int ret; From patchwork Tue Apr 4 12:48:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125767 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 2C278428CD; Tue, 4 Apr 2023 14:50:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CB1DF42D50; Tue, 4 Apr 2023 14:49:52 +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 B132E42B71 for ; Tue, 4 Apr 2023 14:49:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612590; 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=KcFpmpznI2XRCD1VSIc2bbnAF5zPwBBdxHUEHc5OQ3w=; b=F7hv/I4Cl0il99UxLXUxjxABj3P5ZGdDRM7xaFVHQ/4mdArTB9k4pS9Kxg72GTig36eSvk epmbrl78sNmwGJSZ6PuEar0vrvfk9KN97SDHlc6WnFA6QVDeYXDKaRY+fyugQUN9hBSQf/ iMjZT5aP/u6s7ScK8VzKYKsYST7awiQ= 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-113-BUCFQaIOMDqyZbwc8rr0EA-1; Tue, 04 Apr 2023 08:49:47 -0400 X-MC-Unique: BUCFQaIOMDqyZbwc8rr0EA-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 CE476800B23; Tue, 4 Apr 2023 12:49:45 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1C9C2166B26; Tue, 4 Apr 2023 12:49:40 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Chenbo Xia , Anatoly Burakov , Hemant Agrawal , Sachin Saxena , Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , Matan Azrad , Viacheslav Ovsiienko , Pavan Nikhilesh , Shijith Thotton , Rasesh Mody , Shahed Shaikh , Ajit Khaparde , Somnath Kotur , John Daley , Hyong Youb Kim , Gaetan Rivet , Ziyang Xuan , Xiaoyun Wang , Guoyang Zhou , Dongdong Liu , Yisen Zhuang , Ferruh Yigit , Andrew Rybchenko , Konstantin Ananyev , Vladimir Medvedkin , Erik Gabriel Carrillo , Maxime Coquelin Subject: [PATCH v3 16/16] enable lock check Date: Tue, 4 Apr 2023 14:48:40 +0200 Message-Id: <20230404124840.1898-17-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-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 Now that a lot of components can be compiled with the lock checks, invert the logic and opt out for components not ready yet: - drivers/bus/dpaa, - drivers/common/cnxk, - drivers/common/mlx5, - drivers/event/cnxk, - drivers/net/bnx2x, - drivers/net/bnxt, - drivers/net/cnxk, - drivers/net/enic, - drivers/net/hns3, - drivers/net/mlx5, - lib/ipsec, - lib/timer, The FreeBSD pthread API has been annotated but Linux glibc does not have those annotations. Disable lock checks for FreeBSD where pthread_mutex_* are used: - drivers/net/failsafe, - drivers/net/hinic, - lib/eal, - lib/ethdev, Signed-off-by: David Marchand Reviewed-by: Chenbo Xia Acked-by: Sachin Saxena --- Changes since v2: - disabled checks on FreeBSD when code relies on pthread mutexes, --- doc/guides/prog_guide/env_abstraction_layer.rst | 5 +++-- drivers/bus/dpaa/meson.build | 1 + drivers/common/cnxk/meson.build | 1 + drivers/common/mlx5/meson.build | 1 + drivers/event/cnxk/meson.build | 1 + drivers/meson.build | 2 +- drivers/net/bnx2x/meson.build | 1 + drivers/net/bnxt/meson.build | 1 + drivers/net/cnxk/meson.build | 1 + drivers/net/enic/meson.build | 1 + drivers/net/failsafe/meson.build | 4 ++++ drivers/net/hinic/meson.build | 4 ++++ drivers/net/hns3/meson.build | 1 + drivers/net/mlx5/meson.build | 1 + lib/eal/meson.build | 4 ++++ lib/ethdev/meson.build | 4 ++++ lib/ipsec/meson.build | 1 + lib/meson.build | 2 +- lib/timer/meson.build | 1 + lib/vhost/meson.build | 1 - 20 files changed, 33 insertions(+), 5 deletions(-) diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst b/doc/guides/prog_guide/env_abstraction_layer.rst index 3f33621e05..93c8a031be 100644 --- a/doc/guides/prog_guide/env_abstraction_layer.rst +++ b/doc/guides/prog_guide/env_abstraction_layer.rst @@ -550,8 +550,9 @@ Some general comments: waiving checks with ``__rte_no_thread_safety_analysis`` in your code, please discuss it on the mailing list, -A DPDK library/driver can enable/disable the checks by setting -``annotate_locks`` accordingly in its ``meson.build`` file. +The checks are enabled by default for libraries and drivers. +They can be disabled by setting ``annotate_locks`` to ``false`` in +the concerned library/driver ``meson.build``. IOVA Mode Detection ~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/bus/dpaa/meson.build b/drivers/bus/dpaa/meson.build index 5506f2bffc..183b251459 100644 --- a/drivers/bus/dpaa/meson.build +++ b/drivers/bus/dpaa/meson.build @@ -29,3 +29,4 @@ if cc.has_argument('-Wno-pointer-arith') endif includes += include_directories('include', 'base/qbman') +annotate_locks = false diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build index 402c3249cd..b32fae9f5a 100644 --- a/drivers/common/cnxk/meson.build +++ b/drivers/common/cnxk/meson.build @@ -89,3 +89,4 @@ sources += files('cnxk_telemetry_bphy.c', deps += ['bus_pci', 'net', 'telemetry'] require_iova_in_mbuf = false +annotate_locks = false diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build index 9dc809f192..b5fc4c9346 100644 --- a/drivers/common/mlx5/meson.build +++ b/drivers/common/mlx5/meson.build @@ -45,3 +45,4 @@ endif mlx5_config = configuration_data() subdir(exec_env) configure_file(output: 'mlx5_autoconf.h', configuration: mlx5_config) +annotate_locks = false diff --git a/drivers/event/cnxk/meson.build b/drivers/event/cnxk/meson.build index 3517e79341..89e1aa860f 100644 --- a/drivers/event/cnxk/meson.build +++ b/drivers/event/cnxk/meson.build @@ -480,3 +480,4 @@ endforeach deps += ['bus_pci', 'common_cnxk', 'net_cnxk', 'crypto_cnxk'] require_iova_in_mbuf = false +annotate_locks = false diff --git a/drivers/meson.build b/drivers/meson.build index b85bec235d..74ae8cb96b 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -92,7 +92,7 @@ foreach subpath:subdirs build = true # set to false to disable, e.g. missing deps reason = '' # set if build == false to explain name = drv - annotate_locks = false + annotate_locks = true sources = [] headers = [] driver_sdk_headers = [] # public headers included by drivers diff --git a/drivers/net/bnx2x/meson.build b/drivers/net/bnx2x/meson.build index 156f97d31f..dbf9c7225d 100644 --- a/drivers/net/bnx2x/meson.build +++ b/drivers/net/bnx2x/meson.build @@ -21,3 +21,4 @@ sources = files( 'ecore_sp.c', 'elink.c', ) +annotate_locks = false diff --git a/drivers/net/bnxt/meson.build b/drivers/net/bnxt/meson.build index 0288ed6262..72d4f82e7c 100644 --- a/drivers/net/bnxt/meson.build +++ b/drivers/net/bnxt/meson.build @@ -72,3 +72,4 @@ if arch_subdir == 'x86' elif arch_subdir == 'arm' and dpdk_conf.get('RTE_ARCH_64') sources += files('bnxt_rxtx_vec_neon.c') endif +annotate_locks = false diff --git a/drivers/net/cnxk/meson.build b/drivers/net/cnxk/meson.build index 8b5773ce65..abece91e40 100644 --- a/drivers/net/cnxk/meson.build +++ b/drivers/net/cnxk/meson.build @@ -197,3 +197,4 @@ endforeach headers = files('rte_pmd_cnxk.h') require_iova_in_mbuf = false +annotate_locks = false diff --git a/drivers/net/enic/meson.build b/drivers/net/enic/meson.build index 0a0992c3cb..bde7428953 100644 --- a/drivers/net/enic/meson.build +++ b/drivers/net/enic/meson.build @@ -43,3 +43,4 @@ elif cc.has_argument('-mavx2') and dpdk_conf.get('RTE_ARCH_64') c_args: [cflags, '-mavx2']) objs += enic_avx2_lib.extract_objects('enic_rxtx_vec_avx2.c') endif +annotate_locks = false diff --git a/drivers/net/failsafe/meson.build b/drivers/net/failsafe/meson.build index 3066d37995..6013e13722 100644 --- a/drivers/net/failsafe/meson.build +++ b/drivers/net/failsafe/meson.build @@ -29,3 +29,7 @@ sources = files( ) require_iova_in_mbuf = false + +if is_freebsd + annotate_locks = false +endif diff --git a/drivers/net/hinic/meson.build b/drivers/net/hinic/meson.build index dbcf177782..8242e0052e 100644 --- a/drivers/net/hinic/meson.build +++ b/drivers/net/hinic/meson.build @@ -18,3 +18,7 @@ sources = files( ) includes += include_directories('base') + +if is_freebsd + annotate_locks = false +endif diff --git a/drivers/net/hns3/meson.build b/drivers/net/hns3/meson.build index 97cb85dcc8..7dcf21f72a 100644 --- a/drivers/net/hns3/meson.build +++ b/drivers/net/hns3/meson.build @@ -32,6 +32,7 @@ sources = files( 'hns3_common.c', 'hns3_dump.c', ) +annotate_locks = false require_iova_in_mbuf = false diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build index dba911693e..3184a41a25 100644 --- a/drivers/net/mlx5/meson.build +++ b/drivers/net/mlx5/meson.build @@ -82,3 +82,4 @@ testpmd_sources += files('mlx5_testpmd.c') subdir(exec_env) subdir('hws') +annotate_locks = false diff --git a/lib/eal/meson.build b/lib/eal/meson.build index 056beb9461..9aa941a5ae 100644 --- a/lib/eal/meson.build +++ b/lib/eal/meson.build @@ -32,3 +32,7 @@ endif if cc.has_function('getentropy', prefix : '#include ') cflags += '-DRTE_LIBEAL_USE_GETENTROPY' endif + +if is_freebsd + annotate_locks = false +endif diff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build index 9e97f05983..1ba0fac5c0 100644 --- a/lib/ethdev/meson.build +++ b/lib/ethdev/meson.build @@ -44,3 +44,7 @@ driver_sdk_headers += files( ) deps += ['net', 'kvargs', 'meter', 'telemetry'] + +if is_freebsd + annotate_locks = false +endif diff --git a/lib/ipsec/meson.build b/lib/ipsec/meson.build index 0b8b935cd2..ff44d6fbdf 100644 --- a/lib/ipsec/meson.build +++ b/lib/ipsec/meson.build @@ -13,5 +13,6 @@ sources = files('esp_inb.c', 'esp_outb.c', headers = files('rte_ipsec.h', 'rte_ipsec_sa.h', 'rte_ipsec_sad.h') indirect_headers += files('rte_ipsec_group.h') +annotate_locks = false deps += ['mbuf', 'net', 'cryptodev', 'security', 'hash', 'telemetry'] diff --git a/lib/meson.build b/lib/meson.build index 0812ce6026..dc8aa4ac84 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -121,7 +121,7 @@ foreach l:libraries reason = '' # set if build == false to explain why name = l use_function_versioning = false - annotate_locks = false + annotate_locks = true sources = [] headers = [] indirect_headers = [] # public headers not directly included by apps diff --git a/lib/timer/meson.build b/lib/timer/meson.build index 89b17e0397..87bbb10592 100644 --- a/lib/timer/meson.build +++ b/lib/timer/meson.build @@ -3,3 +3,4 @@ sources = files('rte_timer.c') headers = files('rte_timer.h') +annotate_locks = false diff --git a/lib/vhost/meson.build b/lib/vhost/meson.build index 197a51d936..0d1abf6283 100644 --- a/lib/vhost/meson.build +++ b/lib/vhost/meson.build @@ -18,7 +18,6 @@ endif dpdk_conf.set('RTE_LIBRTE_VHOST_POSTCOPY', cc.has_header('linux/userfaultfd.h')) cflags += '-fno-strict-aliasing' -annotate_locks = true sources = files( 'fd_man.c', 'iotlb.c',