From patchwork Tue Jun 13 23:09:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yipeng1" X-Patchwork-Id: 775506 X-Patchwork-Delegate: dlu998@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wnQX72Q6gz9sCX for ; Wed, 14 Jun 2017 09:12:23 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D5ACABC9; Tue, 13 Jun 2017 23:10:47 +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 4C710BAA for ; Tue, 13 Jun 2017 23:10:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 970D0204 for ; Tue, 13 Jun 2017 23:10:42 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP; 13 Jun 2017 16:10:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,339,1493708400"; d="scan'208";a="273879166" Received: from bdw-yipeng.jf.intel.com ([10.54.81.23]) by fmsmga004.fm.intel.com with ESMTP; 13 Jun 2017 16:10:40 -0700 From: yipeng1.wang@intel.com To: dev@openvswitch.org Date: Tue, 13 Jun 2017 16:09:34 -0700 Message-Id: <1497395376-69228-4-git-send-email-yipeng1.wang@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497395376-69228-1-git-send-email-yipeng1.wang@intel.com> References: <1497395376-69228-1-git-send-email-yipeng1.wang@intel.com> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 3/5] dpif-netdev: Add CD 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: Yipeng Wang This patch adds CD hit and miss statistics to dp_stat_type. PMD stats will show the total CD hit and miss counts. This patch depends on the first patch. Signed-off-by: Yipeng Wang Signed-off-by: Charlie Tai Co-authored-by: Charlie Tai Signed-off-by: Sameh Gobriel Co-authored-by: Sameh Gobriel Signed-off-by: Ren Wang Co-authored-by: Ren Wang Signed-off-by: Antonio Fischetti Co-authored-by: Antonio Fischetti --- lib/dpif-netdev.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 23b3e42..691fbad 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -263,7 +263,7 @@ static void dpcls_remove(struct dpcls *, struct dpcls_rule *); static bool dpcls_lookup(struct dpcls *cls, const struct netdev_flow_key keys[], struct dpcls_rule **rules, size_t cnt, - int *num_lookups_p); + int *num_lookups_p, int *cd_hit); static inline struct dpcls_subtable * dpcls_find_subtable(struct dpcls *cls, const struct netdev_flow_key *mask); @@ -387,6 +387,8 @@ enum dp_stat_type { DP_STAT_LOST, /* Packets not passed up to the client. */ DP_STAT_LOOKUP_HIT, /* Number of subtable lookups for flow table hits */ + DP_STAT_CD_HIT, /* Packets that hit CD. */ + DP_STAT_CD_MISS, /* Packets that miss CD. */ DP_N_STATS }; @@ -848,7 +850,8 @@ pmd_info_show_stats(struct ds *reply, stats[i] = 0; } - if (i != DP_STAT_LOST) { + if (i != DP_STAT_LOST && i != DP_STAT_LOOKUP_HIT + && i != DP_STAT_CD_MISS && i != DP_STAT_CD_HIT) { /* Lost packets are already included in DP_STAT_MISS */ total_packets += stats[i]; } @@ -885,6 +888,10 @@ pmd_info_show_stats(struct ds *reply, : 0, stats[DP_STAT_MISS], stats[DP_STAT_LOST]); + ds_put_format(reply, + "\tCD hits:%llu\n\tCD miss:%llu\n", + stats[DP_STAT_CD_HIT], stats[DP_STAT_CD_MISS]); + if (total_cycles == 0) { return; } @@ -2486,7 +2493,7 @@ find_index_in_sub_ptrs(struct dpcls *cls, static struct dp_netdev_flow * dp_netdev_pmd_lookup_flow(struct dp_netdev_pmd_thread *pmd, const struct netdev_flow_key *key, - int *lookup_num_p) + int *lookup_num_p, int *cd_hit) { struct dpcls *cls; struct dpcls_rule *rule; @@ -2495,7 +2502,7 @@ dp_netdev_pmd_lookup_flow(struct dp_netdev_pmd_thread *pmd, cls = dp_netdev_pmd_lookup_dpcls(pmd, in_port); if (OVS_LIKELY(cls)) { - dpcls_lookup(cls, key, &rule, 1, lookup_num_p); + dpcls_lookup(cls, key, &rule, 1, lookup_num_p, cd_hit); netdev_flow = dp_netdev_flow_cast(rule); } return netdev_flow; @@ -2848,7 +2855,7 @@ flow_put_on_pmd(struct dp_netdev_pmd_thread *pmd, } ovs_mutex_lock(&pmd->flow_mutex); - netdev_flow = dp_netdev_pmd_lookup_flow(pmd, key, NULL); + netdev_flow = dp_netdev_pmd_lookup_flow(pmd, key, NULL, NULL); if (!netdev_flow) { if (put->flags & DPIF_FP_CREATE) { if (cmap_count(&pmd->flow_table) < MAX_FLOWS) { @@ -5048,7 +5055,7 @@ handle_packet_upcall(struct dp_netdev_pmd_thread *pmd, * to be locking everyone out of making flow installs. If we * move to a per-core classifier, it would be reasonable. */ ovs_mutex_lock(&pmd->flow_mutex); - netdev_flow = dp_netdev_pmd_lookup_flow(pmd, key, NULL); + netdev_flow = dp_netdev_pmd_lookup_flow(pmd, key, NULL, NULL); if (OVS_LIKELY(!netdev_flow)) { netdev_flow = dp_netdev_flow_add(pmd, key, &match, &ufid, add_actions->data, @@ -5080,6 +5087,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, struct dp_netdev *dp = pmd->dp; int miss_cnt = 0, lost_cnt = 0; int lookup_cnt = 0, add_lookup_cnt; + int cd_hit = 0, add_cd_hit; bool any_miss; size_t i; @@ -5090,7 +5098,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, /* Get the classifier for the in_port */ cls = dp_netdev_pmd_lookup_dpcls(pmd, in_port); if (OVS_LIKELY(cls)) { - any_miss = !dpcls_lookup(cls, keys, rules, cnt, &lookup_cnt); + any_miss = !dpcls_lookup(cls, keys, rules, cnt, &lookup_cnt, &cd_hit); } else { any_miss = true; memset(rules, 0, sizeof(rules)); @@ -5113,9 +5121,10 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, * a rule covering this flow. In this case, it's a lot cheaper * to catch it here than execute a miss. */ netdev_flow = dp_netdev_pmd_lookup_flow(pmd, &keys[i], - &add_lookup_cnt); + &add_lookup_cnt, &add_cd_hit); if (netdev_flow) { lookup_cnt += add_lookup_cnt; + cd_hit += add_cd_hit; rules[i] = &netdev_flow->cr; continue; } @@ -5156,6 +5165,9 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, dp_netdev_count_packet(pmd, DP_STAT_LOOKUP_HIT, lookup_cnt); dp_netdev_count_packet(pmd, DP_STAT_MISS, miss_cnt); dp_netdev_count_packet(pmd, DP_STAT_LOST, lost_cnt); + dp_netdev_count_packet(pmd, DP_STAT_CD_HIT, cd_hit); + dp_netdev_count_packet(pmd, DP_STAT_CD_MISS, cnt-cd_hit); + } /* Packets enter the datapath from a port (or from recirculation) here. @@ -6124,7 +6136,7 @@ dpcls_rule_matches_key(const struct dpcls_rule *rule, static bool dpcls_lookup(struct dpcls *cls, const struct netdev_flow_key keys[], struct dpcls_rule **rules, const size_t cnt, - int *num_lookups_p) + int *num_lookups_p, int *cd_hit) { /* The received 'cnt' miniflows are the search-keys that will be processed * to find a matching entry into the available subtables. @@ -6151,8 +6163,8 @@ dpcls_lookup(struct dpcls *cls, const struct netdev_flow_key keys[], * The cuckoo distributor lookup pass begin first before go to megaflow * cache. CD hit will return a subtable index to the subtable to lookup. */ - int i; + int cd_match = 0; int data[MAP_BITS]; cd_lookup_bulk_pipe(cls, keys, cnt, &found_map, data); @@ -6168,6 +6180,7 @@ dpcls_lookup(struct dpcls *cls, const struct netdev_flow_key keys[], if (OVS_LIKELY(dpcls_rule_matches_key(rule, &keys[i]))) { rules[i] = rule; lookups_match += 1; + cd_match += 1; goto scnext; } } @@ -6196,6 +6209,9 @@ dpcls_lookup(struct dpcls *cls, const struct netdev_flow_key keys[], if (num_lookups_p) { *num_lookups_p = lookups_match; } + if (cd_hit) { + *cd_hit = cd_match; + } return true; /* All found in CD. */ }