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 EAFFA2BB5 for ; Fri, 1 Mar 2019 11:00:16 +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 x219tIOK006802 for ; Fri, 1 Mar 2019 02:00:15 -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=OT1iHOudFSxjj/vfCOUyOJhGHCiDfdkGzYtxAtIj+tA=; b=WjUWH3YS6e/YkNVcHiEU+o0IwvHkUxCjYOSQyRa9j+ac+w1wP9Sfr2FriTt7EG+G4Xo9 D/QxOvLeQNluYL+ELS8lsrKKYYuvY1oc0WCuX3XOxsTfIM2AwYg9TwWHIFAN2xHKqcUS BQ1rL45TvyEZp90j6Qr1Z/rIBDWpeV1CPVQPDlr9pirHIRPWVa+oS5ZWgNY/sF5Jsu0K tms2jPnapdYXOR8d3zzZPNKCLZBha1LJpOGnivA8tV01WaVb64haNrAlM++Vk6DRTqx7 WLvDH7UzamvPP6A7bRI543qT0s8CL/fKJQauiiiswuHaztQIehksvzQUhnpgb286qTIJ /A== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2qxce637hv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 01 Mar 2019 02:00:13 -0800 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 1 Mar 2019 02:00:08 -0800 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (104.47.33.53) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Fri, 1 Mar 2019 02:00: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=OT1iHOudFSxjj/vfCOUyOJhGHCiDfdkGzYtxAtIj+tA=; b=MgZel6NUQZlKwyAFzlQaPnFhWOdHhJ2QLVPTRv8Tia6uvXcC1bMBDavtmSKwpaOi/+iSF0Tk7tiXEQHabckE7jliLH7Mt3K/KnsALxhKQ9DaVu0+5KNHQJ7OGuprfdFtPQCI51hUKed0Jnbn21gj4vEDV7o9qz2/ykL/A5V6rTE= Received: from SN1PR18MB2237.namprd18.prod.outlook.com (52.132.199.27) by SN1PR18MB2317.namprd18.prod.outlook.com (52.132.199.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.17; Fri, 1 Mar 2019 10:00:06 +0000 Received: from SN1PR18MB2237.namprd18.prod.outlook.com ([fe80::ad6a:84a9:7b19:f901]) by SN1PR18MB2237.namprd18.prod.outlook.com ([fe80::ad6a:84a9:7b19:f901%2]) with mapi id 15.20.1665.015; Fri, 1 Mar 2019 10:00:06 +0000 From: Harman Kalra To: Harman Kalra CC: "stable@dpdk.org" Thread-Topic: [PATCH v2 1/2] metrics: new API to deinitialise metrics library Thread-Index: AQHU0BWMGJjrx68MCUqtxoaDFQkGBg== Date: Fri, 1 Mar 2019 10:00:06 +0000 Message-ID: <1551434386-31464-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: BM1PR0101CA0069.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::31) 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: d703d750-adbd-411d-d117-08d69e2cae7b 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:SN1PR18MB2317; x-ms-traffictypediagnostic: SN1PR18MB2317: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; SN1PR18MB2317; 23:CXvhBasGIjSvVrHKBJ1TWan1x15k5z1aQldj5mw?= =?iso-8859-1?Q?xCt3HffP/NC4cqIAG8qYUnTydaJTBdzhg9dkVIXpzf0rH/serHClxyGGQe?= =?iso-8859-1?Q?aC19fT5ApvhXoVbwml6HL2tEKetIsH4vLoLULWIiLAAI2gmVEcp5ERG89P?= =?iso-8859-1?Q?wT6WCQMZmOw2Kp7mG2+fwbsp0vRQxk2X+B2pB3RC1v6oSFmZFn/z856U4e?= =?iso-8859-1?Q?YkZSCVVNnTZq3/jtDui+Vms+DAKfnqCn2neQtnkkhAXOQKiSePbPWX5+NA?= =?iso-8859-1?Q?lfOYWsNoqyesPo9ogtZttF7y8A22OQ6Jvphl0ez669nHUxd0h7PBmpCx9c?= =?iso-8859-1?Q?qpN/7CGCjplar/SRIcPKH+bdYfCGUC9r7w4g1Suc56AtxX3YAsvLkJyCdE?= =?iso-8859-1?Q?PqefRLumqzDCaxgFh19irbrnIpmwD5trOaCSV0JKIKoaPWE3FfFaueGRie?= =?iso-8859-1?Q?/l9a5ZOQ/s2T57cK6Q9Y23MEpvDQs9/SxUU8AzV/ywF71HcR32+TgACnMv?= =?iso-8859-1?Q?vqoBBvRIaFWQekUmhAeocRrTt5JccVxOoyCLr6M+KRRvVCc8INPAc4i5WT?= =?iso-8859-1?Q?FDfgpITVhyVWvZXk4Ou3SrCCjzxSZhsEmbCJKmx1RPzBcO7kLCT/ahzTjA?= =?iso-8859-1?Q?UIzPPM7HArH+ql0yfUTVUcGFe5rbVc2ZX7AapV5i82B9ed8tAmawMMmE6k?= =?iso-8859-1?Q?2L0FnZKTVEeZRCW2hEimTe7QvAaYCK7wIVPOPxdIBGXwuVDlr/QNy9FjYS?= =?iso-8859-1?Q?OyBb9H+KU5b37DHVbiXgjz6nVGJE1i7VOeiSLqUkUfp8Zng6+5q6GBfPEx?= =?iso-8859-1?Q?2kwvyHHj/509AqQXESYd3QlHASROVLkjxx5K72acjakEycTODpUOSARnxH?= =?iso-8859-1?Q?DokiajVyMZd0wAv8sL++z3+hZgijAZFt1U75pH/bXiNCjL95B7SHAlTuCF?= =?iso-8859-1?Q?9KsHXeNCAt+2lt45pSPfSDe70ZI+Um81wEv8IS+xgBMcvK9ZaTWMRTqFdW?= =?iso-8859-1?Q?p8Ij3BOP8ioRGJtGHZK6FZSh1B/TFUCMQUcB94cECbiZo8lEGVmTtYR//5?= =?iso-8859-1?Q?Qs9kd43DTOe6YrCWjFGoUNsB3/ofVb4P5uG+RsTxGT8htHdJMOCCVeQtlC?= =?iso-8859-1?Q?yY3Alo6an1cLksVD3vgqOVqXt9zynBCB0QnT1DFDVWtjjU1B6xhorIO4eG?= =?iso-8859-1?Q?gPwyEwaR+55UZH2eJcK8LaRPUC8woUWloNGtjRRZaFN4xVZ/WrdF5MvDa+?= =?iso-8859-1?Q?0HjooaLK8MnmQQ1s7?= x-microsoft-antispam-prvs: x-forefront-prvs: 09634B1196 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(136003)(39860400002)(366004)(376002)(396003)(199004)(189003)(8936002)(6862004)(86362001)(105586002)(386003)(2616005)(2906002)(186003)(97736004)(5660300002)(478600001)(71200400001)(256004)(26005)(14444005)(6506007)(55236004)(6200100001)(102836004)(52116002)(106356001)(99286004)(36756003)(486006)(53936002)(14454004)(81166006)(6486002)(8676002)(316002)(37006003)(71190400001)(6512007)(7049001)(66066001)(6116002)(3846002)(68736007)(81156014)(50226002)(25786009)(6436002)(7736002)(4326008)(305945005)(476003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR18MB2317; 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: k1iJFfYfp8m3M/tBYqN5ewMAS/DD4U9G4R8rDMDX55HPYQnfrriZyettSD9euBA7x6tX1VGdEbP2p7I3PkV259isE2brp5AQiMRHElol8RIn20aU7Y8H1PAAAlNwv/cTCT2CZ/i8LCrIxdenCKpCmKQdVjleRXHKQKbcYfRGkaUGpdffsOmMoFPFZGGmKtPVeaC2tpi5p1Uno5uLJ+9jnR0ID/80DUfC6MsOPhYqoSwcZeF8q6IuMnKWZD0DU0K/CoBxv1pMm8pblxFcHOT9pf/bAXWwPa8XJSUMRyX0Rbb4p8stbw5F8hcjlS3BZmURyHuOmsUGzYDC0ykFoBfYbSTpXtT+scBROe49o1tmYnXQXTMlId80Mv3MeEEYdaP1pSOwc+pQNTvgC4flQcjkUHnJzBji8NuEYjz9id7FMb0= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: d703d750-adbd-411d-d117-08d69e2cae7b X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Mar 2019 10:00:06.6035 (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-Transport-CrossTenantHeadersStamped: SN1PR18MB2317 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-01_08:, , 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=1015 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-1903010069 Subject: [dpdk-stable] [PATCH v2 1/2] metrics: new API to deinitialise metrics library X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Mar 2019 10:00:17 -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. Cc: stable@dpdk.org Signed-off-by: Harman Kalra --- v2: * Adding stable@dpdk.org into cc as this patch falls between bug fix and new feature. 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