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 DC6B7A00C5 for ; Thu, 25 Aug 2022 12:09:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0ABEB4280C; Thu, 25 Aug 2022 12:09:21 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2054.outbound.protection.outlook.com [40.107.220.54]) by mails.dpdk.org (Postfix) with ESMTP id 6B57F40156; Thu, 25 Aug 2022 12:09:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A+W1Oh9ssWTEQ/muFdFUcO+kcj1nbVlTtrHohHrjXSPWkwe54ZRohH7ZSLIzi6rDZkHqQh/XBipnrqqlAhQujFwYALMPMw7xttAsxp+mliCTiZNpGQCT6/5A7NmoZRrflLAhGI51TjH99+fw9dUC/F9U1LgFmOGYQbJQnVRAOtxNakMwWNcc0m9F1p2agBA5Ebc56H/XZuS2Rdce+nLPNVswm6vLJuv2e+URw5IexGVQv+LB/akD70glQctPtrH+xn8SsHp/S+JZSYgsDa5/9INgTh8yT59OoRAInDteoLcmsGuHUNLhmrgbQK5f+9m2PwDBDIVwgvt4L2JR1t+6pw== 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=5KVoR/LL7NZ6WAecjc2+o+mX3hvVIf4VeNEp3uAwsN4=; b=grdEquT0RvmmH1J6bXGIy0Mo5vFtyI74puWCIzOjlg+35QuXRgxE1u/iWcedOABUpwYXFUkUsevH9JQoNmxiYmvTvoB/HqBhSjivD1HmFP9DzzC+C7we2L3k84YYXL6B768UeXgD7wNQSVVfLiLV3At3fh4m+KhZXknBOL94wrZv/dOOP+P8fwujADknjFSaV/pKXz3FX0kcKXYwQISJYoNCfzHGyH1rX2L9f4hD2bnXJ1LhIdGObqw+hUWimhzqirxlGXOihqI9E6cZjDwpeWz3kXIDHWJur9KofdfLcgPsXkPkz77+pvloL3sSsgSNOzzxBmS057y7r8fM9ZWBvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.80.198) smtp.rcpttodomain=intel.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5KVoR/LL7NZ6WAecjc2+o+mX3hvVIf4VeNEp3uAwsN4=; b=U5UqKPYOmhGkyHD7mtNr8hjJilW5JfQTczoVPo+cYdNZDbJU3yN8mXDNTi4a8l+qSvbYxfnd5t6FZ+qmf4C7lbJNAae5KIqgDN5cv6Q+Els3VyOzYZpZb88z9ZI4qzky3WgeNZDSTlmmcjpKjnej1JRLmvIHAnKt2FaLLa175yw= Received: from BN9PR03CA0635.namprd03.prod.outlook.com (2603:10b6:408:13b::10) by BYAPR02MB4664.namprd02.prod.outlook.com (2603:10b6:a03:52::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.22; Thu, 25 Aug 2022 10:09:16 +0000 Received: from BN1NAM02FT062.eop-nam02.prod.protection.outlook.com (2603:10b6:408:13b:cafe::43) by BN9PR03CA0635.outlook.office365.com (2603:10b6:408:13b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15 via Frontend Transport; Thu, 25 Aug 2022 10:09:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.80.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.80.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.80.198; helo=xir-pvapexch02.xlnx.xilinx.com; pr=C Received: from xir-pvapexch02.xlnx.xilinx.com (149.199.80.198) by BN1NAM02FT062.mail.protection.outlook.com (10.13.2.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5566.15 via Frontend Transport; Thu, 25 Aug 2022 10:09:15 +0000 Received: from xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) by xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Thu, 25 Aug 2022 11:09:14 +0100 Received: from smtp.xilinx.com (172.21.105.198) by xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Thu, 25 Aug 2022 11:09:14 +0100 Envelope-to: yidingx.zhou@intel.com, dev@dpdk.org, qi.z.zhang@intel.com, stable@dpdk.org Received: from [10.71.194.74] (port=63140) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1oR9nW-0006X8-Gx; Thu, 25 Aug 2022 11:09:14 +0100 Message-ID: Date: Thu, 25 Aug 2022 11:09:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH] net/pcap: reduce time for stopping device To: Yiding Zhou , CC: , References: <20220825072041.10768-1-yidingx.zhou@intel.com> Content-Language: en-US From: Ferruh Yigit In-Reply-To: <20220825072041.10768-1-yidingx.zhou@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1f4aac29-b6f3-4d3e-41f8-08da8681de09 X-MS-TrafficTypeDiagnostic: BYAPR02MB4664:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2nUVkhqixlY7avZEuR0iR+aseq5zbID50DIgZePgrLDJh1IZb+g4lrla+2r9p2C4iSpFuyFzH1kmIGlq7Vx3sixgbwzfqxQM4LQBKLHHyLokRE9pXolF4S4GvjmagXm4sLztu5QJMXta7HJL9PpPjXMsTu3VGCaAU6WsGrzKIEo4xe8T/k59MLfeOHhI+v41PMAoA/aVK8Lnx/Bqhjub/Ss53BNKji7Kkr37cuMhjl8Ekv95qSJLaMiFZw6ASmiXPAC/HseeGBqO5NIyWWQWpkZiqUbk7G1ZNblQg5TRC+BSDY4wtgL3RnY0GmKaZu2soSBKPB30S9ZofHPW/65GYA8X3WmJVLk2nzQmZqhP3R+TBHCguPsS1mjh4tzM3dBFa/SCxdqjdQtB7eBg3ZqwnI9JRqNKguyw+pK/ASIn6YjJ2yWU88ynoR2Rx2uF4QDYIUUjBtBzUbOjsY0qqwTZexf7Wkpjofpp8DzaMjy/NZjY940/PaSC8ySs/SSY4wCF2u5PzE6U8ob26MBcooY/n5Si2kitnWc4O1JUeci+Mh1gtxDg723IRz5YvfkWrOfWhgu5+3lXTc+uSnIJ/YA5+EmesghNXGBYYsmhAtmfrajQ5OtvqLIjLWd6GPmVHfRF2yj7oe9/4DnbKoGX3IGN4Jor7jcJHmTU7+oDeDwgx0uMq5eovb7bgXZQ1Okjg2MnbKpqNv4vWj8fLG+g6knI9zo8S3wGDzUAADxN9Z1aXBL6Sb1SQjbiOCw1bF2to1LwglHloeUhmiFGQRe7TUTLQzdcgqWEeATrxT94mQMqtmb1zoNEnvPkV/adJuvXGCQm X-Forefront-Antispam-Report: CIP:149.199.80.198; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:xir-pvapexch02.xlnx.xilinx.com; PTR:unknown-80-198.xilinx.com; CAT:NONE; SFS:(13230016)(4636009)(346002)(376002)(39860400002)(396003)(136003)(46966006)(36840700001)(40470700004)(41300700001)(70586007)(316002)(70206006)(44832011)(5660300002)(82310400005)(478600001)(31686004)(9786002)(4326008)(110136005)(54906003)(8676002)(31696002)(36756003)(40480700001)(8936002)(2616005)(2906002)(82740400003)(336012)(186003)(47076005)(53546011)(83380400001)(26005)(426003)(36860700001)(356005)(7636003)(40460700003)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2022 10:09:15.8835 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f4aac29-b6f3-4d3e-41f8-08da8681de09 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.80.198]; Helo=[xir-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT062.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR02MB4664 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On 8/25/2022 8:20 AM, Yiding Zhou wrote: > The pcap file will be synchronized to the disk when stopping the device. > It takes a long time if the file is large that would cause the > 'detach sync request' timeout when the device is closed under multi-process > scenario. > > This commit fixes the issue by performing synchronization in Tx path > > Fixes: 4c173302c307 ("pcap: add new driver") > Cc: stable@dpdk.org > > Signed-off-by: Yiding Zhou > --- > drivers/net/pcap/pcap_ethdev.c | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c > index ec29fd6bc5..52eafa5674 100644 > --- a/drivers/net/pcap/pcap_ethdev.c > +++ b/drivers/net/pcap/pcap_ethdev.c > @@ -3,7 +3,7 @@ > * Copyright(c) 2014 6WIND S.A. > * All rights reserved. > */ > - > +#include > #include > > #include > @@ -38,6 +38,8 @@ > > #define RTE_PMD_PCAP_MAX_QUEUES 16 > > +#define ETH_PCAP_SYNC_THRESHOLD 0x20000000 > + > static char errbuf[PCAP_ERRBUF_SIZE]; > static struct timespec start_time; > static uint64_t start_cycles; > @@ -47,6 +49,8 @@ static uint8_t iface_idx; > static uint64_t timestamp_rx_dynflag; > static int timestamp_dynfield_offset = -1; > > +RTE_DEFINE_PER_LCORE(uint64_t, _pcap_cached_bytes); > + > struct queue_stat { > volatile unsigned long pkts; > volatile unsigned long bytes; > @@ -144,6 +148,16 @@ static struct rte_eth_link pmd_link = { > > RTE_LOG_REGISTER_DEFAULT(eth_pcap_logtype, NOTICE); > > +static inline void > +pcap_dumper_data_sync(pcap_dumper_t *dumper, uint32_t bytes) > +{ > + RTE_PER_LCORE(_pcap_cached_bytes) += bytes; > + if (unlikely(RTE_PER_LCORE(_pcap_cached_bytes) > ETH_PCAP_SYNC_THRESHOLD)) { > + if (!fdatasync(fileno(pcap_dump_file(dumper)))) > + RTE_PER_LCORE(_pcap_cached_bytes) = 0; > + } > +} > + > static struct queue_missed_stat* > queue_missed_stat_update(struct rte_eth_dev *dev, unsigned int qid) > { > @@ -421,7 +435,7 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) > * process stops and to make sure the pcap file is actually written, > * we flush the pcap dumper within each burst. > */ > - pcap_dump_flush(dumper); > + pcap_dumper_data_sync(dumper, tx_bytes); 'pcap_dump_flush()' should be doing the same thing, to write buffer to file, isn't it working? Can you check the return value of the 'pcap_dump_flush()' API, I wonder if it keeps failing, for some reason? > dumper_q->tx_stat.pkts += num_tx; > dumper_q->tx_stat.bytes += tx_bytes; > dumper_q->tx_stat.err_pkts += nb_pkts - num_tx;