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 3CA24A09E4; Sat, 5 Dec 2020 14:02:02 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B333F4C7B; Sat, 5 Dec 2020 14:02:00 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 86F6B2C6E for ; Sat, 5 Dec 2020 14:01:59 +0100 (CET) IronPort-SDR: oiBaX/+tuSPKlkwZ0lFp0hVoY+hLv0evnuRnnkpWeEpZlmVwJtfY3cBvxY92xXc2oaEMGxlesy cf9B/U/MXjWg== X-IronPort-AV: E=McAfee;i="6000,8403,9825"; a="153330819" X-IronPort-AV: E=Sophos;i="5.78,395,1599548400"; d="scan'208";a="153330819" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2020 05:01:56 -0800 IronPort-SDR: m7qhXIR7RQbYifbVIzMuHFvH4MU8gY+sAkP44P3GyFKRryhmjl4sEBGL5DJMRgv/13zcU4lv7x bLB0z1uFQLrg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,395,1599548400"; d="scan'208";a="346904238" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga002.jf.intel.com with ESMTP; 05 Dec 2020 05:01:56 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sat, 5 Dec 2020 05:01:55 -0800 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sat, 5 Dec 2020 05:01:55 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Sat, 5 Dec 2020 05:01:55 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.175) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Sat, 5 Dec 2020 05:01:55 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SSodmaPZRzwJZaDfCndJPKdpSAJk9Q3zKYZqWlpmMAb4eD5zjSa+VZ0KOanW5fNghBEPkapaAdYfOi3t0cK0KSPZ51JvF1voG/xwB5AKyQc1rUWseIlXbjRy8Za2Ck9f7nRbai9mswJ76nfBnEYfZEv+j3dM1HfT24gDHZzE7aydHKugHy7vaG00/Qd0RYNnzHxTh+DzesyO2c+v1cGQsnCEQcPa5Uj8DDOhct25jnuidHkYJiO8NaMLepqa9r7TREBpXgQ8JJ5ak63Za7O9ldu4GceM3lAh1cEZAV5B79YGqk1lPDwto8JWAOYPR3ITHMt7Cm3+WwjsHZSyQE3Phg== 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=j952Ou+3IyJW8ISage1lRpYAOa/dvIldQcPEfnMRvi4=; b=PA93GulNoStwFH6BoQ7Z78xrgfaEz7m9DSRLiuZ44uUpZcedOWw7fH/Xn5TSo4Eko9thKwxTmYFrVirwugYIc3X/vO2xPdJpTJ0N4qoFVfpVA+M8NY4SuMNNcH5u3jNZJadFf3FLn5J1irGXRV3RS1yb3xb4wNxNGYVMk2kLRF/WLjELgHZi8Z1RplBO0LNIi7Acia1/m58CTs7m14CZDXoSDM/r6qjXL1KpLdG3P1/vuAQd7lzZAIdXcjAwIwyjwEuuf/l0H56gj2xKhzpnBKIHkpdvTEqRNbA1mdYpBQNJL19XS/er1G3vgfz5hEWGHxeAtOuKGviEdgJgbhKwgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j952Ou+3IyJW8ISage1lRpYAOa/dvIldQcPEfnMRvi4=; b=ddJfZEvfMC1bFqpLoWwIoT2BlDnk1K9RaOGCzcAfU7RE8Z0u+HY3ib/yQ+rbS6SLyK+7F/JhOYsMmZT5YRf/3CJtCTNUmP/YnjkX3/0XV43K7+ks1GBJcJm8ahT2J7PuURV0YuKJMUigwQ/ujdl106nZX3sQSn3RDcLJpdljwcE= Received: from MWHPR11MB1581.namprd11.prod.outlook.com (2603:10b6:301:d::9) by MWHPR11MB1741.namprd11.prod.outlook.com (2603:10b6:300:10d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Sat, 5 Dec 2020 13:01:51 +0000 Received: from MWHPR11MB1581.namprd11.prod.outlook.com ([fe80::556:15d2:6ce4:d49d]) by MWHPR11MB1581.namprd11.prod.outlook.com ([fe80::556:15d2:6ce4:d49d%2]) with mapi id 15.20.3632.022; Sat, 5 Dec 2020 13:01:51 +0000 From: "Varghese, Vipin" To: Hideyuki Yamashita , Thomas Monjalon , "Yigit, Ferruh" , "Andrew Rybchenko" , Ray Kinsella , Neil Horman , "Burakov, Anatoly" CC: "dev@dpdk.org" , Hideyuki Yamashita Thread-Topic: [dpdk-dev] [PATCH 5/5] librte_ethdev: add to use apistats Thread-Index: AQHWyhKwadCmfM61F0iHLWavOWZdvKnodPIg Date: Sat, 5 Dec 2020 13:01:50 +0000 Message-ID: References: <20201204075109.14694-1-yamashita.hideyuki@ntt-tx.co.jp> <20201204075109.14694-6-yamashita.hideyuki@ntt-tx.co.jp> In-Reply-To: <20201204075109.14694-6-yamashita.hideyuki@ntt-tx.co.jp> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: ntt-tx.co.jp; dkim=none (message not signed) header.d=none;ntt-tx.co.jp; dmarc=none action=none header.from=intel.com; x-originating-ip: [202.164.130.107] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 65e604f7-4c77-4d5d-7677-08d8991deec2 x-ms-traffictypediagnostic: MWHPR11MB1741: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2887; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: C4m8dNizsOQAHSGOPfmLe3z15Wjv8MpvFsmJMnsjsHvy83QL9Ck0s3mnmRorGFp09arcRpBTWG7MVunPUm5F7R8n10Vi7RWawx9s5K/0f7fpJGhahJkfKNvhXuZypHc3bSG5owKU606bNIa1P26UqvmDq7Fj/dxhpkRqwxS9S7UZiq0U+Klwzt2zeewglNZzUy3IqlIhrV4UA/sxWnz7LsXZq7hU1J4Scb1E8/2NFkRUCkRHOYpTC0xokXpB3fDePDXU1iVX1YIGq99P0IIE7E23w7mEXGzRRiuyn9coDF60HhPRVqSWcu8og4EsP3A6vqtRYaXcID9DD3fLhmyYgw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1581.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(396003)(376002)(136003)(346002)(66946007)(66476007)(54906003)(52536014)(66446008)(8676002)(64756008)(5660300002)(110136005)(71200400001)(33656002)(8936002)(186003)(26005)(83380400001)(2906002)(316002)(7696005)(55016002)(66556008)(6506007)(76116006)(478600001)(4326008)(9686003)(6636002)(86362001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?Ed87Cr+cwWtfp8w8MHfROJk/yTpvjy3JIpoKJS0r5ezb3PFsgu/ERWeiZSgB?= =?us-ascii?Q?jzu9KQ8KrUE+mf1Gi0g11xkbItQMToR4njKbHjXcvDLw5K/f0kecEokJ8aKe?= =?us-ascii?Q?/5W7Ru23Kk06ZtJI1C+omFOaszhtFlkhMtXQKs+dncp7GMYzNxAl0qJkPpsG?= =?us-ascii?Q?9Y+COHhgMfjqS4dME7jk/OzALoXezmkKdsntUZX2UUsNPMojYykj54U8aP3+?= =?us-ascii?Q?7ILuheJPwM5JgYzQ6GbFZaEJq3pAr1x9E/CzvlWuvjGEVzsNA0OE+OXeNkN1?= =?us-ascii?Q?Rw69LdE3QiaN1VTM7XzTS3BGXjB+6KYJZhVbI6xk4CgamsIZgy/FZKLEzn9+?= =?us-ascii?Q?kodHiKDpBcRRhtRV7D0s7zAP1AGYggtrJHmiPepBJ8Lle9jUMthGg3rJfjkV?= =?us-ascii?Q?lgCiTIhnwaqBISTiLPCOqJ7XuKp+3Mm7foy2ImQ+1BVG2OMG8Ls2zuBDngLJ?= =?us-ascii?Q?jOzHd+4T5JWupKsfbReY8y3Bp00Jh8pLXXL6/aUaTFEKCNs6CnKw6tLC2zWS?= =?us-ascii?Q?DCljxnvoaumvInI+meFfx7sK0hno8S6wQzWqM2nFdPxqfMRBiq3SeHpfEc3o?= =?us-ascii?Q?h5zh7pEbKBBiwJnIuj1Frm4XmEZbP7YPkzKOJ8dzWhwXzL9EkSdN18+SYzOr?= =?us-ascii?Q?+iRKYbg/QYcsKfNwCPxIbUXSIH9RgZLy8T5aYn6wmvKyDtcmQouNASaSG538?= =?us-ascii?Q?WV9uoNfrpkA6fMrGyEMjHd9/rAl7MjCwaE2j1VOydePRk+YkyUFzBsz5T89w?= =?us-ascii?Q?DLm1ICd+iw7AuvLGnizsy1JpUKPQo9gmJXIPO7d5wbynw8kP/Hgs+/CZNJG6?= =?us-ascii?Q?nOKhTTqovGoqw/lDEqu2IsMv6aC1n13aZm27guSqVuVFjW3445hrnkSSpjdY?= =?us-ascii?Q?7+yqPqDk8mAcZqAEgFSQAuxP/G9TRsc+ldgsc8G4k6J73YljIHWEjZtbePV2?= =?us-ascii?Q?pP68gf1BoF0btqu4Xpvg1dtH9TfAnDANdsNRTbjpRhg=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1581.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65e604f7-4c77-4d5d-7677-08d8991deec2 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Dec 2020 13:01:51.0828 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 2H/TDzWy1o9F1gNoVjV1nJFD4crRLFzBQe04kZubz4KdEIsgRxnGHJs1qpK1aODepQjhqUynW+5ISpJI/PkKD/ZRdMWJaFwlBk99VqV6D+o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1741 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 5/5] librte_ethdev: add to use apistats 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" snipped > + > +int rte_apistats_init(void) > +{ > + int i; > + const struct rte_memzone *mz =3D NULL; > + const unsigned int flags =3D 0; > + > + /** Allocate stats in shared memory fo multi process support */ > + if (rte_eal_process_type() =3D=3D RTE_PROC_SECONDARY) { > + mz =3D rte_memzone_lookup(MZ_APISTATS); > + if (mz =3D=3D NULL) { > + RTE_LOG(ERR, APISTATS, "Cannot get info > structure\n"); Could be more readable if the LOG is modified `failed to lookup memory for = %s by Secondary!, MZ_APISTATS ` > + return -1; > + } > + rte_apicounts =3D mz->addr; > + } else { > + /* RTE_PROC_PRIMARY */ > + mz =3D rte_memzone_reserve(MZ_APISTATS, > sizeof(*rte_apicounts), Would rte_memzone_reserve_aligned be better use if you are creating per ins= tance of lcore data. > + rte_socket_id(), flags); > + if (mz =3D=3D NULL) { > + RTE_LOG(ERR, APISTATS, "Cannot reserve memory > zone\n"); > + return -ENOMEM; Could be more readable if the LOG is modified `failed to allocate memory fo= r %s in Primary!, MZ_APISTATS ` > + } > + rte_apicounts =3D mz->addr; > + memset(rte_apicounts, 0, sizeof(*rte_apicounts)); > + } > + > + /* set up array for data */ > + RTE_LCORE_FOREACH(i) { Suggestion, since there would be lcore from different NUMA, Memzone_reserve= from current socketid will not be the best approach. Requesting for re-loo= k if per socketed stats for lcore is to be maintained. > + rte_apicounts->lcoreid_list[i] =3D 1; > + RTE_LOG(INFO, APISTATS, "Enable core usage for lcore %u\n", > i); > + } > + return 0; > +} > + > +int rte_apistats_uninit(void) > +{ > + const struct rte_memzone *mz =3D NULL; > + /* free up the memzone */ > + mz =3D rte_memzone_lookup(MZ_APISTATS); > + if (mz) > + rte_memzone_free(mz); Highly recommend to split the behavior for secondary and primary. Memory al= location is done primary and secondary only looks up. Hence it would be wis= e to free memory in primary only. > + return 0; > +} > diff --git a/lib/librte_ethdev/rte_apistats.h b/lib/librte_ethdev/rte_api= stats.h > new file mode 100644 > index 0000000..afea50e > --- /dev/null > +++ b/lib/librte_ethdev/rte_apistats.h > @@ -0,0 +1,64 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2019 NTT TechnoCross Corporation */ > + > +#ifndef _RTE_APISTATS_H_ > +#define _RTE_APISTATS_H_ > + > +/** > + * @file > + * RTE apistats > + * > + * library to provide rte_rx_burst/tx_burst api stats. > + */ > + > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +#include > +#include > + > +/** > + * A structure for rte_rx_burst/tx_burst api statistics. > + */ > +struct rte_apistats { > + int lcoreid_list[RTE_MAX_LCORE]; /**< In use lcoreid list */ > + /**< Total rte_rx_burst call counts */ > + uint64_t rx_burst_counts[RTE_MAX_LCORE]; > + > + /**< Total rte_tx_burst call counts */ > + uint64_t tx_burst_counts[RTE_MAX_LCORE]; }; Looks like the struct elements are not bifurcated based on cacheline. Reque= sting to avoid overlap if each core are is going to update per lcoreid. > + > +extern struct rte_apistats *rte_apicounts; > + > +/** > + * Initialize rte_rx_burst/tx_burst call count area. > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * @return > + * -1 : On error > + * -ENOMEM: On error > + * 0 : On success > + */ > +__rte_experimental > +int rte_apistats_init(void); > + > +/** > + * Clean up and free memory. > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * @return > + * -1: On error > + * 0: On success > + */ > +__rte_experimental > +int rte_apistats_uninit(void); > + > +#ifdef __cplusplus > +} > +#endif > + > +#endif /* _RTE_APISTATS_H_ */ > diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethde= v.h > index f5f8919..bef9bc6 100644 > --- a/lib/librte_ethdev/rte_ethdev.h > +++ b/lib/librte_ethdev/rte_ethdev.h > @@ -160,6 +160,7 @@ extern "C" { >=20 > #include "rte_ethdev_trace_fp.h" > #include "rte_dev_info.h" > +#include >=20 > extern int rte_eth_dev_logtype; >=20 > @@ -4849,6 +4850,9 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t > queue_id, > nb_rx =3D (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id], > rx_pkts, nb_pkts); >=20 > + int lcore_id =3D rte_lcore_id(); > + rte_apicounts->rx_burst_counts[lcore_id]++; > + > #ifdef RTE_ETHDEV_RXTX_CALLBACKS > struct rte_eth_rxtx_callback *cb; >=20 > @@ -5124,6 +5128,9 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t > queue_id, > } > #endif >=20 > + int lcore_id =3D rte_lcore_id(); > + rte_apicounts->tx_burst_counts[lcore_id]++; As per the current code, the feature is enabled by default. Should not be t= his an option to turn on or turn off via compiler flag?=20 > + > #ifdef RTE_ETHDEV_RXTX_CALLBACKS > struct rte_eth_rxtx_callback *cb; >=20 > diff --git a/lib/librte_ethdev/version.map b/lib/librte_ethdev/version.ma= p > index d3f5410..adea432 100644 > --- a/lib/librte_ethdev/version.map > +++ b/lib/librte_ethdev/version.map > @@ -240,6 +240,11 @@ EXPERIMENTAL { > rte_flow_get_restore_info; > rte_flow_tunnel_action_decap_release; > rte_flow_tunnel_item_release; > + > + # added in 21.02 > + rte_apistats_init; > + rte_apistats_uninit; > + rte_apicounts; > }; >=20 > INTERNAL { > -- > 2.18.0