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 06E88A00C2; Thu, 21 Jul 2022 13:20:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A035A40A7A; Thu, 21 Jul 2022 13:20:32 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id B3973400D7 for ; Thu, 21 Jul 2022 13:20:31 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26L76SHv003615; Thu, 21 Jul 2022 04:20:30 -0700 Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3hf2448smh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Jul 2022 04:20:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F4s5l2I8ZVjl+NR3kFqc56VRrvtrQrM8T8qJPw4DqXAHAJ44Z1RXMBTT3Yl+SsQydDDaG8JGxTFFz9mY+GLYNIZLIA0CFJjp6/FDNaj6RCu4eX1ufBXoYKzZq4UfSLRJF9rTwnrkce3jX0fAMo8wAxdxbL0DGI7qG6uyExA9Kw5aM67okuxxRa6NtY0A7MAj+L7finR/eE3KLwfzm/WUaO+iQd0npJuxwdacsrH091qtdX2djGA+b54ugPYBcAQxikVxRNH+bBmLI0x/nUGZpninZtdi/kAKfD7ryLNCBOZnh1YfsYp8QhmKlfVNDlYDkQQusNDQT6RuDNR+c2iIGg== 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=feCWI+lVFgDgNnzbWOYkQ6qDEHovCrZair3yZb0TjL8=; b=eTRqs6wQFpaMOW6nLk0F2908Te6PFwufIWQC194MZJhfpGYqwCSIrH4fao/WwB5gjnuyVwM9xwar09SkYDQFqu2WGnnggl8918o51zhygjjJQN3ClpiVf/jXDsygGClVRyWDagdqOZRlEBhoHoDvSIh7wxnFP4QOoF4TxjW/9oyhmNBOZk3OTtS/Olcy+Dpat5vaidz3ZR1Ei0+Hz1KQufcXjQElAUSQo+pY/P1enNunsOM2/Ojoot7yD03aKHo3+NKZ/R3E3eW+oH3zfnN7K9NdccAafqyIrvqjHGjkT12c5mICrijquhp62nsrXtHBS1p8d04nm5CeKu3G8h+j7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=feCWI+lVFgDgNnzbWOYkQ6qDEHovCrZair3yZb0TjL8=; b=ucvsLrUZuW0go/3OfAwgPBN693AEc2wawUknfmXKOjC3mTguKWeiVCOn0XQxvV6u6bmjXjkWW1+p4wTd1GyMYVfroU30BpZ14UBH5hObL6k/KAoHdoG7ukMgXckUIWbA3o2Cq89J1cj5QBrGG8KamQEXyg2zj8RL4xgSagUE7CQ= Received: from PH0PR18MB5167.namprd18.prod.outlook.com (2603:10b6:510:168::7) by BYAPR18MB2455.namprd18.prod.outlook.com (2603:10b6:a03:132::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18; Thu, 21 Jul 2022 11:20:27 +0000 Received: from PH0PR18MB5167.namprd18.prod.outlook.com ([fe80::55b1:e473:794e:91bb]) by PH0PR18MB5167.namprd18.prod.outlook.com ([fe80::55b1:e473:794e:91bb%8]) with mapi id 15.20.5458.018; Thu, 21 Jul 2022 11:20:27 +0000 From: Amit Prakash Shukla To: Anatoly Burakov , "david.marchand@redhat.com" , "bruce.richardson@intel.com" CC: "dev@dpdk.org" , Jerin Jacob Kollanukkaran Subject: RE: [PATCH v4 1/2] mem: telemetry support for memseg and element information Thread-Topic: [PATCH v4 1/2] mem: telemetry support for memseg and element information Thread-Index: AQHYcCL8vGgRzBvCo0WblTGzoVZTC61O+hGggBivORCAIVvmMA== Date: Thu, 21 Jul 2022 11:20:27 +0000 Message-ID: References: <20220519063038.637836-1-amitprakashs@marvell.com> <20220525103352.1806937-1-amitprakashs@marvell.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 434e36f4-56fb-4435-5c63-08da6b0b0381 x-ms-traffictypediagnostic: BYAPR18MB2455:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: evKy/fknmOqKNXsxLnWejSU0L8O9HHwV86lGp5ZD4UG6rMHU5q87LdnLp4HZB2X5JzhFllIWoe2Mf2MpckTmL2LngdpLeVHvTxatsH8xEFtepeu3p4SjYPFzaBvK1Y/gNLje7cBR5mra+n4UjU3meiT5Xu8d2hvQtY4QHIuGGZhQQBtP/90laB7sFQhz19S8d60DMwgnfzBbRKepGTcLKn8MZMhD5AR98mIYZKuANsdv12edYML677QL4Biq19bh2kSc58V546R2tcq4KsrQvIqSYWL+jWCgLzy6jAdPILpw/FvAqlkMO5wqoPaWFSDvn2+RLTmqyeLjR3HIpFhMuJBeooGsy5YF0oq19KC4w7UwktYMKZDfkSrwE5RO2UJaxSeuXlx6CbmMZum39J9olVk2K1XRlaeW523Fx5Ww/iO5cNF0vthRSL2jqwe9mfO7mgaaqoZ3kS0UlaJRoYbCsTfT7DGO6r7gXaQfpJ3uK6IfQ8AspGN1UqH80LZyvTEBg5VNTR75AS08EXZt1CSCunt/+10CCzVzB2sqCrSdn2QYHLZSLoXW4ri0vylX/BWYyFczm1GJLMKs5Oogck0zSZNcKzYXbHjf2JFtaVK9hlMz8064Jcvg1KKUsOi+xCtQZM48plqzFWwY+KvEYcu5DCg+cG4yWFaApDBNa9Sxss0uEtBp7t+VByUH1dW1Ak560Gj+Fs24WMBh2hTEEN1XqZgWhmBSxarvnWEL9NJS6F/Q2cWcK7vLYnIXT4mBNjVRixGNG0eZm/GnPRkQ+V+3RHXcJX/RBJrdOCsTUK3O1FRfrzSwLE3kfLlSeRRTC3BW x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR18MB5167.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39860400002)(136003)(346002)(376002)(396003)(366004)(186003)(38100700002)(316002)(107886003)(66946007)(9686003)(26005)(110136005)(76116006)(66446008)(66476007)(66556008)(38070700005)(64756008)(86362001)(54906003)(4326008)(8676002)(71200400001)(53546011)(2906002)(6506007)(83380400001)(7696005)(55016003)(122000001)(52536014)(478600001)(33656002)(30864003)(8936002)(41300700001)(5660300002)(579004); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?oZvQtpZdG7Z2GtRUG4zz4QsT+9EE9woAJ4+nY8ZuO9kJ5fL6cDZpk87QYkjL?= =?us-ascii?Q?1tXRJfWT/JLOTKQYBzH605cLvtSgNrXG8xsySMWdC2qg4M6y44k5jNynr6I8?= =?us-ascii?Q?x2t+P2yz/PIH6Bltbysvn+4v2fjXDnktHj6Iui+c/eSfQRM+f6q1zrj1WJJz?= =?us-ascii?Q?/MCMQGsUfEFYNnCE/GSuGVUGQfPFhmTLQjgNSYqOqGac936RkjgK6CaeQc5t?= =?us-ascii?Q?UIR+Qp+5wk+j8ppRzNFUC3pv5y10E2DtoZ7yG2RaPHigxQW+KR5i5nvzOLQl?= =?us-ascii?Q?4REtKzQej5f0hxmTeXVUxYQ2pfFkZSw/avz1TbcGo3reXZmBMkGoICeXD3sQ?= =?us-ascii?Q?OoG+aEPINj24xQeRNyK9MKy7n+YxMVsQ1+r/7m/1ONJClSW+ZqRSVvBfel5n?= =?us-ascii?Q?EnmLo2tfmyDFhB++E5bSWbLj4sWOj9cLPGBDgHxvF1uTwxRMyz3Rb4S/fh4b?= =?us-ascii?Q?uK/MLrfs838+/A2oYKqsl9uf0cKCG+evw0Uk+XBBwDtceJBRowdKLPA/Llcw?= =?us-ascii?Q?Gz+Ip1Lf+BuDlHHsQ6Zp0D5N57F/J2PgwHXtkIjF2VTSQhxVA9M5KlmNCLdm?= =?us-ascii?Q?vCdXzzRvjsF8NEDXuB+Cu2v+rYpEtjeI7vkg95pm1QcY6OreAavnyiTNK3U8?= =?us-ascii?Q?fm/HWMq3VTrfFFihgmfocveDKfVsjrY3tm2JgL2nPXJDTbKN86cKCHMOFEYL?= =?us-ascii?Q?KnI4cwdgbLBK2kJdPqjC7d7akSIay1Cf21i/ZCHFwPsrpaHGLt3qCeRgIo/s?= =?us-ascii?Q?5st2nnlfvuPxnhT4FVOsXzacw+mP4BL7P3b8TjNPu7UsCAJfB1dUncGIHSDC?= =?us-ascii?Q?xbEbSzxaAKvYVPsAv5wkutKFyKSRc9vNGn3lYCY9Oxn2A8rwrBwCUKxfpHKs?= =?us-ascii?Q?5EpF3ff2pg/PfYz38mGC1khxLI47MckJCalxzXpul73L9+WUq81Yy/IbTAJ+?= =?us-ascii?Q?SBiSb7abcobRKWEzDZDCOyBVrtwA2QX/uTCpDuEVSNhoe/qnVnTwhM8HGGhs?= =?us-ascii?Q?sZfXPLpy1akeW3yqhQcAOkmjin+c4mJ553TCuWJGl2jfVdGDrDJs14hyxy7f?= =?us-ascii?Q?zeiRqILgm3ufMYYjZudowGHwalC6keiFbkolUr9DU+J8TwO6veOGofWD6dXH?= =?us-ascii?Q?UPkMIXcDRk1qZzZ54IGQTAwy0mhTD8BBrkCpPbuRfjT4u5QMq1wJgfQNUt7k?= =?us-ascii?Q?mOAg6Nmtu12LVt5sRJzkxDePBl6v2vCJaFli6oUShEEN0i+uY5sFeiAeE1kg?= =?us-ascii?Q?4d1wXbXc7BbqaHVUXGNN3SRvLwYGrvZfETqbVNRLNIxUr69ZyYVJ1HchzZqN?= =?us-ascii?Q?MOEKiFITvAetJA9BsfoNO9FY86AOip0o5EGAny2YpCl491DLk6MNDp2VNtUl?= =?us-ascii?Q?1ukfwTDDzRmp/MyA/RfmnplYWSwLlZY16gQCctxOGAGzBmOTwM5pqlt1hQ01?= =?us-ascii?Q?mYX53cZsRyVJsTIeDM3I32lMi40FMfzdiuxuMkYkH3xUMsRVsQQEUoD+Gm9H?= =?us-ascii?Q?udb7ADvsVxnFpjOPQ6DL1CQ0YhOwMJ1hWoOARD01YxXm+0dQ2/OGKaot1PmJ?= =?us-ascii?Q?B8qBsBuEVar4fX2iFuE59OR9MC4YPVFupCe6iwcq?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: marvell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR18MB5167.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 434e36f4-56fb-4435-5c63-08da6b0b0381 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jul 2022 11:20:27.3812 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ma7Ib6mHjLkilIIq5f5Yy2OUjdY/B7aQXaJZ8Tm0nBVG/r3iXPufkd/SH3fSnwqedX+6iJIKZo44v1zMaMCsJY8Kz6gCDtiBYB6LSV7+sOQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2455 X-Proofpoint-GUID: dEjzkb1tC9ggEX3N7EBJP-SMkMn7lKJK X-Proofpoint-ORIG-GUID: dEjzkb1tC9ggEX3N7EBJP-SMkMn7lKJK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_15,2022-07-20_01,2022-06-22_01 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 Ping for review or feedback for the updated patch. Thanks, Amit Shukla > -----Original Message----- > From: Amit Prakash Shukla > Sent: Thursday, June 30, 2022 11:22 AM > To: Anatoly Burakov ; > david.marchand@redhat.com; bruce.richardson@intel.com > Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran > Subject: RE: [PATCH v4 1/2] mem: telemetry support for memseg and > element information >=20 > Ping. >=20 > > -----Original Message----- > > From: Amit Prakash Shukla > > Sent: Tuesday, June 14, 2022 6:21 PM > > To: Amit Prakash Shukla ; Anatoly Burakov > > > > Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran ; > > bruce.richardson@intel.com > > Subject: RE: [PATCH v4 1/2] mem: telemetry support for memseg and > > element information > > > > Ping. > > > > > -----Original Message----- > > > From: Amit Prakash Shukla > > > Sent: Wednesday, May 25, 2022 4:04 PM > > > To: Anatoly Burakov > > > Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran ; > > > bruce.richardson@intel.com; Amit Prakash Shukla > > > > > > Subject: [PATCH v4 1/2] mem: telemetry support for memseg and > > > element information > > > > > > Changes adds telemetry support to display memory occupancy in > memseg > > > and the information of the elements allocated from a memseg based on > > > arguments provided by user. This patch adds following endpoints: > > > > > > 1. /eal/memseg_list_array > > > The command displays the memseg list from which the memory has been > > > allocated. > > > Example: > > > --> /eal/memseg_list_array > > > {"/eal/memseg_list_array": [0, 1]} > > > > > > 2. /eal/memseg_list_info, > > > The command outputs the memsegs, from which the memory is > allocated, > > > for the memseg_list given as input. Command also supports help. > > > Example: > > > --> /eal/memseg_list_info,help > > > {"/eal/memseg_list_info": "/eal/memseg_list_info,"} > > > > > > --> /eal/memseg_list_info,1 > > > {"/eal/memseg_list_info": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, \ > > > 12, 13, 14, 15]} > > > > > > 3. /eal/memseg_info,, > > > The command outputs the memseg information based on the memseg- > list > > > and the memseg-id given as input. Command also supports help. > > > Example: > > > --> /eal/memseg_info,help > > > {"/eal/memseg_info": "/eal/memseg_info,, \ > > > id>"} > > > > > > --> /eal/memseg_info,0,10 > > > {"/eal/memseg_info": {"Memseg_list_index": 0, \ > > > "Memseg_index": 10, "Memseg_list_len": 64, \ > > > "Start_addr": "0x260000000", "End_addr": "0x280000000", \ > > > "Size": 536870912}} > > > > > > --> /eal/memseg_info,1,15 > > > {"/eal/memseg_info": {"Memseg_list_index": 1, \ > > > "Memseg_index": 15, "Memseg_list_len": 64, \ > > > "Start_addr": "0xb20000000", "End_addr": "0xb40000000", \ > > > "Size": 536870912}} > > > > > > 4. /eal/element_list,,, > > > The command outputs number of elements in a memseg based on the > > heap- > > > id, memseg-list-id and memseg-id given as input. > > > Command also supports help. > > > Example: > > > --> /eal/element_list,help > > > {"/eal/element_list": "/eal/element_list,, \ > > id>,"} > > > > > > --> /eal/element_list,0,0,63 > > > {"/eal/element_list": {"Element_count": 52}} > > > > > > --> /eal/element_list,0,1,15 > > > {"/eal/element_list": {"Element_count": 52}} > > > > > > 5. /eal/element_info,,,, \ > > > , > > > The command outputs element information like element start address, > > > end address, to which memseg it belongs, element state, element size. > > > User can give a range of elements to be printed. Command also > > > supports > > help. > > > Example: > > > --> /eal/element_info,help > > > {"/eal/element_info": "/eal/element_info,, \ > > id>,,,"} > > > > > > --> /eal/element_info,0,1,15,1,2 > > > {"/eal/element_info": {"element.1": {"msl_id": 1, \ > > > "ms_id": 15, "memseg_start_addr": "0xb20000000", \ > > > "memseg_end_addr": "0xb40000000", \ > > > "element_start_addr": "0xb201fe680", \ > > > "element_end_addr": "0xb20bfe700", \ > > > "element_size": 10485888, "element_state": "Busy"}, \ > > > "element.2": {"msl_id": 1, "ms_id": 15, \ > > > "memseg_start_addr": "0xb20000000", \ > > > "memseg_end_addr": "0xb40000000", \ > > > "element_start_addr": "0xb20bfe700", \ > > > "element_end_addr": "0xb215fe780", "element_size": 10485888, \ > > > "element_state": "Busy"}, "Element_count": 2}} > > > > > > Signed-off-by: Amit Prakash Shukla > > > --- > > > v2: > > > - Fixed compilation error related int-to-pointer-cast > > > - Changes for code review suggestions > > > > > > v3: > > > - Commit message changes > > > - Renaming end-points > > > - Changing input parameters to comma-seperated > > > - Reverting telemetry output buffer size > > > > > > v4: > > > - Patch-2 adds telemetry support to display system memory > > > > > > lib/eal/common/eal_common_memory.c | 482 > > > ++++++++++++++++++++++++++++- > > > 1 file changed, 477 insertions(+), 5 deletions(-) > > > > > > diff --git a/lib/eal/common/eal_common_memory.c > > > b/lib/eal/common/eal_common_memory.c > > > index 688dc615d7..e66de6a872 100644 > > > --- a/lib/eal/common/eal_common_memory.c > > > +++ b/lib/eal/common/eal_common_memory.c > > > @@ -26,6 +26,7 @@ > > > #include "eal_memcfg.h" > > > #include "eal_options.h" > > > #include "malloc_heap.h" > > > +#include "malloc_elem.h" > > > > > > /* > > > * Try to mmap *size bytes in /dev/zero. If it is successful, > > > return the @@ - > > > 1113,11 +1114,17 @@ rte_eal_memory_init(void) } > > > > > > #ifndef RTE_EXEC_ENV_WINDOWS > > > -#define EAL_MEMZONE_LIST_REQ "/eal/memzone_list" > > > -#define EAL_MEMZONE_INFO_REQ "/eal/memzone_info" > > > -#define EAL_HEAP_LIST_REQ "/eal/heap_list" > > > -#define EAL_HEAP_INFO_REQ "/eal/heap_info" > > > -#define ADDR_STR 15 > > > +#define EAL_MEMZONE_LIST_REQ "/eal/memzone_list" > > > +#define EAL_MEMZONE_INFO_REQ > > "/eal/memzone_info" > > > +#define EAL_HEAP_LIST_REQ "/eal/heap_list" > > > +#define EAL_HEAP_INFO_REQ "/eal/heap_info" > > > +#define EAL_MEMSEG_LIST_ARR_REQ > > > "/eal/memseg_list_array" > > > +#define EAL_MEMSEG_LIST_INFO_REQ "/eal/memseg_list_info" > > > +#define EAL_MEMSEG_INFO_REQ "/eal/memseg_info" > > > +#define EAL_ELEMENT_LIST_REQ "/eal/element_list" > > > +#define EAL_ELEMENT_INFO_REQ "/eal/element_info" > > > +#define ADDR_STR 15 > > > + > > > > > > /* Telemetry callback handler to return heap stats for requested > > > heap id. */ static int @@ -1265,6 +1272,454 @@ > > > handle_eal_memzone_list_request(const char *cmd __rte_unused, > > > return 0; > > > } > > > > > > +static int > > > +handle_eal_memseg_list_array_request(const char *cmd > __rte_unused, > > > + const char *params __rte_unused, > > > + struct rte_tel_data *d) > > > +{ > > > + struct rte_mem_config *mcfg; > > > + int i; > > > + > > > + rte_tel_data_start_array(d, RTE_TEL_INT_VAL); > > > + > > > + rte_mcfg_mem_read_lock(); > > > + mcfg =3D rte_eal_get_configuration()->mem_config; > > > + > > > + for (i =3D 0; i < RTE_MAX_MEMSEG_LISTS; i++) { > > > + struct rte_memseg_list *msl =3D &mcfg->memsegs[i]; > > > + if (msl->memseg_arr.count =3D=3D 0) > > > + continue; > > > + > > > + rte_tel_data_add_array_int(d, i); > > > + } > > > + rte_mcfg_mem_read_unlock(); > > > + > > > + return 0; > > > +} > > > + > > > +static int > > > +handle_eal_memseg_list_info_request(const char *cmd > __rte_unused, > > > + const char *params, struct rte_tel_data *d) > > > { > > > + struct rte_mem_config *mcfg; > > > + struct rte_memseg_list *msl; > > > + struct rte_fbarray *arr; > > > + uint32_t ms_list_idx; > > > + int ms_idx; > > > + > > > + if (params =3D=3D NULL || strlen(params) =3D=3D 0) > > > + return -1; > > > + > > > + if (strncasecmp(params, "help", strlen(params)) =3D=3D 0) { > > > + char buff[RTE_TEL_MAX_SINGLE_STRING_LEN]; > > > + snprintf(buff, RTE_TEL_MAX_SINGLE_STRING_LEN, > > > + "%s,", > > > EAL_MEMSEG_LIST_INFO_REQ); > > > + rte_tel_data_string(d, buff); > > > + return 0; > > > + } > > > + > > > + if (!isdigit(*params)) > > > + return -1; > > > + > > > + ms_list_idx =3D strtoul(params, NULL, 10); > > > + if (ms_list_idx >=3D RTE_MAX_MEMSEG_LISTS) > > > + return -1; > > > + > > > + rte_tel_data_start_array(d, RTE_TEL_INT_VAL); > > > + > > > + rte_mcfg_mem_read_lock(); > > > + mcfg =3D rte_eal_get_configuration()->mem_config; > > > + msl =3D &mcfg->memsegs[ms_list_idx]; > > > + if (msl->memseg_arr.count =3D=3D 0) > > > + goto done; > > > + > > > + arr =3D &msl->memseg_arr; > > > + > > > + ms_idx =3D rte_fbarray_find_next_used(arr, 0); > > > + while (ms_idx >=3D 0) { > > > + rte_tel_data_add_array_int(d, ms_idx); > > > + ms_idx =3D rte_fbarray_find_next_used(arr, ms_idx + 1); > > > + } > > > + > > > +done: > > > + rte_mcfg_mem_read_unlock(); > > > + > > > + return 0; > > > +} > > > + > > > +static int > > > +handle_eal_memseg_info_request(const char *cmd __rte_unused, > > > + const char *params, struct rte_tel_data *d) { > > > + struct rte_mem_config *mcfg; > > > + uint64_t ms_start_addr, ms_end_addr, ms_size; > > > + struct rte_memseg_list *msl; > > > + const struct rte_memseg *ms; > > > + struct rte_fbarray *arr; > > > + char addr[ADDR_STR]; > > > + uint32_t ms_list_idx =3D 0; > > > + uint32_t ms_idx =3D 0; > > > + uint32_t msl_len; > > > + char dlim[2] =3D ","; > > > + char *token; > > > + char *params_args; > > > + > > > + if (params =3D=3D NULL || strlen(params) =3D=3D 0) > > > + return -1; > > > + > > > + if (strncasecmp(params, "help", strlen(params)) =3D=3D 0) { > > > + char buff[RTE_TEL_MAX_SINGLE_STRING_LEN]; > > > + snprintf(buff, RTE_TEL_MAX_SINGLE_STRING_LEN, > > > + "%s,,", > > > + EAL_MEMSEG_INFO_REQ); > > > + rte_tel_data_string(d, buff); > > > + return 0; > > > + } > > > + > > > + /* strtok expects char * and param is const char *. Hence on using > > > + * params as "const char *" compiler throws warning. > > > + */ > > > + params_args =3D strdup(params); > > > + token =3D strtok(params_args, dlim); > > > + if (token =3D=3D NULL || !isdigit(*token)) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + ms_list_idx =3D strtoul(token, NULL, 10); > > > + if (ms_list_idx >=3D RTE_MAX_MEMSEG_LISTS) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + token =3D strtok(NULL, dlim); > > > + if (token =3D=3D NULL || !isdigit(*token)) { > > > + free(params_args); > > > + return -1; > > > + } > > > + ms_idx =3D strtoul(token, NULL, 10); > > > + > > > + free(params_args); > > > + > > > + rte_mcfg_mem_read_lock(); > > > + > > > + mcfg =3D rte_eal_get_configuration()->mem_config; > > > + msl =3D &mcfg->memsegs[ms_list_idx]; > > > + if (msl->memseg_arr.count =3D=3D 0) { > > > + rte_mcfg_mem_read_unlock(); > > > + return -1; > > > + } > > > + > > > + arr =3D &msl->memseg_arr; > > > + msl_len =3D arr->len; > > > + > > > + ms =3D rte_fbarray_get(arr, ms_idx); > > > + if (ms =3D=3D NULL) { > > > + rte_mcfg_mem_read_unlock(); > > > + RTE_LOG(DEBUG, EAL, "Error fetching requested > > > memseg.\n"); > > > + return -1; > > > + } > > > + > > > + ms_start_addr =3D ms->addr_64; > > > + ms_end_addr =3D (uint64_t)RTE_PTR_ADD(ms_start_addr, ms->len); > > > + ms_size =3D ms->hugepage_sz; > > > + > > > + rte_mcfg_mem_read_unlock(); > > > + > > > + rte_tel_data_start_dict(d); > > > + rte_tel_data_add_dict_int(d, "Memseg_list_index", ms_list_idx); > > > + rte_tel_data_add_dict_int(d, "Memseg_index", ms_idx); > > > + rte_tel_data_add_dict_int(d, "Memseg_list_len", msl_len); > > > + snprintf(addr, ADDR_STR, "0x%"PRIx64, ms_start_addr); > > > + rte_tel_data_add_dict_string(d, "Start_addr", addr); > > > + snprintf(addr, ADDR_STR, "0x%"PRIx64, ms_end_addr); > > > + rte_tel_data_add_dict_string(d, "End_addr", addr); > > > + rte_tel_data_add_dict_int(d, "Size", ms_size); > > > + > > > + return 0; > > > +} > > > + > > > +static int > > > +handle_eal_element_list_request(const char *cmd __rte_unused, > > > + const char *params, struct rte_tel_data *d) { > > > + struct rte_mem_config *mcfg; > > > + struct rte_memseg_list *msl; > > > + const struct rte_memseg *ms; > > > + struct malloc_elem *elem; > > > + struct malloc_heap *heap; > > > + uint64_t ms_start_addr, ms_end_addr; > > > + uint64_t elem_start_addr, elem_end_addr; > > > + uint32_t ms_list_idx =3D 0; > > > + uint32_t heap_id =3D 0; > > > + uint32_t ms_idx =3D 0; > > > + char dlim[2] =3D ","; > > > + int elem_count =3D 0; > > > + char *token; > > > + char *params_args; > > > + > > > + if (params =3D=3D NULL || strlen(params) =3D=3D 0) > > > + return -1; > > > + > > > + if (strncasecmp(params, "help", strlen(params)) =3D=3D 0) { > > > + char buff[RTE_TEL_MAX_SINGLE_STRING_LEN]; > > > + snprintf(buff, RTE_TEL_MAX_SINGLE_STRING_LEN, > > > + "%s,,,", > > > + EAL_ELEMENT_LIST_REQ); > > > + rte_tel_data_string(d, buff); > > > + return 0; > > > + } > > > + > > > + /* strtok expects char * and param is const char *. Hence on using > > > + * params as "const char *" compiler throws warning. > > > + */ > > > + params_args =3D strdup(params); > > > + token =3D strtok(params_args, dlim); > > > + if (token =3D=3D NULL || !isdigit(*token)) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + heap_id =3D strtoul(token, NULL, 10); > > > + if (heap_id >=3D RTE_MAX_HEAPS) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + token =3D strtok(NULL, dlim); > > > + if (token =3D=3D NULL || !isdigit(*token)) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + ms_list_idx =3D strtoul(token, NULL, 10); > > > + if (ms_list_idx >=3D RTE_MAX_MEMSEG_LISTS) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + token =3D strtok(NULL, dlim); > > > + if (token =3D=3D NULL || !isdigit(*token)) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + ms_idx =3D strtoul(token, NULL, 10); > > > + > > > + free(params_args); > > > + > > > + rte_mcfg_mem_read_lock(); > > > + > > > + mcfg =3D rte_eal_get_configuration()->mem_config; > > > + msl =3D &mcfg->memsegs[ms_list_idx]; > > > + ms =3D rte_fbarray_get(&msl->memseg_arr, ms_idx); > > > + if (ms =3D=3D NULL) { > > > + rte_mcfg_mem_read_unlock(); > > > + RTE_LOG(DEBUG, EAL, "Error fetching requested > > > memseg.\n"); > > > + return -1; > > > + } > > > + > > > + ms_start_addr =3D ms->addr_64; > > > + ms_end_addr =3D (uint64_t)RTE_PTR_ADD(ms_start_addr, ms->len); > > > + rte_mcfg_mem_read_unlock(); > > > + > > > + rte_tel_data_start_dict(d); > > > + > > > + heap =3D &mcfg->malloc_heaps[heap_id]; > > > + rte_spinlock_lock(&heap->lock); > > > + > > > + elem =3D heap->first; > > > + while (elem) { > > > + elem_start_addr =3D (uint64_t)elem; > > > + elem_end_addr =3D > > > + (uint64_t)RTE_PTR_ADD(elem_start_addr, elem- > > > >size); > > > + > > > + if ((uint64_t)elem_start_addr >=3D ms_start_addr && > > > + (uint64_t)elem_end_addr <=3D ms_end_addr) > > > + elem_count++; > > > + elem =3D elem->next; > > > + } > > > + > > > + rte_spinlock_unlock(&heap->lock); > > > + > > > + rte_tel_data_add_dict_int(d, "Element_count", elem_count); > > > + > > > + return 0; > > > +} > > > + > > > +static int > > > +handle_eal_element_info_request(const char *cmd __rte_unused, > > > + const char *params, struct rte_tel_data *d) { > > > + struct rte_mem_config *mcfg; > > > + struct rte_memseg_list *msl; > > > + const struct rte_memseg *ms; > > > + struct malloc_elem *elem; > > > + struct malloc_heap *heap; > > > + struct rte_tel_data *c; > > > + uint64_t ms_start_addr, ms_end_addr; > > > + uint64_t elem_start_addr, elem_end_addr; > > > + uint32_t ms_list_idx =3D 0; > > > + uint32_t heap_id =3D 0; > > > + uint32_t ms_idx =3D 0; > > > + uint32_t start_elem =3D 0, end_elem =3D 0; > > > + uint32_t count =3D 0, elem_count =3D 0; > > > + char dlim[2] =3D ","; > > > + char str[ADDR_STR]; > > > + char *params_args; > > > + char *token; > > > + > > > + if (params =3D=3D NULL || strlen(params) =3D=3D 0) > > > + return -1; > > > + > > > + if (strncasecmp(params, "help", strlen(params)) =3D=3D 0) { > > > + char buff[RTE_TEL_MAX_SINGLE_STRING_LEN]; > > > + snprintf(buff, RTE_TEL_MAX_SINGLE_STRING_LEN, > > > + "%s,,,," > > > + ",", > > > + EAL_ELEMENT_INFO_REQ); > > > + rte_tel_data_string(d, buff); > > > + return 0; > > > + } > > > + > > > + /* strtok expects char * and param is const char *. Hence on using > > > + * params as "const char *" compiler throws warning. > > > + */ > > > + params_args =3D strdup(params); > > > + token =3D strtok(params_args, dlim); > > > + if (token =3D=3D NULL || !isdigit(*token)) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + heap_id =3D strtoul(token, NULL, 10); > > > + if (heap_id >=3D RTE_MAX_HEAPS) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + token =3D strtok(NULL, dlim); > > > + if (token =3D=3D NULL || !isdigit(*token)) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + ms_list_idx =3D strtoul(token, NULL, 10); > > > + if (ms_list_idx >=3D RTE_MAX_MEMSEG_LISTS) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + token =3D strtok(NULL, dlim); > > > + if (token =3D=3D NULL || !isdigit(*token)) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + ms_idx =3D strtoul(token, NULL, 10); > > > + > > > + token =3D strtok(NULL, dlim); > > > + if (token =3D=3D NULL || !isdigit(*token)) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + start_elem =3D strtoul(token, NULL, 10); > > > + > > > + token =3D strtok(NULL, dlim); > > > + if (token =3D=3D NULL || !isdigit(*token)) { > > > + free(params_args); > > > + return -1; > > > + } > > > + > > > + end_elem =3D strtoul(token, NULL, 10); > > > + > > > + free(params_args); > > > + > > > + if (end_elem < start_elem) > > > + return -1; > > > + > > > + rte_mcfg_mem_read_lock(); > > > + > > > + mcfg =3D rte_eal_get_configuration()->mem_config; > > > + msl =3D &mcfg->memsegs[ms_list_idx]; > > > + ms =3D rte_fbarray_get(&msl->memseg_arr, ms_idx); > > > + if (ms =3D=3D NULL) { > > > + rte_mcfg_mem_read_unlock(); > > > + RTE_LOG(DEBUG, EAL, "Error fetching requested > > > memseg.\n"); > > > + return -1; > > > + } > > > + > > > + ms_start_addr =3D ms->addr_64; > > > + ms_end_addr =3D (uint64_t)RTE_PTR_ADD(ms_start_addr, ms->len); > > > + > > > + rte_mcfg_mem_read_unlock(); > > > + > > > + rte_tel_data_start_dict(d); > > > + > > > + heap =3D &mcfg->malloc_heaps[heap_id]; > > > + rte_spinlock_lock(&heap->lock); > > > + > > > + elem =3D heap->first; > > > + while (elem) { > > > + elem_start_addr =3D (uint64_t)elem; > > > + elem_end_addr =3D > > > + (uint64_t)RTE_PTR_ADD(elem_start_addr, elem- > > > >size); > > > + > > > + if (elem_start_addr < ms_start_addr || > > > + elem_end_addr > ms_end_addr) { > > > + elem =3D elem->next; > > > + continue; > > > + } > > > + > > > + if (count < start_elem) { > > > + elem =3D elem->next; > > > + count++; > > > + continue; > > > + } > > > + > > > + c =3D rte_tel_data_alloc(); > > > + if (c =3D=3D NULL) > > > + break; > > > + > > > + rte_tel_data_start_dict(c); > > > + rte_tel_data_add_dict_int(c, "msl_id", ms_list_idx); > > > + rte_tel_data_add_dict_int(c, "ms_id", ms_idx); > > > + snprintf(str, ADDR_STR, "0x%"PRIx64, ms_start_addr); > > > + rte_tel_data_add_dict_string(c, "memseg_start_addr", str); > > > + snprintf(str, ADDR_STR, "0x%"PRIx64, ms_end_addr); > > > + rte_tel_data_add_dict_string(c, "memseg_end_addr", str); > > > + snprintf(str, ADDR_STR, "0x%"PRIx64, elem_start_addr); > > > + rte_tel_data_add_dict_string(c, "element_start_addr", str); > > > + snprintf(str, ADDR_STR, "0x%"PRIx64, elem_end_addr); > > > + rte_tel_data_add_dict_string(c, "element_end_addr", str); > > > + rte_tel_data_add_dict_int(c, "element_size", elem->size); > > > + snprintf(str, ADDR_STR, "%s", elem->state =3D=3D 0 ? "Free" : > > > + elem->state =3D=3D 1 ? "Busy" : elem->state =3D=3D 2 ? > > > + "Pad" : "Error"); > > > + rte_tel_data_add_dict_string(c, "element_state", str); > > > + > > > + snprintf(str, ADDR_STR, "%s.%u", "element", count); > > > + if (rte_tel_data_add_dict_container(d, str, c, 0) !=3D 0) { > > > + rte_tel_data_free(c); > > > + break; > > > + } > > > + > > > + elem_count++; > > > + count++; > > > + if (count > end_elem) > > > + break; > > > + > > > + elem =3D elem->next; > > > + } > > > + > > > + rte_spinlock_unlock(&heap->lock); > > > + > > > + rte_tel_data_add_dict_int(d, "Element_count", elem_count); > > > + > > > + return 0; > > > +} > > > + > > > RTE_INIT(memory_telemetry) > > > { > > > rte_telemetry_register_cmd( > > > @@ -1279,5 +1734,22 @@ RTE_INIT(memory_telemetry) > > > rte_telemetry_register_cmd( > > > EAL_HEAP_INFO_REQ, > > > handle_eal_heap_info_request, > > > "Returns malloc heap stats. Parameters: int > > heap_id"); > > > + rte_telemetry_register_cmd( > > > + EAL_MEMSEG_LIST_ARR_REQ, > > > + handle_eal_memseg_list_array_request, > > > + "Returns hugepage list. Takes no parameters"); > > > + rte_telemetry_register_cmd( > > > + EAL_MEMSEG_LIST_INFO_REQ, > > > + handle_eal_memseg_list_info_request, > > > + "Returns memseg list. Parameters: int > > > memseg_list_id"); > > > + rte_telemetry_register_cmd( > > > + EAL_MEMSEG_INFO_REQ, > > > handle_eal_memseg_info_request, > > > + "Returns memseg info. Parameter: int > > > memseg_list_id,int memseg_id"); > > > + rte_telemetry_register_cmd(EAL_ELEMENT_LIST_REQ, > > > + handle_eal_element_list_request, > > > + "Returns element info. Parameters: int heap_id, int > > > memseg_list_id, int memseg_id"); > > > + rte_telemetry_register_cmd(EAL_ELEMENT_INFO_REQ, > > > + handle_eal_element_info_request, > > > + "Returns element info. Parameters: int heap_id, > > > memseg_list_id, > > > +memseg_id, start_elem_id, end_elem_id"); > > > } > > > #endif > > > -- > > > 2.25.1