From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A0F12A056E; Wed, 11 Mar 2020 13:26:20 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 56B2E1BF7F; Wed, 11 Mar 2020 13:26:20 +0100 (CET) Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by dpdk.org (Postfix) with ESMTP id 025872BAA for ; Wed, 11 Mar 2020 13:26:19 +0100 (CET) Received: by mail-io1-f65.google.com with SMTP id t26so1660205ios.11 for ; Wed, 11 Mar 2020 05:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=84w6m1B1BH58kF0IOdkvBdBkleBla/JZhgPeMg2FgHQ=; b=Hyhv9cuk9rYWJlb34kaBibW4l0OJmVxpxRwGxw9AAGxVCVNulj3rBIIEer26hQCNJD f0e0WtUh9rVyA+76PYk1hvP7IuxkWK7hPPKhCaRb3wPssII+xmMK4gAOql3OxYGnxQLP 2e5V5h7U49rKgxovGzVKG+SEALrmtmFcYLBs2zd39iLQghav7qCnQAs7FW2N+sPcSkQI Kb3h8L6B8q2YAoZCTglsdMzDP82bqoO3ohfQyixzwH2YaUDDc9o5XIwYeL0zce/a4OYi OWjqzp4Q4g9mVid2UihGkhAsJ92vgKan6RcDCfJetbA84eCPI/0V8N4SV8lWy8mEOMmY 1+qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=84w6m1B1BH58kF0IOdkvBdBkleBla/JZhgPeMg2FgHQ=; b=hhzpmAh9/J9K6l23E/yJySrSfAJQh27IoUdOqomU3At+OwNhOqwElwtL1ezaeLks9m mulBeA+hNni0SS2EwAvN9D+V2wObu50xnltdL/Pk3zGMDJltMiLx/vHtWNDVWz6Z/Ml1 JQaoQbVFjI501SpsPmTCsXNL6NalEjZrANYAAYMn9EcssDCehj3HlDT5QiwegoAj5EJo 7P66sCU4a1M+3u7LEZazL2Wk+nOFE/ZGoGwKDrONMvR/xlN7GIMNeLm//CbytmsbF5Gl CcCn1S5yXjhjaoASL+VFmc3T1P+uhUbWiOGih83RuP/nyADUhQy8IVZj+iHTx+AAgp29 5wNA== X-Gm-Message-State: ANhLgQ29hI3nLsSFZC4bSgeMs/jpwyqpK9SKsiV5XjiIkbHVlQK6RuXJ 0zprox1Fqr5Cu7jELzunYBrqK9NWzNbY9dYw/8kor+lX X-Google-Smtp-Source: ADFU+vuZVoX9HYFdW4YCoiXzM9WdGTaIlFkZ6tPioS6Btd+7qVB4xP42AilZxfQPPOd80dquc40FeVH+lckVS1IeZqg= X-Received: by 2002:a02:3506:: with SMTP id k6mr2411494jaa.104.1583929578217; Wed, 11 Mar 2020 05:26:18 -0700 (PDT) MIME-Version: 1.0 References: <20200304173349.26459-1-tgw_team@tencent.com> <20200305164704.29900-1-tgw_team@tencent.com> In-Reply-To: From: Jerin Jacob Date: Wed, 11 Mar 2020 17:56:02 +0530 Message-ID: To: "Ananyev, Konstantin" Cc: ZY Qiu , Thomas Monjalon , "Yigit, Ferruh" , Andrew Rybchenko , "dev@dpdk.org" , "stephen@networkplumber.org" , ZY Qiu Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v3] rte_ethdev: safer memory access by calling Rx/Tx callback X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Mar 11, 2020 at 5:52 PM Ananyev, Konstantin wrote: > > > > > -----Original Message----- > > From: ZY Qiu > > Sent: Thursday, March 5, 2020 4:47 PM > > To: Thomas Monjalon ; Yigit, Ferruh ; Andrew Rybchenko > > Cc: dev@dpdk.org; stephen@networkplumber.org; Ananyev, Konstantin ; ZY Qiu > > > > Subject: [PATCH v3] rte_ethdev: safer memory access by calling Rx/Tx callback > > > > When compiling with -O0, > > the compiler does not optimize two memory accesses into one. > > Leads to accessing a null pointer when queue post Rx burst callback > > removal while traffic is running. > > > > Signed-off-by: ZY Qiu > > --- > > lib/librte_ethdev/rte_ethdev.h | 9 +++++---- > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h > > index d1a593ad1..c46612e3e 100644 > > --- a/lib/librte_ethdev/rte_ethdev.h > > +++ b/lib/librte_ethdev/rte_ethdev.h > > @@ -4388,10 +4388,10 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id, > > rx_pkts, nb_pkts); > > > > #ifdef RTE_ETHDEV_RXTX_CALLBACKS > > - if (unlikely(dev->post_rx_burst_cbs[queue_id] != NULL)) { > > - struct rte_eth_rxtx_callback *cb = > > - dev->post_rx_burst_cbs[queue_id]; > > + struct rte_eth_rxtx_callback *volatile cb = > > + dev->post_rx_burst_cbs[queue_id]; I prefer to change to compiler_barrier() if it working as volatile may have a performance impact on fast-path code. > > > > + if (unlikely(cb != NULL)) { > > do { > > nb_rx = cb->fn.rx(port_id, queue_id, rx_pkts, nb_rx, > > nb_pkts, cb->param); > > @@ -4652,7 +4652,8 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t queue_id, > > #endif > > > > #ifdef RTE_ETHDEV_RXTX_CALLBACKS > > - struct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id]; > > + struct rte_eth_rxtx_callback *volatile cb = > > + dev->pre_tx_burst_cbs[queue_id]; > > > > if (unlikely(cb != NULL)) { > > do { > > -- > > Acked-by: Konstantin Ananyev > > > 2.17.1 >