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 768A043EB4; Sat, 20 Apr 2024 01:10:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F4021427E1; Sat, 20 Apr 2024 01:07:31 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id ACFE740DCE for ; Sat, 20 Apr 2024 01:06:54 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id E118B20FE870; Fri, 19 Apr 2024 16:06:48 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E118B20FE870 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1713568009; bh=YoDGJqKQIHtKiVJT2n0pJDKfvMzWCUld0g7lwp7Pt3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dQwBjlaujEn85TsBl7y4zGvhEPWc/x/KrWWtQhjYi1ILW8unLVQRC4oQl5UF7vjsg hb+VeyFCbouRia3djVC8RcCUg9ir6SvRcBa3kktFJpqeRpWl++0q1eCQQXmc4kO/pS Lbj2K0BkENe5FvA8KbHaU1s9MEHmfzIOBeObFoOY= From: Tyler Retzlaff To: dev@dpdk.org Cc: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Abdullah Sevincer , Ajit Khaparde , Alok Prasad , Anatoly Burakov , Andrew Rybchenko , Anoob Joseph , Bruce Richardson , Byron Marohn , Chenbo Xia , Chengwen Feng , Ciara Loftus , Ciara Power , Dariusz Sosnowski , David Hunt , Devendra Singh Rawat , Erik Gabriel Carrillo , Guoyang Zhou , Harman Kalra , Harry van Haaren , Honnappa Nagarahalli , Jakub Grajciar , Jerin Jacob , Jeroen de Borst , Jian Wang , Jiawen Wu , Jie Hai , Jingjing Wu , Joshua Washington , Joyce Kong , Junfeng Guo , Kevin Laatz , Konstantin Ananyev , Liang Ma , Long Li , Maciej Czekaj , Matan Azrad , Maxime Coquelin , Nicolas Chautru , Ori Kam , Pavan Nikhilesh , Peter Mccarthy , Rahul Lakkireddy , Reshma Pattan , Rosen Xu , Ruifeng Wang , Rushil Gupta , Sameh Gobriel , Sivaprasad Tummala , Somnath Kotur , Stephen Hemminger , Suanming Mou , Sunil Kumar Kori , Sunil Uttarwar , Tetsuya Mukawa , Vamsi Attunuru , Viacheslav Ovsiienko , Vladimir Medvedkin , Xiaoyun Wang , Yipeng Wang , Yisen Zhuang , Yuying Zhang , Yuying Zhang , Ziyang Xuan , Tyler Retzlaff Subject: [PATCH v4 25/45] event/dsw: use rte stdatomic API Date: Fri, 19 Apr 2024 16:06:23 -0700 Message-Id: <1713568003-30453-26-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1713568003-30453-1-git-send-email-roretzla@linux.microsoft.com> References: <1710967892-7046-1-git-send-email-roretzla@linux.microsoft.com> <1713568003-30453-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 rte stdatomic API. Signed-off-by: Tyler Retzlaff Acked-by: Stephen Hemminger Reviewed-by: Mattias Rönnblom --- drivers/event/dsw/dsw_evdev.h | 6 +++--- drivers/event/dsw/dsw_event.c | 47 +++++++++++++++++++++++++++--------------- drivers/event/dsw/dsw_xstats.c | 4 ++-- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/drivers/event/dsw/dsw_evdev.h b/drivers/event/dsw/dsw_evdev.h index 3a5989f..2018306 100644 --- a/drivers/event/dsw/dsw_evdev.h +++ b/drivers/event/dsw/dsw_evdev.h @@ -227,9 +227,9 @@ struct __rte_cache_aligned dsw_port { alignas(RTE_CACHE_LINE_SIZE) struct rte_ring *ctl_in_ring; /* Estimate of current port load. */ - alignas(RTE_CACHE_LINE_SIZE) int16_t load; + alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(int16_t) load; /* Estimate of flows currently migrating to this port. */ - alignas(RTE_CACHE_LINE_SIZE) int32_t immigration_load; + alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(int32_t) immigration_load; }; struct dsw_queue { @@ -252,7 +252,7 @@ struct dsw_evdev { uint8_t num_queues; int32_t max_inflight; - alignas(RTE_CACHE_LINE_SIZE) int32_t credits_on_loan; + alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(int32_t) credits_on_loan; }; #define DSW_CTL_PAUS_REQ (0) diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c index 23488d9..70c3c3a 100644 --- a/drivers/event/dsw/dsw_event.c +++ b/drivers/event/dsw/dsw_event.c @@ -33,7 +33,8 @@ } total_on_loan = - __atomic_load_n(&dsw->credits_on_loan, __ATOMIC_RELAXED); + rte_atomic_load_explicit(&dsw->credits_on_loan, + rte_memory_order_relaxed); available = dsw->max_inflight - total_on_loan; acquired_credits = RTE_MAX(missing_credits, DSW_PORT_MIN_CREDITS); @@ -45,13 +46,16 @@ * allocation. */ new_total_on_loan = - __atomic_fetch_add(&dsw->credits_on_loan, acquired_credits, - __ATOMIC_RELAXED) + acquired_credits; + rte_atomic_fetch_add_explicit(&dsw->credits_on_loan, + acquired_credits, + rte_memory_order_relaxed) + + acquired_credits; if (unlikely(new_total_on_loan > dsw->max_inflight)) { /* Some other port took the last credits */ - __atomic_fetch_sub(&dsw->credits_on_loan, acquired_credits, - __ATOMIC_RELAXED); + rte_atomic_fetch_sub_explicit(&dsw->credits_on_loan, + acquired_credits, + rte_memory_order_relaxed); return false; } @@ -77,8 +81,9 @@ port->inflight_credits = leave_credits; - __atomic_fetch_sub(&dsw->credits_on_loan, return_credits, - __ATOMIC_RELAXED); + rte_atomic_fetch_sub_explicit(&dsw->credits_on_loan, + return_credits, + rte_memory_order_relaxed); DSW_LOG_DP_PORT(DEBUG, port->id, "Returned %d tokens to pool.\n", @@ -156,19 +161,22 @@ int16_t period_load; int16_t new_load; - old_load = __atomic_load_n(&port->load, __ATOMIC_RELAXED); + old_load = rte_atomic_load_explicit(&port->load, + rte_memory_order_relaxed); period_load = dsw_port_load_close_period(port, now); new_load = (period_load + old_load*DSW_OLD_LOAD_WEIGHT) / (DSW_OLD_LOAD_WEIGHT+1); - __atomic_store_n(&port->load, new_load, __ATOMIC_RELAXED); + rte_atomic_store_explicit(&port->load, new_load, + rte_memory_order_relaxed); /* The load of the recently immigrated flows should hopefully * be reflected the load estimate by now. */ - __atomic_store_n(&port->immigration_load, 0, __ATOMIC_RELAXED); + rte_atomic_store_explicit(&port->immigration_load, 0, + rte_memory_order_relaxed); } static void @@ -390,10 +398,11 @@ struct dsw_queue_flow_burst { for (i = 0; i < dsw->num_ports; i++) { int16_t measured_load = - __atomic_load_n(&dsw->ports[i].load, __ATOMIC_RELAXED); + rte_atomic_load_explicit(&dsw->ports[i].load, + rte_memory_order_relaxed); int32_t immigration_load = - __atomic_load_n(&dsw->ports[i].immigration_load, - __ATOMIC_RELAXED); + rte_atomic_load_explicit(&dsw->ports[i].immigration_load, + rte_memory_order_relaxed); int32_t load = measured_load + immigration_load; load = RTE_MIN(load, DSW_MAX_LOAD); @@ -523,8 +532,10 @@ struct dsw_queue_flow_burst { target_qfs[*targets_len] = *candidate_qf; (*targets_len)++; - __atomic_fetch_add(&dsw->ports[candidate_port_id].immigration_load, - candidate_flow_load, __ATOMIC_RELAXED); + rte_atomic_fetch_add_explicit( + &dsw->ports[candidate_port_id].immigration_load, + candidate_flow_load, + rte_memory_order_relaxed); return true; } @@ -882,7 +893,8 @@ struct dsw_queue_flow_burst { } source_port_load = - __atomic_load_n(&source_port->load, __ATOMIC_RELAXED); + rte_atomic_load_explicit(&source_port->load, + rte_memory_order_relaxed); if (source_port_load < DSW_MIN_SOURCE_LOAD_FOR_MIGRATION) { DSW_LOG_DP_PORT(DEBUG, source_port->id, "Load %d is below threshold level %d.\n", @@ -1301,7 +1313,8 @@ struct dsw_queue_flow_burst { * above the water mark. */ if (unlikely(num_new > 0 && - __atomic_load_n(&dsw->credits_on_loan, __ATOMIC_RELAXED) > + rte_atomic_load_explicit(&dsw->credits_on_loan, + rte_memory_order_relaxed) > source_port->new_event_threshold)) return 0; diff --git a/drivers/event/dsw/dsw_xstats.c b/drivers/event/dsw/dsw_xstats.c index 2a83a28..f61dfd8 100644 --- a/drivers/event/dsw/dsw_xstats.c +++ b/drivers/event/dsw/dsw_xstats.c @@ -48,7 +48,7 @@ struct dsw_xstats_port { static uint64_t dsw_xstats_dev_credits_on_loan(struct dsw_evdev *dsw) { - return __atomic_load_n(&dsw->credits_on_loan, __ATOMIC_RELAXED); + return rte_atomic_load_explicit(&dsw->credits_on_loan, rte_memory_order_relaxed); } static struct dsw_xstat_dev dsw_dev_xstats[] = { @@ -126,7 +126,7 @@ struct dsw_xstats_port { { int16_t load; - load = __atomic_load_n(&dsw->ports[port_id].load, __ATOMIC_RELAXED); + load = rte_atomic_load_explicit(&dsw->ports[port_id].load, rte_memory_order_relaxed); return DSW_LOAD_TO_PERCENT(load); } -- 1.8.3.1