From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8400C43200; Thu, 26 Oct 2023 02:33:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6A60742E05; Thu, 26 Oct 2023 02:32:19 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9099740DDE for ; Thu, 26 Oct 2023 02:32:01 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 0374820B74CC; Wed, 25 Oct 2023 17:31:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0374820B74CC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1698280320; bh=rY4lmR2gWxJMN7393MDpNdH7LXvEpEyXdr+d+xurNR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ayfQiO9XO5e+xqTmprV+NjJSxfJ8ItWb/ZH+MIk2oyjs4O2O0p7frzEr4ZJkVdbZs z76FG1+ckCFUcNyM2KwSMct4pZol+BMErDM7264lIxUDFLGxS6ewyyKwInWpd9Shdq Yz5cBAZKqDUihRLsBePdl1xLKQMvWqRG4Ge/pW9Q= From: Tyler Retzlaff To: dev@dpdk.org Cc: Akhil Goyal , Anatoly Burakov , Andrew Rybchenko , Bruce Richardson , Chenbo Xia , Ciara Power , David Christensen , David Hunt , Dmitry Kozlyuk , Dmitry Malloy , Elena Agostini , Erik Gabriel Carrillo , Fan Zhang , Ferruh Yigit , Harman Kalra , Harry van Haaren , Honnappa Nagarahalli , Jerin Jacob , Konstantin Ananyev , Matan Azrad , Maxime Coquelin , Narcisa Ana Maria Vasile , Nicolas Chautru , Olivier Matz , Ori Kam , Pallavi Kadam , Pavan Nikhilesh , Reshma Pattan , Sameh Gobriel , Shijith Thotton , Sivaprasad Tummala , Stephen Hemminger , Suanming Mou , Sunil Kumar Kori , Thomas Monjalon , Viacheslav Ovsiienko , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v3 12/19] telemetry: use rte optional stdatomic API Date: Wed, 25 Oct 2023 17:31:47 -0700 Message-Id: <1698280314-25861-13-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1698280314-25861-1-git-send-email-roretzla@linux.microsoft.com> References: <1697497745-20664-1-git-send-email-roretzla@linux.microsoft.com> <1698280314-25861-1-git-send-email-roretzla@linux.microsoft.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 Replace the use of gcc builtin __atomic_xxx intrinsics with corresponding rte_atomic_xxx optional stdatomic API Signed-off-by: Tyler Retzlaff --- lib/telemetry/telemetry.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index aeb078c..9298284 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -45,7 +45,7 @@ struct socket { int sock; char path[sizeof(((struct sockaddr_un *)0)->sun_path)]; handler fn; - uint16_t *num_clients; + RTE_ATOMIC(uint16_t) *num_clients; }; static struct socket v2_socket; /* socket for v2 telemetry */ static struct socket v1_socket; /* socket for v1 telemetry */ @@ -64,7 +64,7 @@ struct socket { /* Used when accessing or modifying list of command callbacks */ static rte_spinlock_t callback_sl = RTE_SPINLOCK_INITIALIZER; #ifndef RTE_EXEC_ENV_WINDOWS -static uint16_t v2_clients; +static RTE_ATOMIC(uint16_t) v2_clients; #endif /* !RTE_EXEC_ENV_WINDOWS */ int @@ -404,7 +404,7 @@ struct socket { bytes = read(s, buffer, sizeof(buffer) - 1); } close(s); - __atomic_fetch_sub(&v2_clients, 1, __ATOMIC_RELAXED); + rte_atomic_fetch_sub_explicit(&v2_clients, 1, rte_memory_order_relaxed); return NULL; } @@ -421,14 +421,14 @@ struct socket { return NULL; } if (s->num_clients != NULL) { - uint16_t conns = __atomic_load_n(s->num_clients, - __ATOMIC_RELAXED); + uint16_t conns = rte_atomic_load_explicit(s->num_clients, + rte_memory_order_relaxed); if (conns >= MAX_CONNECTIONS) { close(s_accepted); continue; } - __atomic_fetch_add(s->num_clients, 1, - __ATOMIC_RELAXED); + rte_atomic_fetch_add_explicit(s->num_clients, 1, + rte_memory_order_relaxed); } rc = pthread_create(&th, NULL, s->fn, (void *)(uintptr_t)s_accepted); @@ -437,8 +437,8 @@ struct socket { strerror(rc)); close(s_accepted); if (s->num_clients != NULL) - __atomic_fetch_sub(s->num_clients, 1, - __ATOMIC_RELAXED); + rte_atomic_fetch_sub_explicit(s->num_clients, 1, + rte_memory_order_relaxed); continue; } pthread_detach(th); -- 1.8.3.1