From patchwork Thu Jul 11 09:26:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harman Kalra X-Patchwork-Id: 56323 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 130844C8E; Thu, 11 Jul 2019 11:26:14 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id DBBBB1C01 for ; Thu, 11 Jul 2019 11:26:12 +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 x6B9QCvL016049; Thu, 11 Jul 2019 02:26:12 -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=tuomv/v67yxMcXHkBkDO0+E3NSF7ihLWGETsEif4Byw=; b=K6vJy8Tebh/d/Q0lZiORyJmyEgesC4q53g9MHBH03+3WcXNsP8d29QEnZaJUrYLg6x7U 7hHu3DTTdjPojLv7HBEYIFMJwuelxzHoY9qn1FuMYZHi/vBWmvsZClqKIk8/ay01s+OP nvrjl6Bj7wed8hdzWvQC8vusUtZlLPcgYl+xr1qNYCxzcPB7+6XJWxAWV/soUfASiRqN OLr3psjysY9u82irw6s6++Ju+x/LV+M91OafwJdXdSDegi6vO/+ozZm9qyrWXvlTDDWl giAZpgzsuXDUGXeAw7q/ae6taBzRk2a7ty5wIzx/3t/kjcxDwvB+vHaicqxZ1Asa/NOQ Rg== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2tnq21ae18-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 11 Jul 2019 02:26:12 -0700 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; Thu, 11 Jul 2019 02:26:10 -0700 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (104.47.46.55) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Thu, 11 Jul 2019 02:26:10 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e1S1JssrvnptmzyNU6Li1r3ckFmOsPo0lsk79O7l1bJH4Q4ihePPdk26OKL+iuXhNT7RFIogM7EAKQO9Lj4kzKVO4WhPmzyfv3e+yGa6D3QWrE0weN8qSsx4xVKdENdmjwnNV0dlFl5K+saBlY3DkajkTV0PPuoE+ftrBzswlO9rswKoQBiYETUpljCsXP0PI/OpdyEXpnN9q9AKZG7uU00ulnV2gsFeEolicdWhtqOHJsSpLZTctyCca3V3O0vMjGbIMyBQTvFAvwJxgFxPj5kGoYX81/M6blQXIId8HMw9q4qG7oNGNtRwgr/bYneWXkTA+jElkgj5tFHMxBhaew== 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=tuomv/v67yxMcXHkBkDO0+E3NSF7ihLWGETsEif4Byw=; b=b4ztrtznoZkUV6UJWLFDSVcknLQ9boL4Wme+VhD/pLc0a5nwigslgmZe/5ZblEX/qnRR5tKrq1WS0yZbK8t8jvlnWnLI1W4tso2AFKDuWd41RKgohxX0MUREO8tUvi6PvWhmsK+F3OAHbkyiOU1ZhGQ8EgKtCOw8Fg/1k9w73JqHM/9t9pM4H/yKgZySIfg9sx+6wwkUWnH+VZvLsa6AJ+xMq6yvsyi7b8f8wW7S6XOliNgSU/2Kd5Oro1JMR+PN5OTxvHFQ6aT1h97UJXJJHbKzmCCNAOZP6BKSIkPihzsKxD4udaG/nHe7T+t/j1NDJdSgCcYfVXorQ5paIlEVJQ== 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=tuomv/v67yxMcXHkBkDO0+E3NSF7ihLWGETsEif4Byw=; b=FzSe/GXzOKNISKj5wf+3qckBJSEWfAFarJXR96+Nbdncugixq34QjnW/0/JWNj/PQxRXE39vwKXdY8Qfldag9VQ8qa2QBZOgtnPywx4FTCnx6d9YMH8/ZQT7fiStpjV067ng8hWdD4Zrfrw9m3J1B5qUrkeCNCzb/RUalmpGdCo= Received: from MN2PR18MB2848.namprd18.prod.outlook.com (20.179.21.149) by MN2PR18MB3072.namprd18.prod.outlook.com (20.179.20.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2073.10; Thu, 11 Jul 2019 09:26:05 +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; Thu, 11 Jul 2019 09:26:05 +0000 From: Harman Kalra To: "thomas@monjalon.net" , "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 Thread-Topic: [PATCH v4 1/2] metrics: new API to deinitialise metrics library Thread-Index: AQHVN8qqJXgUkBpbfEepBWhalrWEAw== Date: Thu, 11 Jul 2019 09:26:05 +0000 Message-ID: <1562837134-14830-1-git-send-email-hkalra@marvell.com> References: <2087123.3zRFCGiTdz@xps> In-Reply-To: <2087123.3zRFCGiTdz@xps> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PN1PR0101CA0058.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::20) 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: b6bd3949-2038-42ee-23e5-08d705e1cc76 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:MN2PR18MB3072; x-ms-traffictypediagnostic: MN2PR18MB3072: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2657; x-forefront-prvs: 0095BCF226 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(39850400004)(346002)(376002)(396003)(136003)(366004)(199004)(189003)(6116002)(3846002)(86362001)(68736007)(107886003)(11346002)(71190400001)(8676002)(53936002)(81166006)(2616005)(2201001)(66946007)(446003)(81156014)(486006)(66476007)(64756008)(66556008)(66446008)(14454004)(25786009)(6512007)(71200400001)(476003)(36756003)(14444005)(6436002)(6506007)(52116002)(4326008)(76176011)(7736002)(478600001)(99286004)(386003)(50226002)(5660300002)(2906002)(55236004)(316002)(6486002)(305945005)(102836004)(110136005)(66066001)(2501003)(26005)(54906003)(186003)(256004)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB3072; 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: LdtgWmDwGNhEHgQSyuDZhY7cKYZw73glUyoeozvEuRjAjXROEmet2Ey5F9PI9TN7Uj0PCnTca3fgo80fETEW8ODULg+O8pCxFqcB26KXeke6QJEep2stVuxR0614VRjb6YU4/BMHxn3MLSl/vNVWXZ0cLxkV5K1tOwfHIPpeadjWlPLxty959S7oCscQQPlWZAf8XYEZHmsDf9hAaGvEbHWAUHg171cKxjYW3TR+CQobhN0ZeVn2gIO/EOvf52GF8r3DE6H4X0uJElZI2eHCnKGGRMM00UAUD4W8dW0vzeSZbe1e55enuXlRKN9abKCRa388hLWl2I9A8Zfuu4r+TAdOJGfii6gpy6nZje96rIfA9GVRQqQEbo2rNMhUILywUPFDs8hO7hylZAxvYGZvsGlKTwQIL4SpLAd8QoxVvRA= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: b6bd3949-2038-42ee-23e5-08d705e1cc76 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jul 2019 09:26:05.7156 (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: MN2PR18MB3072 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-11_01:, , signatures=0 Subject: [dpdk-dev] [PATCH v4 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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. Signed-off-by: Harman Kalra Tested-by : Reshma Pattan Reviewed-by: Reshma Pattan Acked-by: Reshma Pattan Acked-by: Remy Horton --- 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. v4: * Included the tested, reveiewed, acked tags received as review comments. * Removed stable@dpdk.org from CC. 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: } +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 = 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 --------------------------- diff --git a/lib/librte_metrics/rte_metrics.c b/lib/librte_metrics/rte_metrics.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); } +int +rte_metrics_deinit(void) +{ + struct rte_metrics_data_s *stats; + const struct rte_memzone *memzone; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return -EINVAL; + + memzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME); + if (memzone == NULL) + return -EIO; + + stats = 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_metrics.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_ #include +#include #ifdef __cplusplus extern "C" { @@ -80,6 +81,23 @@ struct rte_metric_value { */ void rte_metrics_init(int socket_id); +/** + * @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_metrics/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 { local: *; }; + +EXPERIMENTAL { + global: + + rte_metrics_deinit; +};