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 3F9C4A04B1; Mon, 23 Nov 2020 11:22:57 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A5E6F23D; Mon, 23 Nov 2020 11:22:54 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 2BD55160 for ; Mon, 23 Nov 2020 11:22:52 +0100 (CET) IronPort-SDR: FaStmxr0aWCciFTLwwtV3/xxJuU5ToB5AMX8PNsbG6ym+mki9nW5gij6aMscfs3rlhaL243QZN IsB0asdZ86Bw== X-IronPort-AV: E=McAfee;i="6000,8403,9813"; a="169171631" X-IronPort-AV: E=Sophos;i="5.78,363,1599548400"; d="scan'208";a="169171631" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2020 02:22:51 -0800 IronPort-SDR: CMvJq0ryRJHPAwgrWR6FvSbHkGnOE/nxjTitlnkHB+aZFHAfVdtXVsXmwQqwmxlZ278ZXUQoXv SPAikuVCmXIg== X-IronPort-AV: E=Sophos;i="5.78,363,1599548400"; d="scan'208";a="327149009" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.252.20.15]) ([10.252.20.15]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2020 02:22:46 -0800 To: "Jiawei(Jonny) Wang" , "wenzhuo.lu@intel.com" , "beilei.xing@intel.com" , "bernard.iremonger@intel.com" , Ori Kam , Slava Ovsiienko , NBU-Contact-Thomas Monjalon , Raslan Darawsheh Cc: "dev@dpdk.org" References: <1605355308-427475-1-git-send-email-jiaweiw@nvidia.com> <1605893733-84486-1-git-send-email-jiaweiw@nvidia.com> <5ce906d3-3790-a076-0744-309a8c860e85@intel.com> From: Ferruh Yigit Message-ID: <15cb428b-70ee-cc08-2c34-3eeb0ea9f04e@intel.com> Date: Mon, 23 Nov 2020 10:22:43 +0000 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v3] app/testpmd: fix testpmd packets dump overlapping 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" On 11/23/2020 6:13 AM, Jiawei(Jonny) Wang wrote: > Hi Ferruh, > >> -----Original Message----- >> From: Ferruh Yigit >> Sent: Saturday, November 21, 2020 1:50 AM >> To: Jiawei(Jonny) Wang ; wenzhuo.lu@intel.com; >> beilei.xing@intel.com; bernard.iremonger@intel.com; Ori Kam >> ; Slava Ovsiienko ; NBU- >> Contact-Thomas Monjalon ; Raslan Darawsheh >> >> Cc: dev@dpdk.org >> Subject: Re: [PATCH v3] app/testpmd: fix testpmd packets dump overlapping >> >> On 11/20/2020 5:35 PM, Jiawei Wang wrote: >>> When testpmd enabled the verbosity for the received packets, if two >>> packets were received at the same time, for example, sampling packet >>> and normal packet, the dump output of these packets may be overlapping >>> due to multiple core handling the multiple queues simultaneously. >>> >>> The patch uses one string buffer that collects all the packet dump >>> output into this buffer and then printouts it at last, that guarantees >>> to printout separately the dump output per packet. >>> >>> Fixes: d862c45 ("app/testpmd: move dumping packets to a separate >>> function") >>> >>> Signed-off-by: Jiawei Wang >> >> <...> >> >>> @@ -74,13 +85,16 @@ >>> uint32_t vx_vni; >>> const char *reason; >>> int dynf_index; >>> + int buf_size = MAX_STRING_LEN; >>> + char print_buf[buf_size]; >>> + int cur_len = 0; >>> >>> + memset(print_buf, 0, sizeof(print_buf)); >> >> Should 'print_buf' cleaned per each packet below, if not can we drop 'memset' >> completely? >> > Since the 'snprintf' always append the a terminating null character('\0') after the written string, > and in the code the following character be appended start from previous null character, so only one > '\0' will be appended in the last 'snprintf' calls, > snprintf(buf + cur_len, buf_size - cur_len .. > At the last 'printf("%s") will print the string buffer up to a terminating null character ('\0'). > so it's ok even not 'memset' calls to clean 'print_buf' per each packets. agree, so why not drop the memset completely?