From patchwork Thu Mar 5 16:47:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ZY Qiu X-Patchwork-Id: 66301 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 35810A0573; Thu, 5 Mar 2020 17:47:19 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 983C22BE3; Thu, 5 Mar 2020 17:47:18 +0100 (CET) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 7F1F32BB8 for ; Thu, 5 Mar 2020 17:47:17 +0100 (CET) Received: by mail-pl1-f196.google.com with SMTP id b8so2871030plx.4 for ; Thu, 05 Mar 2020 08:47:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ysdLsVacmGxszA530RlIE2eYrBgC9/Qf07NCeV+h5EQ=; b=W9YQRqsqhXx5gJT5BlTvYDTbCqbIhsbsLtB5++r/qL5EjyTqO6wLSMM0vwfryXJQv+ AS/agxXOs7rcIwzMONs3JriXIS/VYBYgPnyBSMSOkhw6BPSXgto7BJQnb+WgUlIUMlWV Xs8D9xc93TdlKmVEXyWdhv9r9UX+tysU3yYwB5ucpY7moP7AiRrN+D9ZSGONbAbI6uHk qNAes3aG3WRuVh6WAODON2Wfdmc5JRrU9KJQivxf/BrJ7W0KG/MY/MUm/ErJxqRZkXNO KmfiQSDKfxF5MTNUds6+wT54ml4/tBku81nwkCRHCEpA983xEihN6ZSNvGnXJgpTOJit lZ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ysdLsVacmGxszA530RlIE2eYrBgC9/Qf07NCeV+h5EQ=; b=oAtb4hnwIlK6u5oAXa7UsXyviwCjf8LQwsTGy4P8wwGkQB5BxYvpqXIhm9oNoxXr3z T8AiUYbN7wWgENozEzBe+sWnvMfEpMPzQF4gRTRZnIOi17YA2+60/jV+6CMbYmUhEPJl 69jjb/8OKJoYMEkUGjbXQCT6yCwDTCDmtsxOosPKpagxr5DQjDHFiJ2WH+CAj5gUR2m+ FsmQl7zYoJKMEt52R3GHY61OnSAYgCx5QSCBISaQU7anpBU4jmBCZhK0tKrFdLuRmMpf 0zL7iEo9kjZFQ65Bir0rKLKcyYnYfeaYaD2ZA0I2rs4wWRsv24ymyy3VhyQ9ZCpoOAVw eDUw== X-Gm-Message-State: ANhLgQ17Se5trD+onmD96f30ErnXvZwL6D+NmfxthmholrK3tP3oOaXp M10q2KYbdVbxVY8SCZllBEs= X-Google-Smtp-Source: ADFU+vtK/rYPpLicG5wrPMI9Nfe7u/cPV7ASh5jouOt99uNX+HNV3m3ptx0+xfSZstkAgB3tt5qFaQ== X-Received: by 2002:a17:90a:3ab0:: with SMTP id b45mr9914217pjc.9.1583426836601; Thu, 05 Mar 2020 08:47:16 -0800 (PST) Received: from localhost.localdomain ([124.156.211.233]) by smtp.gmail.com with ESMTPSA id a3sm15935069pfl.132.2020.03.05.08.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2020 08:47:16 -0800 (PST) From: ZY Qiu X-Google-Original-From: ZY Qiu To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Cc: dev@dpdk.org, stephen@networkplumber.org, konstantin.ananyev@intel.com, ZY Qiu Date: Fri, 6 Mar 2020 00:47:04 +0800 Message-Id: <20200305164704.29900-1-tgw_team@tencent.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200304173349.26459-1-tgw_team@tencent.com> References: <20200304173349.26459-1-tgw_team@tencent.com> Subject: [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" 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 Acked-by: Konstantin Ananyev --- 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]; + 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 {