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 532D7A00C5 for ; Wed, 3 Aug 2022 11:59:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D5FA42684; Wed, 3 Aug 2022 11:59:11 +0200 (CEST) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by mails.dpdk.org (Postfix) with ESMTP id AD5AA40A7E for ; Wed, 3 Aug 2022 11:59:09 +0200 (CEST) Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 912B83F129 for ; Wed, 3 Aug 2022 09:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1659520749; bh=FTglVik3+MWHPfntd+2pyElTFwmI8QQmNgT+i+jFQeU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=UC3mDSmhrnj9IVpuvrT4/Hg/p01Jt/+2i7ToZLXVD4P6wuXb+YANA9M9xUA+qrutw wgQMJouc9Vmx03Aslk6IUmpfan5o8Ys1QHE9VZoShVloBobdBXU9DJHOs/jxr4kBJK B2iF+PJ02XQFBSoS9xxkLcWu3+Q+eswC+ejICTt9Wbo8JH/jCFx6B4LCMhihV1rBcH ZtqISmKakt4dXlB5zmFDf509ZzcV17UrUvq4NRUwuNhXjMDG8Yw9kl159+MLesiRhE VoVAUj/UW0FmSloYEHAk8RTiww1NyPwWzovYhVYoMLTk+UVydp0limBCD5xFuv2Gjc kU3OlyNV6ZY9A== Received: by mail-lf1-f72.google.com with SMTP id g16-20020ac24d90000000b0048aeea325ddso2873034lfe.16 for ; Wed, 03 Aug 2022 02:59:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=FTglVik3+MWHPfntd+2pyElTFwmI8QQmNgT+i+jFQeU=; b=o2oxnvip3GVOYZoWb7slRZbsD/e/aNTItTCiP2tJ0b1FcJwwCt001K1bG/6VlkvMDx S1NoJiW3X2IyRjEpDyxTGCMAQaRe+Q4aKvZZImHPUru5LgsfZPxwjVJnYjrOsk8FJsF4 5RcnaMOlFFvS1Qu0wsw/09oGUFUVAkhTsxglzpA0ywZRctsbEjSF7iO9iYSGEgjMD3t0 vm6Z7Sf25KpTUZSS+mMsTbPs++o5AHptNnZmE5TD+F7lPg03q3sM3+WAgvqNEp8ppzZd aoSOOifEOqkIs6pfcT0mKAfnq9NZXUUGXI7zpH1IdoDye7fFbcvQVbvOIqPWH8ytjz4i K6Mg== X-Gm-Message-State: AJIora+YsmtkdNqfDLR80Hx5qU0jKqFzh+fwhP6oXi21BBHWrNbByAFp 2O4EqJ3SX679wKwKuhyONcyLygiSXyEL/eX6QXYG2z5fLo1MHl8bI9Iavn6VvGiraP3JAJSbs6B JDUuWwO9qOF4NbrfBttfv7A6886n3A2m8gaMJkunS X-Received: by 2002:a05:651c:1581:b0:255:48d1:fdae with SMTP id h1-20020a05651c158100b0025548d1fdaemr7903267ljq.286.1659520748389; Wed, 03 Aug 2022 02:59:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1taFPg77MwVnqxpsWu1z0oI5LNEJM18Am28B0H9W22lqPSvCx7HYc1gmwR9wbcf/ck4UTd4F6Z8lTkE3HYEblY= X-Received: by 2002:a05:651c:1581:b0:255:48d1:fdae with SMTP id h1-20020a05651c158100b0025548d1fdaemr7903260ljq.286.1659520748098; Wed, 03 Aug 2022 02:59:08 -0700 (PDT) MIME-Version: 1.0 References: <20220720052251.272916-1-ke1x.zhang@intel.com> In-Reply-To: <20220720052251.272916-1-ke1x.zhang@intel.com> From: Christian Ehrhardt Date: Wed, 3 Aug 2022 11:58:42 +0200 Message-ID: Subject: Re: [PATCH 19.11] net/iavf: net/iavf: fix mbuf release in multi-process To: Ke Zhang Cc: stable@dpdk.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Wed, Jul 20, 2022 at 7:31 AM Ke Zhang wrote: > > [ upstream commit fced83c1229e0ad89f26d07fa7bd46b8767d9f5c ] Thank you, your patch was too late in regard to my original deadline and I was then unavailable for a while. In the meantime more patches came in and I do not want to waste any of them just because they were late. Your patch is applied to the WIP branch now, but currently testing of -rc1 is going on which I do not want to disrupt. If we need an -rc2 anyway or generally have the time to do an -rc2 without too much disruption it will be in 19.11.13, otherwise it is already queued for 19.11.14 > In the multiple process environment, the subprocess operates on the > shared memory and changes the function pointer of the main process, > resulting in the failure to find the address of the function when main > process releasing, resulting in crash. > > Fixes: 319c421f3890 ("net/avf: enable SSE Rx Tx") > Cc: stable@dpdk.org > > Signed-off-by: Ke Zhang > --- > drivers/net/iavf/iavf_rxtx.c | 32 +++++++++++++++++----------- > drivers/net/iavf/iavf_rxtx.h | 10 +++++++++ > drivers/net/iavf/iavf_rxtx_vec_sse.c | 16 ++++---------- > 3 files changed, 34 insertions(+), 24 deletions(-) > > diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c > index d406f0d99..eda102a5a 100644 > --- a/drivers/net/iavf/iavf_rxtx.c > +++ b/drivers/net/iavf/iavf_rxtx.c > @@ -295,12 +295,20 @@ release_txq_mbufs(struct iavf_tx_queue *txq) > } > } > > -static const struct iavf_rxq_ops def_rxq_ops = { > - .release_mbufs = release_rxq_mbufs, > +static const > +struct iavf_rxq_ops iavf_rxq_release_mbufs_ops[] = { > + [IAVF_REL_MBUFS_DEFAULT].release_mbufs = release_rxq_mbufs, > +#ifdef RTE_ARCH_X86 > + [IAVF_REL_MBUFS_SSE_VEC].release_mbufs = iavf_rx_queue_release_mbufs_sse, > +#endif > }; > > -static const struct iavf_txq_ops def_txq_ops = { > - .release_mbufs = release_txq_mbufs, > +static const > +struct iavf_txq_ops iavf_txq_release_mbufs_ops[] = { > + [IAVF_REL_MBUFS_DEFAULT].release_mbufs = release_txq_mbufs, > +#ifdef RTE_ARCH_X86 > + [IAVF_REL_MBUFS_SSE_VEC].release_mbufs = iavf_tx_queue_release_mbufs_sse, > +#endif > }; > > int > @@ -402,7 +410,7 @@ iavf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, > rxq->q_set = TRUE; > dev->data->rx_queues[queue_idx] = rxq; > rxq->qrx_tail = hw->hw_addr + IAVF_QRX_TAIL1(rxq->queue_id); > - rxq->ops = &def_rxq_ops; > + rxq->rel_mbufs_type = IAVF_REL_MBUFS_DEFAULT; > > if (check_rx_bulk_allow(rxq) == TRUE) { > PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are " > @@ -513,7 +521,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev, > txq->q_set = TRUE; > dev->data->tx_queues[queue_idx] = txq; > txq->qtx_tail = hw->hw_addr + IAVF_QTX_TAIL1(queue_idx); > - txq->ops = &def_txq_ops; > + txq->rel_mbufs_type = IAVF_REL_MBUFS_DEFAULT; > > if (check_tx_vec_allow(txq) == FALSE) { > struct iavf_adapter *ad = > @@ -618,7 +626,7 @@ iavf_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) > } > > rxq = dev->data->rx_queues[rx_queue_id]; > - rxq->ops->release_mbufs(rxq); > + iavf_rxq_release_mbufs_ops[rxq->rel_mbufs_type].release_mbufs(rxq); > reset_rx_queue(rxq); > dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED; > > @@ -646,7 +654,7 @@ iavf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) > } > > txq = dev->data->tx_queues[tx_queue_id]; > - txq->ops->release_mbufs(txq); > + iavf_txq_release_mbufs_ops[txq->rel_mbufs_type].release_mbufs(txq); > reset_tx_queue(txq); > dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED; > > @@ -661,7 +669,7 @@ iavf_dev_rx_queue_release(void *rxq) > if (!q) > return; > > - q->ops->release_mbufs(q); > + iavf_rxq_release_mbufs_ops[q->rel_mbufs_type].release_mbufs(q); > rte_free(q->sw_ring); > rte_memzone_free(q->mz); > rte_free(q); > @@ -675,7 +683,7 @@ iavf_dev_tx_queue_release(void *txq) > if (!q) > return; > > - q->ops->release_mbufs(q); > + iavf_txq_release_mbufs_ops[q->rel_mbufs_type].release_mbufs(q); > rte_free(q->sw_ring); > rte_memzone_free(q->mz); > rte_free(q); > @@ -699,7 +707,7 @@ iavf_stop_queues(struct rte_eth_dev *dev) > txq = dev->data->tx_queues[i]; > if (!txq) > continue; > - txq->ops->release_mbufs(txq); > + iavf_txq_release_mbufs_ops[txq->rel_mbufs_type].release_mbufs(txq); > reset_tx_queue(txq); > dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; > } > @@ -707,7 +715,7 @@ iavf_stop_queues(struct rte_eth_dev *dev) > rxq = dev->data->rx_queues[i]; > if (!rxq) > continue; > - rxq->ops->release_mbufs(rxq); > + iavf_rxq_release_mbufs_ops[rxq->rel_mbufs_type].release_mbufs(rxq); > reset_rx_queue(rxq); > dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; > } > diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h > index c3baf9386..6be05deb3 100644 > --- a/drivers/net/iavf/iavf_rxtx.h > +++ b/drivers/net/iavf/iavf_rxtx.h > @@ -87,6 +87,7 @@ struct iavf_rx_queue { > struct rte_mbuf *pkt_first_seg; /* first segment of current packet */ > struct rte_mbuf *pkt_last_seg; /* last segment of current packet */ > struct rte_mbuf fake_mbuf; /* dummy mbuf */ > + uint8_t rel_mbufs_type; > > /* used for VPMD */ > uint16_t rxrearm_nb; /* number of remaining to be re-armed */ > @@ -132,6 +133,7 @@ struct iavf_tx_queue { > uint16_t last_desc_cleaned; /* last desc have been cleaned*/ > uint16_t free_thresh; > uint16_t rs_thresh; > + uint8_t rel_mbufs_type; > > uint16_t port_id; > uint16_t queue_id; > @@ -156,6 +158,12 @@ union iavf_tx_offload { > }; > }; > > +enum iavf_rxtx_rel_mbufs_type { > + IAVF_REL_MBUFS_DEFAULT = 0, > + IAVF_REL_MBUFS_SSE_VEC = 1, > + IAVF_REL_MBUFS_AVX512_VEC = 2, > +}; > + > int iavf_dev_rx_queue_setup(struct rte_eth_dev *dev, > uint16_t queue_idx, > uint16_t nb_desc, > @@ -215,6 +223,8 @@ int iavf_rx_vec_dev_check(struct rte_eth_dev *dev); > int iavf_tx_vec_dev_check(struct rte_eth_dev *dev); > int iavf_rxq_vec_setup(struct iavf_rx_queue *rxq); > int iavf_txq_vec_setup(struct iavf_tx_queue *txq); > +void iavf_rx_queue_release_mbufs_sse(struct iavf_rx_queue *rxq); > +void iavf_tx_queue_release_mbufs_sse(struct iavf_tx_queue *txq); > > static inline > void iavf_dump_rx_descriptor(struct iavf_rx_queue *rxq, > diff --git a/drivers/net/iavf/iavf_rxtx_vec_sse.c b/drivers/net/iavf/iavf_rxtx_vec_sse.c > index aefa81ecd..3c2eed0cd 100644 > --- a/drivers/net/iavf/iavf_rxtx_vec_sse.c > +++ b/drivers/net/iavf/iavf_rxtx_vec_sse.c > @@ -668,37 +668,29 @@ iavf_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, > return nb_tx; > } > > -static void __attribute__((cold)) > +void > iavf_rx_queue_release_mbufs_sse(struct iavf_rx_queue *rxq) > { > _iavf_rx_queue_release_mbufs_vec(rxq); > } > > -static void __attribute__((cold)) > +void > iavf_tx_queue_release_mbufs_sse(struct iavf_tx_queue *txq) > { > _iavf_tx_queue_release_mbufs_vec(txq); > } > > -static const struct iavf_rxq_ops sse_vec_rxq_ops = { > - .release_mbufs = iavf_rx_queue_release_mbufs_sse, > -}; > - > -static const struct iavf_txq_ops sse_vec_txq_ops = { > - .release_mbufs = iavf_tx_queue_release_mbufs_sse, > -}; > - > int __attribute__((cold)) > iavf_txq_vec_setup(struct iavf_tx_queue *txq) > { > - txq->ops = &sse_vec_txq_ops; > + txq->rel_mbufs_type = IAVF_REL_MBUFS_SSE_VEC; > return 0; > } > > int __attribute__((cold)) > iavf_rxq_vec_setup(struct iavf_rx_queue *rxq) > { > - rxq->ops = &sse_vec_rxq_ops; > + rxq->rel_mbufs_type = IAVF_REL_MBUFS_SSE_VEC; > return iavf_rxq_vec_setup_default(rxq); > } > > -- > 2.25.1 > -- Christian Ehrhardt Senior Staff Engineer, Ubuntu Server Canonical Ltd