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 D88CCA0545; Thu, 30 Jun 2022 07:54:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9D37740223; Thu, 30 Jun 2022 07:54:06 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 00D9B400EF for ; Thu, 30 Jun 2022 07:54:04 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25TLaiH1006216; Wed, 29 Jun 2022 22:54:04 -0700 Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3h0kgcc4ga-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Jun 2022 22:54:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iLtEdJOOy2pHJyHdWxb9Aa3x+jP//4DWLnzawNIxxpMTevIxXUlavzxa+JMGpqrfD9kDJmHXXp58R/jftRRnhKBZxbYP2sH0ZWfYeykZrAQ3WHhT+WunKUG/qUhtbvHHyAPxZkAuyhJNquR2/6D8M1WX+rZODEXsqGy8X+XGNkjJQildsTbpsqJy1syh7mfTeFQ8IVSJUug+MvduWKL3G2mp5XfV+SJs1RSrUnVh6BBlZpy03dWVHu6uDrVorJ87kbyVJD3nT0NZ7N17/2Rj4Aw/I5oQY0Vx7P9s/CwdWM+gDpaBZmS3dWNIpq5t4MB0zoTdv2mskoe56HyjLRnhgA== 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=yfqRPjy0e4diEb8mxNdx2xJ95f1L3ZrAoZ+ajfAdHoo=; b=HXKrEt84jUprhbebLXAueWNzTAGfJezWP+QzmB1gGXxfsQg4a7zUBooCRWmUEHh+XxYPBtT++SWQyLTbb2L1+uHOb131eGa8Scc10ZKu+POHPX2YspG69TVUpwaEB7MUt2xuJYIUs6f+SEWtjbz293CheA/fXY1IOB2pqugWZANWo7sb8OW9ll0XXE2PrddOYYROP7PboFBSZG//oaMEor5xD0aVaiS94P2iPOwTBm2Pyk+u4Zr5XDuy+zrb0nvKwQDo3MKEMhjf4hLSWlf+QUsvchIw075c8hPvUMPeMJfh5MSLVCs+4+tiJPDa4FzySLmbwKJ1du3biXXR7nOhiA== 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=yfqRPjy0e4diEb8mxNdx2xJ95f1L3ZrAoZ+ajfAdHoo=; b=bEqYaLj3UuhmxJSEe07AVg/iUst6bQMzT3FeNQlNfUJ8VvXFo/+E2+hJA5TFALjbQhPOxyyuhU8PmGfPu7zdoULNDskB7EYvPpej6o7P+tLsSpXqWWROcxvPQ8R6ZzXA6AKVdR+0CuB9FMBuLYPRAQF2dIdzm2vVm116nICZRdM= Received: from PH0PR18MB5167.namprd18.prod.outlook.com (2603:10b6:510:168::7) by SA1PR18MB4582.namprd18.prod.outlook.com (2603:10b6:806:1d1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.15; Thu, 30 Jun 2022 05:54:01 +0000 Received: from PH0PR18MB5167.namprd18.prod.outlook.com ([fe80::694d:ceb9:bc7b:dbfa]) by PH0PR18MB5167.namprd18.prod.outlook.com ([fe80::694d:ceb9:bc7b:dbfa%5]) with mapi id 15.20.5395.014; Thu, 30 Jun 2022 05:54:01 +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: AQHYcCMKTIJQHjQ95ESVw4YRPnDShq1nqw5w Date: Thu, 30 Jun 2022 05:54:01 +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: <20220525103352.1806937-2-amitprakashs@marvell.com> 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: 51110218-2e5b-469e-530d-08da5a5ceef1 x-ms-traffictypediagnostic: SA1PR18MB4582:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 3GPSBmW8Dq5KhI9R+1hFR2SJqJc46sBuInZfZTgxEuRlwqm4BM9Uhj7yWHOUWHHXAwRggGRoCRnho4fhaqUaTPgkoGFLODI+ayBkJ2RjWFpU6XnW2gtdXCmESIBH0UQoJjfmCzCWDGQ9tRlm6WmgIQtsEfXGLwMJ/qlYlkdRuz8N4HyYO0Hu+t1kxbuaFWUHI1PbQw3ysaUev+nPy5oRBHX4yfLRqticnGjKPKVtAiqYaCAOIZQocmAJOG+wtZztsmVmT48YmAt2I3Gx+crg15fF2aIPrelkGqJdeoVsjvOanLZ/2gbgDtG1h6ZOjZUOZ2IsY0kijdUCyOPulcxdeOinYtnOxV/Z81hhCMx9C3IlrTE+Bs4lEAu1Af6RlvosGv4vStvCRKod74L7fLC/4ypJjEllzWTk6rkgegyiPWFNL5Z6ObdNMijn8umzxFTZrY0jM4GEzSoUqJMwcARZSOF+Iefq5CYkpnPBLLIuOHN+IrXWCVb+yBubNi3NzZEnQQwwxWaqRuqPnAseIC/96Drz3ynXVAFBp1VL2Cb617HLNK7oed/A13gtg4032ZzR6piUDBC8D0tnXV5pI2FSIFMvhsNpRzCskC7iwwP5txh1IqpoSoVXe9Phj+k2pNCxPqj85s3ai25JOYYwN9BuBM1s7lT6/ScA06wpJVeQ3K8CPr/rQenTkyRpVKJf2np20QVhkB45XAwJfBQYN5lZjzOgSaT2Sywhq5NbRgUlf0V98FIpV0hYhESeBoR3tcFNdIJ0HhV9lDxZPaleG4w6DYJBAj5URtmR2s87dAf4gRxjiFJa2hcMHK9QhPn+2+7G 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)(396003)(346002)(366004)(136003)(376002)(4326008)(8676002)(122000001)(316002)(38070700005)(55016003)(66946007)(64756008)(76116006)(66556008)(66476007)(66446008)(83380400001)(186003)(71200400001)(26005)(9686003)(30864003)(41300700001)(86362001)(33656002)(5660300002)(2906002)(53546011)(55236004)(110136005)(38100700002)(54906003)(107886003)(8936002)(52536014)(478600001)(7696005)(6506007); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?5ToLwQ2AWO6oxUer4A43Jj5I43H0g1TrjVjZd5pnu5PkJHw1U6xJax9u1cq1?= =?us-ascii?Q?6SDZtESUb7dIR6MT5Lgis/lmGvCFQ0BrwgAaCIExinJ1cFdSwfRclYMYYzYw?= =?us-ascii?Q?MbfJsZ6Bt8H2NEetuCKA9MIKHPeaIe67USuwKMTVgMQpl1R882U2w7ZVnNP5?= =?us-ascii?Q?oQaunfTYoBbY8xQrJa/b2DyuTQixM9RpAdI9HpAr+fQGjXsN6zw+EAfHVIhk?= =?us-ascii?Q?Jj6nNdG3fHLSN503bL0fGqqyIrLtMkG2D+4mRZhxftvYKDkuxU7NxGVTeOx2?= =?us-ascii?Q?YJv4EIm9I9rfIMWsBVppQfnCiuJuOG5vzjYklZXjacVQpT+05raTR9//Y1bH?= =?us-ascii?Q?eoe3+pMPJRwGkGS18MfzYwAptTGKI+s1+mVvDn8WJvC6RhiopeXTeru+nq7Y?= =?us-ascii?Q?fJ4iwOpsXev+ICYlQNNj6TTrKERv43IJHPDZCgxEt+AdVl08JXqeyxfCwJLW?= =?us-ascii?Q?4MnJpU1WPsdjr2nSG/6acXRyOGiEILF5yKlFy7DzPJMns4sRQHnXps3egsRG?= =?us-ascii?Q?Dobbt3/nHouI8QcsexGc3GI9BjhXUHkcBPJm4XXGwqLzw0/iVPIBDV+iH0zH?= =?us-ascii?Q?k35VVXjDqbkTTV0tY0pqKQ8GGgfjEqK0DdOLx0WXic32gmeHzeWD6dkZHK9T?= =?us-ascii?Q?au+85m7FiyWDOtho51maMn4hVDlCdJGqSRA7vhDeYKkdNJ1zfZrcZ/ZUGHlA?= =?us-ascii?Q?iL8CNrY8AzVbaKRjZ53iDIQzcsKreaowJEJlMuPJBOKtwQvWPQy2yVTsGYKy?= =?us-ascii?Q?2SErIB3mPzL7f6UKJBiYmWeqp857UXdbQ4jylUvKt4ppG8YeGzhbytkn4Afj?= =?us-ascii?Q?aXMQVVzY9IJ/4ySWZeUGrdm6trWbQB+4FQ9VSbI+L2omeGAp7DyK5AZR9+rj?= =?us-ascii?Q?iyRsfDrvCqacl3o0xI7/dywdKtDEbEIwC8rUsvsa5XagFE7scVIjcOpxak2/?= =?us-ascii?Q?jXYm8nWSbnPSccdrafKwC9Xnh/vV5kxQZAi4cXisgMsFcoUl1n+r5HRukxGE?= =?us-ascii?Q?Du7sy63kqJVIX1HKKIrrXEiKK0kr8CyILAlhYXyuK7q1KPbIQaAdjl0Y7KnM?= =?us-ascii?Q?7iCW+LKnWB+0S5o4Xid0hGWFNmicnju8vzZQt4x4hL+kQn41jdTMfpkL7aVp?= =?us-ascii?Q?UjG2No8led9ydT8RuV32N0sngHuc2LBWAyQ2Q/6GUXpTZDAdCQpHSJKue5hG?= =?us-ascii?Q?5aVoF5roaPIo/dq0X+P3cIrYrfailTRT4QaltPbzzGWPabTWlElw7Vc2volY?= =?us-ascii?Q?tLbbjKm3CglrzBLjeVeywLH63HFOHyaczSFRoiP+/u+wQDQvSvrMt9ofo6Bq?= =?us-ascii?Q?wwfMX1tqxFiASDZHjzZTivSjgRBfOxf75V1+RIoVddifqXIHEQAAKM0csExL?= =?us-ascii?Q?51vDqiivdkdr3OKSnyHG63rBm3iJviQdIclHDBkn2x7FbzVbmFXUGhVVpuLG?= =?us-ascii?Q?FpiSTgEBtMB/gb3FW+RUQ7xvg1lADldGG595MYwdKA9StuOq0rju68h52nEq?= =?us-ascii?Q?nqIXFMb9NAxW1e6ZBHcYGkvV/L9pUbtqfAAzXeQYts7yIahlu3JWu4/K0SQT?= =?us-ascii?Q?g8VEaBxjl/sV/r+ya9tiTsBmHBw+8H43nWtbwuwi?= 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: 51110218-2e5b-469e-530d-08da5a5ceef1 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jun 2022 05:54:01.8474 (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: FOmEgYxKLYWZ9spO4Bw/7LPsiu5Rrfgp8cFuzYviRNa3dKLAHB4OmmKHuoik1byz5KcPS3HH1Pm2orREb+sJh3MH9LXM9vBHSYVi7LPI72A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR18MB4582 X-Proofpoint-GUID: zPwrncgtAz3Uo3odYHucZ6H1fThNXioS X-Proofpoint-ORIG-GUID: zPwrncgtAz3Uo3odYHucZ6H1fThNXioS 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-06-30_02,2022-06-28_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. > -----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 >=20 > 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: >=20 > 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]} >=20 > 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}} >=20 > The last arena-id in the list gives total of all arenas. >=20 > --> /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}} >=20 > Signed-off-by: Amit Prakash Shukla > --- > lib/eal/common/eal_common_memory.c | 330 > +++++++++++++++++++++++++++++ > 1 file changed, 330 insertions(+) >=20 > 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 >=20 > #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 >=20 >=20 > @@ -1720,6 +1729,318 @@ handle_eal_element_info_request(const char > *cmd __rte_unused, > return 0; > } >=20 > +#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