From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 0A33A2BDB for ; Fri, 22 Feb 2019 15:45:10 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x1MEYpJp020038; Fri, 22 Feb 2019 06:45:10 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=owKlq4vyxn42Uyb9BqNUaL8Lf/oPWAW1XN0bMvUw6d8=; b=goiU4mcvJNhzBDmU7yuIJLQblqTZpdJn0sDWYwoIV98AQp8TPgpXB3Ed06b+YUGhsq1m BT1/2L03JrmdUFPuFcFwyhsOSvmwJZVhBjO0YUYWAiw4UCcvrWlEDs0iuOtI8OUXzTan ihIWgPKpnJCSL8o0cyPHAWU9ed9hI9saPwmnAJ77rMi2XDnFxDuMUJblMyLWuDPmpXyX iKrbUcj+JhqqHt2VbUL/Vr7zLo+plEr+nPVyzxQYS7nLsgBTPfToEYeaCcOusK4SZYIr qBSbUP2fenoF18BSP0erm/W03Ru2w3vraGy5gJ8sBpk5IoirQcWJnwgUCFW7SPOlEb4o aA== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2qtdt28qwr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 22 Feb 2019 06:45:09 -0800 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 22 Feb 2019 06:45:08 -0800 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (104.47.38.55) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Fri, 22 Feb 2019 06:45:08 -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=R7lkGBP9TsEyicmvNYfsfVErxABgwOE+H00w4wWgHfa/JQErzwEIW612WMnHN0cTUBmYb4EXaQiOy5E8+bY5ZMEiN/VNmA8u8aNr8BqfdhJ5un3s29ZMN/WWjBdEVUryRtmvyxdMd8uHyQUz4SrJHlZnwfOqvE+GlkEQCtAbDl4= Received: from SN1PR18MB2237.namprd18.prod.outlook.com (52.132.199.27) by SN1PR18MB2303.namprd18.prod.outlook.com (52.132.199.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.15; Fri, 22 Feb 2019 14:45:07 +0000 Received: from SN1PR18MB2237.namprd18.prod.outlook.com ([fe80::54e7:8dc7:8a93:b859]) by SN1PR18MB2237.namprd18.prod.outlook.com ([fe80::54e7:8dc7:8a93:b859%4]) with mapi id 15.20.1643.018; Fri, 22 Feb 2019 14:45:07 +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" , Harman Kalra Thread-Topic: [PATCH 1/2] metrics: new API to deinitialise metrics library Thread-Index: AQHUyr0zLeCwUIZIwka5DYymjXQYIQ== Date: Fri, 22 Feb 2019 14:45:06 +0000 Message-ID: <1550846689-6615-1-git-send-email-hkalra@marvell.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0002.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::12) To SN1PR18MB2237.namprd18.prod.outlook.com (2603:10b6:802:2e::27) 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: 77cb8a11-1e3e-4494-c056-08d698d45633 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:SN1PR18MB2303; x-ms-traffictypediagnostic: SN1PR18MB2303: x-microsoft-exchange-diagnostics: 1; SN1PR18MB2303; 20:rtkWqm2xD0h0xQGDV3KzM+RmQkKKDzWWrvFonDkJIDmVCoj2TsosOiOYLIK6n9xtsILqHouBTHeUvIpNC7+gjO20NtqygjE0yTruq2wYD1tZ9rAYturJvEXMjJwFdofyBG7kKxKSTwHXHLyrOmTbPIiOKJJrL5HZd7oxRi8rpPs= x-microsoft-antispam-prvs: x-forefront-prvs: 09565527D6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(366004)(39850400004)(346002)(396003)(136003)(199004)(189003)(4326008)(107886003)(6116002)(36756003)(478600001)(5660300002)(3846002)(7736002)(25786009)(68736007)(305945005)(6436002)(2501003)(14444005)(106356001)(256004)(6486002)(6512007)(53936002)(14454004)(110136005)(186003)(8936002)(6506007)(2906002)(54906003)(86362001)(2201001)(81156014)(2616005)(316002)(486006)(99286004)(55236004)(102836004)(81166006)(476003)(66066001)(50226002)(71200400001)(97736004)(52116002)(26005)(8676002)(386003)(105586002)(71190400001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR18MB2303; H:SN1PR18MB2237.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: vl1/L8UpcmuSSXJOX6MeQD6TUrL0t7sjJXlV5g7vULmQ9HphjOjiMD2xbfIqi+CdNZs9W2+jo+DVRHESRT1Bt0YioqhzV8o6A1dFFLDE/TswL4csEvvOt15Ow9ITPMQmdZiobQdrKKIsWUvgmSzGtZ9UN0SfixBofDlWFw8hBYBRDrrdSZJOgyky45DKYyK7Nxxyea38tndIYMACUjz8l5fKNJ2QuW3L57QixUQah4oC1E+9Gtc2aGp1q/+piKvmBik6LwvKeRqR5yIfQ4CJfDZv3Z4O7JBuACRFUWXXpwgJ8oO/IihxRoiVaLFs0zcTntl7BJy3IlsAPN3wsHuvc0kRnGPsIdx4THJCBpwDk5Y0V5oGMZ5aHKEqphVq8tRynDllpLLNake2zp/HDYRLDhd9Nc65DN11xXkQfjKj0D0= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 77cb8a11-1e3e-4494-c056-08d698d45633 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Feb 2019 14:45:04.6591 (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: SN1PR18MB2303 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-02-22_10:, , 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-1902220104 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: Fri, 22 Feb 2019 14:45:11 -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