From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C0E70A0C41; Thu, 16 Sep 2021 07:18:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 89F074003F; Thu, 16 Sep 2021 07:18:00 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id A13CA4003C for ; Thu, 16 Sep 2021 07:17:58 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10108"; a="220605618" X-IronPort-AV: E=Sophos;i="5.85,297,1624345200"; d="scan'208";a="220605618" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2021 22:17:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,297,1624345200"; d="scan'208";a="530045724" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by fmsmga004.fm.intel.com with ESMTP; 15 Sep 2021 22:17:55 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Wed, 15 Sep 2021 22:17:55 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Wed, 15 Sep 2021 22:17:55 -0700 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (104.47.73.173) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Wed, 15 Sep 2021 22:17:55 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lVN8Z48ads3ojW/D6q5jI+gn+E7M0qhu3EY9bX6wqJ9W84cYOXpBZ8qE5iuAhHlaB/rYgwjuUdafHT8GNwA6AY81aN60wD5LxYg+is1EKshdBStmXw1B5kM7XdIwB7+bY7n2zRrF9/w4Nbpn9oQHnzTcWeiop6Y54YRqnD1WWxg3Ivvwc0GDNTXoXa27qFNmdKirZaLD7Vn/qL5HjLrABV0XFaBQ5Dd22/pGG2MGe541achoR4LsR9pzPWJQKAXtAQrXyU1bSByj68SMTQgTd5tnBQhdoBMyjW5SW0IfiKoxcjFhaufynfdsmhAGIR6uYZz12+BtLae5/G6ZmmSZEg== 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; bh=jvkZ2UOhTayZSkC//mQJvaprjcJLo2fCIaq3cN3CVsQ=; b=OuLXYuQtAU4MTybln34n3mUJ5BNq3IbAxcyn9Vq0SyaQlxFQ5QUTMinI9OypmgQstqfLsjQgIlhJRrGLOSIQzZBgC8Krjgc/5hcbzrs7fFhgD/xGIg87OUsI5eAvB+6Ffx5VnrKmQIvB2CXj11ms3M55KkdQJgZ7isq6jpTefwQ3rGLL3whYCl/sQmmzowd+zJHdkwRXfSPh6Jpw0hdHt8VjMim71eCKw4y7ClSgyMWO3y2XoUxQl/f7tBUy4EV9WKf7Yhsv7Tv2O3+you96y2Qt4XyTak6TZTXzASwCUzcYIyspj8w3cUs4NrSHw6THLSpYko+Y27xuPfYKPiPiSA== 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=jvkZ2UOhTayZSkC//mQJvaprjcJLo2fCIaq3cN3CVsQ=; b=kLLj+rUgtLBByLeE5jsXwl47yCuxujbNESXoT/Igdi2R7pWg9hK39F6OSnPgmoTsygetXBah0SK9h8luGv4AZKST3XV7B8TfLBJ4Hz2Z8c/wOw6+mCkMeqH0uZZqKSs5M2/70aVTTrAjXg/i0FCRGOez/7JQ06gFhbNynhIT5xI= Received: from DM4PR11MB5534.namprd11.prod.outlook.com (2603:10b6:5:391::22) by DM5PR11MB1386.namprd11.prod.outlook.com (2603:10b6:3:11::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Thu, 16 Sep 2021 05:17:54 +0000 Received: from DM4PR11MB5534.namprd11.prod.outlook.com ([fe80::3d9b:76d7:e274:bad3]) by DM4PR11MB5534.namprd11.prod.outlook.com ([fe80::3d9b:76d7:e274:bad3%3]) with mapi id 15.20.4523.014; Thu, 16 Sep 2021 05:17:54 +0000 From: "Li, Xiaoyun" To: "Min Hu (Connor)" , "dev@dpdk.org" CC: "Yigit, Ferruh" Thread-Topic: [PATCH] app/testpmd: fix statistics in multiple process Thread-Index: AQHXqRabYpVksU9BdEG+ZX1WVaqp2aumHwCg Date: Thu, 16 Sep 2021 05:17:54 +0000 Message-ID: References: <20210914031233.988-1-humin29@huawei.com> In-Reply-To: <20210914031233.988-1-humin29@huawei.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e7169f90-4b29-409f-4ea8-08d978d15661 x-ms-traffictypediagnostic: DM5PR11MB1386: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Qqo+/GSTaPZ/KdGqRlz3EFNSk5YB1c19vsZSmnRFjvzPUMUXGG5JUx4wFFrSLLOt7dQvwwQzeXV6QqO5xlDgaHM9bamzjci+zRXvOy4Te1GCi2dGaob82ks6chAGJPP2RNFu3Mp99bI7dI1A4u+YYxNQprpJNbwAO5WW0amgWKSCVnLXp11NV2KQCkZZFsSvTWRwspPMzz2lHMUmjwtyxtrat1opls64F2PGwd2CHLN7+J3AlfvzosREA7Y6YN684y+CRV7kzmI3G1SEupNSQBR5L7KVGQudyDBrXtyN1RaloyH33qFQQgcA0zmo8K7E+l4oRuimVjJJ5pzpB3agBYlNy+ruskIp2M635/GbOAG/wI3LNy+hSsNUCshSkK3TN05MNrhzjJ+E8LTIZ9IwYWhQmtnPmLXbri0sN0paSi8RbiVUboRd5aHl2ANVFsmJW4im03bxsgtgl1zzJK1lKzbsts3+y+Gx9svUZ08Zziz0R40Jv9dOTEnkRBgTb19NaPpiYRDChMAXSSQkKZmukx6ejtmOyOSY/PBWE421HmKZK4JQ4ZYu9VOraNQjvl6lyJj9X96EcFIlcJBGK8GZa8Z2ZYN8+CvdCRwZnM6S2EBrKKM3/LrPxtMKsPuBtDQR4ZjRZ7hTzMXPQEYs4FCPzs+rgkMEBc41h13d17bPjbKrEZfIoGQusS5kJVohM0kLycKE0fVGRDPXLYixc3xOyQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5534.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8676002)(7696005)(4326008)(8936002)(83380400001)(6506007)(71200400001)(53546011)(2906002)(316002)(52536014)(508600001)(38100700002)(55016002)(110136005)(186003)(5660300002)(26005)(66556008)(66446008)(66946007)(66476007)(64756008)(76116006)(107886003)(33656002)(122000001)(38070700005)(9686003)(86362001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?wjlQKE0aif5/F041gKYpoJkH9r+6GK9aX9jvTrI1P/jQPV4KuYWZV0FkugPy?= =?us-ascii?Q?5wqTN65/muVP1GW5TXJGSr5MkBEuJ1taTqudh/lP6+PhYaJQQaoTXXhouFnO?= =?us-ascii?Q?j8v0Ezm6NyZ5l46p3ia/xndX5TpJryDhee+2pP/zUAB04EJRTWc7U+s0atxI?= =?us-ascii?Q?J4X3EdGBSm60B/1w8zeEIVn/e2DlgH8c8EmnbCSKY8AjPcEiqEz7GKeC1HdL?= =?us-ascii?Q?UWkzY4XOUeJasqpOqvcRYhhoWjI5Tj8Pa+NG/8sIP9YQBG9fMjEKtEKzV3QJ?= =?us-ascii?Q?3wMW/U7HjQrMbTZEsCrLuOIeR1DNFVh5d9CHyBhLJ7cajUKuNs/Rp08tMoS4?= =?us-ascii?Q?CgXdvb7Xqb8ow6kB9xD5l2bzDKIrPHu640+3Y+5pP3PA8453ELx1m7mRVXs1?= =?us-ascii?Q?xA7NitVyMHDsRmcAOj4nUdPigmwLxAXgtMjHa7EVM7WKP4jiGfRYRvDjnZKi?= =?us-ascii?Q?BoSNAByI/2FJ4k9mjeQo3RTXoZHqJihyTI0D5GQbZ0z+/WgiVE4hkBr8Z+NM?= =?us-ascii?Q?FJ/D92fFU4fcxFZGhbZ4KCaYUNnb58GB79rr5UThJt4Tcjsi1hIT4EaDcBAU?= =?us-ascii?Q?soBfDG5zLDvE7/h5VIOvY8Ehux87ck0XnvohbCj9q701LizP9hIFX+mK2BfE?= =?us-ascii?Q?JTzXgfVxrfvZUrZyQXb6oCr1SHUjOBRQniSOKuq8KLLQ0kMVoS8slEq36XeE?= =?us-ascii?Q?N2zzdmaEdh3pzZMAVvRvlef9L9SNAvEJ4Tnk+DE9lpwIdOEBxvqvhwasF5I/?= =?us-ascii?Q?dK/+9asIir4i7trPctcqxVV7gxBU5VPmpNV6BqnQMg30ZvqiJDNxBkxdzWHj?= =?us-ascii?Q?LCePI2rgu7jSINRCO56TZbJvDV2+wFE0TYbROsU/hXu21L5/psteaaWr8PBn?= =?us-ascii?Q?AVR5yo48Bdo09m3cq+2ehnfXrVKIBYURUxAtJIDZss1HTXprToJ2qHLcMm9U?= =?us-ascii?Q?GypCK3X0zMRncB8v6cT+Rx+zGBNKkPDCGvVvYsKdWb6fK+hw31+EoLuxyiY9?= =?us-ascii?Q?RekXbOzKmNgeY+/f9VJg72bLI2YgXuPcNskxCTyQEMC9YrFdqSwl2bSr0JKY?= =?us-ascii?Q?v9Suz5keoH4Q4uSAjV9HX2WLGJXSBBQTABbxjQnrCPtI4uXJiE7JWd8zebwz?= =?us-ascii?Q?olHLq6H6p0hdDQ5J+Q4j3DeNjS5SlhHqLpeZXNtPeEO13O48aINDQnCuAlaD?= =?us-ascii?Q?gHQR9KtInzJLSEhRvPO4rrVKKaFstIrYf9dBvxdroiQRLh4OSMdfKkJR2gRU?= =?us-ascii?Q?1Y5hHyFJf859qJM/pwz8BY4egxpLgEodd9DK/mQ25w5AJT+DOaXp6h5/QFWF?= =?us-ascii?Q?gZYsFV3Vhs9Ri/W6xRTc8w1F?= 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: DM4PR11MB5534.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7169f90-4b29-409f-4ea8-08d978d15661 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Sep 2021 05:17:54.1296 (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: BJwHS5LQWqnQIZ623dznQSs6vVUJvN9u/kuZvW3CrNFytdU3zZT0A2rquyfU6VpD4MI/+nTcW35g3bYpu+V99A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1386 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH] app/testpmd: fix statistics in multiple process X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 > -----Original Message----- > From: Min Hu (Connor) > Sent: Tuesday, September 14, 2021 11:13 > To: dev@dpdk.org > Cc: Yigit, Ferruh ; Li, Xiaoyun > Subject: [PATCH] app/testpmd: fix statistics in multiple process >=20 > Currently, 'clear port stats all' in secondary will clear stats in PMD, a= nd also > update stats which APP stores in 'ports[]' array in secondary process, no= te that, > that in primary process remains unchanged. So, when 'show fwd stats all' = in > primary process, stats in PMD may be less than stats which APP stores in = 'ports[]' > array(the stats is different with that in secondary). So forward statisti= cs(stats in > PMD minus stats which APP stores in 'ports[]' array) will be wrong. Like = this: > ---------------------- Forward statistics for port 0 -------------- > RX-packets: 18446744073703120168 RX-dropped: 18446744073704076766 > RX-total: 18446744073697645318 > TX-packets: 18446744073703122216 TX-dropped: 0 > TX-total: 18446744073703122216 > -------------------------------------------------------------------- > Stats in PMD are shared between multiple processes, but stats which APP s= tores > have their own copies in multiple processes. And this will result in bugs= . >=20 > This patch will fix it by creating shared memory to store last stats for = multiple > and secondary process in testpmd. Why not just limit "clear port stats " behavior to only primary process? Is there any particular reason second process has to do clear stats? Stats is quite complicate struct. I feel like it will have race condition i= ssue if you allow two processes to clear it. Only allow getting for multiple processes makes more sense. Also your patch has issues even if this idea is accepted by others. Please = see below. >=20 > Fixes: 184de26c78d0 ("app/testpmd: support multi-process") >=20 > Signed-off-by: Min Hu (Connor) > --- > app/test-pmd/config.c | 4 +-- > app/test-pmd/testpmd.c | 63 ++++++++++++++++++++++++++++++++++++------ > app/test-pmd/testpmd.h | 2 +- > 3 files changed, 58 insertions(+), 11 deletions(-) >=20 > @@ -3572,6 +3614,7 @@ init_port_config(void) > port->dev_conf.intr_conf.lsc =3D 1; > if (rmv_interrupt && (*port->dev_info.dev_flags & > RTE_ETH_DEV_INTR_RMV)) > port->dev_conf.intr_conf.rmv =3D 1; > + port_stats_init(pid); Init_port_config is called in several places. Why init stats as 0 for port-= >stats here? You did so. Then if user use cmd like "port config 0 rxq 2" which calls ini= t_port_config, port->stats is cleared while device stats isn't. Then the fwd stats you got will be wrong. Please read code carefully. Port->stats will be reset as device stats when = start_fwd. Not reset as 0. Port->stats should be only cleared when you do clear_nic_stats. Otherwise, = it doesn't make sense as "last port stats". > } > } >=20 > @@ -3882,6 +3925,10 @@ main(int argc, char** argv) > rte_exit(EXIT_FAILURE, "Cannot init EAL: %s\n", > rte_strerror(rte_errno)); >=20 > + ret =3D eth_stats_zone_reserve(); > + if (ret !=3D 0) > + rte_exit(EXIT_FAILURE, "Allocate memzone ethdev stats failed"); > + > ret =3D register_eth_event_callback(); > if (ret !=3D 0) > rte_exit(EXIT_FAILURE, "Cannot register for ethdev events"); > diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index > 5863b2f43f..a48a302343 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > @@ -202,7 +202,7 @@ struct rte_port { > struct rte_eth_dev_info dev_info; /**< PCI info + driver name */ > struct rte_eth_conf dev_conf; /**< Port configuration. */ > struct rte_ether_addr eth_addr; /**< Port ethernet address */ > - struct rte_eth_stats stats; /**< Last port statistics */ > + struct rte_eth_stats *stats; /**< Last port statistics */ > unsigned int socket_id; /**< For NUMA support */ > uint16_t parse_tunnel:1; /**< Parse internal headers */ > uint16_t tso_segsz; /**< Segmentation offload MSS for n= on- > tunneled packets. */ > -- > 2.33.0