From patchwork Fri Feb 24 15:11:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124521 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 B33D241D5F; Fri, 24 Feb 2023 16:11:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 508D540697; Fri, 24 Feb 2023 16:11:57 +0100 (CET) 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 B53EB40693 for ; Fri, 24 Feb 2023 16:11:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251515; 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=pys5mz0G2mUZukXwaKteJY89qQfoORUAaHkqtbFYt4A=; b=fqtkNfINJapdM1HqRgVoiaYHCb72Vget+V97khwJU5U6Ph6H56cwfmZUabMpNSKrhJaCPZ wKQPxbz0ANp7/Z7fgwyj8gHJ0Rs4CdZJxShnM47MrPcl1OAHSy3IDiOPK6/qqD/bGya7/k JcnZITHw74kQBngBPSmWzUcV/X/sK5U= 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-622-apF7A6HFOt-mMYtK6Tb41Q-1; Fri, 24 Feb 2023 10:11:53 -0500 X-MC-Unique: apF7A6HFOt-mMYtK6Tb41Q-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 6729C1871D94; Fri, 24 Feb 2023 15:11:53 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id A624840C10FA; Fri, 24 Feb 2023 15:11:52 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Anatoly Burakov Subject: [PATCH v2 01/20] malloc: rework heap lock handling Date: Fri, 24 Feb 2023 16:11:24 +0100 Message-Id: <20230224151143.3274897-2-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-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 Move all heap->lock manipulation to malloc_heap.c to have a single location where to look at and make higher level code unaware of this locking constraint. 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. This makes the code less scary even though, at this point of its life, the heap object is probably referenced only by the caller. Signed-off-by: David Marchand --- lib/eal/common/malloc_heap.c | 45 +++++++++++++++++++++++++++--------- lib/eal/common/rte_malloc.c | 10 -------- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index d7c410b786..cc84dce672 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -1292,6 +1292,8 @@ int malloc_heap_add_external_memory(struct malloc_heap *heap, struct rte_memseg_list *msl) { + rte_spinlock_lock(&heap->lock); + /* erase contents of new memory */ memset(msl->base_va, 0, msl->len); @@ -1308,6 +1310,11 @@ malloc_heap_add_external_memory(struct malloc_heap *heap, eal_memalloc_mem_event_notify(RTE_MEM_EVENT_ALLOC, msl->base_va, msl->len); + /* mark it as heap segment */ + msl->heap = 1; + + rte_spinlock_unlock(&heap->lock); + return 0; } @@ -1315,7 +1322,12 @@ int malloc_heap_remove_external_memory(struct malloc_heap *heap, void *va_addr, size_t len) { - struct malloc_elem *elem = heap->first; + struct malloc_elem *elem; + int ret = -1; + + rte_spinlock_lock(&heap->lock); + + elem = heap->first; /* find element with specified va address */ while (elem != NULL && elem != va_addr) { @@ -1323,20 +1335,24 @@ malloc_heap_remove_external_memory(struct malloc_heap *heap, void *va_addr, /* stop if we've blown past our VA */ if (elem > (struct malloc_elem *)va_addr) { rte_errno = ENOENT; - return -1; + goto out; } } /* check if element was found */ if (elem == NULL || elem->msl->len != len) { rte_errno = ENOENT; - return -1; + goto out; } /* if element's size is not equal to segment len, segment is busy */ if (elem->state == ELEM_BUSY || elem->size != len) { rte_errno = EBUSY; - return -1; + goto out; } - return destroy_elem(elem, len); + ret = destroy_elem(elem, len); + +out: + rte_spinlock_unlock(&heap->lock); + return ret; } int @@ -1372,23 +1388,30 @@ malloc_heap_create(struct malloc_heap *heap, const char *heap_name) int malloc_heap_destroy(struct malloc_heap *heap) { + int ret = -1; + + rte_spinlock_lock(&heap->lock); + if (heap->alloc_count != 0) { RTE_LOG(ERR, EAL, "Heap is still in use\n"); rte_errno = EBUSY; - return -1; + goto fail; } if (heap->first != NULL || heap->last != NULL) { RTE_LOG(ERR, EAL, "Heap still contains memory segments\n"); rte_errno = EBUSY; - return -1; + goto fail; } 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)); - - return 0; + RTE_BUILD_BUG_ON(offsetof(struct malloc_heap, lock) != 0); + memset(RTE_PTR_ADD(heap, sizeof(heap->lock)), 0, + sizeof(*heap) - sizeof(heap->lock)); + ret = 0; +fail: + rte_spinlock_unlock(&heap->lock); + return ret; } int diff --git a/lib/eal/common/rte_malloc.c b/lib/eal/common/rte_malloc.c index d39870bf3c..4f500892f2 100644 --- a/lib/eal/common/rte_malloc.c +++ b/lib/eal/common/rte_malloc.c @@ -436,10 +436,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len, goto unlock; } - rte_spinlock_lock(&heap->lock); ret = malloc_heap_add_external_memory(heap, msl); - msl->heap = 1; /* mark it as heap segment */ - rte_spinlock_unlock(&heap->lock); unlock: rte_mcfg_mem_write_unlock(); @@ -482,9 +479,7 @@ rte_malloc_heap_memory_remove(const char *heap_name, void *va_addr, size_t len) goto unlock; } - rte_spinlock_lock(&heap->lock); ret = malloc_heap_remove_external_memory(heap, va_addr, len); - rte_spinlock_unlock(&heap->lock); if (ret != 0) goto unlock; @@ -655,12 +650,7 @@ rte_malloc_heap_destroy(const char *heap_name) goto unlock; } /* 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); unlock: rte_mcfg_mem_write_unlock(); From patchwork Fri Feb 24 15:11: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: 124524 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 7F1BC41D5F; Fri, 24 Feb 2023 16:12:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9CBB041148; Fri, 24 Feb 2023 16:12:05 +0100 (CET) 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 7D32E410F6 for ; Fri, 24 Feb 2023 16:12:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251522; 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=46WTwH0iZm3s0MjED3yPyKn9iluz8WAx2mokaxcg8qQ=; b=ZeRpcEOl6Eaw3qVxBzsPB5MCBqeMZR1TiaEzDIP0AUvhbU3NpMLgtvtl4MA1bGvql5Zlcy rDTnST5W8h6ybAsTRCJ0+UxXKgmfA5dQvy0Byekj/Qn9mLmBRspFFAwuocDE0UNSjg4ntb 4f7fqxNI5diVcFe+S6z9ia8iw4rtkWw= 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-392-sCEzoJmkOzih_BGXlt9Paw-1; Fri, 24 Feb 2023 10:11:57 -0500 X-MC-Unique: sCEzoJmkOzih_BGXlt9Paw-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 F26CB1871D9B; Fri, 24 Feb 2023 15:11:56 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C30E440D8; Fri, 24 Feb 2023 15:11:55 +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 v2 02/20] mem: rework malloc heap init Date: Fri, 24 Feb 2023 16:11:25 +0100 Message-Id: <20230224151143.3274897-3-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-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 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 c917b981bc..5e162a1092 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 cc84dce672..7498a05ed3 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -1442,18 +1442,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 fabafbc39b..7242ee2c9a 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -1197,7 +1198,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; @@ -1207,6 +1211,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 Fri Feb 24 15:11: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: 124523 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 C2D9441D5F; Fri, 24 Feb 2023 16:12:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7BA7B4111C; Fri, 24 Feb 2023 16:12:04 +0100 (CET) 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 57112410D0 for ; Fri, 24 Feb 2023 16:12:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251522; 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=U8tzSHFhxxgMjRRoNwctVYSHUmlHsm0WBdKPf4DF6BSsvyxkSd3pCNOjwg935xezLT1Wnh ThBx58tFVQpdNdQujvZ2a/ZlxhEjcvzXeXYPDCYoPJgBzcZsAYwJZz2r+7VXPSuroWSm9J RqM/XzI8AVvtj17eLGBPCF1ooiTgkp4= 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-256-aK7AHXGZOHyTuWvl9quP_g-1; Fri, 24 Feb 2023 10:11:59 -0500 X-MC-Unique: aK7AHXGZOHyTuWvl9quP_g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 828623810B24; Fri, 24 Feb 2023 15:11:59 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF910140EBF6; Fri, 24 Feb 2023 15:11:58 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net Subject: [PATCH v2 03/20] mem: annotate shared memory config locks Date: Fri, 24 Feb 2023 16:11:26 +0100 Message-Id: <20230224151143.3274897-4-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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 Fri Feb 24 15:11: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: 124525 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 9BFE341D5F; Fri, 24 Feb 2023 16:12:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0991742B7E; Fri, 24 Feb 2023 16:12:11 +0100 (CET) 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 EAB8C427F5 for ; Fri, 24 Feb 2023 16:12:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251528; 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=S9ipcFv+BOAxYQ6WxfMjyTammqJvInye0acC45fXaczfYBTTFfnlo37JeaLidPsgrWZUit 6HYlu4ItnPbv9TEXsQgcRbdq1hbfJWlekpnqVGDQvvt8uViU8pv3N5/SiDVgNtmWkwySmT pW78Te1Xhr9ji86uGc+IPExLI/pdRjc= 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-6-mw_WpelFMn6CfTjtLJ1K6g-1; Fri, 24 Feb 2023 10:12:03 -0500 X-MC-Unique: mw_WpelFMn6CfTjtLJ1K6g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC5003810B26; Fri, 24 Feb 2023 15:12:02 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94F73404BEC0; Fri, 24 Feb 2023 15:12:01 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH v2 04/20] hash: annotate cuckoo hash lock Date: Fri, 24 Feb 2023 16:11:27 +0100 Message-Id: <20230224151143.3274897-5-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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 Fri Feb 24 15:11: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: 124526 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 3036D41D5F; Fri, 24 Feb 2023 16:12:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 37A7142B8B; Fri, 24 Feb 2023 16:12:12 +0100 (CET) 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 C84B9427E9 for ; Fri, 24 Feb 2023 16:12:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251528; 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=Pod/kR4nuh/N/T9Fuiebc4yaPXpbXifmTJx+Hs9jmS0gCLC21zTXeSX4A55ZuQQjws42h5 EgyATJ59UEDr/J0AeFw6MzFqnPLBxJwo5Gd2t8M74e5qi0+UJewXHTuU5oh8EY81aQAV2D hREfExc8op0l32MNTZiNmxDHTd7N+58= 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-364-tSfacSYUOQCHEw7r4iTmMg-1; Fri, 24 Feb 2023 10:12:06 -0500 X-MC-Unique: tSfacSYUOQCHEw7r4iTmMg-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 AA5CA100F907; Fri, 24 Feb 2023 15:12:05 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5C582026D4B; Fri, 24 Feb 2023 15:12:04 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram Subject: [PATCH v2 05/20] graph: annotate graph lock Date: Fri, 24 Feb 2023 16:11:28 +0100 Message-Id: <20230224151143.3274897-6-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-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 Fri Feb 24 15:11: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: 124527 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 DD8BC41D5F; Fri, 24 Feb 2023 16:12:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 46F8E42BD9; Fri, 24 Feb 2023 16:12:14 +0100 (CET) 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 4BF0342BD9 for ; Fri, 24 Feb 2023 16:12:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251532; 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=+tkzNdYdaEMg7nLjjDLlht/iQdXqJxQW6oh+tndfXwk=; b=UqvY97ePgxj+HEVvhKVxsfw4GXxEwoJcvdL0K3chPGwbnZtfb48KmhZ+1oSybw+fYkZxcK Y6oGGoVsMNh9WOsemVMYlVfIM+4MPVApy1WBo032xkmUjCRI4MJ2HtzFgONr5mHWf2MWma A5maq9ls/+hWiO98BtALHSDvy7ikWeM= 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-ohh5oBEqNRC4kwBdkEEH7A-1; Fri, 24 Feb 2023 10:12:09 -0500 X-MC-Unique: ohh5oBEqNRC4kwBdkEEH7A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1B5F395D605; Fri, 24 Feb 2023 15:12:09 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFA39C15BA0; Fri, 24 Feb 2023 15:12:07 +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 v2 06/20] drivers: inherit lock annotations for Intel drivers Date: Fri, 24 Feb 2023 16:11:29 +0100 Message-Id: <20230224151143.3274897-7-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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 7726a89d99..cf2969f6ce 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -4622,30 +4622,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 Fri Feb 24 15:11: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: 124529 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 3006741D5F; Fri, 24 Feb 2023 16:12:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A1FF242D13; Fri, 24 Feb 2023 16:12:21 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 6604F41153 for ; Fri, 24 Feb 2023 16:12:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251537; 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=UJR7Sctd7wo2qSn2lIfh2NdRREDBJgv1oz2jI+xIvg2EYEFoYTPMKAfn/0s1Wc7bkNZvt4 GHJva6a4KAoVsEMjNVRdhIVkx68s3VgnjAxIEwQ94HU9bzDjE9sL3asMy3scOBmibf2Irs iyU/aPsyL2l9IbIzRFNqyF2E7T3j33c= 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-245-0Dx0SF-qOnWwLKEhQHxNfA-1; Fri, 24 Feb 2023 10:12:12 -0500 X-MC-Unique: 0Dx0SF-qOnWwLKEhQHxNfA-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 BF2E3100F901; Fri, 24 Feb 2023 15:12:11 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0393A2166B29; Fri, 24 Feb 2023 15:12:10 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Rahul Lakkireddy Subject: [PATCH v2 07/20] net/cxgbe: inherit lock annotations Date: Fri, 24 Feb 2023 16:11:30 +0100 Message-Id: <20230224151143.3274897-8-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-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 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 Fri Feb 24 15:11: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: 124528 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 277DD41D5F; Fri, 24 Feb 2023 16:12:43 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 781A842D0E; Fri, 24 Feb 2023 16:12:18 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id CB62A41153 for ; Fri, 24 Feb 2023 16:12:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251536; 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=da70ADZshZjDuAaEMQlH98DKLAwlAvikpwmtzpPzYuEwp4nBGt3nmLw/jMUrvkg6NHTog1 yzqKmEjbeyZZOCY6F7AoM1YPYxxcnHSy0K5Q8dAF3B2j/h8hK0oIn6106qNMyf1LeDm6+Y L7o195IfseTNj9JhacHO78b1ygwyvk8= 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-67-htishIkbOkCatsMlFSE-3g-1; Fri, 24 Feb 2023 10:12:15 -0500 X-MC-Unique: htishIkbOkCatsMlFSE-3g-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 B339F857D07; Fri, 24 Feb 2023 15:12:14 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id D06CC492C3E; Fri, 24 Feb 2023 15:12:13 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Qi Zhang , Xiao Wang Subject: [PATCH v2 08/20] net/fm10k: annotate mailbox lock Date: Fri, 24 Feb 2023 16:11:31 +0100 Message-Id: <20230224151143.3274897-9-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-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 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 Fri Feb 24 15:11: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: 124530 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 722CD41D5F; Fri, 24 Feb 2023 16:12:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1A0142D1A; Fri, 24 Feb 2023 16:12:22 +0100 (CET) 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 67B3D41153 for ; Fri, 24 Feb 2023 16:12:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251538; 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=pIyWTv3RHZWLdtSDwGJsVinsd2PFzP34hSWO7rnujgs=; b=MxnQuUaZmazTOY3px7PnZY/zuLrIiyW/7QrIo46aN/DOcI8yn7bLDyHID+vwBdAAkjg/Rj UyIDK20fOc2aEkIG7amkXn0C9C/d24/RL2DiKaedJl4IWB2J/Fqi1z7Eg+Vb/8wbLviXiw WdE6WvgL4RpyQ3zXdz1dBFcWu+f52aI= 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-648-M7SDaBWsMa2d9sVFkRNK1A-1; Fri, 24 Feb 2023 10:12:17 -0500 X-MC-Unique: M7SDaBWsMa2d9sVFkRNK1A-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 7D8903C02B78; Fri, 24 Feb 2023 15:12:17 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99A3B4015319; Fri, 24 Feb 2023 15:12:16 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Andrew Rybchenko Subject: [PATCH v2 09/20] net/sfc: rework locking in proxy code Date: Fri, 24 Feb 2023 16:11:32 +0100 Message-Id: <20230224151143.3274897-10-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-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 Remove one extra layer for proxy code: sfc_get_adapter_by_pf_port_id() now only resolves the sa object and 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 Fri Feb 24 15:11: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: 124531 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 018C941D5F; Fri, 24 Feb 2023 16:13:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A1FE842D3F; Fri, 24 Feb 2023 16:12:25 +0100 (CET) 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 6564442D3C for ; Fri, 24 Feb 2023 16:12:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251543; 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=9QDwi+7WhFrIcDtHhsxTZ9Ark+m4xRxs7VV2a6EW9og=; b=QUQeKw8eTgAgcYsnkq5+hCeUzu/P9Tyv9LPTChrvEV7GkpXb0YGVLOROILYaDCxSvZBaNz vXsZA+gVKpeICSK5wVaYGRSPOAW1RyI6H0Sl6Z6O8mdMYOFeTPWeL6j/Nw8+/YU31TQ3fC v/NBIsFjoBlMhPiUC3vrhCvwrjzKa7Q= 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-620-1MfDLGJNOhGDp4TeNmMuAg-1; Fri, 24 Feb 2023 10:12:20 -0500 X-MC-Unique: 1MfDLGJNOhGDp4TeNmMuAg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5115285A588; Fri, 24 Feb 2023 15:12:20 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EFB4404BEC0; Fri, 24 Feb 2023 15:12:19 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Andrew Rybchenko Subject: [PATCH v2 10/20] net/sfc: inherit lock annotations Date: Fri, 24 Feb 2023 16:11:33 +0100 Message-Id: <20230224151143.3274897-11-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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 4b03b101d8..017c3fb247 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 Fri Feb 24 15:11: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: 124533 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 145ED41D5F; Fri, 24 Feb 2023 16:13:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 338C742D12; Fri, 24 Feb 2023 16:12:32 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id E638842D12 for ; Fri, 24 Feb 2023 16:12:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251550; 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=FNKdnYQyMUzLNusZYQbwqNoGk9i+a3hOl3yqKhvqFhg=; b=LR9e2hHyZF0kLTVxNPaochjqxKZdZNvTQx7Wz6LWKGDystJEApmtkNXNuPp7iIeO2qWFiJ v3myXaZnErctwGcWXWsjIevQMkxh1I+xHhzIuU3moPa1NIsyJtU+wn7Jw1Kg/jXLPlwbHc 25Ka0RlI+tXgehzBDNK5zAv/1swAzAI= 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-505-pkgUXsjBOBSBzC1IRU_2pQ-1; Fri, 24 Feb 2023 10:12:23 -0500 X-MC-Unique: pkgUXsjBOBSBzC1IRU_2pQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2B93B1871D97; Fri, 24 Feb 2023 15:12:23 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DC06404BEC1; Fri, 24 Feb 2023 15:12:22 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Maxime Coquelin , Chenbo Xia Subject: [PATCH v2 11/20] net/virtio: annotate lock for guest announce Date: Fri, 24 Feb 2023 16:11:34 +0100 Message-Id: <20230224151143.3274897-12-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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 VIRTIO_DEV_TO_HW(dev)->state_lock lock. Signed-off-by: David Marchand --- drivers/net/virtio/virtio_ethdev.c | 8 ++++---- drivers/net/virtio/virtio_ethdev.h | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 0103d95920..a3de44958c 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1149,11 +1149,11 @@ virtio_dev_pause(struct rte_eth_dev *dev) { struct virtio_hw *hw = dev->data->dev_private; - rte_spinlock_lock(&hw->state_lock); + rte_spinlock_lock(&VIRTIO_DEV_TO_HW(dev)->state_lock); if (hw->started == 0) { /* Device is just stopped. */ - rte_spinlock_unlock(&hw->state_lock); + rte_spinlock_unlock(&VIRTIO_DEV_TO_HW(dev)->state_lock); return -1; } hw->started = 0; @@ -1174,7 +1174,7 @@ 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); + rte_spinlock_unlock(&VIRTIO_DEV_TO_HW(dev)->state_lock); } /* @@ -1217,7 +1217,7 @@ virtio_notify_peers(struct rte_eth_dev *dev) } /* If virtio port just stopped, no need to send RARP */ - if (virtio_dev_pause(dev) < 0) { + if (virtio_dev_pause(dev) != 0) { rte_pktmbuf_free(rarp_mbuf); return; } diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h index c08f382791..ece0130603 100644 --- a/drivers/net/virtio/virtio_ethdev.h +++ b/drivers/net/virtio/virtio_ethdev.h @@ -112,8 +112,11 @@ 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); +#define VIRTIO_DEV_TO_HW(dev) ((struct virtio_hw *)(dev)->data->dev_private) +int virtio_dev_pause(struct rte_eth_dev *dev) + __rte_exclusive_trylock_function(0, &VIRTIO_DEV_TO_HW(dev)->state_lock); +void virtio_dev_resume(struct rte_eth_dev *dev) + __rte_unlock_function(&VIRTIO_DEV_TO_HW(dev)->state_lock); 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, From patchwork Fri Feb 24 15:11: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: 124532 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 1940141D5F; Fri, 24 Feb 2023 16:13:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F36B042D32; Fri, 24 Feb 2023 16:12:29 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 294F040A87 for ; Fri, 24 Feb 2023 16:12:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251547; 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=DlhyGHyu2iuDkPb9YLhvdlpR0IDaMFlp3a5uHtcSOIs=; b=IwkKKDpGdMSVvCGet4wP7dmLzJ9aaRF6LIz1iBNt2WSFTZ33xFWhrJDx8gvz0IVqjPdIcB s/vty3bZdHdmPLXhe26EJT5geUoG016F3jISCyuu9Q4VueAf9hA4xtT9TskATCZ6ituxL1 n+BcAuOExRC/cKJ2zU5n8+XNmeqRKFk= 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-553-GJkKx8L9Nu6f9tZfd1xoNA-1; Fri, 24 Feb 2023 10:12:26 -0500 X-MC-Unique: GJkKx8L9Nu6f9tZfd1xoNA-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 1D46A80D0E3; Fri, 24 Feb 2023 15:12:26 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B38A2166B29; Fri, 24 Feb 2023 15:12:25 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Rosen Xu , Tianfei Zhang Subject: [PATCH v2 12/20] raw/ifpga: inherit lock annotations Date: Fri, 24 Feb 2023 16:11:35 +0100 Message-Id: <20230224151143.3274897-13-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-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 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 Fri Feb 24 15:11: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: 124534 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 EE05E41D5F; Fri, 24 Feb 2023 16:13:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B164742D3C; Fri, 24 Feb 2023 16:12:35 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 992C241151 for ; Fri, 24 Feb 2023 16:12:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251552; 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=xCxK/xLB+oxeBoLgNQJynT94ZXelKq+BK0zch25nYyc=; b=B5mA0mdycT4Ug31Se3gTNmO4daxNcrnX8V8eZgVDjkn/gWni5P3nVwwabsuYFnlh0QqN/L c62fGGNYMQhSMpoYGmK5BK3o41yQSIicmw8EUem2I+/vFEi8ep5Q7SRYupXkygyEe/hF3q FxUia9pguNAzE9LBrkG4B2IkzxEPXRg= 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-595-_kLBxya6NxOgn_wMmJlTQQ-1; Fri, 24 Feb 2023 10:12:29 -0500 X-MC-Unique: _kLBxya6NxOgn_wMmJlTQQ-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 CA2B31C041A2; Fri, 24 Feb 2023 15:12:28 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B4FC2026D4B; Fri, 24 Feb 2023 15:12:27 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Vijay Kumar Srivastava Subject: [PATCH v2 13/20] vdpa/sfc: inherit lock annotations Date: Fri, 24 Feb 2023 16:11:36 +0100 Message-Id: <20230224151143.3274897-14-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-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. 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 6401d4e16f..afa6b7e8ef 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 Fri Feb 24 15:11: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: 124535 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 0A1D141D5F; Fri, 24 Feb 2023 16:13:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F3E1442D46; Fri, 24 Feb 2023 16:12:36 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id C550342D41 for ; Fri, 24 Feb 2023 16:12:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251555; 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=i0FvZ0tRPnfF2GlOGHjrSOmc/x2xyhRFGRCH4vcWHAU=; b=VeI4MXVp5BWTxjKXCncpGuZTFDY7dp3pG9BitUiDy/gTsyxyAVFwDfZ/vDy6+rZsLvP2S7 kE+ly5gaYoNtcp48qHaInadn+JGAfhWuD2bn1F5drRAHzDHd049Ema0B8lhLIgkbknkOom ZUo4cNVQGfD5apDNtKitzngI6RrF10Y= 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-59-hLP9jQDROw21ModMqsseAw-1; Fri, 24 Feb 2023 10:12:32 -0500 X-MC-Unique: hLP9jQDROw21ModMqsseAw-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 9C6BF1C041A8; Fri, 24 Feb 2023 15:12:31 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB53D1121315; Fri, 24 Feb 2023 15:12:30 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Anatoly Burakov Subject: [PATCH v2 14/20] ipc: annotate pthread mutex Date: Fri, 24 Feb 2023 16:11:37 +0100 Message-Id: <20230224151143.3274897-15-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-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 pthread_cond_timedwait() requires pending_requests.lock being taken. Signed-off-by: David Marchand --- lib/eal/common/eal_common_proc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c index 1fc1d6c53b..aa060ae4dc 100644 --- a/lib/eal/common/eal_common_proc.c +++ b/lib/eal/common/eal_common_proc.c @@ -908,6 +908,9 @@ mp_request_async(const char *dst, struct rte_mp_msg *req, static int mp_request_sync(const char *dst, struct rte_mp_msg *req, struct rte_mp_reply *reply, const struct timespec *ts) +#ifdef RTE_EXEC_ENV_FREEBSD + __rte_exclusive_locks_required(pending_requests.lock) +#endif { int ret; pthread_condattr_t attr; From patchwork Fri Feb 24 15:11: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: 124536 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 CFE3741D5F; Fri, 24 Feb 2023 16:13:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 32BC742D3A; Fri, 24 Feb 2023 16:12:39 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id B258742D3D for ; Fri, 24 Feb 2023 16:12:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251557; 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=QHSias8zg/nWLRhrBkSMJQy7pTrcEFjgQUDrQoJnJHs=; b=B+hDL2gN/t5o/u+dNwzTx591pYvwYJOZKCqJ/68qfDeLyDhrRq7djqteWBEGkW0AcY/jqd YQ6eO9dMQww5z7pcfWstNoxT38iFR7BJWjRWshtlLdTZB8XRXIJYM1SPskx4q7SrB1VcGB TUNZiXz0cqAouTO2pucqF0+vT0/tLDY= 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-587-gauduz42MqS9cPFDxpzdlQ-1; Fri, 24 Feb 2023 10:12:35 -0500 X-MC-Unique: gauduz42MqS9cPFDxpzdlQ-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 8E99195D601; Fri, 24 Feb 2023 15:12:34 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8560C1121314; Fri, 24 Feb 2023 15:12:33 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Ori Kam , Ferruh Yigit , Andrew Rybchenko Subject: [PATCH v2 15/20] ethdev: annotate pthread mutex Date: Fri, 24 Feb 2023 16:11:38 +0100 Message-Id: <20230224151143.3274897-16-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-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 fts_enter/exit take mutexes depending on device flags set at initialisation. Annotate those helpers and, since clang does not support conditional locking, waive the lock check on their implementation. Signed-off-by: David Marchand --- lib/ethdev/rte_flow.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 69e6e749f7..c66625d1fe 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -297,6 +297,10 @@ rte_flow_dynf_metadata_register(void) static inline void fts_enter(struct rte_eth_dev *dev) +#ifdef RTE_EXEC_ENV_FREEBSD + __rte_exclusive_lock_function(dev->data->flow_ops_mutex) + __rte_no_thread_safety_analysis +#endif { if (!(dev->data->dev_flags & RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE)) pthread_mutex_lock(&dev->data->flow_ops_mutex); @@ -304,6 +308,10 @@ fts_enter(struct rte_eth_dev *dev) static inline void fts_exit(struct rte_eth_dev *dev) +#ifdef RTE_EXEC_ENV_FREEBSD + __rte_unlock_function(dev->data->flow_ops_mutex) + __rte_no_thread_safety_analysis +#endif { if (!(dev->data->dev_flags & RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE)) pthread_mutex_unlock(&dev->data->flow_ops_mutex); From patchwork Fri Feb 24 15:11: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: 124537 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 C7EEC41D5F; Fri, 24 Feb 2023 16:13:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CD20F42D4F; Fri, 24 Feb 2023 16:12:43 +0100 (CET) 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 B4C4540A87 for ; Fri, 24 Feb 2023 16:12:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251561; 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=XH0Q63zUNT3pFmnDlCqConhXmxmDu4cPjrPGC8/AXiQ=; b=HPqlz70FTDJueT/HHIL7KEhqE1wRDvR7Yn9Iaj3zxKKe/wCPhC1mL8o0wan3wspmC1RggG 2p9MwpoB8JinIYsz5NBRvXlyrDREhY8q5BAubT4MzIhxYqdHJji+BDnFG8uctxhrvfK+PJ xyGnadaq1rimIpG6koWSUAHp9Ff4d0c= 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-568-X1JhKFepOZOQi8Ksfzrixw-1; Fri, 24 Feb 2023 10:12:37 -0500 X-MC-Unique: X1JhKFepOZOQi8Ksfzrixw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8EC3E29A9CA0; Fri, 24 Feb 2023 15:12:37 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id A126A492B13; Fri, 24 Feb 2023 15:12:36 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Gaetan Rivet Subject: [PATCH v2 16/20] net/failsafe: fix mutex locking Date: Fri, 24 Feb 2023 16:11:39 +0100 Message-Id: <20230224151143.3274897-17-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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 Fri Feb 24 15:11: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: 124538 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 B380741D5F; Fri, 24 Feb 2023 16:13:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 13EA542D3D; Fri, 24 Feb 2023 16:12:46 +0100 (CET) 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 567CF42C24 for ; Fri, 24 Feb 2023 16:12:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251563; 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=1x0ozyplJfxRGA50pWZ/HfMRUddCkTN1RWYJADUinE0=; b=i8HJbaQBIhgJAhN9HynGw8Yfw+9MPoLzzGnL2Dz/qkPBgtso1cG7VqpR4l1obghcS15/AY Jv0CqWMXnzULCQOFSAV0fzyLI7PW4GXiOePu0ipROplpOdTTL0QZcLIh3GIRI1BoHx+amV Tp9GtfJNh929vMShOYqsl3tIOny40EE= 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-550-2NBkWV70P0aY2lIwhTSp-Q-1; Fri, 24 Feb 2023 10:12:40 -0500 X-MC-Unique: 2NBkWV70P0aY2lIwhTSp-Q-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 3B0401C04184; Fri, 24 Feb 2023 15:12:40 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A4AA492B07; Fri, 24 Feb 2023 15:12:39 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Gaetan Rivet Subject: [PATCH v2 17/20] net/failsafe: annotate pthread mutex Date: Fri, 24 Feb 2023 16:11:40 +0100 Message-Id: <20230224151143.3274897-18-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-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 Annotate wrappers on top of the pthread mutex API. Signed-off-by: David Marchand --- drivers/net/failsafe/failsafe_private.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h index 53a451c1b1..97b6f5300d 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -403,6 +403,9 @@ fs_dev(struct sub_device *sdev) { */ static inline int fs_lock(struct rte_eth_dev *dev, unsigned int is_alarm) +#ifdef RTE_EXEC_ENV_FREEBSD + __rte_exclusive_trylock_function(0, PRIV(dev)->hotplug_mutex) +#endif { int ret; @@ -430,6 +433,9 @@ fs_lock(struct rte_eth_dev *dev, unsigned int is_alarm) */ static inline void fs_unlock(struct rte_eth_dev *dev, unsigned int is_alarm) +#ifdef RTE_EXEC_ENV_FREEBSD + __rte_unlock_function(PRIV(dev)->hotplug_mutex) +#endif { int ret; From patchwork Fri Feb 24 15:11:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124539 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 ADEA441D5F; Fri, 24 Feb 2023 16:13:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A147742D52; Fri, 24 Feb 2023 16:12:50 +0100 (CET) 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 6EC0242D44 for ; Fri, 24 Feb 2023 16:12:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251569; 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=GG+VE/hQPkh0vpXYERM6KnBZ6Pq1nqAwckzjQfIDZ8c=; b=TN/K1dTNefRR//lY0e5wUwxFNhjU5lIuhkjZpQOiLQhoGuPmqYDeXlVG8Xr0eFREI7iqJe sOMHXv+rF1mNjO7+z+VVQpEN9+qpd9doPnGbsHi9JkmUhjdXQLJXetdApqnUTTSL9Fh+jV t/fhUsziSvR5IIAC2lIoEGaghH7yFxI= 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-610-GiB4iw4lPcWH2TU3NFYg5w-1; Fri, 24 Feb 2023 10:12:43 -0500 X-MC-Unique: GiB4iw4lPcWH2TU3NFYg5w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5214C85A588; Fri, 24 Feb 2023 15:12:43 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B69A404BEC0; Fri, 24 Feb 2023 15:12:42 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Ziyang Xuan , Xiaoyun Wang , Guoyang Zhou Subject: [PATCH v2 18/20] net/hinic: annotate pthread mutex Date: Fri, 24 Feb 2023 16:11:41 +0100 Message-Id: <20230224151143.3274897-19-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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 Annotate wrappers on top of the pthread mutex API. Signed-off-by: David Marchand --- drivers/net/hinic/base/hinic_compat.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/hinic/base/hinic_compat.h b/drivers/net/hinic/base/hinic_compat.h index aea332046e..89732ca11a 100644 --- a/drivers/net/hinic/base/hinic_compat.h +++ b/drivers/net/hinic/base/hinic_compat.h @@ -224,6 +224,9 @@ static inline int hinic_mutex_destroy(pthread_mutex_t *pthreadmutex) } static inline int hinic_mutex_lock(pthread_mutex_t *pthreadmutex) +#ifdef RTE_EXEC_ENV_FREEBSD + __rte_exclusive_trylock_function(0, *pthreadmutex) +#endif { int err; struct timespec tout; @@ -239,6 +242,9 @@ static inline int hinic_mutex_lock(pthread_mutex_t *pthreadmutex) } static inline int hinic_mutex_unlock(pthread_mutex_t *pthreadmutex) +#ifdef RTE_EXEC_ENV_FREEBSD + __rte_unlock_function(*pthreadmutex) +#endif { return pthread_mutex_unlock(pthreadmutex); } From patchwork Fri Feb 24 15:11:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124541 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 307F241D5F; Fri, 24 Feb 2023 16:14:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 87BD342D0C; Fri, 24 Feb 2023 16:13:28 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 2AB3842B71 for ; Fri, 24 Feb 2023 16:13:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251605; 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=LAaNZzwjd6K03wsRMhv78Ubbb1H6T52kcIxWPjLjU2kDOdhNY4CBctMK5EhVRvk2vC0bOG s7DHx+QDWqPpljgmmMavLw9natlR1dZgC3ZHJ4QQpvvV53JWoKKxPLjNp4aNfVvbsZzY6i yip13eZ+k1SJc9Le6irpfLAwRWV2d0E= 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-441-NHDPdh_ZMSOJYRrwdu0_BA-1; Fri, 24 Feb 2023 10:13:11 -0500 X-MC-Unique: NHDPdh_ZMSOJYRrwdu0_BA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 639EA1871D9C; Fri, 24 Feb 2023 15:12:46 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D274492B12; Fri, 24 Feb 2023 15:12:45 +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 v2 19/20] eal/windows: disable lock check on alarm code Date: Fri, 24 Feb 2023 16:11:42 +0100 Message-Id: <20230224151143.3274897-20-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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 --- 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 Fri Feb 24 15:11:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 124540 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 B0AE041D5F; Fri, 24 Feb 2023 16:13:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3425A41141; Fri, 24 Feb 2023 16:12:59 +0100 (CET) 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 A0AE441143 for ; Fri, 24 Feb 2023 16:12:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251577; 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=zTdKAsfU6rHWPaDywfC6VbQKozW84Mrn5zWEqJ/zf7o=; b=aYHpClzsb0XOx215urWOHFJ7FNMAEIpM+b4zlrgjuKdpd1dXjqrHdIyJLbdfgYFpxL/YzY cROq3HAbfhfmotX7Rc0vRiwWFPkNMTRJ4WwdwnEeSFQTwknEhi0LiFevtnBJICB8aqR1Tm paMU0lt+Jz3FltNHswczpNkZ6SpTHXU= 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-396-cMwhfRs5N2mAKD9DEgjoCA-1; Fri, 24 Feb 2023 10:12:54 -0500 X-MC-Unique: cMwhfRs5N2mAKD9DEgjoCA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B3E423C02B7E; Fri, 24 Feb 2023 15:12:52 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 805C7140EBF6; Fri, 24 Feb 2023 15:12:48 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, 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 , Dongdong Liu , Yisen Zhuang , Konstantin Ananyev , Vladimir Medvedkin , Erik Gabriel Carrillo , Maxime Coquelin , Chenbo Xia Subject: [PATCH v2 20/20] enable lock check Date: Fri, 24 Feb 2023 16:11:43 +0100 Message-Id: <20230224151143.3274897-21-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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, Signed-off-by: David Marchand Reviewed-by: Chenbo Xia --- 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/hns3/meson.build | 1 + drivers/net/mlx5/meson.build | 1 + lib/ipsec/meson.build | 1 + lib/meson.build | 2 +- lib/timer/meson.build | 1 + lib/vhost/meson.build | 1 - 16 files changed, 17 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 849735921c..9beb1cddba 100644 --- a/drivers/common/cnxk/meson.build +++ b/drivers/common/cnxk/meson.build @@ -88,3 +88,4 @@ sources += files('cnxk_telemetry_bphy.c', deps += ['bus_pci', 'net', 'telemetry'] pmd_supports_disable_iova_as_pa = true +annotate_locks = false diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build index 60ccd95cbc..d38255dc82 100644 --- a/drivers/common/mlx5/meson.build +++ b/drivers/common/mlx5/meson.build @@ -40,3 +40,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 aa42ab3a90..20c6a0484a 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'] pmd_supports_disable_iova_as_pa = true +annotate_locks = false diff --git a/drivers/meson.build b/drivers/meson.build index 0618c31a69..d529980fc5 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -91,7 +91,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 09d494e90f..f43dbfc445 100644 --- a/drivers/net/bnxt/meson.build +++ b/drivers/net/bnxt/meson.build @@ -68,3 +68,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 c7ca24d437..86ed2d13dd 100644 --- a/drivers/net/cnxk/meson.build +++ b/drivers/net/cnxk/meson.build @@ -196,3 +196,4 @@ endforeach headers = files('rte_pmd_cnxk.h') pmd_supports_disable_iova_as_pa = true +annotate_locks = false diff --git a/drivers/net/enic/meson.build b/drivers/net/enic/meson.build index 7131a25f09..1523511ba5 100644 --- a/drivers/net/enic/meson.build +++ b/drivers/net/enic/meson.build @@ -39,3 +39,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/hns3/meson.build b/drivers/net/hns3/meson.build index e1a5afa2ec..43e52e6107 100644 --- a/drivers/net/hns3/meson.build +++ b/drivers/net/hns3/meson.build @@ -38,6 +38,7 @@ sources = files( 'hns3_common.c', 'hns3_dump.c', ) +annotate_locks = false deps += ['hash'] diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build index abd507bd88..5e7d0d4e1a 100644 --- a/drivers/net/mlx5/meson.build +++ b/drivers/net/mlx5/meson.build @@ -79,3 +79,4 @@ testpmd_sources += files('mlx5_testpmd.c') subdir(exec_env) subdir('hws') +annotate_locks = false 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 2bc0932ad5..9b5e412454 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -120,7 +120,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',