From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id D22364CA9; Wed, 27 Feb 2019 11:51:59 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x1RApkhd014280; Wed, 27 Feb 2019 02:51:59 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=owKlq4vyxn42Uyb9BqNUaL8Lf/oPWAW1XN0bMvUw6d8=; b=pnUzjghd4nPRKIx64lgNo00DH8pDAUXfi3z1p62CJPVbB8W8VQdCLjXxbAgwVAwH3omt VmCE+usAWug8Q+b8wJXX2KS3uxgOOwaiBMorb7AAgaHXqz1mi777quWZCg5SAPapVwKH TRtlFY2nZIyG0bSPLfpUoRkXNW0GyX1JcpEmGEEdT4WoyQmFtMTBhNY1iEYWGS8iXt+N kxV4H4jVYyTeB1zR1axcETtgh3Eu0FV0oHVoo5KBfwKnQs8Codgk+rOnLeH2c09PrV8T Mx2zW5DtcBQN4cRyLE+vWuKVG33xEjT+fEOvfGXW38eqytHU2pJUggdnkUcnHFM2aC6j pw== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2qwhfgs9eu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 27 Feb 2019 02:51:59 -0800 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 27 Feb 2019 02:51:57 -0800 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (104.47.41.53) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Wed, 27 Feb 2019 02:51:57 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=owKlq4vyxn42Uyb9BqNUaL8Lf/oPWAW1XN0bMvUw6d8=; b=hyE6jvevpJQ3LVVxogGU7HV2JXClrLpCiNotBFfSrIKu690p0rTIQg9Q34n4uYnbbPckxmZEpq+746S0DcvXEOJmr0LRLr049X0sLXtqjzCeA0lYmhVkoHwD7lfnZnjGi9ldCCGA3Z33BHz02FpuTw6C9HCX1oudGY4Fgw/yBmk= Received: from DM5PR18MB2230.namprd18.prod.outlook.com (52.132.143.153) by DM5PR18MB1194.namprd18.prod.outlook.com (10.173.213.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.16; Wed, 27 Feb 2019 10:51:53 +0000 Received: from DM5PR18MB2230.namprd18.prod.outlook.com ([fe80::9d95:af4:298b:7454]) by DM5PR18MB2230.namprd18.prod.outlook.com ([fe80::9d95:af4:298b:7454%5]) with mapi id 15.20.1643.019; Wed, 27 Feb 2019 10:51:53 +0000 From: Harman Kalra To: "john.mcnamara@intel.com" , "marko.kovacevic@intel.com" , "remy.horton@intel.com" , "anatoly.burakov@intel.com" CC: "dev@dpdk.org" , "stable@dpdk.org" , "Harman Kalra" Thread-Topic: [PATCH 1/2] metrics: new API to deinitialise metrics library Thread-Index: AQHUzopzCaCIReKdAEKxvlW6m88KaA== Date: Wed, 27 Feb 2019 10:51:53 +0000 Message-ID: <1551264691-26353-1-git-send-email-hkalra@marvell.com> References: <6343c206-78f0-e4cf-9dc9-574ce7d6e743@intel.com> In-Reply-To: <6343c206-78f0-e4cf-9dc9-574ce7d6e743@intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0039.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1a::25) To DM5PR18MB2230.namprd18.prod.outlook.com (2603:10b6:4:b9::25) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-originating-ip: [115.113.156.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8ee3becb-2898-49f7-b235-08d69ca195a0 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:DM5PR18MB1194; x-ms-traffictypediagnostic: DM5PR18MB1194: x-microsoft-exchange-diagnostics: 1; DM5PR18MB1194; 20:804+fi9SIkLOV5nQ2sfdqswE7fpxFnr3yQmphUgzuBLBfWiZXrrHg7q7zTh4HbQTJ2dvIKYKuCn/tM6pNyovzG9WLiMtOVIcV4VdxK+EGfgDhw7nwYa8MZ/wofI0fH2MPchsJYXCsaDQmiS0IgsZvBY4FVL78Yr/ZJcJzzimAq4= x-microsoft-antispam-prvs: x-forefront-prvs: 0961DF5286 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(376002)(136003)(366004)(346002)(199004)(189003)(6506007)(54906003)(110136005)(68736007)(478600001)(5660300002)(99286004)(3846002)(6116002)(50226002)(186003)(8936002)(4326008)(53936002)(26005)(2201001)(76176011)(55236004)(102836004)(52116002)(386003)(14454004)(316002)(6486002)(6512007)(105586002)(97736004)(25786009)(6436002)(71190400001)(71200400001)(66066001)(106356001)(8676002)(305945005)(7736002)(256004)(14444005)(107886003)(2906002)(2501003)(81156014)(81166006)(446003)(11346002)(2616005)(476003)(486006)(86362001)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR18MB1194; H:DM5PR18MB2230.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: adlf5WIgDPTFyhQ47gpyygWmESFNfnetgta3hl7r2/D8gpryG7sS4vNW+RXmeUxAx/Pri3Nz6VDWRKFWmvQtwfdOru9G43JEMXB4hoKFQ5IENr38dACJVN6pMdkc6FxE2DPApPhMRBG3FMbI3zn6tUKxPFtDiVwYw2qetTIN97UuOsFu6s8OMf8hyUpzFcn6C+6c9o9+CNkb8iM3yBhx2CJrVYJlR2Q2VSADDSOussR8TsmIBVl3sPkgAXcBzGf/PUWSSnFhb8nnEP3JNlJHLZ9Xpi1fgAX2ZNiAVT2H43hKkn951EbhDtuzoPNuT4Okrvw71ypjQCAb0WoOS7dmidUdDc92hq9rMnWZ26CfIHWhImdL3A91uSfBENXxbnRFzyUoDJmDItiXLuVKsyBo3+FxiADu1yundkH7Qlmu+8E= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 8ee3becb-2898-49f7-b235-08d69ca195a0 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Feb 2019 10:51:50.6078 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR18MB1194 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-02-27_07:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902270074 Subject: [dpdk-dev] [PATCH 1/2] metrics: new API to deinitialise metrics library X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Feb 2019 10:52:00 -0000 Once the library usage is over, it must be deinitialized which will free the shared memory reserved during initialization. Fixes: observed an issue while running 'metrics_autotest' continuously without quiting. For the first run 'metrics_autotest' passes all test cases but second run onwards first test case fails because metrics library is already initialized during first run. Signed-off-by: Harman Kalra --- doc/guides/prog_guide/metrics_lib.rst | 14 ++++++++++++++ lib/librte_metrics/rte_metrics.c | 20 ++++++++++++++++++++ lib/librte_metrics/rte_metrics.h | 17 +++++++++++++++++ lib/librte_metrics/rte_metrics_version.map | 6 ++++++ 4 files changed, 57 insertions(+) diff --git a/doc/guides/prog_guide/metrics_lib.rst b/doc/guides/prog_guide/= metrics_lib.rst index e68e4e743..08e107df3 100644 --- a/doc/guides/prog_guide/metrics_lib.rst +++ b/doc/guides/prog_guide/metrics_lib.rst @@ -154,6 +154,20 @@ print out all metrics for a given port: } =20 =20 +Deinitialising the library +------------------------ + +Once the library usage is done, it must be deinitialized by calling +``rte_metrics_deinit()`` which will free the shared memory reserved +during initialization. + +.. code-block:: c + + err =3D rte_metrics_deinit(void); + +If the return value is negative, it means deinitialization failed. +This function **must** be called from a primary process. + Bit-rate statistics library --------------------------- =20 diff --git a/lib/librte_metrics/rte_metrics.c b/lib/librte_metrics/rte_metr= ics.c index 99a96b651..0c816a1fc 100644 --- a/lib/librte_metrics/rte_metrics.c +++ b/lib/librte_metrics/rte_metrics.c @@ -76,6 +76,26 @@ rte_metrics_init(int socket_id) rte_spinlock_init(&stats->lock); } =20 +int __rte_experimental +rte_metrics_deinit(void) +{ + struct rte_metrics_data_s *stats; + const struct rte_memzone *memzone; + + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) + return -EINVAL; + + memzone =3D rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME); + if (memzone =3D=3D NULL) + return -EIO; + + stats =3D memzone->addr; + memset(stats, 0, sizeof(struct rte_metrics_data_s)); + + return rte_memzone_free(memzone); + +} + int rte_metrics_reg_name(const char *name) { diff --git a/lib/librte_metrics/rte_metrics.h b/lib/librte_metrics/rte_metr= ics.h index 67a60fadd..0957a94b6 100644 --- a/lib/librte_metrics/rte_metrics.h +++ b/lib/librte_metrics/rte_metrics.h @@ -24,6 +24,7 @@ #define _RTE_METRICS_H_ =20 #include +#include =20 #ifdef __cplusplus extern "C" { @@ -80,6 +81,22 @@ struct rte_metric_value { */ void rte_metrics_init(int socket_id); =20 +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Deinitialize metric module. This function must be called from + * a primary process after all the metrics usage is over, to + * release the shared memory. + * + * @return + * -EINVAL - invalid parameter. + * -EIO: Error, unable to access metrics shared memory + * (rte_metrics_init() not called) + * 0 - success + */ +int __rte_experimental rte_metrics_deinit(void); + /** * Register a metric, making it available as a reporting parameter. * diff --git a/lib/librte_metrics/rte_metrics_version.map b/lib/librte_metric= s/rte_metrics_version.map index 4c5234cd1..6ac99a44a 100644 --- a/lib/librte_metrics/rte_metrics_version.map +++ b/lib/librte_metrics/rte_metrics_version.map @@ -11,3 +11,9 @@ DPDK_17.05 { =20 local: *; }; + +EXPERIMENTAL { + global: + + rte_metrics_deinit; +}; --=20 2.18.0