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 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+aWAiH6xw9CnoJfTNgP+R8W/ySKmF5x+nmTzPRDssNBKy9DNE3?= =?iso-8859-1?Q?eObPcpoFeZNlcOgWoqanDE7rSWNJ52Bvy2+qdhrBMSVvlE8k81Thq+xT7h?= =?iso-8859-1?Q?8PXknWB9AOZ1JkqBoCwwhfHalH9wHMhy6RCgfc52MAeywoHlj+M/0c7xYK?= =?iso-8859-1?Q?jl99qB032LA86aOJuGDsYBjBxFKWWi+B+Upn9L5g+iMOiR2niXyp2gK1KW?= =?iso-8859-1?Q?9yuT1FZlPlRYVtE7vmHztuNZVXQ5wEoSnj8GMSB03n4fVk2Bf/5fsM4LVT?= =?iso-8859-1?Q?wkOQqwXP+VvVqYpy/WC9BCSt3XG/nOM1N0WQNEIEAsX7DWF6O3NK97hH6y?= =?iso-8859-1?Q?O1spvyMDWYJo6DJd8/XbDfZygOIGPaRNacjV5o3hHA8AqfYmxJvx52xiu3?= =?iso-8859-1?Q?sS94RqeQfXjH7EP/L7RqHUYWNcKPR8NMav8AVJJGCiJGw6jk7xTt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1196 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= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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-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:07:42 -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