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 99E9DA0547; Tue, 26 Oct 2021 18:22:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5765240E0F; Tue, 26 Oct 2021 18:22:56 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 986E3407FF for ; Tue, 26 Oct 2021 18:22:54 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10149"; a="290791720" X-IronPort-AV: E=Sophos;i="5.87,184,1631602800"; d="scan'208";a="290791720" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2021 09:22:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,184,1631602800"; d="scan'208";a="537201458" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by fmsmga008.fm.intel.com with ESMTP; 26 Oct 2021 09:22:53 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) 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.2242.12; Tue, 26 Oct 2021 09:22:52 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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.2242.12 via Frontend Transport; Tue, 26 Oct 2021 09:22:52 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.168) 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.2242.12; Tue, 26 Oct 2021 09:22:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hxVpcDar8qXozvDBDvETRwbVhxr45Q7MHjCp96tA2kY4HyYIpu+PpfQ1qOkcE8i33P73MEO9JaJaQML1xHPT2KYda8/Bfav+QL0zDr5dL+68IfXSCI0lRdTq4FgUoCOI7N7yvI+/Jb937Pc/CiQMJrxOI9jY03c/iUJxE0rh7Y/7xODigNIvEq3wVPdBAMABLR7YBTZrzW8DIdG55XO1kv9yM8u8ib+3sF2A7x6KMgKCvLlw/6Iyv2724of/5fhr3eQDTSxkxkfhVoC0qoYOp0RD9C1AsjS1+rQiGzox4SYMBQoUQiITvweEsGOIV9T2sK2Jv/Iwif/ZYfpEGauoJA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JZKXoRyL8HqBF22lXV5Wi15FIRAM5UyccCh6tG5JqTc=; b=Un5GKIeS3Esyki9FsKeU9Z13tGz8/N8zfkrrEdl6JnZu/W1inoYlsApnj+FGgRnChj+izCUacOj5bV5JaVazwABnwFOUMnF8SIfnE5bpAd+lsB5BirrSIgStf4FeBMTTaTPO8vS9WxWYs739xpIJt1a5FWCgTJo8QSdpNQ548HotXHb2c7h6GDiRsviGTMd4YPT/SwLVS69wuaT3YveecCgNvQkTF/7+HThlN+CdbY+tCUYrTHzlzvyeYBuwcUynwueWjWLG28M9R99tWD79Xz6M1LM4kQ5Ss12Dyr7vGI4Dud5YZDUsoaEu+EfwYCLSUYfBzBe6wOAvd45oSwA62A== 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=JZKXoRyL8HqBF22lXV5Wi15FIRAM5UyccCh6tG5JqTc=; b=Hxog2VdwQLbwr1FN8sVDJ9bhRoqQfici+Q3pwTrITv3N34mRV+5IfO0K/IBhr65rydN4LbmL3yWhjfDTcaul0/099twszuArFOCzGifdM6RYVYFZ5M+O8pPtVIyFzoTKgTOArdj1t0e0y1W0nwYFuSth/UCsdImZwzk9nmCDwHM= Authentication-Results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) by PH0PR11MB5190.namprd11.prod.outlook.com (2603:10b6:510:3c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.13; Tue, 26 Oct 2021 16:22:51 +0000 Received: from PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd7d:29be:3342:632c]) by PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::bd7d:29be:3342:632c%6]) with mapi id 15.20.4628.020; Tue, 26 Oct 2021 16:22:51 +0000 Message-ID: Date: Tue, 26 Oct 2021 17:22:44 +0100 Content-Language: en-US To: "Min Hu (Connor)" , "Li, Xiaoyun" , "dev@dpdk.org" References: <20210914031233.988-1-humin29@huawei.com> From: Ferruh Yigit X-User: ferruhy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: DB6P195CA0003.EURP195.PROD.OUTLOOK.COM (2603:10a6:4:cb::13) To PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) MIME-Version: 1.0 Received: from [192.168.0.206] (37.228.236.146) by DB6P195CA0003.EURP195.PROD.OUTLOOK.COM (2603:10a6:4:cb::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14 via Frontend Transport; Tue, 26 Oct 2021 16:22:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b418010-78ca-4713-b0f5-08d9989cdb46 X-MS-TrafficTypeDiagnostic: PH0PR11MB5190: 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: dE7/OpSoCCeMjNNQgdOdRgtbceeRLhL2f9VyFnnWyICOp16toes6DQiRlCjOBmstMWdeGeafY6DFNIkDlJ0KqkAQiykWj4RTKRytuXg0/xUMK3SzbfIbhB6uQK6g3Z0kH0sUQDRlqmxcuF0L4WyQBptF1DzF/BYd9dwGW8azCemfGiEH94TPToRJSasIekB5ygul4hqvn3sUQrvR764C+WdeQa7i1YNiylPD9y/RPHNuLgFkVVpEHkUFSlpXWf8vcCG77lMyXfuPaMsu5rc296U2f4SZQ/R+hdeuJV+8hY/NmfBP9aYBlqTlAcGvHwjMOltF6aeOCXK/tTqHSacnSCj6ORABT1flhVRczm3+0DzFS3rrsMc/UEY2RMmWkvgd6W5pOCKagaG9UNdseOCpLBBP512Q4llmSJVbo6QAFexOUfpqMp1+fjDN/zENRxJBO2exLAQ9Elj7853S0BRe2VfLxTR5KzSZdi4xxXYG5Xrc5j2i2/G5qcmlE51mAdm+Op06INCvnVvCG4bFuPI7Kavq7YBBPR8ia4c+eBs0lQDpv//lwfcOg2HCfctQ+TVOLHWz7+Cv6k0nYuhHeQHZZJrM6j7pgmuGHSIDPHCzUmU4ylVhl8ezCBIyu9ND01SxIURlPnvnyjZSmVZ2JQXppa+i9Pg/XW7K+AQlG+MpPeToCnA+4KMH14ojAzRiugmHmJh9neYmb+wNY2VT+ZNs7A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5000.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(2906002)(82960400001)(36756003)(110136005)(8936002)(6666004)(26005)(186003)(38100700002)(31686004)(5660300002)(316002)(16576012)(956004)(8676002)(2616005)(66946007)(53546011)(66556008)(66476007)(83380400001)(31696002)(44832011)(6486002)(86362001)(508600001)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?a2xUSCtyanVDd2RGNlU0eDIxbDkxY2ZJcnBrTDRmV1RxQmhJUC9nUnF1UkFr?= =?utf-8?B?K0p6MHFoMU1TRmQvcm13Nzg5TzRnNUhzcUNaTnIrZG9rcVB2eUZQZGh5ajNM?= =?utf-8?B?cllDVERXNFUxZ1hja0VJajZlbGU0bVBCYjVDcGVBTGlvNjgyS3JqYXpQZnlZ?= =?utf-8?B?Smx0MDgvdFBHMVBVMjh0TGhBdW9RdFBDekZtd0VjamtGd1JhU3libUpYRkNQ?= =?utf-8?B?NFc3aXNrMGFxWlIyQXlaLzJMVE5JbDcwck1hc0lPS3RGZ3plNEE1aEZUa1g4?= =?utf-8?B?NjVhREx0U1NVdEhvZ1M5MlYwRmtDa0p4TlAyVmdmc1lCVy9VSlJTeFF2d3g2?= =?utf-8?B?QTZtMVZFbkVuNk1CWEtLdVNYTDFwRVVVYUM4NHplb1dGV0RkT0ZRY2dINkFX?= =?utf-8?B?ZmFqdDJUWE5HTUdJcVpYK1VaWW1xclEvaFdDVWxIS2wyREl4TjhwbDBvbGIw?= =?utf-8?B?NmhlOVRPNndEdVB0dzRmYjBhb1RmMFkycXVYcWFKdXZ1SU9kTlFkY3dJOEMr?= =?utf-8?B?bHNXeHcrZ0FLbUFxZndud29nY0xlOGNXM1BDUzFh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C9sUTBGSkd1TlVJbUkvbnFXYUNMeVhxRjVG?= =?utf-8?B?VktBUFJINDZsK0svRGxCMlg2K0Vzc1Y5LzludEdZcWpSM3lBNmJ0ZXBMWHpT?= =?utf-8?B?bytUZ2ppTm9salNvUUl1aTkxUWNtZVpJUkhxaGd3cWU4R1B2NVU0QTd1UUhY?= =?utf-8?B?c0tmZTRYUUFHVU1ucHkvU1ViVldjVmNXWmZpWXVwL2l0VW95ekpDWVVhNlQ0?= =?utf-8?B?UnpFVHk2Q0F1TUpmOC9ycGE4Ymw0QVh0WkdxNTY4ak94RHRzbDR6eVFlcXZk?= =?utf-8?B?eWtObHM0NmNmR1haWEpUM2JESy9LQkEzM2I0YjV1OWNObjVBQzdvakxQYy9Y?= =?utf-8?B?MmtySzJncGV3am5nMUFHVy9Ea09iQVZoM2hhUHZNdWRvUjdUTFUrZHNMV0wr?= =?utf-8?B?djA5bzluMU5sVEJOdmVqeTZQTlhIa1ZWM25uWVhDQVkycXBWTXpyUStES2pW?= =?utf-8?B?OFNuV0tPRWJBUk1QcVU0bzIyY2xaOGVhT3dsRXdaMUFNVE1ZbllBOEp0VWpq?= =?utf-8?B?QkNHMlptNEtsTEJQTk8yNUZlSjE1ZHIveDdRUjBpZXhuMGtDV2xGTEhQaFJv?= =?utf-8?B?TUFpNzlOSE1UVkdXT1dQeXprNXFaU05BbWhJVk91bXBrVkxBTzVWUVlzdjU0?= =?utf-8?B?RUgwNTdCc0RuTDdKcmthTE1COWhsK21iZjBlTmhzTGFVMEdPeEJiTlVGMnha?= =?utf-8?Q?9wn+40U0Wz1qEOVnL+UypU4=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 9b418010-78ca-4713-b0f5-08d9989cdb46 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2021 16:22:51.3865 (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: fGXghvdKHWvwrPtz/yACpOiMaw1dldOTDrKBFgRb5EB51+oVouzhnuoy/8dlSE1dCAY5Hz6wO12UWQtconx4tA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5190 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" On 9/17/2021 4:33 AM, Min Hu (Connor) wrote: > Hi, Xiaoyun, > > 在 2021/9/16 13:17, Li, Xiaoyun 写道: >> 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 >>> >>> Currently, 'clear port stats all' in secondary will clear stats in PMD, and also >>> update stats which APP stores in 'ports[]' array in secondary process, note 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 statistics(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 stores >>> have their own copies in multiple processes. And this will result in bugs. >>> >>> 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? > While, I have no idea if some particular reason exists second process has to do clear stats. I just want to implement this function. > >> >> Stats is quite complicate struct. I feel like it will have race condition issue if you allow two processes to clear it. > >> Only allow getting for multiple processes makes more sense. > Yes, I agree with you, maybe I can add constrains in testpmd guide doc. > BTW, what abot any others' opinion ? > I agree with Xiaoyun on possible race conditions, and to restrict the secondary to read the stats but not clear it. >> >> Also your patch has issues even if this idea is accepted by others. Please see below. >> >>> >>> Fixes: 184de26c78d0 ("app/testpmd: support multi-process") >>> >>> 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(-) >>> >> >>> @@ -3572,6 +3614,7 @@ init_port_config(void) >>>               port->dev_conf.intr_conf.lsc = 1; >>>           if (rmv_interrupt && (*port->dev_info.dev_flags & >>> RTE_ETH_DEV_INTR_RMV)) >>>               port->dev_conf.intr_conf.rmv = 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 init_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". >> > I know your meaning. > Actually, My purpose for 'port_stats_init' is only called for all port >  at init stage. While 'init_port config' confusd me, May I can put the > 'port_stats_init' in 'init_config', this may can work out. > > Thanks. > > >>>       } >>>   } >>> >>> @@ -3882,6 +3925,10 @@ main(int argc, char** argv) >>>           rte_exit(EXIT_FAILURE, "Cannot init EAL: %s\n", >>>                rte_strerror(rte_errno)); >>> >>> +    ret = eth_stats_zone_reserve(); >>> +    if (ret != 0) >>> +        rte_exit(EXIT_FAILURE, "Allocate memzone ethdev stats failed"); >>> + >>>       ret = register_eth_event_callback(); >>>       if (ret != 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 non- >>> tunneled packets. */ >>> -- >>> 2.33.0 >> >> . >>