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 3AE39A00C2; Thu, 21 Jul 2022 13:21:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2A1AA40A7A; Thu, 21 Jul 2022 13:21:19 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 9D9EE400D7 for ; Thu, 21 Jul 2022 13:21:17 +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 26L76NQ8003324; Thu, 21 Jul 2022 04:21:16 -0700 Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2108.outbound.protection.outlook.com [104.47.58.108]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3hf2448spa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Jul 2022 04:21:16 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kFO0Q8V8YZR/VChH9n1HqLyXAMXzTS9BwEq/oz24LgmBD3h3/TgGjQ5JE3Bub9tdL5cPlRnKdvQb/YnK3kcEdvyNpSBGxEhcS62dZvrSKtdHYw/7Ihl4rj3bzfWfNkZQLy00oEt/K5vskfrQIgMTxpBZb+IPxVlwBQVsc1nDVsTtF3gLVhJidlfv/1395FwVPX3dFU+hZYn2xZ+xtSyrYqkta4vLSc7r7AXdd88eHUYZXgTQQJpe28WzKr7rN3PLMTDLfozl3Ef5IyE8NSlRdsFrkcdgW1nIqqmVsKXbczHiAHynvG527fHyCKkfvPdyZP3W7mb5QkOzAkb/Ftxj5A== 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=taUEjZ90KrV3LEBrdPyrikfMG5UHhfK2mDR/ru0+OT4=; b=PJcJoVwujEs3yTWNWtSPmqhzF0ewETBXb8g9p1HAPNmQXbctGS1yNEQoOvMcC2aT8Ra+0vY0G2hmMsQQTv8X2poQxHDy5/RV8W+22hHBBv+MG51K1Tt0vbm/z+YtHI+VEtr4bqJ1wv7aodyjP9Z58lLDUOes2U/r2AjgFoq2qGzvKFWbmBJizHOF3uErY3h4FWn8juKAKXVrEo2gt8oO4/fjuyN9hw3C8rmLA9ZIzrcvLXXQThqaAuw7msekVsTwxGbTCX6XppuA26aCnB1ITdgMu1RKwNlqyhLRXlAV6DwkxNYIXwpDNq3yc5Lk9mqF533W89PqoSwJEXzCCKyXDA== 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=taUEjZ90KrV3LEBrdPyrikfMG5UHhfK2mDR/ru0+OT4=; b=kBqHeAljGJCsGCeGkjfOoaOf2E2KTGPIIm70Qv+gSEtg0pm5YXpXbSS3ZsUcebo2+qoTk/dLOUV8NVVx24DbwMEFstx7KACYkHFuFIC2NJSOdxsI4NJFuVLFMyjjYBvdx8IwyJAKM8jP1nLhELGMpH+zQmF2pM9/P5jJFu9t/Ns= 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:21:14 +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:21:14 +0000 From: Amit Prakash Shukla To: Anatoly Burakov , "bruce.richardson@intel.com" , "david.marchand@redhat.com" CC: "dev@dpdk.org" , Jerin Jacob Kollanukkaran Subject: RE: [PATCH v4 2/2] mem: telemetry support for system memory information Thread-Topic: [PATCH v4 2/2] mem: telemetry support for system memory information Thread-Index: AQHYcCMKTIJQHjQ95ESVw4YRPnDShq1nqw5wgCFcdQA= Date: Thu, 21 Jul 2022 11:21:14 +0000 Message-ID: References: <20220519063038.637836-1-amitprakashs@marvell.com> <20220525103352.1806937-1-amitprakashs@marvell.com> <20220525103352.1806937-2-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: 38fda76e-8d9d-4806-0226-08da6b0b1f9b 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: aHazIAu8c/ZX10qtmPxN+ywcV5t8hdN1QvaRKkgOApSdR9YSplV7yxEfZ++kAVnJo5gWcmZHNjncbYGVQ88/ssqhc2CkPYgR2rDvqyZ181KE5gFaijB9sCpLw9BI1p3yV7HDfU8uK0oWruIWWrPOUTFtsEcaFg06ka959/DZzlGW+tof8qW8pyVb4V6cvXI3O2FbMTE6FH2LKxTd20A3Xi6eaVRVW3eeH+qnlOhnq83M4CCMvn1WAWSWSpgXLE/nOO2DC6wigvPOw9FVDs3Tr5ljJBDCs6PCqaBk3hooBlOq0IwbUa9SZiZ5SbOMOVUQJiDflK3A0MddO1sT+LPgIlmtE8JFMDfdmIFxmxV7jObG005xb/BMI0n54W2AApfmSHFHhJt3K49lXfYaaSPfDKSsUJ3ouO3jHDtSYsLht9cK/J0zNF+UvCOxDApaVNM6+4tDKiPI6lvjVkLmdqGkHM4d+XOzWkA2ddwNQG9t2irQToai2qzCzSN9PkzI3mJZhArjDs5K7NxWxt8JqhMrY/zxTPte4Iak24k90RMplfDwly+nDeXtwpAqLk9cpKgNbkBldxu6KAZidJj3zWXDTGwn1eQfL3DTFdMULfU3se0rzgV5PvJ2v6PYQKbA20yxIxoFtU2uyDbhmA935m8MX17F2G2DPfGEddtkBjyyFMr5ycG8SRuHQ0cgY02DxAVPGly9+9eICHVKibWyOR/gBCmy688/qlynvuyU3Ctjmy4qBaNO0WSTARG+o+NS6t0poWeA9OPjWVw8h/u8ozOa5fxNqn+EnXrBwY4byZGpmSE= 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); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?cjlElW9z14PMHmktq3AT38E1qQw3Ugmio39cK0ALDsrWzwpRZB/LAD5p17bX?= =?us-ascii?Q?bK+gqo+CbjO8rlXYwLKvcNV9uP/O5Tp+820wY1vS0WPqf56WabILKAePAiut?= =?us-ascii?Q?YeHyQjcCpWR8fGkQQ22un1qYWQxzdRSl1Bel3lO042mgsiSu0emjFqF3EQ4x?= =?us-ascii?Q?QtUgc3GA2eGqkg750KNjFlh5bOh2EY9A2ETu4eG2D6UK16OLJ+HmbLGGI+D9?= =?us-ascii?Q?Ubl8lklMLiCj4LMMb5c+RaRyeVb4nvdvsAXXEEGBdISMS1Na+JQGcTICDZpa?= =?us-ascii?Q?lMqxXZwrTmDqfVuxLPhLQxufgjA/NlIZEEMITBKP7tBCjnoIHKAdQhrilvSJ?= =?us-ascii?Q?Bq1lktJkJTI+nGz1a4NjR12pk1jSE4cAV3lpnVJjlAj5Ce6HbtzdlszT+tAl?= =?us-ascii?Q?IB4X0nny2sxSf3EmsNQ47PrhrewlxJE2W1UNg+waALhKBdUgeD/xZlw4zZMR?= =?us-ascii?Q?EANRBj9/BDMe4aKt+ALzL6PYj/iwP1YCRfvbi4MZ3vuMOJaTnTOJfll+OQWf?= =?us-ascii?Q?RfViSb/nI7lInfojlmbWFYKnEmzdIu0VCCGEC2/ivWjyeectyt+jTlYjc8Og?= =?us-ascii?Q?mbllU6Lyn4NShA15PngWrHdCHU//4Audd6WyrDd9IRD0FVo7xF64qj+Lpbwv?= =?us-ascii?Q?i+4OHQ50nERmbJmx4UPU1sCNTEhOr83aTWYKDVmOn7fN1PgfypwQyGUyIUdq?= =?us-ascii?Q?FAE7Pj3PFP/zUykNQWeVQHZC/KHeAiCDv359DqfwI6w7TpzkN4xEQigIyrYw?= =?us-ascii?Q?1JSkqep2s4VK1hZFxh5y43Xd23ihIF6AwwOva7RCe1Vm1q5hATjU0CA1x6QV?= =?us-ascii?Q?HzfCKsSm1d4y9crzdE6EKGRFHDUN1XYZoD/Pvfm7uP4tlrgoxiKoGcvsQ/VF?= =?us-ascii?Q?kCU7g95qwKNw1HtiBaG+Tlf7Xlp24TH1WG5fPG3+psoRFLZdZv1gUSb7BDYI?= =?us-ascii?Q?uPfOUaZY7W5/gi2AlvB8PPhV/e+lZUmaIsR3quM6fnA4Q0Gi3EkSVx3Fi0WN?= =?us-ascii?Q?/Pvqn0Ygp1xeS78rMHgd+DWLZQwyrRfOTEcEe8BM4/yv9gdmBmr5ySkc83At?= =?us-ascii?Q?ufexWimXUhejaqL97lLpyuD4GyKsMThFyVaWpbmkzWsed8Rm+y79kx7hx9oM?= =?us-ascii?Q?81uGUms5VWVkqKnJoXpuPdgKIFAoar9x66vi23uxqCK6Av5TrxrjtoGcEHcp?= =?us-ascii?Q?WsS2NUlF/mFldO7/5Tg8ulLPKp9fTiFXN35VNrarkZwyuEPQUGwrwHvBIWZx?= =?us-ascii?Q?u7Q0ACJHNrfpvMxYCmkE7QMSShBeH0npuhV4xfCz0L82t3U2x8dduJ62QGK1?= =?us-ascii?Q?rG+yMQvxz3mlAf26YEJCYYbF0Ba3vI0b0o2Vt5TcmG7qs9dMClhH97YCLRBf?= =?us-ascii?Q?PH2CUQt95tND7rHww10+2sgVNr1jhGtUGcewtytptdLLWBBOeGcb+QoCh2D0?= =?us-ascii?Q?g3ztKEiGQeOeGtim2hxhuCvC5wMHyrfytSKfKF82al55wT6FoaDeUp833vrB?= =?us-ascii?Q?o7I4OFcYug3oLP5DMpyAxV/byeBOuSnt1AuzLaV0U8O1KK4SdKBfearyjGnn?= =?us-ascii?Q?ron8rk6F1sGTcKPTKKRpuipe6eXz03AT02tl+TNd?= 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: 38fda76e-8d9d-4806-0226-08da6b0b1f9b X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jul 2022 11:21:14.4786 (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: b1pxakNWhaBjpNo9LdkynXjYfcSs/vj9LmPC42IdZLN+RdslG7j31N68n6YNNsLZjgXPRavljyCMlcEraeoIGAhD6VY5E8whj539+q4yAh0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR18MB2455 X-Proofpoint-GUID: UZObpHSXHZzkWTxc8X3XkmzgRd9MrZu0 X-Proofpoint-ORIG-GUID: UZObpHSXHZzkWTxc8X3XkmzgRd9MrZu0 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 patch. Thanks, Amit Shukla > -----Original Message----- > From: Amit Prakash Shukla > Sent: Thursday, June 30, 2022 11:24 AM > To: Anatoly Burakov ; > bruce.richardson@intel.com; david.marchand@redhat.com > Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran > Subject: RE: [PATCH v4 2/2] mem: telemetry support for system memory > information >=20 > Ping. >=20 > > -----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 2/2] mem: telemetry support for system memory > > information > > > > Changes adds telemetry support to display system memory information, > > allocated using calls malloc, calloc, mmap, etc. This patch is based > > on malloc_info. This patch adds following endpoints: > > > > 1. /sysmem/sys_heap_list > > The commands displays the arenas currently in use. > > Example: > > --> /sysmem/sys_heap_list > > {"/sysmem/sys_heap_list": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]} > > > > 2. /sysmem/sys_heap_info, > > This command displays the information about arena. > > Example: > > --> /sysmem/sys_heap_info,0 > > {"/sysmem/sys_heap_info": {"Arena_id": 0, "Allocated_size": 2069934, \ > > "Free_count": 4, "Free_size": 223826, "Curr_size": 2293760, \ > > "Mmap_count": 0, "Mmap_size": 0, "Heap_count": 0, \ > > "Heap_size": 2293760}} > > --> /sysmem/sys_heap_info,6 > > {"/sysmem/sys_heap_info": {"Arena_id": 6, "Allocated_size": 3136, \ > > "Free_count": 2, "Free_size": 193472, "Curr_size": 196608, \ > > "Mmap_count": 0, "Mmap_size": 0, "Heap_count": 1, \ > > "Heap_size": 196608}} > > > > The last arena-id in the list gives total of all arenas. > > > > --> /sysmem/sys_heap_info,10 > > {"/sysmem/sys_heap_info": {"Arena_id": 10, "Allocated_size": 2107774, \ > > "Free_count": 20, "Free_size": 1955458, "Curr_size": 4063232, \ > > "Mmap_count": 0, "Mmap_size": 0, "Heap_count": 0, \ > > "Heap_size": 4063232}} > > > > Signed-off-by: Amit Prakash Shukla > > --- > > lib/eal/common/eal_common_memory.c | 330 > > +++++++++++++++++++++++++++++ > > 1 file changed, 330 insertions(+) > > > > diff --git a/lib/eal/common/eal_common_memory.c > > b/lib/eal/common/eal_common_memory.c > > index e66de6a872..a1677082c1 100644 > > --- a/lib/eal/common/eal_common_memory.c > > +++ b/lib/eal/common/eal_common_memory.c > > @@ -8,6 +8,9 @@ > > #include > > #include > > #include > > +#ifdef RTE_EXEC_ENV_LINUX > > +#include > > +#endif > > > > #include > > #include > > @@ -1123,6 +1126,12 @@ rte_eal_memory_init(void) > > #define EAL_MEMSEG_INFO_REQ "/eal/memseg_info" > > #define EAL_ELEMENT_LIST_REQ "/eal/element_list" > > #define EAL_ELEMENT_INFO_REQ "/eal/element_info" > > + > > +#ifdef RTE_EXEC_ENV_LINUX > > +#define SYSMEMORY_LIST_REQ "/sysmem/sys_heap_list" > > +#define SYSMEMORY_INFO_REQ "/sysmem/sys_heap_info" > > +#endif > > + > > #define ADDR_STR 15 > > > > > > @@ -1720,6 +1729,318 @@ handle_eal_element_info_request(const char > > *cmd __rte_unused, > > return 0; > > } > > > > +#ifdef RTE_EXEC_ENV_LINUX > > +#define MAX_SYS_MEM_ARENAS 128 > > +#define MAX_TAG_CHAR 128 > > + > > +/* Memory size are in bytes. */ > > +struct mem_stats { > > + uint64_t fast_count; /* Number of free blocks in fast bin. */ > > + uint64_t fast_size; /* Size in bytes of free blocks in fast bin. */ > > + uint64_t rest_count; /* Number of free blocks in bin. */ > > + uint64_t rest_size; /* Size in bytes of free blocks in bin. */ > > + uint64_t mmap_count; /* Number of mmap blocks. */ > > + uint64_t mmap_size; /* Size in bytes of mmap'd memory. */ > > + uint64_t curr_size; /* Size in bytes allocated by system. */ > > + uint64_t heap_size; /* Heap size in bytes. */ > > + uint64_t heap_count; /* Number of heaps. */ }; > > + > > +struct rte_heap_mem_stats { > > + unsigned int num_active_arena; > > + struct mem_stats stats[MAX_SYS_MEM_ARENAS]; }; > > + > > +/* This function shall be called to parse only attributes. > > + * Parsing of the "tags" shall be done by the caller. > > + */ > > +static int > > +parse_attr(char *buf, uint32_t *i, char *attr, const char *key) { > > + int j =3D 0; > > + int keymatch =3D 0; > > + > > + attr[j] =3D '\0'; > > + > > + while ((buf[*i] !=3D '>') && (j < MAX_TAG_CHAR)) { > > + /* Ignore spaces. */ > > + if (buf[*i] =3D=3D ' ') { > > + attr[j] =3D '\0'; > > + j =3D 0; > > + (*i)++; > > + continue; > > + } > > + > > + /* Attribute key */ > > + if (buf[*i] =3D=3D '=3D') { > > + attr[j] =3D '\0'; > > + j =3D 0; > > + (*i)++; > > + > > + /* If the key is matched, extract the value. */ > > + if (strncmp(attr, key, strlen(key)) !=3D 0) > > + continue; > > + else > > + keymatch =3D 1; > > + } > > + > > + /* Attribute value */ > > + if ((buf[*i] =3D=3D '"') && (keymatch =3D=3D 1)) { > > + j =3D 0; > > + (*i)++; > > + > > + while ((buf[*i] !=3D '"') && (j < MAX_TAG_CHAR)) > > + attr[(j)++] =3D buf[(*i)++]; > > + attr[j] =3D '\0'; > > + (*i)++; > > + return 0; > > + } > > + > > + keymatch =3D 0; > > + attr[(j)++] =3D buf[(*i)++]; > > + } > > + > > + (*i)++; > > + return -1; > > +} > > + > > +/* Get the system memory stats into buffer by calling malloc_info(). > > + * malloc_info() returns the stats in XML format. Parse the XML to > > +extract > > + * number of heaps, size of each heap, free memory in heap. > > + */ > > +static int > > +parse_heap_mem_stats(struct rte_heap_mem_stats *heap_stats) { > > + char tag[MAX_TAG_CHAR] =3D {0}; > > + int old_mem_index =3D -1; > > + int mem_index =3D -1; > > + uint32_t i =3D 0; > > + uint32_t j =3D 0; > > + size_t length; > > + char *buf; > > + FILE *fp; > > + int ret; > > + > > + /* buf is dynamically allocated by open_memstream. */ > > + fp =3D open_memstream(&buf, &length); > > + if (fp =3D=3D NULL) { > > + RTE_LOG(DEBUG, EAL, "Error: Failed to open memory > > stream\n"); > > + return -1; > > + } > > + > > + /* Gets system memory stat's XML format. */ > > + ret =3D malloc_info(0, fp); > > + fclose(fp); > > + > > + if (ret !=3D 0) { > > + RTE_LOG(DEBUG, EAL, "Error: malloc_info returned > > error\n"); > > + return -1; > > + } > > + > > + while (i < length) { > > + j =3D 0; > > + tag[j] =3D '\0'; > > + > > + /* Ignore newline and spaces. */ > > + if ((buf[i] =3D=3D '\n') || (buf[i] =3D=3D ' ') || (buf[i] =3D=3D '/= ') || > > + (buf[i] =3D=3D '>')) { > > + i++; > > + continue; > > + } > > + > > + if (buf[i] =3D=3D '<') { > > + i++; > > + while ((buf[i] !=3D ' ') && (buf[i] !=3D '>') && > > + (j < MAX_TAG_CHAR)) { > > + tag[j++] =3D buf[i++]; > > + } > > + > > + if (strncmp(tag, "heap", strlen("heap")) =3D=3D 0) { > > + old_mem_index =3D mem_index++; > > + if (mem_index >=3D MAX_SYS_MEM_ARENAS) > > { > > + RTE_LOG(DEBUG, EAL, "Memory > > arena " > > + "exceeded max limit: %d", > > + MAX_SYS_MEM_ARENAS); > > + goto done; > > + } > > + heap_stats->num_active_arena++; > > + } > > + > > + continue; > > + } > > + > > + if (mem_index < 0) { > > + i++; > > + continue; > > + } > > + > > + if (parse_attr(buf, &i, tag, "type") < 0) > > + continue; > > + > > + if (strncmp(tag, "fast", strlen("fast")) =3D=3D 0) { > > + /* For total of all arenas, "heap" tag is not present > > + * in xml. Below check is to handle that scenarios. > > + * > > + * FIXME: mem_index increment shall be > > independent of > > + * the tag. > > + */ > > + if (old_mem_index =3D=3D mem_index) { > > + mem_index++; > > + if (mem_index >=3D MAX_SYS_MEM_ARENAS) > > { > > + RTE_LOG(DEBUG, EAL, "Memory > > arena " > > + "exceeded max limit: %d\n", > > + MAX_SYS_MEM_ARENAS); > > + goto done; > > + } > > + heap_stats->num_active_arena++; > > + } > > + old_mem_index =3D mem_index; > > + > > + if (parse_attr(buf, &i, tag, "count") =3D=3D 0) > > + heap_stats->stats[mem_index].fast_count =3D > > + strtoul(tag, NULL, 10); > > + if (parse_attr(buf, &i, tag, "size") =3D=3D 0) > > + heap_stats->stats[mem_index].fast_size =3D > > + strtoul(tag, NULL, 10); > > + continue; > > + } > > + > > + if (strncmp(tag, "rest", strlen("rest")) =3D=3D 0) { > > + if (parse_attr(buf, &i, tag, "count") =3D=3D 0) > > + heap_stats->stats[mem_index].rest_count =3D > > + strtoul(tag, NULL, 10); > > + if (parse_attr(buf, &i, tag, "size") =3D=3D 0) > > + heap_stats->stats[mem_index].rest_size =3D > > + strtoul(tag, NULL, 10); > > + continue; > > + } > > + > > + if (strncmp(tag, "current", strlen("current")) =3D=3D 0) { > > + if (parse_attr(buf, &i, tag, "size") =3D=3D 0) > > + heap_stats->stats[mem_index].curr_size =3D > > + strtoul(tag, NULL, 10); > > + continue; > > + } > > + > > + if (strncmp(tag, "total", strlen("total")) =3D=3D 0) { > > + if (parse_attr(buf, &i, tag, "size") =3D=3D 0) > > + heap_stats->stats[mem_index].heap_size =3D > > + strtoul(tag, NULL, 10); > > + continue; > > + } > > + > > + if (strncmp(tag, "subheaps", strlen("subheaps")) =3D=3D 0) { > > + if (parse_attr(buf, &i, tag, "size") =3D=3D 0) > > + heap_stats->stats[mem_index].heap_count > > =3D > > + strtoul(tag, NULL, 10); > > + continue; > > + } > > + > > + if (strncmp(tag, "mmap", strlen("mmap")) =3D=3D 0) { > > + if (parse_attr(buf, &i, tag, "count") =3D=3D 0) > > + heap_stats- > > >stats[mem_index].mmap_count =3D > > + strtoul(tag, NULL, 10); > > + if (parse_attr(buf, &i, tag, "size") =3D=3D 0) > > + heap_stats->stats[mem_index].mmap_size > > =3D > > + strtoul(tag, NULL, 10); > > + continue; > > + } > > + > > + i++; > > + } > > + > > +done: > > + /* All done! Let's free the buf. */ > > + free(buf); > > + return 0; > > +} > > + > > +static int > > +handle_sysmem_list_request(const char *cmd __rte_unused, > > + const char *params __rte_unused, > > + struct rte_tel_data *d) > > +{ > > + struct rte_heap_mem_stats heap_mem_stats; > > + unsigned int num_arena; > > + unsigned int i; > > + > > + memset(&heap_mem_stats, 0, sizeof(struct rte_heap_mem_stats)); > > + if (parse_heap_mem_stats(&heap_mem_stats) !=3D 0) > > + return -1; > > + > > + /* Note: > > + * Total active arenas are (num_active_arena - 1). The last entry in > > + * the array is total of all arenas. > > + */ > > + num_arena =3D heap_mem_stats.num_active_arena; > > + > > + rte_tel_data_start_array(d, RTE_TEL_INT_VAL); > > + for (i =3D 0; i < num_arena; i++) > > + rte_tel_data_add_array_int(d, i); > > + > > + return 0; > > +} > > + > > +static int > > +handle_sysmem_info_request(const char *cmd __rte_unused, const > char > > *params, > > + struct rte_tel_data *d) > > +{ > > + struct rte_heap_mem_stats heap_mem_stats; > > + unsigned int arena_id; > > + uint64_t free_size; > > + uint64_t free_count; > > + uint64_t allocated_size; > > + > > + if (params =3D=3D NULL || strlen(params) =3D=3D 0 || !isdigit(*params= )) > > + return -1; > > + > > + arena_id =3D (unsigned int)strtoul(params, NULL, 10); > > + if (arena_id > UINT32_MAX) > > + return -1; > > + > > + if (arena_id >=3D MAX_SYS_MEM_ARENAS) > > + return -1; > > + > > + memset(&heap_mem_stats, 0, sizeof(struct rte_heap_mem_stats)); > > + if (parse_heap_mem_stats(&heap_mem_stats) !=3D 0) > > + return -1; > > + > > + if (arena_id >=3D heap_mem_stats.num_active_arena) { > > + RTE_LOG(DEBUG, EAL, "Memory arena exceeded max limit: > > %d\n", > > + MAX_SYS_MEM_ARENAS); > > + return -1; > > + } > > + > > + /* Fast and rest account for the total free memory. */ > > + free_size =3D heap_mem_stats.stats[arena_id].fast_size + > > + heap_mem_stats.stats[arena_id].rest_size; > > + > > + free_count =3D heap_mem_stats.stats[arena_id].fast_count + > > + heap_mem_stats.stats[arena_id].rest_count; > > + > > + /* (System memory - free size) =3D allocated memory size. */ > > + allocated_size =3D heap_mem_stats.stats[arena_id].curr_size - > > free_size; > > + > > + rte_tel_data_start_dict(d); > > + rte_tel_data_add_dict_int(d, "Arena_id", arena_id); > > + rte_tel_data_add_dict_int(d, "Allocated_size", allocated_size); > > + rte_tel_data_add_dict_u64(d, "Free_count", free_count); > > + rte_tel_data_add_dict_u64(d, "Free_size", free_size); > > + rte_tel_data_add_dict_u64(d, "Curr_size", > > + > > heap_mem_stats.stats[arena_id].curr_size); > > + rte_tel_data_add_dict_u64(d, "Mmap_count", > > + > > heap_mem_stats.stats[arena_id].mmap_count); > > + rte_tel_data_add_dict_u64(d, "Mmap_size", > > + > > heap_mem_stats.stats[arena_id].mmap_size); > > + rte_tel_data_add_dict_u64(d, "Heap_count", > > + > > heap_mem_stats.stats[arena_id].heap_count); > > + rte_tel_data_add_dict_u64(d, "Heap_size", > > + > > heap_mem_stats.stats[arena_id].heap_size); > > + > > + return 0; > > +} > > +#endif > > + > > RTE_INIT(memory_telemetry) > > { > > rte_telemetry_register_cmd( > > @@ -1751,5 +2072,14 @@ RTE_INIT(memory_telemetry) > > 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"); > > + > > +#ifdef RTE_EXEC_ENV_LINUX > > + rte_telemetry_register_cmd(SYSMEMORY_LIST_REQ, > > + handle_sysmem_list_request, > > + "Returns element information. Takes no > > parameters"); > > + rte_telemetry_register_cmd(SYSMEMORY_INFO_REQ, > > + handle_sysmem_info_request, > > + "Returns element information. Parameters: int > > arena_id"); #endif > > } > > #endif > > -- > > 2.25.1