From patchwork Tue Apr 4 12:48:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 125756 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BFB94428CD; Tue, 4 Apr 2023 14:49:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 283E742D1D; Tue, 4 Apr 2023 14:49:10 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 6074942B7E for ; Tue, 4 Apr 2023 14:49:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680612546; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5IXdKEIbzNEn/czHJyiyto+op04BlCukyTQehteBcjw=; b=RauylB2zlqUaNousxvfFE36I4pghJqp/JNE9wSZIvCKnlIjsRUigi0QAaWd7L4s3kvBQmo GGtYd0lUcN1aXwPJ9x5yqbnT7HRnlvYQu7AZTJWxpqq8qu/A8qOqY0HS6L5JhI2t5Tpbkv 0dNQVKQg+XIoAg3YYIgMbiLY9ZPLfCM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-cPp5EjsJOLKNMZGZMW_BeA-1; Tue, 04 Apr 2023 08:49:05 -0400 X-MC-Unique: cPp5EjsJOLKNMZGZMW_BeA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5756F2807D63; Tue, 4 Apr 2023 12:49:05 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27BC9202701F; Tue, 4 Apr 2023 12:49:04 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH v3 04/16] hash: annotate cuckoo hash lock Date: Tue, 4 Apr 2023 14:48:28 +0200 Message-Id: <20230404124840.1898-5-david.marchand@redhat.com> In-Reply-To: <20230404124840.1898-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230404124840.1898-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org __hash_rw_(reader|writer)_(|un)lock helpers take locks depending on conditions that are fixed at the rte_hash object initialisation. So we can tell clang that those helpers unconditionally take/release those locks (and waive the lock check on their implementation). Signed-off-by: David Marchand --- lib/hash/rte_cuckoo_hash.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 829b79c89a..d92a903bb3 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -575,6 +575,8 @@ rte_hash_count(const struct rte_hash *h) /* Read write locks implemented using rte_rwlock */ static inline void __hash_rw_writer_lock(const struct rte_hash *h) + __rte_exclusive_lock_function(&h->readwrite_lock) + __rte_no_thread_safety_analysis { if (h->writer_takes_lock && h->hw_trans_mem_support) rte_rwlock_write_lock_tm(h->readwrite_lock); @@ -584,6 +586,8 @@ __hash_rw_writer_lock(const struct rte_hash *h) static inline void __hash_rw_reader_lock(const struct rte_hash *h) + __rte_shared_lock_function(&h->readwrite_lock) + __rte_no_thread_safety_analysis { if (h->readwrite_concur_support && h->hw_trans_mem_support) rte_rwlock_read_lock_tm(h->readwrite_lock); @@ -593,6 +597,8 @@ __hash_rw_reader_lock(const struct rte_hash *h) static inline void __hash_rw_writer_unlock(const struct rte_hash *h) + __rte_unlock_function(&h->readwrite_lock) + __rte_no_thread_safety_analysis { if (h->writer_takes_lock && h->hw_trans_mem_support) rte_rwlock_write_unlock_tm(h->readwrite_lock); @@ -602,6 +608,8 @@ __hash_rw_writer_unlock(const struct rte_hash *h) static inline void __hash_rw_reader_unlock(const struct rte_hash *h) + __rte_unlock_function(&h->readwrite_lock) + __rte_no_thread_safety_analysis { if (h->readwrite_concur_support && h->hw_trans_mem_support) rte_rwlock_read_unlock_tm(h->readwrite_lock);