From patchwork Fri Mar 1 10:07:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harman Kalra X-Patchwork-Id: 50712 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 82BA42BF4; Fri, 1 Mar 2019 11:07:43 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id BD13C2B9E; Fri, 1 Mar 2019 11:07:41 +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 x21A05eV013723; Fri, 1 Mar 2019 02:07:41 -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=OT1iHOudFSxjj/vfCOUyOJhGHCiDfdkGzYtxAtIj+tA=; b=bHYJgsmZ5uxoINC3Zn6OUSqrNxatrvT2yhDTByMwTctPKoYIDEsfitfMyWZhtySX9cbs jq28Pa5y45DJhnWURK5BhcRn1b4UUE0vdE0kZEgEZFP1AnilRuhrw8YNqHfOm8Vi0qvq DHkPKBMb8lNwBGI8ogloAOm6IIaz/d8XvyEFTZmbpoaR3PiqEBhXiO3bxxbvDC3yLXXo 4cKRsMunzSSgcgBmsbeZuohxhmEivpQ9AYaO2PGTQSJaUbpy1WkxccHWGfM8WIgnZHPL jky1vuK0kHyPcHzUc8kfzQodisyqhNSkRfKKwwyspuQf66FloRMlJD5vsZxxBzXnZB3q eg== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 2qxprq1kvb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 01 Mar 2019 02:07:40 -0800 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 1 Mar 2019 02:07:40 -0800 Received: from NAM04-SN1-obe.outbound.protection.outlook.com (104.47.44.57) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Fri, 1 Mar 2019 02:07:39 -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=VtVvRhneK2f1YZEawRC/faFCHwJkU+gWOIQlB4RGPQ588hNa68RNVQ3zDS14WJrAsCSEgvXnu9WrQfM0tcCKXal4F/VvUfMUzj1oTa+zA0FMJ2xeNcPCHM81qudqHQmNnFTnFKpF7ESQUDvTTeTbaVmhtojlCujHl7TlHKpTmTA= Received: from SN1PR18MB2237.namprd18.prod.outlook.com (52.132.199.27) by SN1PR18MB2126.namprd18.prod.outlook.com (52.132.196.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.18; Fri, 1 Mar 2019 10:07:36 +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:07:36 +0000 From: Harman Kalra To: "remy.horton@intel.com" , "anatoly.burakov@intel.com" , "marko.kovacevic@intel.com" , "john.mcnamara@intel.com" CC: "dev@dpdk.org" , "stable@dpdk.org" , "Harman Kalra" Thread-Topic: [PATCH v2 1/2] metrics: new API to deinitialise metrics library Thread-Index: AQHU0BaYFB5FuyCnREe1slOCmpOxfQ== Date: Fri, 1 Mar 2019 10:07:35 +0000 Message-ID: <1551434828-3518-1-git-send-email-hkalra@marvell.com> References: <1551264691-26353-1-git-send-email-hkalra@marvell.com> In-Reply-To: <1551264691-26353-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: BM1PR0101CA0064.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::26) 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: 9a3369a5-ad19-4c18-845d-08d69e2dba65 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:SN1PR18MB2126; x-ms-traffictypediagnostic: SN1PR18MB2126: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; SN1PR18MB2126; 23:MxzR5tNkvJnydwgeTR1EKrWjbBDa9Te9RgPFX46?= =?iso-8859-1?q?lWC6dFK1+aWAiH6xw9CnoJfTN?= =?iso-8859-1?q?gP+R8W/ySKmF5x+nmTzPRDssNBKy9DNE3eObPcpoFeZNlcOgWoq?= =?iso-8859-1?q?anDE7rSWNJ52Bvy2+qdhrBMSVvlE8k81Thq+xT7h8PXknWB9AOZ?= =?iso-8859-1?q?1JkqBoCwwhfHalH9wHMhy6RCgfc52MAeywoHlj+M/0c7xYKjl99?= =?iso-8859-1?q?qB032LA86aOJuGDsYBjBxFKWWi+B+Upn9L5g+iMOiR2niXyp2gK?= =?iso-8859-1?q?1KW9yuT1FZlPlRYVtE7vmHztuNZVXQ5wEoS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?= =?iso-8859-1?q?E0UPD4zP73jfzXlkfL1nWuJ+eCDmTv9OSG7C/jYJiKN8Ui1tR9y?= =?iso-8859-1?q?9FvPLnvd7aLOasI+/yGYM+eCKogfDUbpdaSM9ZPIrB3JxrrjQ0y?= =?iso-8859-1?q?ErjwR36blZ0qH53biprPoAqo/zd9FgNzJFEAs0OHJ3f8rqbVnnf?= =?iso-8859-1?q?7i4b1/L3KcklqQ=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 09634B1196 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(346002)(366004)(376002)(396003)(39860400002)(199004)(189003)(106356001)(305945005)(68736007)(86362001)(50226002)(36756003)(8936002)(105586002)(7736002)(6486002)(107886003)(97736004)(66066001)(5660300002)(3846002)(76176011)(478600001)(2906002)(6116002)(316002)(2501003)(25786009)(386003)(6506007)(186003)(14454004)(6436002)(14444005)(256004)(53936002)(81166006)(71200400001)(71190400001)(4326008)(2201001)(110136005)(486006)(8676002)(11346002)(446003)(81156014)(102836004)(26005)(54906003)(6512007)(52116002)(55236004)(2616005)(476003)(99286004); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR18MB2126; 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: NwGtrtrhVDAEIevr1Y8rx5JTxOlAop5Nt7XnmTmxhM/mXZpiKYlKKHwsFxNloWbpUL7Iml6Cp3DHVqk1CCIr81VkQvQ3Xzi9KovhX1MKuzbPU4bn8Y2jqxHM4hwvXV7DRMpNsaFerD80tuFO4uHA9oHbWsfkny0Uu4n0eZyETyzhagiXsIoaVjFMzpb64mU+eMJ3SXn2TfnzsK1sCDaTpQ0Ds4Kw2XLXqwGun5LfhekBzklnQ3C6ZxfZm7/Ah18YZO1zUjEd4JW+IYu+4k+GUEELS0G1Sy8Lfm4wIWcPvLNTKwmk6CRbHpVxo6zvoEv1oHTIFZJflW06YKfn/dBlNuDXuoTEEx19ekx1Tc1uoTulKFiyB6c8tGovNuek+iUi9dKE24kVfsvctFJ86nAzxPkOMxmgA6GvyfKn9JfoR94= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 9a3369a5-ad19-4c18-845d-08d69e2dba65 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Mar 2019 10:07:35.9307 (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: SN1PR18MB2126 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-1903010070 Subject: [dpdk-dev] [PATCH v2 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. 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 Reviewed-by: Reshma Pattan Acked-by: Reshma Pattan Reviewed-by: Reshma Pattan Acked-by: Reshma Pattan --- 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: } +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..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); } +int __rte_experimental +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..0957a94b6 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,22 @@ 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 + */ +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_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; +};