From patchwork Tue Aug 15 19:21:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 801730 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eRi1LHLi"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xX2RN0PqYz9t1t for ; Wed, 16 Aug 2017 05:22:08 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id AE6B8A7B; Tue, 15 Aug 2017 19:21:34 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 912DF982 for ; Tue, 15 Aug 2017 19:21:30 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 8561F3D9 for ; Tue, 15 Aug 2017 19:21:30 +0000 (UTC) Received: by mail-pg0-f65.google.com with SMTP id y192so2804701pgd.1 for ; Tue, 15 Aug 2017 12:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gqhyss4mizv4pMOpY+fw7sHZAJBl8XY4oFufPI3BuqY=; b=eRi1LHLihTRxwrbU9GzMDqIwVnPCuE8gjA/33Yo82RTWPhcQEi9gznXTQcaxUf9v9x Ki17JmqnGJBF7MXbBw54JtqVyOc8/BhgFAU43LgmjXjPpiFwA7XdtLZ9dAxQKmU0X2Yi SAHktSHiHpI/dFUOEECA4pnma+8LcEOUZvmOk4sYHCxJiiiwcF1j31DmTcETTtyqT5Mz 4/WtqG+wvLf0AJv+05gp2Cf6OTK18kkIwsGV3/c9/pDCG4oyw9i9ywPxdny9r6m6sj0s XoA9Ch0yNtXZGpohuHPZtZhJKJdwo6ZZwNuvS5lgkUowlokEcFN5HyRjaWFMuNSmTBXO 2l5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gqhyss4mizv4pMOpY+fw7sHZAJBl8XY4oFufPI3BuqY=; b=GseF0lLwhAY1TAczVzsE4pyCZmuwbM2W1ilSV08YRn85nHpVeZobA1VvRRtAhveqvh cYCamyVV8SO6EBAmDXrRxFm/h0Fp/nOudkmB0zinGryqSniIgXqAHcdJ7ynk5lnD89oG mwDMMGKb6Ere38+U3jtxklnez59PhftROLCwWx0J8liWUWXjNh05JHlXPgX06vZw2CbK JRgujlgiay76WrlzNGQ0HeAUU57WIizER/6e/V0a9uRHB7pEbjidsBM8kUT1CqVJ/a0E NW/eibbEPLfoOB6rTNJ57hIsxK3sk9fQFH6R9iGR6ndlXFiF/0TtG2r56ukK/oTSZ1p0 xv0Q== X-Gm-Message-State: AHYfb5iwcBvRtfxmxNQyJeSNtl0CNmJT9ViFmU3KEsXC3mvLnTkJJg0q KOTxER2oTTuuKg== X-Received: by 10.99.97.204 with SMTP id v195mr27706001pgb.422.1502824890189; Tue, 15 Aug 2017 12:21:30 -0700 (PDT) Received: from localhost.localdomain (c-73-162-236-45.hsd1.ca.comcast.net. [73.162.236.45]) by smtp.gmail.com with ESMTPSA id j1sm16959949pgs.77.2017.08.15.12.21.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Aug 2017 12:21:29 -0700 (PDT) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Tue, 15 Aug 2017 12:21:17 -0700 Message-Id: <1502824878-127778-2-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502824878-127778-1-git-send-email-dlu998@gmail.com> References: <1502824878-127778-1-git-send-email-dlu998@gmail.com> Cc: Ilya Maximets Subject: [ovs-dev] [patch_v4 1/2] dpif-netdev: Fix per packet cycles statistics. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Ilya Maximets DP_STAT_LOOKUP_HIT statistics used mistakenly for calculation of total number of packets. This leads to completely wrong per packet cycles statistics. For example: emc hits:0 megaflow hits:253702308 avg. subtable lookups per hit:1.50 miss:0 lost:0 avg cycles per packet: 248.32 (157498766585/634255770) In this case 634255770 total_packets value used for avg per packet calculation: total_packets = 'megaflow hits' + 'megaflow hits' * 1.5 The real value should be 524.38 (157498766585/253702308) Fix that by summing only stats that reflect match/not match. It's decided to make direct summing of required values instead of disabling some stats in a loop to make calculations more clear and avoid similar issues in the future. CC: Jan Scheurich Fixes: 3453b4d62a98 ("dpif-netdev: dpcls per in_port with sorted subtables") Signed-off-by: Ilya Maximets Acked-by: Jan Scheurich --- lib/dpif-netdev.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index e2cd931..17e1666 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -755,7 +755,7 @@ pmd_info_show_stats(struct ds *reply, unsigned long long stats[DP_N_STATS], uint64_t cycles[PMD_N_CYCLES]) { - unsigned long long total_packets = 0; + unsigned long long total_packets; uint64_t total_cycles = 0; int i; @@ -771,13 +771,12 @@ pmd_info_show_stats(struct ds *reply, } else { stats[i] = 0; } - - if (i != DP_STAT_LOST) { - /* Lost packets are already included in DP_STAT_MISS */ - total_packets += stats[i]; - } } + /* Sum of all the matched and not matched packets gives the total. */ + total_packets = stats[DP_STAT_EXACT_HIT] + stats[DP_STAT_MASKED_HIT] + + stats[DP_STAT_MISS]; + for (i = 0; i < PMD_N_CYCLES; i++) { if (cycles[i] > pmd->cycles_zero[i]) { cycles[i] -= pmd->cycles_zero[i];