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 4D12941CE5; Mon, 20 Feb 2023 10:44:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 406C243000; Mon, 20 Feb 2023 10:44:09 +0100 (CET) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by mails.dpdk.org (Postfix) with ESMTP id 003B240395; Mon, 20 Feb 2023 10:44:07 +0100 (CET) Received: from frapeml500005.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4PKyBB2c4yz6J9fS; Mon, 20 Feb 2023 17:42:10 +0800 (CST) Received: from frapeml500007.china.huawei.com (7.182.85.172) by frapeml500005.china.huawei.com (7.182.85.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Mon, 20 Feb 2023 10:44:07 +0100 Received: from frapeml500007.china.huawei.com ([7.182.85.172]) by frapeml500007.china.huawei.com ([7.182.85.172]) with mapi id 15.01.2507.017; Mon, 20 Feb 2023 10:44:06 +0100 From: Konstantin Ananyev To: Ashok Kaladi , "jerinj@marvell.com" , "thomas@monjalon.net" CC: "dev@dpdk.org" , "s.v.naga.harish.k@intel.com" , "erik.g.carrillo@intel.com" , "abhinandan.gujjar@intel.com" , "stable@dpdk.org" Subject: RE: [PATCH 2/2] ethdev: fix race condition in fast-path ops setup Thread-Topic: [PATCH 2/2] ethdev: fix race condition in fast-path ops setup Thread-Index: AQHZRPHnBL1vPilgIEWuG59yHT+R767XlUiw Date: Mon, 20 Feb 2023 09:44:06 +0000 Message-ID: <5fbc2c46c9d94532a0e55656acb4d5a8@huawei.com> References: <20230220060839.1267349-1-ashok.k.kaladi@intel.com> <20230220060839.1267349-2-ashok.k.kaladi@intel.com> In-Reply-To: <20230220060839.1267349-2-ashok.k.kaladi@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.48.156.21] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected 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 > If ethdev enqueue or dequeue function is called during > eth_dev_fp_ops_setup(), it may get pre-empted after setting > the function pointers, but before setting the pointer to port data. > In this case the newly registered enqueue/dequeue function will use > dummy port data and end up in seg fault. >=20 > This patch moves the updation of each data pointers before updating > corresponding function pointers. First, such re-ordering wouldn't really fix that race condition. Second, eth_dev_fp_ops_setup() supposed to be called only by dev/queue star= t/stop functions. With current DPDK design it is not allowed to simultaneously call dev start= /stop and data-path RX/TX functions and it is user responsibility to ensure that= . In other words - it is user responsibility to ensure that such race conditi= on would=20 not happen. So, NACK. >=20 > Fixes: c87d435a4d79 ("ethdev: copy fast-path API into separate structure"= ) > Cc: stable@dpdk.org >=20 > Signed-off-by: Ashok Kaladi >=20 > diff --git a/lib/ethdev/ethdev_private.c b/lib/ethdev/ethdev_private.c > index 48090c879a..a0232c669f 100644 > --- a/lib/ethdev/ethdev_private.c > +++ b/lib/ethdev/ethdev_private.c > @@ -270,17 +270,17 @@ void > eth_dev_fp_ops_setup(struct rte_eth_fp_ops *fpo, > const struct rte_eth_dev *dev) > { > + fpo->rxq.data =3D dev->data->rx_queues; > fpo->rx_pkt_burst =3D dev->rx_pkt_burst; > + fpo->txq.data =3D dev->data->tx_queues; > fpo->tx_pkt_burst =3D dev->tx_pkt_burst; > fpo->tx_pkt_prepare =3D dev->tx_pkt_prepare; > fpo->rx_queue_count =3D dev->rx_queue_count; > fpo->rx_descriptor_status =3D dev->rx_descriptor_status; > fpo->tx_descriptor_status =3D dev->tx_descriptor_status; >=20 > - fpo->rxq.data =3D dev->data->rx_queues; > fpo->rxq.clbk =3D (void **)(uintptr_t)dev->post_rx_burst_cbs; >=20 > - fpo->txq.data =3D dev->data->tx_queues; > fpo->txq.clbk =3D (void **)(uintptr_t)dev->pre_tx_burst_cbs; > } >=20 > -- > 2.25.1