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 D64CF43CED; Tue, 19 Mar 2024 15:19:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B4D0840298; Tue, 19 Mar 2024 15:19:44 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2109.outbound.protection.outlook.com [40.107.22.109]) by mails.dpdk.org (Postfix) with ESMTP id 8709640041 for ; Tue, 19 Mar 2024 15:19:43 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hvsoq4+OyUhWJoG+UskEZiGphYj/XDOODknsFRJLjYHJ97udt1xUmRfj67+fSosT28RpsTOamlk7nA7Neg7EfrKbPINf0KBPxzMoF+hUUSi7DoTbWjObCSUQ0IBhynIdB3WaAps51qZdzhGI1TgSm8YeiKjnBoInusL9GbA2wyolKcn/r8K5mUXhLQ8+mpekzw6h6Byp+5ktozVSIzDyiAGcv2TowYfYhXyhoK1cmB50m9NK4nSqsdFXCKPKNdKPSzu2jGLSRJv98CdWKYzjr+6X38QDcMJFZ0m/NFX7XbOsKIvJsJ6RFXHtXOcdumbpPQmZw3cGYwz5yNMK/eG4YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fqr+5q3X2rbtrpZGTqRgCgKY9tgBeNE9zG0N+CJgjH4=; b=FRQUuh1vOgFULPonGYfwcVqYTm0f2sioXTAuvYm8M5p30ah+EIvcSSKFGQdEODTo1JlbD0dejrtyBXMMwsjMUJBNmt0uLwj08askS7135ocTVDrKxjxj4fiM0gHNzV3zrUDAPmRKFMouNeBKIwIq3rHGEwnIdf8C5hh9BNdTTbeiOyqVgnuQSCo+shBS2krAtXX97A/uNCUTgXgWDYuDKgIMnX9sSX1B8MhKqyD/Hd8iKyTLnLZvCzhfuhNJxWk3djBwWEkFI692xbdPAso/yAC9gszNT4+RZeBxhBUKKspsgzSUrjlzY+bfIvv9bN98YVxfPI89jvK0/d9wX1k4PQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fqr+5q3X2rbtrpZGTqRgCgKY9tgBeNE9zG0N+CJgjH4=; b=Wyio11Q/903fVYq+74WXYua5CY5jE4R2+BFt+GpF4rzlNB+qF71heq24h+mDbAoDoQOjC7vSYyfX5uHa2gDyCYodk/vIkwqRSUb3owBBKT0QZOatpckIyvMtG6xh7gRgmJvoSsAlqCSR4VoDAETJW6/y58RmYU9OdlXC6k7VCDY= Received: from PA4PR83MB0526.EURPRD83.prod.outlook.com (2603:10a6:102:26b::17) by DBBPR83MB0586.EURPRD83.prod.outlook.com (2603:10a6:10:533::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13; Tue, 19 Mar 2024 14:19:41 +0000 Received: from PA4PR83MB0526.EURPRD83.prod.outlook.com ([fe80::f0b:6b7f:eef8:2bcc]) by PA4PR83MB0526.EURPRD83.prod.outlook.com ([fe80::f0b:6b7f:eef8:2bcc%2]) with mapi id 15.20.7409.010; Tue, 19 Mar 2024 14:19:41 +0000 From: Alan Elder To: Long Li , Ferruh Yigit , Andrew Rybchenko CC: "dev@dpdk.org" , stephen Subject: RE: [PATCH v2] net/netvsc: fix number Tx queues > Rx queues Thread-Topic: [PATCH v2] net/netvsc: fix number Tx queues > Rx queues Thread-Index: AQHacYPRvICdWr2D80SqgVYZcULqOrE0fmOAgAquwKA= Date: Tue, 19 Mar 2024 14:19:40 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=979ac031-206c-4225-b627-540697dac625; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2024-02-29T19:11:26Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PA4PR83MB0526:EE_|DBBPR83MB0586:EE_ x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: NDPRJ+zmn4fCucs02x4JfowrNY88gUVugEt/QhhUQnA7eTRcYGTFLt0ZB+aQFABYzTw7DWR0hpyKxDEcUSY/jDRw0x3AHMHp9pI0ZRIDfU+utdwY4Ft1Q1M+zGiKur65H6l+YTFSVBvr2k2aP6EwMFajgmwiCOviLcNdOy+Hs9CAOrERDwNikQKMFPrS56dGjzFbpbIHtGPVJXYg2JBycEHNqz/Dm26hok+IcfjUhBBWd8m1gEiWKP8Vp4Bs5qgwv7Rq4kEz4cXHowQrmr09ukpLJV0R8MUHYbH6N/09GjUpWbU0pnewQ6aiXKRMGfcT7lYfjHaxuw+g8u+oaSHYFfQDySzckuwHwUqmuJ/jKy3FDOErvvlR5a6Q6FNDZguBe02pU/ShZQNms6rpYBhD/e6JPIv9LedAWrEyaDax5cUs35MBO1bfvoSszFiYadd68/y3TB8dlPDxaOVHEYmyTyirTOAjtQ6oR//tikdIExe7WyahkJpo0bzg0LBNx2RZvKc1Zwiu0W4bNcR/hG7uRnb+9nJ4DmRj6inmgJS8lvzfaoo+dM6F4V89dVe02BX6nG1MudyPmSf7rNWO7o7iR+m05qNsxL4ZVZWDPT4C1MCC18LRt6qf4pFwTzU++pj72W9ObGzucgI3xTrLV4KzmmUVWqKZU4PWf/FmCsgVEOk= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR83MB0526.EURPRD83.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(366007); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?vc/AFaICspOkm3qwmXun89kjpVaXx+qvjXiJZXGD11mC8+Cq8wZEMJs4MDq8?= =?us-ascii?Q?Z6EceydqkkhkV1LRB3XYhxCwBvsRfUBTXgyCEJIeV2NQ/uG7kyDz0WltEuye?= =?us-ascii?Q?VvLAmcWxLH8EHCfsZfWWvONF2D6aFxsPcdqATqzMV1u7Xu/lyOcFP0XfIxYJ?= =?us-ascii?Q?oVzAThIpmhlGWDEf+Lu9bsSyyFS7NNciY0jkEWcboxWyPRWxuKkAF9WGR36r?= =?us-ascii?Q?dlzrHzqQDwP0LQQtjgIOE5kPMdCErkSqwesPERS7GPUVRb6x30WOdNQ2Bn/R?= =?us-ascii?Q?e1dF5Olt9nFvVfS3pmGAX53RCnewaFzK+JCS7Fdd24RqH7CWmwLRRZAYOPSY?= =?us-ascii?Q?scQrXW9bcgH83VQq70fJu93st962gE5H7jv1POrgRZY8oMHhA9aM4ViBWMph?= =?us-ascii?Q?oSxr5qyUsg5kzBtj4fZPow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= =?us-ascii?Q?RQjKY4v/QguH1KJOKYfrxSkbx0GwFsGSX62FYxNVJ0DTQZY0kXBFBtTVGVrI?= =?us-ascii?Q?TohrY4/xge74Ba68JJzPZ4qwvGKV/enQjxhrNmOl0Kp20X+FBg2h8UAVgyuF?= =?us-ascii?Q?n3POiqHHBK2S7hvWpWUdrhGoq6uUyGK07v2SxstJ0Lx+Ly18br7Liz2OK1VV?= =?us-ascii?Q?8ytFCTI5durBbEnpnJwEIVOkzE+fsLZ5zVid?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR83MB0526.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b5e83ee-5bd2-4042-c748-08dc481f9de0 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2024 14:19:40.9356 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: KUAiVUzr5AkVVGzmYao0DT8EmBrlGnb8HCjod6IXVWBLcabS9JlItdvMeq8rboBboKpfKJNdF9RG2qooYXNN9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR83MB0586 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 Thanks for the feedback Long. I've made both changes you suggested, plus one additional one to not try an= d allocate an mbuf if the pool is null. This means if a packet is received on a Rx queue that isn't being polled we= will see it appear as "mbuf allocation failed" rather than causing a segfa= ult. Cheers, Alan > -----Original Message----- > From: Long Li > Sent: Tuesday, March 12, 2024 7:09 PM > To: Alan Elder ; Ferruh Yigit > ; Andrew Rybchenko > > Cc: dev@dpdk.org; stephen > Subject: RE: [PATCH v2] net/netvsc: fix number Tx queues > Rx queues >=20 > > a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c index > > 9bf1ec5509..c0aaeaa972 100644 > > --- a/drivers/net/netvsc/hn_rxtx.c > > +++ b/drivers/net/netvsc/hn_rxtx.c > > @@ -243,6 +243,7 @@ hn_dev_tx_queue_setup(struct rte_eth_dev *dev, { > > struct hn_data *hv =3D dev->data->dev_private; > > struct hn_tx_queue *txq; > > + struct hn_rx_queue *rxq; > > char name[RTE_MEMPOOL_NAMESIZE]; > > uint32_t tx_free_thresh; > > int err =3D -ENOMEM; > > @@ -301,6 +302,22 @@ hn_dev_tx_queue_setup(struct rte_eth_dev *dev, > > goto error; > > } > > > > + /* > > + * If there are more Tx queues than Rx queues, allocate rx_queues > > + * with event buffer so that Tx completion messages can still be > > + * received > > + */ > > + if (queue_idx >=3D dev->data->nb_rx_queues) { > > + rxq =3D hn_rx_queue_alloc(hv, queue_idx, socket_id); >=20 > Need to check if rxq is NULL. >=20 > > + /* > > + * Don't allocate mbuf pool or rx ring. RSS is always configured > > + * to ensure packets aren't received by this Rx queue. > > + */ > > + rxq->mb_pool =3D NULL; > > + rxq->rx_ring =3D NULL; > > + dev->data->rx_queues[queue_idx] =3D rxq; > > + } > > + > > txq->agg_szmax =3D RTE_MIN(hv->chim_szmax, hv->rndis_agg_size); > > txq->agg_pktmax =3D hv->rndis_agg_pkts; > > txq->agg_align =3D hv->rndis_agg_align; @@ -354,6 +371,17 @@ static > > void hn_txd_put(struct hn_tx_queue *txq, struct hn_txdesc *txd) > > rte_mempool_put(txq->txdesc_pool, txd); } > > > > +static void > > +hn_rx_queue_free_common(struct hn_rx_queue *rxq) { > > + if (!rxq) > > + return; > > + > > + rte_free(rxq->rxbuf_info); > > + rte_free(rxq->event_buf); > > + rte_free(rxq); > > +} > > + > > void > > hn_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid) { @@ > > -364,6 > > +392,13 @@ hn_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t > > +qid) > > if (!txq) > > return; > > > > + /* > > + * Free any Rx queues allocated for a Tx queue without a > corresponding > > + * Rx queue > > + */ > > + if (qid >=3D dev->data->nb_rx_queues) > > + hn_rx_queue_free_common(dev->data->rx_queues[qid]); > > + > > rte_mempool_free(txq->txdesc_pool); > > > > rte_memzone_free(txq->tx_rndis_mz); > > @@ -942,6 +977,13 @@ hn_dev_rx_queue_setup(struct rte_eth_dev *dev, > > if (queue_idx =3D=3D 0) { > > rxq =3D hv->primary; > > } else { > > + /* > > + * If the number of Tx queues was previously greater than > > + * the number of Rx queues, we may already have allocated > > + * an rxq. If so, free it now before allocating a new one. > > + */ > > + hn_rx_queue_free_common(dev->data- > > >rx_queues[queue_idx]); >=20 > This logic seems strange. How about check if rxq is already allocated. If= not, > allocate it. >=20 > Something like: >=20 > if (!dev->data->rx_queues[queue_idx]) > rxq =3D hn_rx_queue_alloc(hv, queue_idx, socket_id); >=20 >=20 >=20 > Thanks, >=20 > Long