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 7BFA6A0524; Mon, 7 Dec 2020 13:38:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 89B14C8E6; Mon, 7 Dec 2020 13:38:19 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 2AABCF12 for ; Mon, 7 Dec 2020 13:38:16 +0100 (CET) IronPort-SDR: C4adcEdyazcsUnjlnAw6ZM0vegq7qW6b/+9F2ASA57Io0ybvtyRbw0wf7FTBgIEzFk+2Plpxec H8UDn6WllPTw== X-IronPort-AV: E=McAfee;i="6000,8403,9827"; a="258400952" X-IronPort-AV: E=Sophos;i="5.78,399,1599548400"; d="scan'208";a="258400952" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2020 04:38:15 -0800 IronPort-SDR: CO1j0s7gKjCLOMaiv6KF5m7Ha1btosSgmjsinC4SasYB8igPvmNfbCsbzWrUYnAnuGJU1lgj2k wKeVhm92WUcw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,399,1599548400"; d="scan'208";a="317761672" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by fmsmga007.fm.intel.com with ESMTP; 07 Dec 2020 04:38:15 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 7 Dec 2020 04:38:14 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 7 Dec 2020 04:38:14 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.106) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Mon, 7 Dec 2020 04:38:14 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wzm6fK3ZYQPEIHgOQB3QU/8wuGyuR8lrr+9jGMB3ALP+m5s3nJApvmnu5JWkjx+DBbdi6zgwfprrMpLW28G0tgxhuaXn72cFBBqfBcuBUv7ioZvGfhW+mw8p99ipyg/FhGsriZzCRxCbPu+XLemxLFcqtBZk03HkmZ7su8heZIS6D2bBP1no8UnCWQ2UPMjL06qvim32YH1GVE8tlvp7haxZJSSS8Tsvso6+iSJcfRd32WzeJwHtv34q9ikOJDxdjYzzq2YyFLrxweuiyPqYa+xdb9lHvZ5wqUBXiVybGppp5qTana1yNJOxRDGjwnmYiPGw6k3kDsa2aBQ7NtAxvg== 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=TD70+v63dbmcGzBgvFB3CrORjUm2A0v2W+zql12kev8=; b=YKJvt2742o091aP/ojNiVK79S+9GBQMphbDn1VLzBuxzPCdEWG3QRsBmORltBYlDcAXtvXDP8RWoNDeJfqz0zEzL+Uc+2DSB1yVNbVESFcPHRTB7VkP2UtYEdoEWXDcVc4RuG3hP4AJs7gls/mQbV37C9WiyvIJlNp7rxOQq3sH21teIzuMRsHXCHGRdBsVuDjbumuEkgf9jCJGXp7gbPY7lz13EB6b+nVFg7Flw3V0OtEyqeQ6YAQOFdSJXdtZcPJFHMUonrNRdIfN3Xh1wAmHKujoLzKvHha+8KwU5rE8kVvNAMoW5p6gBikbvX7XYYsUoEZojHj/Wh2QSNn7hIQ== 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=TD70+v63dbmcGzBgvFB3CrORjUm2A0v2W+zql12kev8=; b=CPifUmcod8oNOi3F70Vgge69PaInWMj7HgVSAdPhn13Zgm+Wn5YPLmhC1niSWB6jKAlwBFS+MEgwkUYtKZxNPwJkqLEAKwlqgsFn4Q5V+ThC6l66SdoX/5HWly25H40M/3E2QZLkQ1DmdOBxfcxL4Cj/etd/KKR/+46xlR2Ei4I= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by SJ0PR11MB5085.namprd11.prod.outlook.com (2603:10b6:a03:2db::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Mon, 7 Dec 2020 12:38:12 +0000 Received: from BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::7101:335e:1c9b:cad8]) by BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::7101:335e:1c9b:cad8%4]) with mapi id 15.20.3611.025; Mon, 7 Dec 2020 12:38:12 +0000 From: "Ananyev, Konstantin" 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: AQHWyhKlWfzw8YlBo0q7fGArv5n7L6nrlSZw Date: Mon, 7 Dec 2020 12:38:12 +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-GB, 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: [46.7.39.127] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 80380ded-0f45-41b7-8577-08d89aacf647 x-ms-traffictypediagnostic: SJ0PR11MB5085: 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:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +RWOL8gbvScq0RftNA+yA6l7Gt9lQh5TxcmAC9v5PXGaUbs8FVrqafEkhBXkzm8szor/SxI/CoLsnHvGsFss0M1eABw8r1axFyAnVBOkSxI2K4cFqj47fKiRE+70GXPnAb0V6OvENSWUrWo6teCtb2CX48oVObruPslCxGyEgmrXf2E+TUAwXSbes/zE1ah/MkMZFuoRviprALdVPtRPdtQJDtGA2pn850sP9jXnHAKoRmydMTVar+PzSoawueuz8xnwTxGxVU9Vltz4NERAMAlDDd5lBlj+i2N4aYfxaqXzWjK1keGSw+76hm1XljvF2sUPypvFJZSwv1BwMTIsTw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB3301.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(136003)(396003)(366004)(346002)(33656002)(6636002)(4326008)(86362001)(9686003)(83380400001)(52536014)(7696005)(66476007)(186003)(5660300002)(2906002)(54906003)(478600001)(66556008)(6506007)(8676002)(76116006)(66446008)(71200400001)(316002)(66946007)(55016002)(110136005)(8936002)(26005)(64756008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?O6kgranXQNvueUTSY1uTHeSva2jpDeRn7o3NxhiH5kScY38J7l3maANwREYs?= =?us-ascii?Q?qERc+zo8T7LGMIZVqgrJi5xr5W4Fe1raANEyuWk9X0y3QcmsfQrg27FpeHAY?= =?us-ascii?Q?hiWAFD7oBPmYsN1++wIvcQiJx+qV/YhpQ5f8dPNwrO4yffZOSS1CyM2RbKRi?= =?us-ascii?Q?S8lal+U9qcQ4TOW/z+2TlL7LziPSupdcrJ/4kOy6IPH0evwrCyZPvjH2rL+g?= =?us-ascii?Q?LWqcwN/qeStsmCOv8raB1YNQV8MavUZEKlamsDYpfkdDMWOrEDjfsHMQ+eyL?= =?us-ascii?Q?V2GeFRjzVtnQJ47BcrGbiwip+7NBdHE5MBBdOzrKnbxtTyczr/zwjzHVPWI7?= =?us-ascii?Q?lNXeIuFmpQfjGLQ8vbHyl1Xy9mk0rWgoHpz4vyCjf5wkQK0+pvhwVj9JXNKp?= =?us-ascii?Q?fwQqLU7Th1g3P7GXet5kDA0dbEO4aFCTGgzjQRNStgWTBZX/f/vgHM1k3lBZ?= =?us-ascii?Q?2qjx9oGeyPHwK5QREx/NxJvpfQcOp+tiscJmY6ngtKRvZUrqwmA/8zawzBxv?= =?us-ascii?Q?SO6VuBB4POt8vlYy3hYQ3tswX8WpA4lMQ7lfJ6gXKmn6HH622HXwanTEKE35?= =?us-ascii?Q?ZtLuNP/oOjNUFlvZsh3Z5I9PECwt5dtwRS63ZjbSW3Q1Tb1zBILigimkBOKP?= =?us-ascii?Q?ZQYIAMVpIWh2TesPPlyvwT7Q6xC/xxYg/q2CYXD8Uicnxk6adYiZP1ze0LTi?= =?us-ascii?Q?YxvKRxdn9gEHGOdJCLMO0+aieW1TE6Qes9bB5JShTkZlohVdGgT8gKrCrFZW?= =?us-ascii?Q?5MJDdsfi0kHzCWPqg923HZWi70IRtDKJrKofNN4ad0b9MgBJw8kkJHsQVIqo?= =?us-ascii?Q?B7v5WC86tY+y+PTAQ3AyX3z/gZpThIEnNuYlzF/KgaBzvL7uCp2OP3NPq6FL?= =?us-ascii?Q?8g4IGA7azR/tC8D+Ayl/Wvl09qrtKkj7YjYwfnXGpLjDEIWsfUUNcmtiNWe7?= =?us-ascii?Q?Mjnfm6zaC+WaieIe/I3tMQZjAUiGbQPwKdKMTRPbf7Q=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: BYAPR11MB3301.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80380ded-0f45-41b7-8577-08d89aacf647 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Dec 2020 12:38:12.8560 (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: Mdm6H2ipjbWUg7YewCpJBjqan2AzTXyf0icUWxCs7mpEW5/YF0+n26gs+PykY8rHkSgq/lOkIK7QeIt1BI4KOLUPdRJkC14+AvW7IM0a4pA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5085 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" Hi, >=20 > This patch modifies to use apistats by librte_ethdev. >=20 > Signed-off-by: Hideyuki Yamashita > --- > lib/librte_ethdev/meson.build | 6 ++- > lib/librte_ethdev/rte_apistats.c | 64 ++++++++++++++++++++++++++++++++ > lib/librte_ethdev/rte_apistats.h | 64 ++++++++++++++++++++++++++++++++ > lib/librte_ethdev/rte_ethdev.h | 7 ++++ > lib/librte_ethdev/version.map | 5 +++ > 5 files changed, 144 insertions(+), 2 deletions(-) > create mode 100644 lib/librte_ethdev/rte_apistats.c > create mode 100644 lib/librte_ethdev/rte_apistats.h >=20 > diff --git a/lib/librte_ethdev/meson.build b/lib/librte_ethdev/meson.buil= d > index e4b6102..d03e784 100644 > --- a/lib/librte_ethdev/meson.build > +++ b/lib/librte_ethdev/meson.build > @@ -8,7 +8,8 @@ sources =3D files('ethdev_private.c', > 'rte_ethdev.c', > 'rte_flow.c', > 'rte_mtr.c', > - 'rte_tm.c') > + 'rte_tm.c' , > + 'rte_apistats.c') >=20 > headers =3D files('rte_ethdev.h', > 'rte_ethdev_driver.h', > @@ -24,6 +25,7 @@ headers =3D files('rte_ethdev.h', > 'rte_mtr.h', > 'rte_mtr_driver.h', > 'rte_tm.h', > - 'rte_tm_driver.h') > + 'rte_tm_driver.h', > + 'rte_apistats.h') >=20 > deps +=3D ['net', 'kvargs', 'meter', 'telemetry'] > diff --git a/lib/librte_ethdev/rte_apistats.c b/lib/librte_ethdev/rte_api= stats.c > new file mode 100644 > index 0000000..c4bde34 > --- /dev/null > +++ b/lib/librte_ethdev/rte_apistats.c > @@ -0,0 +1,64 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2019 NTT TechnoCross Corporation > + */ > + > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "rte_apistats.h" > + > +/* Macros for printing using RTE_LOG */ > +#define RTE_LOGTYPE_APISTATS RTE_LOGTYPE_USER1 > + > +#define MZ_APISTATS "rte_apistats" > + > +struct rte_apistats *rte_apicounts; > + > +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"); > + return -1; > + } > + rte_apicounts =3D mz->addr; > + } else { > + /* RTE_PROC_PRIMARY */ > + mz =3D rte_memzone_reserve(MZ_APISTATS, sizeof(*rte_apicounts), > + rte_socket_id(), flags); > + if (mz =3D=3D NULL) { > + RTE_LOG(ERR, APISTATS, "Cannot reserve memory zone\n"); > + return -ENOMEM; > + } > + rte_apicounts =3D mz->addr; > + memset(rte_apicounts, 0, sizeof(*rte_apicounts)); > + } > + > + /* set up array for data */ > + RTE_LCORE_FOREACH(i) { > + 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); > + 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]; > +}; > + > +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_i= d, > 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]++; There are few problems with current implementation: 1. rx_burst() can be called by non-EAL thread (rte_lcore_id() =3D=3D -1) In that case it would cause a crash. 2. Because of the layout of struct rte_apistats it would cause significant performance degradation (false cache-lines sharing). As a generic one: such sort of statistics can be easily collected by the ap= p itself. Either by just incrementing counters before rx/tx_burst function call direc= tly or via rx/tx callbacks. So I don't see any point to push it inside ethdev layer. =20 Konstantin > #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_i= d, > } > #endif >=20 > + int lcore_id =3D rte_lcore_id(); > + rte_apicounts->tx_burst_counts[lcore_id]++; > #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