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 BD323A0562; Sat, 4 Apr 2020 03:31:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0E5421BDAC; Sat, 4 Apr 2020 03:31:26 +0200 (CEST) Received: from inbox.dpdk.org (xvm-172-178.dc0.ghst.net [95.142.172.178]) by dpdk.org (Postfix) with ESMTP id D7CA93B5 for ; Sat, 4 Apr 2020 03:31:24 +0200 (CEST) Received: by inbox.dpdk.org (Postfix, from userid 33) id A9371A057B; Sat, 4 Apr 2020 03:31:24 +0200 (CEST) From: bugzilla@dpdk.org To: dev@dpdk.org Date: Sat, 04 Apr 2020 01:31:23 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: DPDK X-Bugzilla-Component: testpmd X-Bugzilla-Version: 20.02 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cfb@hpe.com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: Normal X-Bugzilla-Assigned-To: dev@dpdk.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://bugs.dpdk.org/ Auto-Submitted: auto-generated X-Auto-Response-Suppress: All MIME-Version: 1.0 Subject: [dpdk-dev] [Bug 434] bps calculation does not fit in 64 bit 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" https://bugs.dpdk.org/show_bug.cgi?id=3D434 Bug ID: 434 Summary: bps calculation does not fit in 64 bit Product: DPDK Version: 20.02 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: Normal Component: testpmd Assignee: dev@dpdk.org Reporter: cfb@hpe.com Target Milestone: --- The bps calculation in config.c:nic_stats_display() does not fit in a 64 bit for higher clock rates and network speeds. The code: mbps_rx =3D diff_cycles > 0 ? diff_bytes_rx * rte_get_tsc_hz() / diff_cycles : 0; mbps_tx =3D diff_cycles > 0 ? diff_bytes_tx * rte_get_tsc_hz() / diff_cycles : 0; printf("\n Throughput (since last show)\n"); printf(" Rx-pps: %12"PRIu64" Rx-bps: %12"PRIu64"\n Tx-pp= s: %12" PRIu64" Tx-bps: %12"PRIu64"\n", mpps_rx, mbps_rx * = 8, mpps_tx, mbps_tx * 8); multiplies two 64 bit values (diff_bytes_[rt]x and rte_get_tsc_hz()), then divides them by a 64 bit value (diff_cycles). The problem occurs when high = data rates result in diff_bytes_[rt]x wih values that require more than 32 bits = or rte_get_tsc_hz() returns a value that requires more than 32 bits. The failure occurred on a system with a 2 GHz CPU and a data rate that retu= rned a value over 18,000,000,000,000 bytes/second. rte_get_tsc_hz() returned 2,000,000,000, which fits in 32 bits. However, 18,000,000,000,000 requires 36 bits. The multiplication overflows a 64 bit. The overflowed result is then divide= d by diff_cycles, then multiplied by 8 in the printf() statement (to convert from byte/sec to bits/sec), resulting in erratic results. There are a number of possible solutions, however, most will result some lo= ss of precision. The simplest is to move from bps to Mbps (or even Kbps) by performing a division on rte_get_tsc_hz() (or diff_bytes_[rt]x) before multiplying. --=20 You are receiving this mail because: You are the assignee for the bug.=