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);