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 6C7F5A0564; Thu, 5 Mar 2020 18:24:09 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 78DB22BB8; Thu, 5 Mar 2020 18:24:08 +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 DBC202BA8 for ; Thu, 5 Mar 2020 18:24:06 +0100 (CET) Received: by mail-io1-f65.google.com with SMTP id h8so7360297iob.2 for ; Thu, 05 Mar 2020 09:24:06 -0800 (PST) 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=suPxd0Uiu3nmOm0yZcvJUVtE665bPh7eVAeMkMmIl5c=; b=Kt7onORadYfFIyuKBw5pcpGW6epN5Plk6Xk4tA8ZevvQF59fnBKE/LN77xcyf/p+97 xZb0ol3/sHaV1udtb/2PhJNVrr6rfNY5z4V7YZwopnjjWe/vPWRSbO+G9e+3jLsT3gsi F0vSzXY9eruzoCw+J6H2nO814R6shqoNV+sfARTLVfbKAhvqXUq8OeaDNFAtpt/3unUq 7dtpvK25k70k7501sEgy4CgepzMtbYZTCXhI3iDjPaV6hnc2MVOEAYic7ozei37L0ve9 ny4LfQLFxjbhKHX1/6pYtRPjLpg03t+ZsbfQ5c0oKUnt74i0DdIDnV3AcxLUWgfMmEiQ iLgQ== 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=suPxd0Uiu3nmOm0yZcvJUVtE665bPh7eVAeMkMmIl5c=; b=RzZVU4PIBDHcd9cHtAZUsorm6hQHT2c+iWG4GAuF9KWzfRrcIM5Kxp1MUPGhCyIbHT OYPurc9uVn9zgGQCqsxxeuVdsHf5xE+1oBPUPO5NsgMJEpjujGbM6Dbjb2b8xPqs4zAF tXmddNKayWW6plcrR9Sm9yBSMUQ+XcQFweuvrVD+iqyoB1WijzGLwyVJygiHlvszpyzQ 7CxNbOczdE9e7Iibs2Af87zhoa6UU775mUAMQLKX0OeoY4rxdUouaNa+B26U6PAvRY0N HEx8hwfi5aLQ/wsOmQknw1yVBeYeyUy+cjyCRY7M2uKbqoo5ZMQzxAWuFrLardhv9xsC xsAw== X-Gm-Message-State: ANhLgQ0ex7WLpjZB0ZRsWuSsY3XKrEM6mYP8tev9pQz9xO0A84LoOdTk hRGliKAYKGfxqPtvYwFTYb44m8djwdsCi/Vv0nk= X-Google-Smtp-Source: ADFU+vtykZZh+20+vkNmmh6tbbIwp8cNEKZhkFzc6tAQ+7EPyn0FuMQi+i+OFyqm7pJNE936r9/akj6Hacn6lWG/v5c= X-Received: by 2002:a6b:c742:: with SMTP id x63mr110362iof.162.1583429046086; Thu, 05 Mar 2020 09:24:06 -0800 (PST) MIME-Version: 1.0 References: <20200304173349.26459-1-tgw_team@tencent.com> <20200305164704.29900-1-tgw_team@tencent.com> In-Reply-To: <20200305164704.29900-1-tgw_team@tencent.com> From: Jerin Jacob Date: Thu, 5 Mar 2020 22:53:50 +0530 Message-ID: To: ZY Qiu Cc: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , dpdk-dev , Stephen Hemminger , "Ananyev, Konstantin" , 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 Thu, Mar 5, 2020 at 10:17 PM ZY Qiu wrote: > > 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]; Is adding rte_compiler_barrier() here without changing to volatile solving the problem in your case? If so, I prefer to change to compiler_barrier() 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 { > -- > 2.17.1 >