From patchwork Fri Feb 24 08:16: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: 124491 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 F13A841D5D; Fri, 24 Feb 2023 09:17:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6822940EF1; Fri, 24 Feb 2023 09:17:01 +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 2E4DE40693 for ; Fri, 24 Feb 2023 09:17:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226619; 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=hVMDxBnr7rSFX7BBtxoRRpJwzYVNX3doTYQqYsoTvC3O2pVsDq/rdb96XExqksfx1zSMeB im9gg09Ad5EfFP5G2IW87SqqXzpMrYDIXXuI7GqW47QB2s82K9FECzTeyQEYxPac1GOClS ++2JQZK7wPNI2lfpDwksz0y9YSoF1us= 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-669-eAVmm8YxPV6srYQOjMJzDQ-1; Fri, 24 Feb 2023 03:16:55 -0500 X-MC-Unique: eAVmm8YxPV6srYQOjMJzDQ-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 CB2D9800B23; Fri, 24 Feb 2023 08:16:54 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03B8B492B07; Fri, 24 Feb 2023 08:16:53 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Anatoly Burakov Subject: [PATCH 01/14] malloc: rework heap lock handling Date: Fri, 24 Feb 2023 09:16:29 +0100 Message-Id: <20230224081642.2566619-2-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-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 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 08:16: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: 124493 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 72DB541D5D; Fri, 24 Feb 2023 09:17:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF3CF41141; Fri, 24 Feb 2023 09:17:05 +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 C0BDD410F1 for ; Fri, 24 Feb 2023 09:17:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226623; 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=HvicpDChKA79o1A0mgQr1JtZOeXaeipgbc9vjVuKIYDtyvGxsOYnDKpD2Pfv1cDkAExE1K XYSlFu2iL7DlNLoqADwJPFrVkOSDuWnS9xJRdFCFgEfBUL26V/f8gm/M1EmlDGhh0V6bXH k7TmnSMM+VoYwVOwUlQm9oCggYvLMzY= 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-331-2UpEEXlEOvaMK1I_i13BMA-1; Fri, 24 Feb 2023 03:16:59 -0500 X-MC-Unique: 2UpEEXlEOvaMK1I_i13BMA-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 6126C811E9C; Fri, 24 Feb 2023 08:16:58 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF8FC440D8; Fri, 24 Feb 2023 08:16:56 +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 02/14] mem: rework malloc heap init Date: Fri, 24 Feb 2023 09:16:30 +0100 Message-Id: <20230224081642.2566619-3-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-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 08:16: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: 124492 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 22F5E41D5D; Fri, 24 Feb 2023 09:17:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7B22A410F1; Fri, 24 Feb 2023 09:17: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 30795410F1 for ; Fri, 24 Feb 2023 09:17:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226622; 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=G6qiKOUcYasllJwUoCqmQRuY6XeERQcWdpTgIGNiho4BaJUBK4j7qtJIXl5NZsKBh0BCrl y6ZIL89HwXiXqrX7CEAYdamd4sw2CjOx6prnGa80O8leIqbQJGwTfDaAgbyBjHlPNFJunc XB0ATlOq5cnotTv6nmbFoeXj28f2HGs= 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-208-WR9MZYMnN1GsLgdxjCdpow-1; Fri, 24 Feb 2023 03:17:01 -0500 X-MC-Unique: WR9MZYMnN1GsLgdxjCdpow-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 E5C063C02527; Fri, 24 Feb 2023 08:17:00 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50376492B12; Fri, 24 Feb 2023 08:17:00 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net Subject: [PATCH 03/14] mem: annotate shared memory config locks Date: Fri, 24 Feb 2023 09:16:31 +0100 Message-Id: <20230224081642.2566619-4-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-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 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 08:16: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: 124494 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 2B6A141D5D; Fri, 24 Feb 2023 09:17:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7D29C4161A; Fri, 24 Feb 2023 09:17: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 B450241140 for ; Fri, 24 Feb 2023 09:17:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226630; 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=aj7SGoFoKFeNwLJEGlmTCJ8QT8NdB7FJ/SNn1ttmFUW6ZpRyg09O6nPYHID7N8Pp6cSzVq v1Woaz2Wbr6Ec/8DRklBvOjStysYqIOc56R7uh+gjTueLOn1SUeTK6aqCfCjprOIYzvonj 2rghYRUo6UjAd2dDUnJeiSXaqu4H1v0= 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-576-QB5EeKr6N22prtBSGmRVdQ-1; Fri, 24 Feb 2023 03:17:04 -0500 X-MC-Unique: QB5EeKr6N22prtBSGmRVdQ-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 2462E1875043; Fri, 24 Feb 2023 08:17:04 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1B86C15BA0; Fri, 24 Feb 2023 08:17:02 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH 04/14] hash: annotate cuckoo hash lock Date: Fri, 24 Feb 2023 09:16:32 +0100 Message-Id: <20230224081642.2566619-5-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-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 __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 08:16: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: 124495 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 8F34A41D5D; Fri, 24 Feb 2023 09:17:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9F829427F5; Fri, 24 Feb 2023 09:17:14 +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 4726841140 for ; Fri, 24 Feb 2023 09:17:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226630; 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=UWrbUsFiLStyeJtNu+vHIE1uFFUEgxnSGjdzuiYbpL/FuAbFjbRwVhXSoX1Cjiu+eKejd4 O4tqsc8l6MHwV5sFqwQk08PCamFp1LNoBNGWxrhI1v3b7znq/jqw2Y6r+GvUAT3Uqf+ewu J74p+nHTyn+I7UIW6Es/9vhA79oBsjM= 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-315-jhdxto-nO76stHGrWG030A-1; Fri, 24 Feb 2023 03:17:07 -0500 X-MC-Unique: jhdxto-nO76stHGrWG030A-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 16FF329A9D2A; Fri, 24 Feb 2023 08:17:07 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E8E0492B12; Fri, 24 Feb 2023 08:17:05 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram Subject: [PATCH 05/14] graph: annotate graph lock Date: Fri, 24 Feb 2023 09:16:33 +0100 Message-Id: <20230224081642.2566619-6-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-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 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 08:16: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: 124497 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 3E00341D5D; Fri, 24 Feb 2023 09:17:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D89CD42BFE; Fri, 24 Feb 2023 09:17: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 423434114B for ; Fri, 24 Feb 2023 09:17:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226635; 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=gpNkBqfills+F3ztvZH3hQcnxnRBvNnq7dJbLENPGZonVrW9/yGk4FCMQZ8MuC8INfxQ7B Mcz3WhisiZUh5cKs9NvgQqVNaCJi5G4LoJJHTDD+PANbDYH6qrzagk3raLrB26bq5u/KpR BslExGdsBoRBGNYIhjCAJk+TeRL5FlQ= 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-477-ucf2JJT4MCWtkp7HwARfew-1; Fri, 24 Feb 2023 03:17:11 -0500 X-MC-Unique: ucf2JJT4MCWtkp7HwARfew-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 79CBC811E9C; Fri, 24 Feb 2023 08:17:10 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2848F440D8; Fri, 24 Feb 2023 08:17:09 +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 06/14] drivers: inherit lock annotations for Intel drivers Date: Fri, 24 Feb 2023 09:16:34 +0100 Message-Id: <20230224081642.2566619-7-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Due to clang limitation, inline helpers don't inherit lock annotations from the EAL lock API. Replace them with macros. Signed-off-by: David Marchand --- drivers/common/iavf/iavf_osdep.h | 39 ++++++-------------------- drivers/common/iavf/iavf_prototype.h | 6 ---- drivers/common/idpf/base/idpf_osdep.h | 26 +++-------------- drivers/net/i40e/base/i40e_osdep.h | 8 +++--- drivers/net/i40e/base/i40e_prototype.h | 5 ---- drivers/net/i40e/i40e_ethdev.c | 24 ---------------- drivers/net/ice/base/ice_osdep.h | 26 +++-------------- 7 files changed, 20 insertions(+), 114 deletions(-) diff --git a/drivers/common/iavf/iavf_osdep.h b/drivers/common/iavf/iavf_osdep.h index 31d3d809f9..263d92400c 100644 --- a/drivers/common/iavf/iavf_osdep.h +++ b/drivers/common/iavf/iavf_osdep.h @@ -170,11 +170,6 @@ struct iavf_virt_mem { u32 size; } __rte_packed; -/* SW spinlock */ -struct iavf_spinlock { - rte_spinlock_t spinlock; -}; - #define iavf_allocate_dma_mem(h, m, unused, s, a) \ iavf_allocate_dma_mem_d(h, m, s, a) #define iavf_free_dma_mem(h, m) iavf_free_dma_mem_d(h, m) @@ -182,32 +177,14 @@ struct iavf_spinlock { #define iavf_allocate_virt_mem(h, m, s) iavf_allocate_virt_mem_d(h, m, s) #define iavf_free_virt_mem(h, m) iavf_free_virt_mem_d(h, m) -static inline void -iavf_init_spinlock_d(struct iavf_spinlock *sp) -{ - rte_spinlock_init(&sp->spinlock); -} - -static inline void -iavf_acquire_spinlock_d(struct iavf_spinlock *sp) -{ - rte_spinlock_lock(&sp->spinlock); -} - -static inline void -iavf_release_spinlock_d(struct iavf_spinlock *sp) -{ - rte_spinlock_unlock(&sp->spinlock); -} - -static inline void -iavf_destroy_spinlock_d(__rte_unused struct iavf_spinlock *sp) -{ -} +/* SW spinlock */ +struct iavf_spinlock { + rte_spinlock_t spinlock; +}; -#define iavf_init_spinlock(_sp) iavf_init_spinlock_d(_sp) -#define iavf_acquire_spinlock(_sp) iavf_acquire_spinlock_d(_sp) -#define iavf_release_spinlock(_sp) iavf_release_spinlock_d(_sp) -#define iavf_destroy_spinlock(_sp) iavf_destroy_spinlock_d(_sp) +#define iavf_init_spinlock(sp) rte_spinlock_init(&(sp)->spinlock) +#define iavf_acquire_spinlock(sp) rte_spinlock_lock(&(sp)->spinlock) +#define iavf_release_spinlock(sp) rte_spinlock_unlock(&(sp)->spinlock) +#define iavf_destroy_spinlock(sp) RTE_SET_USED(sp) #endif /* _IAVF_OSDEP_H_ */ diff --git a/drivers/common/iavf/iavf_prototype.h b/drivers/common/iavf/iavf_prototype.h index b5124de5bf..ba78ec5169 100644 --- a/drivers/common/iavf/iavf_prototype.h +++ b/drivers/common/iavf/iavf_prototype.h @@ -76,12 +76,6 @@ STATIC INLINE struct iavf_rx_ptype_decoded decode_rx_desc_ptype(u8 ptype) return iavf_ptype_lookup[ptype]; } -/* prototype for functions used for SW spinlocks */ -void iavf_init_spinlock(struct iavf_spinlock *sp); -void iavf_acquire_spinlock(struct iavf_spinlock *sp); -void iavf_release_spinlock(struct iavf_spinlock *sp); -void iavf_destroy_spinlock(struct iavf_spinlock *sp); - __rte_internal void iavf_vf_parse_hw_config(struct iavf_hw *hw, struct virtchnl_vf_resource *msg); diff --git a/drivers/common/idpf/base/idpf_osdep.h b/drivers/common/idpf/base/idpf_osdep.h index 99ae9cf60a..49bd7c4b21 100644 --- a/drivers/common/idpf/base/idpf_osdep.h +++ b/drivers/common/idpf/base/idpf_osdep.h @@ -210,28 +210,10 @@ struct idpf_lock { rte_spinlock_t spinlock; }; -static inline void -idpf_init_lock(struct idpf_lock *sp) -{ - rte_spinlock_init(&sp->spinlock); -} - -static inline void -idpf_acquire_lock(struct idpf_lock *sp) -{ - rte_spinlock_lock(&sp->spinlock); -} - -static inline void -idpf_release_lock(struct idpf_lock *sp) -{ - rte_spinlock_unlock(&sp->spinlock); -} - -static inline void -idpf_destroy_lock(__rte_unused struct idpf_lock *sp) -{ -} +#define idpf_init_lock(sp) rte_spinlock_init(&(sp)->spinlock) +#define idpf_acquire_lock(sp) rte_spinlock_lock(&(sp)->spinlock) +#define idpf_release_lock(sp) rte_spinlock_unlock(&(sp)->spinlock) +#define idpf_destroy_lock(sp) RTE_SET_USED(sp) struct idpf_hw; diff --git a/drivers/net/i40e/base/i40e_osdep.h b/drivers/net/i40e/base/i40e_osdep.h index 51537c5cf3..aa5dc61841 100644 --- a/drivers/net/i40e/base/i40e_osdep.h +++ b/drivers/net/i40e/base/i40e_osdep.h @@ -215,10 +215,10 @@ struct i40e_spinlock { rte_spinlock_t spinlock; }; -#define i40e_init_spinlock(_sp) i40e_init_spinlock_d(_sp) -#define i40e_acquire_spinlock(_sp) i40e_acquire_spinlock_d(_sp) -#define i40e_release_spinlock(_sp) i40e_release_spinlock_d(_sp) -#define i40e_destroy_spinlock(_sp) i40e_destroy_spinlock_d(_sp) +#define i40e_init_spinlock(sp) rte_spinlock_init(&(sp)->spinlock) +#define i40e_acquire_spinlock(sp) rte_spinlock_lock(&(sp)->spinlock) +#define i40e_release_spinlock(sp) rte_spinlock_unlock(&(sp)->spinlock) +#define i40e_destroy_spinlock(sp) RTE_SET_USED(sp) #define I40E_NTOHS(a) rte_be_to_cpu_16(a) #define I40E_NTOHL(a) rte_be_to_cpu_32(a) diff --git a/drivers/net/i40e/base/i40e_prototype.h b/drivers/net/i40e/base/i40e_prototype.h index 29c86c7fe8..691c977172 100644 --- a/drivers/net/i40e/base/i40e_prototype.h +++ b/drivers/net/i40e/base/i40e_prototype.h @@ -546,11 +546,6 @@ i40e_virtchnl_link_speed(enum i40e_aq_link_speed link_speed) } } #endif /* PF_DRIVER */ -/* prototype for functions used for SW spinlocks */ -void i40e_init_spinlock(struct i40e_spinlock *sp); -void i40e_acquire_spinlock(struct i40e_spinlock *sp); -void i40e_release_spinlock(struct i40e_spinlock *sp); -void i40e_destroy_spinlock(struct i40e_spinlock *sp); /* i40e_common for VF drivers*/ void i40e_vf_parse_hw_config(struct i40e_hw *hw, diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 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 08:16: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: 124496 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 DFB8C41D5D; Fri, 24 Feb 2023 09:17:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B5EDD41151; Fri, 24 Feb 2023 09:17:16 +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 6649D42B8B for ; Fri, 24 Feb 2023 09:17:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226634; 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=CPqP/Q6oZBIGdS0PN8OOcmx2oePbMx5Z05P1LFYHRjhW6oAibNUj1VgWwTM9XnAvAAvOhI MBpobyFK7TlzdRNo214Cwru8eZBgNq9M8c7PiYh9af8X4FY20L01TrwLTyP+S5ig1ekylu wurRryAV9Xar7AhuyjkbdtCjYXff+F4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-yvfXlPS4PM2dSVsIm146Jw-1; Fri, 24 Feb 2023 03:17:13 -0500 X-MC-Unique: yvfXlPS4PM2dSVsIm146Jw-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 2B4223C02524; Fri, 24 Feb 2023 08:17:13 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64340492B07; Fri, 24 Feb 2023 08:17:12 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Rahul Lakkireddy Subject: [PATCH 07/14] net/cxgbe: inherit lock annotations Date: Fri, 24 Feb 2023 09:16:35 +0100 Message-Id: <20230224081642.2566619-8-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-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 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 08:16: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: 124498 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 19C3F41D5D; Fri, 24 Feb 2023 09:17:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7595642D29; Fri, 24 Feb 2023 09:17:21 +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 6D04D41611 for ; Fri, 24 Feb 2023 09:17:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226640; 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=EVFPrv4m5PsmY2v777bqJTenKOM3m1+GvPnQkif0Sy5JFqrNi7bAsMoO3SslCihjdSchR6 uaXliGycQCOjeF59ixq2anHZqAMvZOBxAd6n2ysAUD8v+pRVBUai55y1bJWTj99B9pHSMn 3stvWAqj/auyjeQfyrgpaSfdJPGMtD4= 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-140-fFWbbh-cN3qLdSlcFIUi1A-1; Fri, 24 Feb 2023 03:17:16 -0500 X-MC-Unique: fFWbbh-cN3qLdSlcFIUi1A-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 1C3511875043; Fri, 24 Feb 2023 08:17:16 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A0FF2166B29; Fri, 24 Feb 2023 08:17:15 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Qi Zhang , Xiao Wang Subject: [PATCH 08/14] net/fm10k: annotate mailbox lock Date: Fri, 24 Feb 2023 09:16:36 +0100 Message-Id: <20230224081642.2566619-9-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-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 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 08:16: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: 124499 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 6D6DC41D5D; Fri, 24 Feb 2023 09:17:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B186142C54; Fri, 24 Feb 2023 09:17:24 +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 5B60D41611 for ; Fri, 24 Feb 2023 09:17:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226640; 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=Y8zjc1vdYK5JIE2yIZuD3xPNMgbkZQeBoauiL0gnlbxOGJFxmMfmBP3ncaspCRn+coX2bN HlImXDD1yfcBvA2c7VxOBOJ4Gii97+FYNkFqhOIJSRbD5EaO++hSfyL7+aRgivbErrLwra 65b8xvIhf9tGylQxUf3gPLb34Ta5ZWs= 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-327-s9YItj0IO8yvaR4AFU97tg-1; Fri, 24 Feb 2023 03:17:19 -0500 X-MC-Unique: s9YItj0IO8yvaR4AFU97tg-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 C0CFA29A9D3D; Fri, 24 Feb 2023 08:17:18 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 088C2492B07; Fri, 24 Feb 2023 08:17:17 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Andrew Rybchenko Subject: [PATCH 09/14] net/sfc: rework locking in proxy code Date: Fri, 24 Feb 2023 09:16:37 +0100 Message-Id: <20230224081642.2566619-10-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-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 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 08:16: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: 124500 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 7E38A41D5D; Fri, 24 Feb 2023 09:17:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3D1542D1A; Fri, 24 Feb 2023 09:17:27 +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 C11D842D0E for ; Fri, 24 Feb 2023 09:17:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226645; 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=haPL9WEOKkE7nZyuCwKvLouksj4hbNik8ttygu+gkM/ZvYf4A6fwRl/FzVJB4DE2RZ7OCs JN6BKEKm8LH1CA4CJJfeTjgORrJXStG/Iam5qrUJmlV0ZTcIkzddZOiuj1kEuErleHbRj7 +ZFFUldzlXfLj8+h9w8EPJz/CW0BnNE= 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-352-fqmpdo14MPy8STzguYFwCw-1; Fri, 24 Feb 2023 03:17:21 -0500 X-MC-Unique: fqmpdo14MPy8STzguYFwCw-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 8EA6029A9D2A; Fri, 24 Feb 2023 08:17:21 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE8A7C15BA0; Fri, 24 Feb 2023 08:17:20 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Andrew Rybchenko Subject: [PATCH 10/14] net/sfc: inherit lock annotations Date: Fri, 24 Feb 2023 09:16:38 +0100 Message-Id: <20230224081642.2566619-11-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-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. 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 08:16: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: 124501 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 B323841D5D; Fri, 24 Feb 2023 09:18:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5459A42D32; Fri, 24 Feb 2023 09:17:30 +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 CF09242D10 for ; Fri, 24 Feb 2023 09:17:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226646; 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=Go8VU6gjqp6lfeQu1wX7qHB5Kr9xrQI5h0UvzeVS61hCW/GclcM0u/E+OlvSZi+9W8zR1p avP2lopWSGJLIvoIwqukUpSFOmXhgT3DbtYtB38RRFvkPCru7Q6EVnetFtHQBW/MqTPVob sdpJEicUwjG3AvsvH1LMCSe9+mthdSg= 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-532-3oWhGuE4Ncyc9kOWTfP_5w-1; Fri, 24 Feb 2023 03:17:24 -0500 X-MC-Unique: 3oWhGuE4Ncyc9kOWTfP_5w-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 6E95185D061; Fri, 24 Feb 2023 08:17:24 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C4FF2166B29; Fri, 24 Feb 2023 08:17:23 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Maxime Coquelin , Chenbo Xia Subject: [PATCH 11/14] net/virtio: annotate lock for guest announce Date: Fri, 24 Feb 2023 09:16:39 +0100 Message-Id: <20230224081642.2566619-12-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-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 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 08:16: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: 124502 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 68B8A41D5D; Fri, 24 Feb 2023 09:18:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7956142D3A; Fri, 24 Feb 2023 09:17:33 +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 0B82942D0B for ; Fri, 24 Feb 2023 09:17:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226651; 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=EwUXfYcfsohDtcW6q6WSl+09WfG+QtOMR7thxQkUBa8YpRBgKFfwhjUpC3WGpZbztSbdEE XtI9JJB0UnraYjZvcezrxr8NSZIUI1hULU+llQrHlG+fXXjKvdL+gnWvMbXHfMHxGANtvZ bxLNvE8C+ydLVQDG9K6c0vh+dg9P8Qs= 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-81-K9tNDryBNGGE_weYtvmkfg-1; Fri, 24 Feb 2023 03:17:27 -0500 X-MC-Unique: K9tNDryBNGGE_weYtvmkfg-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 6020E38041CF; Fri, 24 Feb 2023 08:17:27 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7DECF404BEC1; Fri, 24 Feb 2023 08:17:26 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Rosen Xu , Tianfei Zhang Subject: [PATCH 12/14] raw/ifpga: inherit lock annotations Date: Fri, 24 Feb 2023 09:16:40 +0100 Message-Id: <20230224081642.2566619-13-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-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 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 --- 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 08:16: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: 124503 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 AB2CF41D5D; Fri, 24 Feb 2023 09:18:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C9DFF42D3D; Fri, 24 Feb 2023 09:17:35 +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 7769D42D1D for ; Fri, 24 Feb 2023 09:17:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226654; 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=bQ4XUZbx1qN1EdaGqbdnNSw0VTArbfF7BADFkhFsXtkxKiQBzJJRLtWRYbwUhGkM27hyHK su+UI5UvqocGrg5z8K2k53uj6EPWRKYTVBGaaqFh1ou/lqg45LcCgNOWCQOE174yrz82c/ js/5tyOcEKJs0R5jK/+go2YnMoes9co= 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-586-9GK8Mw8WNKGoWvEdgLZkOA-1; Fri, 24 Feb 2023 03:17:30 -0500 X-MC-Unique: 9GK8Mw8WNKGoWvEdgLZkOA-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 125C438041D0; Fri, 24 Feb 2023 08:17:30 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A59A2026D4B; Fri, 24 Feb 2023 08:17:29 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Vijay Kumar Srivastava Subject: [PATCH 13/14] vdpa/sfc: inherit lock annotations Date: Fri, 24 Feb 2023 09:16:41 +0100 Message-Id: <20230224081642.2566619-14-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-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 08:16: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: 124504 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 B23B441D5D; Fri, 24 Feb 2023 09:18:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 844CB40697; Fri, 24 Feb 2023 09:17:43 +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 4B7EC4113D for ; Fri, 24 Feb 2023 09:17:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677226661; 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=cyUOL38FKL36V1Jp8EPUT41X+HXl36Ea85whCuzUYJHmvpSqAsxyl7LpiFqbTiCH+Ql501 fzAw1l4Xu7zyp3uIMA9GMaJd01XrULkHShW/JtGyLwCafaakBlBR7ANLM98PPSZbzqhYWd myhzX+C5WPadgg5VukNFdLrNzl4J19k= 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-47-xrhyPvTRPAWGJ1oj3WRmtQ-1; Fri, 24 Feb 2023 03:17:38 -0500 X-MC-Unique: xrhyPvTRPAWGJ1oj3WRmtQ-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 8E26E1C05AFB; Fri, 24 Feb 2023 08:17:36 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 278201121315; Fri, 24 Feb 2023 08:17:32 +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 14/14] enable lock check Date: Fri, 24 Feb 2023 09:16:42 +0100 Message-Id: <20230224081642.2566619-15-david.marchand@redhat.com> In-Reply-To: <20230224081642.2566619-1-david.marchand@redhat.com> References: <20230224081642.2566619-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 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 --- 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',