From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 9BFE341D5F;
	Fri, 24 Feb 2023 16:12:23 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 0991742B7E;
	Fri, 24 Feb 2023 16:12:11 +0100 (CET)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [170.10.133.124])
 by mails.dpdk.org (Postfix) with ESMTP id EAB8C427F5
 for <dev@dpdk.org>; Fri, 24 Feb 2023 16:12:08 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1677251528;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=5IXdKEIbzNEn/czHJyiyto+op04BlCukyTQehteBcjw=;
 b=S9ipcFv+BOAxYQ6WxfMjyTammqJvInye0acC45fXaczfYBTTFfnlo37JeaLidPsgrWZUit
 6HYlu4ItnPbv9TEXsQgcRbdq1hbfJWlekpnqVGDQvvt8uViU8pv3N5/SiDVgNtmWkwySmT
 pW78Te1Xhr9ji86uGc+IPExLI/pdRjc=
Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com
 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS
 (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 us-mta-6-mw_WpelFMn6CfTjtLJ1K6g-1; Fri, 24 Feb 2023 10:12:03 -0500
X-MC-Unique: mw_WpelFMn6CfTjtLJ1K6g-1
Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com
 [10.11.54.1])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC5003810B26;
 Fri, 24 Feb 2023 15:12:02 +0000 (UTC)
Received: from dmarchan.redhat.com (unknown [10.45.224.55])
 by smtp.corp.redhat.com (Postfix) with ESMTP id 94F73404BEC0;
 Fri, 24 Feb 2023 15:12:01 +0000 (UTC)
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, Yipeng Wang <yipeng1.wang@intel.com>,
 Sameh Gobriel <sameh.gobriel@intel.com>,
 Bruce Richardson <bruce.richardson@intel.com>,
 Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Subject: [PATCH v2 04/20] hash: annotate cuckoo hash lock
Date: Fri, 24 Feb 2023 16:11:27 +0100
Message-Id: <20230224151143.3274897-5-david.marchand@redhat.com>
In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com>
References: <20230224081642.2566619-1-david.marchand@redhat.com>
 <20230224151143.3274897-1-david.marchand@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="US-ASCII"; x-default=true
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=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 <david.marchand@redhat.com>
---
 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);
-- 
2.39.2