From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 95B3DA00E6 for ; Wed, 10 Jul 2019 12:52:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 08DA531FC; Wed, 10 Jul 2019 12:52:58 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id AEE2D231E; Wed, 10 Jul 2019 12:52:53 +0200 (CEST) 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 x6AAoNsc000637; Wed, 10 Jul 2019 03:52:52 -0700 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=+giBMnpBAkGZzTgXFFAyReSpjF//ChupD5jOTVL9XDQ=; b=IuQ6TUpEabXj7MyDPTXypykKQ2rfhQ+WzjNTXRe3StR/MMsTvS0rJgwtLrRmG1WFipcf s9ktkzQkpqVSHqny8ll4rVOUeEXiz0F9uS7/6uMw1hvgyM1Hov1++IYXULDCzJ3sdPLz g9PFZJLSUeZyifhXjILWG+ztnvQwIw5GUmCcmM6dzcIGSm16aLIU2aEhq5yvezPDVnYX CcpM9+8N88rQ3xc7Osq6A+enO4/RNCB7L7XKYR2jJBk6vRU2qFOIb7xBup28LBedRNJU xQKy2T+QSdY8lULhFbwB7vCWvex/zbotCv1pu7O9iej2Yx2/F/hnMapuVLEpSoyh/e6s Yg== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2tn5nvht31-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 10 Jul 2019 03:52:52 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 10 Jul 2019 03:52:50 -0700 Received: from NAM05-BY2-obe.outbound.protection.outlook.com (104.47.50.59) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Wed, 10 Jul 2019 03:52:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mTTL/vSSRvbeqcNidAHCg2G7SKbOER547uGC+irLOTrWLd4QSno9Jc0EDkpRrNNpV4sEKklY7asOCSXndrG9S01iMP6dsOm9dki3d6QlAAV7hQ324R1HB+eIslWc2b9wxRmONQZFOsUrw5EBeAA/XB6dO2a8+B1DQIRYK3JHmFWXuetFCx1wUmT2DhbFIaeDUkQ4sMKAKbXaLO0++YrP96cHu0UHcQ/FFbGeCxMVEqSnLThUbXHObXch02hzF3WMlYVs4rgHK0yN4zOylaZ1BrGmZYuC/IMayBNaSjx3SIebhEn4RbI6hfhW9lRhyBLeTkcSwsuSp49ln8Ij+N8Raw== 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-SenderADCheck; bh=+giBMnpBAkGZzTgXFFAyReSpjF//ChupD5jOTVL9XDQ=; b=dFEIVPtODbo2K3VLoHkJkZqieNq2d8DNgnIYY/NWXYmikpFlt/ryCwixrKY3lei00MMvyQqAa4Q6ElDjCmxNWsILj05B5p51RKWGIMxDNYlyDKXDSLSjScmD/IB3BTsPPjgx63YQEKI1eskI+H7JQNWGZTsjuny5aGA1lNihsx2uTbV+UprdfVeABZ8/1CCABqDyV36xl2J7t5mBL9d3g0GsKH+7ScuPVtDLn4KYLkmTMXuHVTTbQVFGfPR4F4arHTNPl3/HhjVkDJMGVbXsA1jVaISe/s3uIywi5qpPqOghEURYHXK4bUEQyVC7Ejd2ddSNRO0WssJWUA8jxi2XEw== 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=selector2-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+giBMnpBAkGZzTgXFFAyReSpjF//ChupD5jOTVL9XDQ=; b=IXXkz4p8tfwfNXBa9QQHdIvdfWucMqmdtAThtX+cm89m3cv79cTOyDW7ax0m4A/CkYI5PkZuKFShzcZthvCf9l1+ZcTk80n6U9tosdz+JOXzz34UXA1sFKG7nxfpwG/0Wa+1F4r7aiuyENw2tWUoUVFlz3jie8kmkIPUHeAaNK4= Received: from MN2PR18MB2848.namprd18.prod.outlook.com (20.179.21.149) by MN2PR18MB2848.namprd18.prod.outlook.com (20.179.21.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2073.10; Wed, 10 Jul 2019 10:52:48 +0000 Received: from MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::4447:9459:5386:2e18]) by MN2PR18MB2848.namprd18.prod.outlook.com ([fe80::4447:9459:5386:2e18%7]) with mapi id 15.20.2073.008; Wed, 10 Jul 2019 10:52:48 +0000 From: Harman Kalra To: "remy.horton@intel.com" , "reshma.pattan@intel.com" , "anatoly.burakov@intel.com" , "marko.kovacevic@intel.com" , "john.mcnamara@intel.com" CC: "dev@dpdk.org" , Harman Kalra , "stable@dpdk.org" Thread-Topic: [PATCH v3 1/2] metrics: new API to deinitialise metrics library Thread-Index: AQHVNw2ctHUWJ3GdU0SJVls0Owunjg== Date: Wed, 10 Jul 2019 10:52:48 +0000 Message-ID: <1562755934-13358-1-git-send-email-hkalra@marvell.com> References: <3AEA2BF9852C6F48A459DA490692831F2A4881E7@irsmsx110.ger.corp.intel.com> In-Reply-To: <3AEA2BF9852C6F48A459DA490692831F2A4881E7@irsmsx110.ger.corp.intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0040.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1a::26) To MN2PR18MB2848.namprd18.prod.outlook.com (2603:10b6:208:3e::21) 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: 15112a8a-9579-4c58-da39-08d70524bf29 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR18MB2848; x-ms-traffictypediagnostic: MN2PR18MB2848: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2657; x-forefront-prvs: 0094E3478A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(346002)(366004)(136003)(39860400002)(396003)(376002)(199004)(189003)(478600001)(50226002)(2906002)(8936002)(26005)(446003)(14444005)(11346002)(186003)(81156014)(316002)(256004)(2616005)(36756003)(7736002)(54906003)(305945005)(476003)(110136005)(81166006)(8676002)(3846002)(486006)(99286004)(6116002)(76176011)(4326008)(6486002)(2501003)(14454004)(66066001)(52116002)(66446008)(64756008)(66946007)(66476007)(66556008)(68736007)(55236004)(102836004)(2201001)(6512007)(86362001)(71190400001)(71200400001)(386003)(6436002)(6506007)(25786009)(5660300002)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2848; H:MN2PR18MB2848.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: vkCAlm2DF4GwvABbFuSUDCSm3eVdPp4zIzUmINonvP7H9aDHWNngoy/xcKKosSiBC2GtBeLj+prOXYW0fatZ2JJrUjCQAngDfCeXvnQOcn/s7dul5vuykl5hBl3Qb6BHtmmtJEBjoSfclaq1L1O+C7XjSqlWkvWpQCnbDeasU3FkdfT100vQ+yS9vKSKzTgi3vnnXaq2gAE1y0kBgsa3tgzrn13yUhaovDxZFlDr/DyGH0Lt+NJvw5v0b8BfYGPkzJYWNqBsVSEG9RmgqhPOv0Clq0hVdvX5tDZ4Gh0XTlSNBH2veMWRZ+k0t8A74bs4BJGQBqDbXJdNs3+4PaSSdSf3Qd4TvvM9c75Khck3CE9VdnOf1FNUarWouvSxNABapg6JPijVUEpm3Guvd1hlzMPXfS/3BsPuXtJlRsPSEfI= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 15112a8a-9579-4c58-da39-08d70524bf29 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Jul 2019 10:52:48.4464 (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: hkalra@marvell.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB2848 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-10_04:, , signatures=0 Subject: [dpdk-stable] [PATCH v3 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: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Once the library usage is over, it must be deinitialized which will free the shared memory reserved during initialization. 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. v3: * Fixed check-git-log.sh and make doc-guides-html issues. doc/guides/prog_guide/metrics_lib.rst | 14 ++++++++++++++ lib/librte_metrics/rte_metrics.c | 20 ++++++++++++++++++++ lib/librte_metrics/rte_metrics.h | 18 ++++++++++++++++++ lib/librte_metrics/rte_metrics_version.map | 6 ++++++ 4 files changed, 58 insertions(+) diff --git a/doc/guides/prog_guide/metrics_lib.rst b/doc/guides/prog_guide/= metrics_lib.rst index 89bc7d68f..eca855d60 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..df5e32c59 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_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..77bffe08e 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,23 @@ 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 + */ +__rte_experimental +int 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