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 7F75243190; Tue, 17 Oct 2023 22:32:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7B5AE42E4F; Tue, 17 Oct 2023 22:31:38 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 7B76F402EC for ; Tue, 17 Oct 2023 22:31:20 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 26DE920B74CC; Tue, 17 Oct 2023 13:31:18 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 26DE920B74CC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1697574679; bh=rY4lmR2gWxJMN7393MDpNdH7LXvEpEyXdr+d+xurNR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jc+XYG1uv2W990pkWHqM+QBU5Qu6POI5lMSwB77kgYshfMgbd0NS9fsL4dn/mnQra n4o6CnMLwUKHuubnc/745ZAnbfLszjwtbUXfcg7me01zvWMps2JTrsfARI2z82loKL XSmTD81XRphrWOSF5yRnXB6TAc5iE46bWpf1hZAo= 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 v2 12/19] telemetry: use rte optional stdatomic API Date: Tue, 17 Oct 2023 13:31:10 -0700 Message-Id: <1697574677-16578-13-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1697574677-16578-1-git-send-email-roretzla@linux.microsoft.com> References: <1697497745-20664-1-git-send-email-roretzla@linux.microsoft.com> <1697574677-16578-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