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 8259141E04; Tue, 7 Mar 2023 17:42:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 204CC40ED6; Tue, 7 Mar 2023 17:42:04 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2058.outbound.protection.outlook.com [40.107.223.58]) by mails.dpdk.org (Postfix) with ESMTP id 673224067B for ; Tue, 7 Mar 2023 17:42:03 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=myKhdwpdIATlUfkzC+gsjPvmztFhYuS8unAPZPlUkNLGUMbsCuddhR0FtGkpsWMxhJvrF9P2CaX9lR0GCJ5bgWnwsPr3bg29DIqKSjzKQXHO6pnE3uu8EO2I5JWgTVAWP9lxgqy4clROGxMOZDFDnmJ2oswhVjLhvhSR5s3zZhHsic2c9DcHBXGQ5lGAARQEgi0gQuOjMTmjSmus21spnww//8RHmqbiN7+tbi0w7XLnbOkrGe1w+uXnSPBCMLEmVNriyvFVrO3B/iUJZk9EljP1okg9RyRbFQ24rlvrFdWaF+i4zjhZlUc613sKX+lhPiRftiVlwPDhtqZVh/XWMQ== 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=gGuDJjlP2toMy2tgVY4GsG7z2a/nROd26DBn0OAnWB4=; b=MFuzX+FESay7Yt404eDvEBsyrGMyN6SdsHY1lO5OidhFJvP33gTka+pr1ku9bpGsyQ00Ujw5DQ0C1GKzkh+Ka58muC8JaVAmJIo+30ToOR6a++XZelbI0Rw7cq7JO7i0Cl61/8Vs5ji49aeNmhmEOvwkSy2Q6iP06lGANFjQKUpvCImZIRGz6qSQDhB44561VlOEW93BibAMWf8Ab3VUxDY0JPG4RgR0vY1NvhOrZO99BjWvjiZdgffxtnd5qX5gvDdPuQlpDSfmeyFaYmRS/yPHnIx1beCkafjYcO54Qf1FiXPzwX1wEIauhf+4Rk6KrgBEfgrX9H42fL+EJPUUIQ== 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=gGuDJjlP2toMy2tgVY4GsG7z2a/nROd26DBn0OAnWB4=; b=Rqqurxovc9TY99Hav8ItTTaarb8pwUsNnNRQKfrLMmLyQlBUN2u/83RuI5gZTUqtquwbDKmnU5oqd/qSvk4bXIjcoZXSzH3ftlgRsCVd/V3wu1ZyRWUGaS4YJoAC3HC73QL8Pyy9nbCmpzMaa/S5x/f/GJB8dRzxaPnvVTnd6xh4QuXWx5Y4PXyKSW01//FcjQ0UpsOwKdFcYNfoyN7227Z0tFRP6BBoUcCbtgokiQQgGh8Y0h3jiIxmb99/WCk/j1XziyZtOvA0S1rjTRN+QSm9JXekAEoPV4KFYGeJ2QMBPZNKfi3byy77MWIm/MnITsZ94Q3gd6moPiE29nMljg== Received: from DM6PR12MB3753.namprd12.prod.outlook.com (2603:10b6:5:1c7::18) by CH2PR12MB4199.namprd12.prod.outlook.com (2603:10b6:610:a7::13) 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:42:01 +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:42:00 +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: AQHYsv5Jrpk588RY5kyAP8dUAQUcNq7wwMhA Date: Tue, 7 Mar 2023 16:42:00 +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_|CH2PR12MB4199:EE_ x-ms-office365-filtering-correlation-id: 2053c425-59c0-4fa6-8372-08db1f2adfda x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qr0Q1Xe1SQq6ybVFmGUxRb5Pg7tN/BOVVIyFCNU7Uh2V2MNI2iGV0XtCCLSuiqySVYO4/5WQ30+SumlEmL+0e5fulFSIb3PShxhqkIyo6sXUEuzMqRBqhDKiFHdXqU1wKRMs6GP6eHOt2q41eOM/cJBBG7q4O+UrDcUXlchsNb69ZRBfAaRPmSH3tmpCtPfa9LRc/Gg0zdlkWp1ohHJLFvAYn5/rfvNKl16LdTE3RG55GRQqcSNa5wefsT9TSV4PXVMU2Bp31zRlQ0t6PLBsrS6IXkzbWua+4A0l/3mnIPTK6KMl1RwDyEJBqRDIgz1zJrAymOo4pJJCG0opC/N2+BNADrmTPOqQSOInzO68htDBY/Sx4KE9WzG7TOJkObdJGvgCYnrPPVh1KTEwueXWnecki8FJuMNcbZIgBQoPMfh2vvotVL6Ximf/pUPDKYjPfyTnb3W6XKowyAmNvc5TQ8OTcEyECtNLJrvwOegYlVHFNZqV784gd0H8I4ow++oOTb8US84LtLPEw4gW1wyEfFLPbl03AHEfXVb7svn0rI25GOfg5JjpzBLBuuTBkGfRc6bkKbdaCUHkwF7z8w8HrM3BzP2COQ2rmrCCUKZISspkg33LiW3hWX+SzaGX+DVE85/kC5vlGuP0VYsgRYy3mhDvLvKfTzyCxaTmL84wuC+ni6cYeHZCEq1JJAjHBcjsPsJQxHACaCzLBCTdJ/CYSA== 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)(346002)(136003)(39860400002)(376002)(366004)(396003)(451199018)(8936002)(2906002)(5660300002)(41300700001)(52536014)(76116006)(66446008)(4326008)(8676002)(64756008)(66476007)(66556008)(83380400001)(66946007)(6636002)(316002)(110136005)(71200400001)(7696005)(53546011)(33656002)(478600001)(6506007)(86362001)(55016003)(9686003)(122000001)(38100700002)(26005)(38070700005)(186003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?koi8-r?Q?H+aSG/Fh8zdjHUEOWtFdukgjItmYIOKv89bjNNEYXwCepYxGKbO+O24/ovtL3f?= =?koi8-r?Q?QDQhVs6Rd5mxrUdokqII+Nd4ipJbfBAgn7oRqnzFkhR4JwEgXquMM0kJVsMkFI?= =?koi8-r?Q?bQO6CUUqRTl+D5y8JtgDJE8G9nZfdUy9SvuG6FUhxrcCuaVmOqDdlA2iDHN1Ud?= =?koi8-r?Q?GOyuO/u6tkTjDd4zDoXnYgQwrf05w++Df0aZN8iMrqX6zp3BvJrTxtnayDuiuh?= =?koi8-r?Q?GnhQBz+UPPtAUGnfo/qjbCwsEjcFQ39Pu2yY3G8mjAkRs6PwHJviQQcY8vJXPb?= =?koi8-r?Q?eSa8lV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Uy+qxT6DUivtUWx3AjLYKhjWFGBMvD8Jg?= =?koi8-r?Q?ebKwxLyHWOOJa/Df86pGHkaMG/J7rR8ANj9nfXgzNhnxUBNK9ciwsNSWmLIVJc?= =?koi8-r?Q?l7i/91q1IzohNduKhF/GyD7ajetSrfKE9ZsWi3c4VNL/1ZIrrswb29IgFIUWcW?= =?koi8-r?Q?UGUtMfmO+qYiJpRM4KgLyURrz5Yb9J9dfyeSFHs4YnbOGiyP7/TsFj6jRibZPX?= =?koi8-r?Q?sEfMOZES6ZoFbqMlRmWV5op4E9JT/k0hPQW0FfJ3t9OCHviwzmCQ4tU2YPTlrK?= =?koi8-r?Q?HeKYx4w4o1Dv43TNKosby23QcdFNTDp8BVSBBO2ssMr4g3hb9B9iExNGLKrAOn?= =?koi8-r?Q?6K49/SaAtjYjkOekq1Ey9mv2V0FGG7rsX/1k/iyT6f4V/CfA+q?= 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: 2053c425-59c0-4fa6-8372-08db1f2adfda X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Mar 2023 16:42:00.7159 (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: L3OO4pplRPMCkln1HjR8XXNS3m7grDMan2TNi8qQ4MMK26U4Sxin8M6MHzSdLmhSYW6IMGqCsGaHWzH7z/LWcw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4199 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 Could you, please, format commit message with capitals in the sentence beginnings? And explanation can be less wordy a little bit. 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