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 1B857A0548 for ; Wed, 10 Nov 2021 14:37:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 047E7410EF; Wed, 10 Nov 2021 14:37:34 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2048.outbound.protection.outlook.com [40.107.220.48]) by mails.dpdk.org (Postfix) with ESMTP id 9141240683; Wed, 10 Nov 2021 14:37:31 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QA1v/OMI5oVVN6AAhjNQNirJskSv0Qf4AYD4meDnGUws6jb8pBuwBXwOPS9fflGXB6WA9AGsTM0guiSU5s0pHCs7cRNcA90nMucThq4XYkrcTKoLjx5fqbtK9tUJj3pv/2iM7INSY0uJhhLMskZla+e8Ivr1nmf0Mc82bhkjucej/CiXGfjqXsiwXN87pxvuuYFnxhvZ/cw9o3VuDNG/fPIoHDjgDXmTeBjeOyv+IKSH3yiYkTysrqv5tm/y0ArF41MZLDgZ9Hdiq/rdW/C10mU9tW6aWqmv51oIVOQaRAeLbn2NlhlEuqe45Bk1FGb5zJrJ3LLUm3pdMQ+afoHJ2g== 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=PgKRDj8F2vrKdXb3byb8NfyTwVBWfdpLIquaPIOxXUU=; b=n1trLt91EN/VCMJsEKAi7c9SOu4XeyyFiJbNcw2Lo/EnhkVxFlda0ukmqvSePoKDxUwkRdsitOEd0/kmOEtf2OEG6zpj6UzhDu2pJ1O90EUV1RoafDc6+OvcVgM/XGbghUV5yBUEChOchE98KGMaPpLo0SLAte3Mhtny2l+iUvm0BPsx5c+79wSl9rQYcjLFVonUurL20yzzCzR2TNoVpUro4OFe0OBmiXh6FlgTbHby2UUiRnZ8nw8N0pJz52oORPJEoZ8iUfpyGGm3kAfJLCY4kozck7dp38OqlvpACM3jXIGX3hU7RJBhcJVh5wsvjXZnwwH6TANK4J6WyrcMMw== 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=PgKRDj8F2vrKdXb3byb8NfyTwVBWfdpLIquaPIOxXUU=; b=QWnOF6pLN//vwXI7l8JodW3+WGlajU2pvathJOQv7Lx5L0U4aM+lW153A7VBq7BIEHYKMBqOmPZI3zBpYVAEhMcAg2qixI7nCtlIHgfYFI6st/bpR3WOD+y2HtsDupacE4H4ZNfZpVl4ldmBcas/63gCNTuncT89DjaLZfJthmdb5l5TX0JCUaY75rO7BQNrMzCsQ6jcnVhT8/cGU5evHau3yygjTw2GyOuIZu5DYrfmguiVd9/3rVzMvy4qKdXdnjABngvtLAAMzu4dBIJ7Xag6+Zxe8oerT+rIPHSmKJDLFYYYKd3S7fkXpdDpIMjhXKFAp8OMdu9Fnj0EqDlsvA== Received: from DM6PR12MB3753.namprd12.prod.outlook.com (2603:10b6:5:1c7::18) by DM6PR12MB4927.namprd12.prod.outlook.com (2603:10b6:5:20a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15; Wed, 10 Nov 2021 13:37:27 +0000 Received: from DM6PR12MB3753.namprd12.prod.outlook.com ([fe80::e550:35a2:96e5:657f]) by DM6PR12MB3753.namprd12.prod.outlook.com ([fe80::e550:35a2:96e5:657f%4]) with mapi id 15.20.4669.016; Wed, 10 Nov 2021 13:37:27 +0000 From: Slava Ovsiienko To: Vladislav Grishenko , Matan Azrad , Shahaf Shuler , NBU-Contact-Adrien Mazarguil , Elad Persiko CC: "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [PATCH] net/mlx5: fix xstats get reinitialization Thread-Index: AQHXsh+o4Vg5u3spOUqnOXVGhrizMav9CrLA Date: Wed, 10 Nov 2021 13:37:27 +0000 Message-ID: References: <20210925151129.24727-1-themiron@yandex-team.ru> In-Reply-To: <20210925151129.24727-1-themiron@yandex-team.ru> 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-office365-filtering-correlation-id: 3033ab41-c7fd-4605-abcd-08d9a44f3c79 x-ms-traffictypediagnostic: DM6PR12MB4927: x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kZbJhmikB5q79DA3An0ESWt+j7XFnSx36hBNZsgoL8NVc03Fn//Q0Z42LzCNGXs5mRgZe8drt0edgGH2YbSRaGjDa3wbBb53dFIa1ZJ8lhQKfbaDNAdJL0oT4jl3TEQe5oVaPJgIyJ0ZleVsKYgSTRzBWu5vWC0ooLWbMJi8KdER09H/ncrRWlpGHBbmpzf75ByjLcfvkuiIysPDC6LlJvHN4Z8wuS9EKilpPDSpbE4oMlB2R0LgKQpYIUVU+aD36LeggzHBQwYzK2VeQzlX9S5QGeayQemmI2dwsBfJhTsRyHSIcoReljgZjWciRSCe7Y/L9tjBHr4JuCxyXyJgC1ZBhLZxvRQoKbGXFEO6jdjwRkuf4pJdL0LG7rYcQDQuOKmVKkEAiMTrpA1kNUs1l2ZPQYckHlX6bdPFiS1y7ZsmEX7Rv17BhuXjK6G5BdIuLaQKpoIzSgJay4p/Gm2ym3EArUVa06dMTzD2FGQ3TL/KKziQBYspYJQRVztxq8sa4bdX/jlKKlgzQqdTfXl09sK6WjihzcxJIExzjChM3MKB6UukLT5rE1sDtPIjJmwhRvkdLofNYBpAK4Mor8Uza9TUVgbPqh20Vg0darkX0VGXJ5hdOEAI5W6zBEH69OZARhk6XjgSOVIoCMYh0MQH7tpyNym515FzLW4cgvJ5mjHzkEEM0N0n9omeegDbcsl4tyPEhzo1wFz+YiEA4gna8w== 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:(4636009)(366004)(186003)(9686003)(26005)(66556008)(53546011)(76116006)(55016002)(7696005)(6506007)(4326008)(86362001)(8936002)(316002)(38100700002)(38070700005)(83380400001)(33656002)(122000001)(8676002)(5660300002)(2906002)(64756008)(508600001)(66446008)(66476007)(54906003)(66946007)(110136005)(71200400001)(52536014); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?MYXtvFGz780hTxrJ/TiCQI22m5xF3dxLyH3eWi/yfaUt7e2nLheO2649ylCK?= =?us-ascii?Q?VW1gXoLCrPa3tPn5bQE9ohSqosvOFDRgiSnnEpO2tPa5S9vYC57VhZExNADo?= =?us-ascii?Q?OpLlkAMIq4RhubkeyIM3ELfz5BbzqDdH637IbczWSTCt73HJ3U8JnCcrTewr?= =?us-ascii?Q?ZcjPNCNkDOy8yWNLO66MNraq86JPgsohdxAyQKpQuVjnKW7QHXGFNflOXXxu?= =?us-ascii?Q?3QR+auOwyevrWwxJG6Ya2J3BHSMr8j1Jjq2oHci4e+OKV1UR7bIcwf7OEUE1?= =?us-ascii?Q?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nynARyL9YpxYUUG8f?= =?us-ascii?Q?4Vr9efywkxUoXBPjb/A07vxFBZWEB+SG0kH876z2qVdW1zIUdluukziVXdGQ?= =?us-ascii?Q?e6sIF4kTOM/acSjsfiTKsTll4rjq8FMoCwx7T3gdGJs49+J+RiwV5GPeLOOR?= =?us-ascii?Q?s+IyIVG0F/WO6gHO2JFlm2MKjKxxih1cB7/JowNX1RsNiYPJi5j9uXavMuS2?= =?us-ascii?Q?qcJvRWE/bKmcK/z2/BjQownoYM3jcMaujB12Otn/wnTHWt7jEWc2viNVgOqW?= =?us-ascii?Q?h7SjYFhZs7w/++/Osfo9pRuL1DwH4Y41Xyah0ti+esFtEE4IqS0CJhhxjqBX?= =?us-ascii?Q?uCP1Z4Gtyxq70hBnOR1qgYO9QmcjkhjbkKrFQN53yl86E1+ZvIAVvElykjOk?= =?us-ascii?Q?ensoojxEKQ0SQVmA5YLN5R/4u/KvooHp+muHzsZO+iE/jGpM4YwqpWZ9hja7?= =?us-ascii?Q?aA=3D=3D?= Content-Type: text/plain; charset="us-ascii" 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: 3033ab41-c7fd-4605-abcd-08d9a44f3c79 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Nov 2021 13:37:27.2015 (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: naNCJLmL5PtBugwE81LAlARiODfJ8OE6P43Z+JNlw3imS+EwVBoJq9VgpttmG8X3gohz8xjbghy+ZbwpYtguPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4927 Subject: Re: [dpdk-stable] [PATCH] net/mlx5: fix xstats get reinitialization 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 Sender: "stable" Hi, Vladislav Thank you for the fix. In general, it looks good to me. Please, see my comments below. > -----Original Message----- > From: Vladislav Grishenko > Sent: Saturday, September 25, 2021 18:11 > To: Matan Azrad ; Slava Ovsiienko > ; Shahaf Shuler ; NBU- > Contact-Adrien Mazarguil ; Elad Persiko > > Cc: dev@dpdk.org; stable@dpdk.org > Subject: [PATCH] net/mlx5: fix xstats get reinitialization >=20 > The mlx5_xstats_get gets the device extended statistics. > In this function the driver may reinitialize the structures that are used= to read > device counters. >=20 > In case of reinitialization, the number of counters may change, which > wouldn't be taken into account by the get API callback and can cause a > segmentation fault. >=20 > In case of insufficient supplied stats table size, ex. zero to query the = number of [SO] I was embarrassed a little bit with ".ex". Let's clarify? > extended stats, reinitialization may never happen and the returned stats > number, that is used for subsequent stats getting, will not be sufficient= too. >=20 > This issue is fixed by getting and allocating the counters size after the > reinitialization. Yes, it would be fair. >=20 > Fixes: 1a611fdaf6ec ("net/mlx5: support missing counter in extended > statistics") > Fixes: a4193ae3bc4f ("net/mlx5: support extended statistics") > Cc: stable@dpdk.org >=20 > Signed-off-by: Vladislav Grishenko > --- > drivers/net/mlx5/mlx5_stats.c | 35 +++++++++++++++++++++++++---------- > 1 file changed, 25 insertions(+), 10 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.= c > index ae2f5668a7..7dd7724b05 100644 > --- a/drivers/net/mlx5/mlx5_stats.c > +++ b/drivers/net/mlx5/mlx5_stats.c > @@ -39,23 +39,37 @@ mlx5_xstats_get(struct rte_eth_dev *dev, struct > rte_eth_xstat *stats, > unsigned int n) > { > 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; > + uint16_t mlx5_stats_n; > + int stats_n; > + > + stats_n =3D mlx5_os_get_stats_n(dev); > + if (stats_n < 0) > + return stats_n; > + if (xstats_ctrl->stats_n !=3D stats_n) > + mlx5_os_stats_init(dev); > + mlx5_stats_n =3D xstats_ctrl->mlx5_stats_n; >=20 > if (n >=3D mlx5_stats_n && stats) { > - int stats_n; > + uint64_t *counters; > + unsigned int i; > int ret; >=20 > - stats_n =3D mlx5_os_get_stats_n(dev); > - if (stats_n < 0) > - return stats_n; > - if (xstats_ctrl->stats_n !=3D stats_n) > - mlx5_os_stats_init(dev); > + counters =3D mlx5_malloc(MLX5_MEM_SYS, sizeof(*counters) * [SO] My concern is alloc/free - can we revert back to local counter[n] on s= tack ? With best regards, Slava > + mlx5_stats_n, 0, > + SOCKET_ID_ANY); > + if (counters =3D=3D NULL) { > + DRV_LOG(WARNING, "port %u unable to allocate " > + "memory for xstats counters", > + dev->data->port_id); > + rte_errno =3D ENOMEM; > + return -rte_errno; > + } > ret =3D mlx5_os_read_dev_counters(dev, counters); > - if (ret) > + if (ret) { > + mlx5_free(counters); > return ret; > + } > for (i =3D 0; i !=3D mlx5_stats_n; ++i) { > stats[i].id =3D i; > if (xstats_ctrl->info[i].dev) { > @@ -76,6 +90,7 @@ mlx5_xstats_get(struct rte_eth_dev *dev, struct > rte_eth_xstat *stats, > (counters[i] - xstats_ctrl->base[i]); > } > } > + mlx5_free(counters); > } > mlx5_stats_n =3D mlx5_txpp_xstats_get(dev, stats, n, mlx5_stats_n); > return mlx5_stats_n; > -- > 2.17.1