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 E5FC741E04; Tue, 7 Mar 2023 17:51:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8B27540ED6; Tue, 7 Mar 2023 17:51:58 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by mails.dpdk.org (Postfix) with ESMTP id E877B4067B for ; Tue, 7 Mar 2023 17:51:56 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wy4r+mFAzSv/hhUOzu/wM1+HcaZL1PF8ceUFqxbpxCMfhEnvhXOhf4zZ4Rbn8FsZYbrUjs1dZNR2btxqbMu0ZIpvrKHMycqq7qpQOqc5gnqoJR2oy2wDWtosjOCl02zQXxqbyIG/C2J3umDPbxtZ0rsigC1czXXvXIf2w4Rwv2zHPqH9C5ZMPp1b8L/Mt4OtHgj1vq+cSN5BW/gAN0TdBH+K4Oad5ClDIu9sT+w0aAix41uC6N0jJ8idLRMMhtD4Q+UBxZ5cr/HXR9S4JDO/4XZ30jzGp474uGmny3kMZW+q0ud6iFKFDij3b25tq+mZGiFNs3gVJ1sieMmCOdn6CA== 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=UEAlK66OcK4RzhIljx0q3sm7KJ3pkbzTLZRWNgWAvB8=; b=VJ8SytlXaKc58k7TQGqPcfjnahSen+x/Z4eqcU1sBaH0LcHWpc1EXY7QuqFBlzmSYwOc+KNwNtA6a7QRcgxlt7vAvdhLJGykwGBDv8Wx7hF0+Gdkhn05nA46AnRADDKQA/dPslcHiX8x/BggV5Y9Q4N1gLttJp+UODnUomS3217BK8GSQvwMPebGYErK6VtZ7blM3NzwLSem/47dmVjJ6C8cVIk3ZHrig8/dDngQR/z6cgxjpvR0GBvvSURL4lvMYpORUObFd9YtYbgErbpKP9XTkO//VnkDGkOn/ytiNKjs1cyvTwqFGxZpdqX//YOAC0cAuhJVPIuTwyvOU5oO6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UEAlK66OcK4RzhIljx0q3sm7KJ3pkbzTLZRWNgWAvB8=; b=cOYrVrzR+zS3pNRZW8uCnmdJ0FLNXGIbLh4UxJqBGs0zJaXqc8mySB57ecIrRYdZd1aQrDMgn/7JAVK0TrF5F6lZxHYlu3JwY6ZhxtQYV+teVu51L8nxgyZ0PeHlMfjauUT+pN+zF5UULwKBIuBOHfsIeC7FPQ9KjPhp5HODDOSr3t7PZBzRZlOk4/JOoQovPen4oHQdds3PVqBuyczsYaWygHAmiwqA3RA0MA6yAJQtKMTHDOI/uIdQHTPIG2CvAiHvJnAtAU8K73/FHXC+wK5Vi4bwJS3Ra2kEz/koEpx10mapduKpnTGdNVoXO1EWhF9/YJ0TUUN1Us6vjlgASw== Received: from DM6PR12MB3753.namprd12.prod.outlook.com (2603:10b6:5:1c7::18) by CYYPR12MB8921.namprd12.prod.outlook.com (2603:10b6:930:c7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.29; Tue, 7 Mar 2023 16:51:54 +0000 Received: from DM6PR12MB3753.namprd12.prod.outlook.com ([fe80::2a72:9d50:8f0d:a925]) by DM6PR12MB3753.namprd12.prod.outlook.com ([fe80::2a72:9d50:8f0d:a925%5]) with mapi id 15.20.6156.029; Tue, 7 Mar 2023 16:51:54 +0000 From: Slava Ovsiienko To: huzaifa.rahman , Matan Azrad CC: "dev@dpdk.org" Subject: RE: [PATCH] mlx5: initially reading xstats does not cause seg fault Thread-Topic: [PATCH] mlx5: initially reading xstats does not cause seg fault Thread-Index: AQHYsv5Jrpk588RY5kyAP8dUAQUcNq7ww54Q Date: Tue, 7 Mar 2023 16:51:54 +0000 Message-ID: References: <20220818123014.2515261-1-huzaifa.rahman@emumba.com> In-Reply-To: <20220818123014.2515261-1-huzaifa.rahman@emumba.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM6PR12MB3753:EE_|CYYPR12MB8921:EE_ x-ms-office365-filtering-correlation-id: 3811c34f-aaa6-4d98-c610-08db1f2c41af x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: hnRD1O1mUzGWQRu+ARYRNpqkY8M/RdJhePv4zgP1vFLN0GvkoFcIAzSZNI02p6KVMbPVHqB7FpSrIRWWqAq91F0slLDQYKDQcVWjn3pr9L4XlIM31rQ9ZZMIjL+6wwcXF+yp7ZHGlvpHgIfVVrKT+XZoxscEVQJP9nNlbPasKVVRlcPeTPrNwlJMIm6QNyG4uc9IIESIjjhG9KsoVRLFomzVVmBKYa8JM+SnA7rCip1YdiaD0ENbEXrlPD67r6nCrdakpT8n3kVOyPgZyYi1/W7tLnEzFVOGKVI9VuNfq5bX4QyBCgePLxon/NUKh5XJ5OOVWdnq3HtkVzDkaIvYcUFNg87/d+3lbVeFkVgd9IevAC1BDJUup9Mbe2k/Pk5r8zR81aq2AcStwH1wgjlXL/ELKUzkC3eLy5otyRnwvU8PORAfqFHb4y7W03cPXmN2HtDA2JJxLU2iuUY1jy5MlCGsLa4lKeYvjOm8TpkBnL0caHJx/r2vTN0AUM78TXez9+VtibGWve/pUVgvkvTkyvHU1dnu2CNGrmGia4lI0BsW2MhJckEyFQuiPOLbUVKe4OeVv63C+62GjAyVoJm8q+KwXRdi8CylYQ13w9pRD/wVrNyIOf8TVryBLxpg+QhylMDar9A59FH46Hl8Iw+arjJ5XVeHYpKi9BZM8zcbLi1hgbka3wpc4Fu4LVI0KKmxUctS6f9oNYklFo3IIzLHvg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB3753.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(376002)(136003)(366004)(39860400002)(346002)(396003)(451199018)(38100700002)(86362001)(122000001)(38070700005)(33656002)(64756008)(8936002)(2906002)(5660300002)(66946007)(76116006)(4326008)(41300700001)(8676002)(66446008)(66556008)(66476007)(52536014)(26005)(53546011)(9686003)(186003)(6506007)(83380400001)(6636002)(110136005)(55016003)(478600001)(316002)(71200400001)(7696005); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?koi8-r?Q?3HLj6l9lN/ztD1lGR1H43DQB2scLclOk4yr7r6kEPCqKw16xKvNgWk0DY7Qre2?= =?koi8-r?Q?MwsL+He2uo30SpfpY1rgnPv351qcVucBjItnll/mJ1S5xsTLs962alyJ8155c4?= =?koi8-r?Q?rPlpBZjtscqlJlzTrTkP9U56/zFdQrRca5JLpvBotgR2ihPezqD3TiLpUgKViV?= =?koi8-r?Q?kRSwhUr2f/j0+gGr0J7vggCBlnxXRbDJ/Klx3kli23Nh8ialw/wl50aJYyx6G5?= =?koi8-r?Q?DVQ6vV14hNgvg5utvuXM7UMTy86iF9Tldq3kr5tU3NB+u8t9tt1zlOjLn1buJl?= =?koi8-r?Q?CW06lcr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dm6D3Ndfz0Fyp70jbRxuXa23snEfN2m5Ggat6MboEthHB?= =?koi8-r?Q?Fyuol7IuhmhNj3sWgmouRrylsczWtvL3SmZID9Q2n2l4iGkob18fVjoEBMVifP?= =?koi8-r?Q?vbaDRGuMAqIhszbxnPI3xgI9fFeVVsMmZhIRlwfMNq+XnlueAgk7yFp7r5LY5D?= =?koi8-r?Q?M2fWPJ3rAKP32TRVwyJ2PFsst1fXiAOSZ952ZossHzy3qC0cQkMvh0y5rbirwX?= =?koi8-r?Q?2mXy8lCGaKsZBsxrJSQsXLgC0V7viT1NkuWKCAIkg//yLddTYN8Q5wk/YYF6MO?= =?koi8-r?Q?QR8RCZ16PttEoaLitVhYB3cJAq0bgWSI2KYKCApCDPElSL3JHbPdE9nYi0/qw0?= =?koi8-r?Q?iqqs3O1J/R9v37qmTw0BdA5ncLB6/qxj9QfpHjHJEWadHkf+3n?= Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3753.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3811c34f-aaa6-4d98-c610-08db1f2c41af X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Mar 2023 16:51:54.4117 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: cYvLsjMNCN6F+HF7h1RpUiiPcMrl4OxPBpQuOLPj59ZJjgwr3u3CFFlV+GuMkalGeFUwhlhGW9ohQRCvFXiSpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8921 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 Hi, Huzaifa "n" - is the parameter of the mlx5_xstats_get() routine, provided by caller= . We should not change this - it specified the size of "struct rte_eth_xstat = *stats " array. With best regards, Slava > -----Original Message----- > From: huzaifa.rahman > Sent: =DE=C5=D4=D7=C5=D2=C7, 18 =C1=D7=C7=D5=D3=D4=C1 2022 =C7. 15:30 > To: Matan Azrad > Cc: dev@dpdk.org; Slava Ovsiienko ; > huzaifa.rahman > Subject: [PATCH] mlx5: initially reading xstats does not cause seg fault >=20 > Bugzilla ID: 296 >=20 > the size of counters array in mlx5_xstats_get() was smaller than the memo= ry > we are setting for this array in mlx5_os_read_dev_counters(). due to whic= h > the extra memory is corrupted and thus corrupting the seemingly unrelated > variables. > this happens at the first run only because the n function arg of > mlx5_xstats_get() which is used to init counters array is initialized by = adding > the preceding statistics which in our case (i.e first run) is zero. after= the > initialization in > mlx5_os_stats_init() the mlx5_stats_n is populated and thus from then > onward the counters array size is correct >=20 > my changes will only affect the flow of the first run when we need to ini= tialize > stats in mlx5_os_stats_init(). the size of the counters array is set acco= rding the > mlx5_stats_n variable. by doing this we will avoid the memset corrupting > other variables` memory >=20 > Signed-off-by: huzaifa.rahman > --- > drivers/net/mlx5/mlx5_stats.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.= c > index f64fa3587b..bccfec10fb 100644 > --- a/drivers/net/mlx5/mlx5_stats.c > +++ b/drivers/net/mlx5/mlx5_stats.c > @@ -40,7 +40,6 @@ mlx5_xstats_get(struct rte_eth_dev *dev, struct > rte_eth_xstat *stats, { > struct mlx5_priv *priv =3D dev->data->dev_private; > unsigned int i; > - uint64_t counters[n]; > struct mlx5_xstats_ctrl *xstats_ctrl =3D &priv->xstats_ctrl; > uint16_t mlx5_stats_n =3D xstats_ctrl->mlx5_stats_n; >=20 > @@ -51,8 +50,11 @@ mlx5_xstats_get(struct rte_eth_dev *dev, struct > rte_eth_xstat *stats, > stats_n =3D mlx5_os_get_stats_n(dev); > if (stats_n < 0) > return stats_n; > - if (xstats_ctrl->stats_n !=3D stats_n) > + if (xstats_ctrl->stats_n !=3D stats_n) { > mlx5_os_stats_init(dev); > + n =3D xstats_ctrl->mlx5_stats_n; > + } > + uint64_t counters[n]; > ret =3D mlx5_os_read_dev_counters(dev, counters); > if (ret) > return ret; > -- > 2.25.1