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 E8BA8A2EEB for ; Thu, 12 Sep 2019 12:48:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DBC861E93C; Thu, 12 Sep 2019 12:48:36 +0200 (CEST) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by dpdk.org (Postfix) with ESMTP id B5D3A2C19 for ; Thu, 12 Sep 2019 12:48:34 +0200 (CEST) Received: by mail-pl1-f181.google.com with SMTP id f19so11608353plr.3 for ; Thu, 12 Sep 2019 03:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=iXI8Jk/0GFLcjKhyhrELklqGr6v74vh7xVcN7zkSBQw=; b=ON+6PEPaw43fx+s4euWU+fain2q1r9SeJAxmIkgEcBi1CR1CmR8prpfEgU/Grc5EZY Apr9+5sQwpIR/5r7Vn2lF7KIqJ/bmejmEGIJVSiZWDyh8V1RJx77vf/hMThJHO53iqcn tSJs3ZvZjjGl/GgSTcjeI1Ihplh0OoHLWl7YtskGqbInz1tfK8DFbZVjR26THSDCR64P VKqtvjbKeeARINONR96Bq9Fc6KiPrMvlYxNDjeyJ2wAwk6QVWx7LnHM7RMvhXAiLReIK 8VpO0PS8NX4/b/w6lGKLH1FjWLK/GPOWn5qUD8LgVVF+Q//Dl8xDEVMTelWoUFgyRwn1 YEbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=iXI8Jk/0GFLcjKhyhrELklqGr6v74vh7xVcN7zkSBQw=; b=hWvNGYscEmC4TSdWoAaIQSiTQeIOwTXi8WhtSbBP53jBk9jZ2nSPGI1mWFqqNO60Pc qgA6otTaTAgmbAoXH8bS+Pbu1szOgr4ttCeYHuFHJKC6B/n2mzgrJTjEofKAqe7F5ndo 0ModJ/tqFJyg6LR8vrUmwsCbadnBb6/YhHo2d6s8tpBC2YxQj1tpokr8Potly/77gaAE 7P9hyHSlpaO1L9AcgRxOGGIjqAL7E6YZ4c4WGeUZfbixFpQYEQg/hUKyE9CXb/ppdkej 2UF5VCmIcjPAb5ZjH0w1u3ALkcMHKsgv5QkBBzQ7/mf++s1VMKouRZtPxfVTIDM252rr tt/A== X-Gm-Message-State: APjAAAWm+kzHIGNKN/Y3tyh+NpbWfF1vBnD8rN7zXrVjmyVqhrrhLUdZ NNFFZS9X+ceywh4zxmzq/V+Afizi X-Google-Smtp-Source: APXvYqxrVVdDUJ/RrbbA5NMe7NaiXFcPYTKGRwEW5QHEjUq5xe7oJuK7tplxcbzYibwH5rK3eyJvOg== X-Received: by 2002:a17:902:4381:: with SMTP id j1mr40763161pld.318.1568285313815; Thu, 12 Sep 2019 03:48:33 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id t3sm26034930pfe.7.2019.09.12.03.48.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Sep 2019 03:48:33 -0700 (PDT) From: yasufum.o@gmail.com To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Thu, 12 Sep 2019 19:48:18 +0900 Message-Id: <20190912104824.21519-4-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190912104824.21519-1-yasufum.o@gmail.com> References: <20190912104824.21519-1-yasufum.o@gmail.com> Subject: [spp] [PATCH 3/9] shared: rename struct for ring latency stats X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" From: Yasufumi Ogawa Struct `spp_ringlatencystats_ring_latency_stats` is for containing stats as a histgram like data. It is only used in `latency_stats.c` and its header locally, so no need to such a long name. This update is to rename it to `ring_latency_stats_t`. This update also includes revising name of vars and comments. Signed-off-by: Yasufumi Ogawa --- .../secondary/spp_worker_th/latency_stats.c | 28 ++++++++----------- .../secondary/spp_worker_th/latency_stats.h | 22 +++++++++------ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/shared/secondary/spp_worker_th/latency_stats.c b/src/shared/secondary/spp_worker_th/latency_stats.c index 036a360..0a5e5a7 100644 --- a/src/shared/secondary/spp_worker_th/latency_stats.c +++ b/src/shared/secondary/spp_worker_th/latency_stats.c @@ -27,10 +27,9 @@ /** ring latency statistics information */ struct ring_latency_stats_info { - uint64_t timer_tsc; /**< sampling interval counter */ - uint64_t prev_tsc; /**< previous time */ - struct spp_ringlatencystats_ring_latency_stats stats; - /**< ring latency statistics list */ + uint64_t timer_tsc; /**< sampling interval */ + uint64_t prev_tsc; /**< previous time */ + struct ring_latency_stats_t stats; /**< list of stats */ }; /** sampling interval */ @@ -133,16 +132,13 @@ sppwk_calc_ring_latency(int ring_id, if (likely(pkts[i]->timestamp == 0)) continue; - /* when mbuf::timestamp is not zero */ - /* calculate latency */ + /* calc latency if mbuf `timestamp` is non-zero. */ latency = (uint64_t)floor((now - pkts[i]->timestamp) / cycles_per_ns()); - if (likely(latency < SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT-1)) - stats_info->stats.slot[latency]++; + if (likely(latency < TOTAL_LATENCY_ENT-1)) + stats_info->stats.distr[latency]++; else - stats_info->stats.slot[ - SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT - -1]++; + stats_info->stats.distr[TOTAL_LATENCY_ENT-1]++; } } @@ -154,12 +150,12 @@ spp_ringlatencystats_get_count(void) void spp_ringlatencystats_get_stats(int ring_id, - struct spp_ringlatencystats_ring_latency_stats *stats) + struct ring_latency_stats_t *stats) { struct ring_latency_stats_info *stats_info = &g_stats_info[ring_id]; rte_memcpy(stats, &stats_info->stats, - sizeof(struct spp_ringlatencystats_ring_latency_stats)); + sizeof(struct ring_latency_stats_t)); } /* Print statistics of time for packet processing in ring interface */ @@ -172,7 +168,7 @@ print_ring_latency_stats(struct iface_info *if_info) printf("%s%s", clr, topLeft); int ring_cnt, stats_cnt; - struct spp_ringlatencystats_ring_latency_stats stats[RTE_MAX_ETHPORTS]; + struct ring_latency_stats_t stats[RTE_MAX_ETHPORTS]; memset(&stats, 0x00, sizeof(stats)); printf("RING Latency\n"); @@ -186,14 +182,14 @@ print_ring_latency_stats(struct iface_info *if_info) } printf("\n"); - for (stats_cnt = 0; stats_cnt < SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT; + for (stats_cnt = 0; stats_cnt < TOTAL_LATENCY_ENT; stats_cnt++) { printf("%3dns", stats_cnt); for (ring_cnt = 0; ring_cnt < RTE_MAX_ETHPORTS; ring_cnt++) { if (if_info->ring[ring_cnt].iface_type == UNDEF) continue; - printf(", 0x%-16lx", stats[ring_cnt].slot[stats_cnt]); + printf(", 0x%-16lx", stats[ring_cnt].distr[stats_cnt]); } printf("\n"); } diff --git a/src/shared/secondary/spp_worker_th/latency_stats.h b/src/shared/secondary/spp_worker_th/latency_stats.h index 4a7abb4..de9ee5d 100644 --- a/src/shared/secondary/spp_worker_th/latency_stats.h +++ b/src/shared/secondary/spp_worker_th/latency_stats.h @@ -9,19 +9,25 @@ * @file * SPP RING latency statistics * - * Measure the latency through ring-PMD. + * Util functions for measuring latency of ring-PMD. */ #include #include "cmd_utils.h" -/** number of slots to save latency. 0ns~99ns and 100ns over */ -#define SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT 101 +/** + * Statistics of latency of ring is counted with histgram like data structure. + * To count frequency of each of time in nano sec, this data is implemented as + * an array in which frequency counts of 1-100[ns] are contained. If the + * latency is larger than 100[ns], it is added to the last entry. It means + * this array has 101 entries, 100 entries for 1-100[ns] and 1 entry for over + * 100[ns]. + */ +#define TOTAL_LATENCY_ENT 101 -/** ring latency statistics */ -struct spp_ringlatencystats_ring_latency_stats { - /** slots to save latency */ - uint64_t slot[SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT]; +/** statistics of latency of ring */ +struct ring_latency_stats_t { + uint64_t distr[TOTAL_LATENCY_ENT]; /* distribution of time */ }; @@ -88,7 +94,7 @@ int spp_ringlatencystats_get_count(void); * The statistics values. */ void spp_ringlatencystats_get_stats(int ring_id, - struct spp_ringlatencystats_ring_latency_stats *stats); + struct ring_latency_stats_t *stats); /* Print statistics of time for packet processing in ring interface */ void print_ring_latency_stats(struct iface_info *if_info); -- 2.17.1