From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 06A8042AE5; Fri, 12 May 2023 14:02:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8BBB142D1A; Fri, 12 May 2023 14:02:52 +0200 (CEST) Received: from mail-ua1-f45.google.com (mail-ua1-f45.google.com [209.85.222.45]) by mails.dpdk.org (Postfix) with ESMTP id 48D6B40041 for ; Fri, 12 May 2023 14:02:51 +0200 (CEST) Received: by mail-ua1-f45.google.com with SMTP id a1e0cc1a2514c-77d483c488bso5952290241.1 for ; Fri, 12 May 2023 05:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683892970; x=1686484970; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+tBR+ab0zU6N2Lo74O96PRjskLv/nLS1QlJgMVQC9LI=; b=MaRyxGACk7jK/o0gLCtaXGk06diOUOSQ2nhuL5Zv1EVbw30ntyMWvMWY4X9/EC3yCr dV5JjNUlaS8MAYm9kb4LAx/ISK1cn6C6+LAdcDKMc1HkavNGUx0gT6VwaIh2trSmOk4H bS6m26HeYa+QcoeDNi5M3Nd6tDvP7Fz6vvJowEjQNpivYSREQe6j988IJ359ahQ1REj7 jDP9gk7WNzFuh82kBQeKl0MuIKFZ9nRZcEwn1X35UeKrnWVd7cCzQHVZbEwC9nIqXzan 8f+o3CjN/UjondZhHJovxKOoVtc8I0NKd4ofCHuehB6Np0QRbKhpgmPXUMmbYokJ+yVS MDWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683892970; x=1686484970; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+tBR+ab0zU6N2Lo74O96PRjskLv/nLS1QlJgMVQC9LI=; b=Ex3AiRU3KYneqXFFd8UD/HdTowCSn6+f2GqlLNf4ekipHNaZZToShw8wodOBHQn4kI 5twefGcbx7a83FlEVlSO/+n6dQ2IrBY4PkkiAH9/+z/RaLJ2Utgey+raMiyjyEeUBocn bAFgGq7kjvOK7sBzHu+zA0s2rV8uV2hh9NPO6um8BPR/Vrsj1wj2Qe1WzbJyJIQMitXT Gnxn3/BlOjEuuMshEIudY0n4kb1M2B1GQ8GlO155ce9LsRE1u997rejGdgz5GUNUsxQd b5O+fkWM9v9YSjDYo7uMXikPieK7aIThuAEYD3c7X0Dpn4KZSDLJIUeoX4mvgkabf6bi bSQA== X-Gm-Message-State: AC+VfDyguyURv8xSW8EYj9PWO/GdMH+3tSXcXcwcy2k0hzT7VKGC9cxH C9+lA1qn+UrwMRpqBxFdafSmaJC1s+aZ1sJJXBt3elMCsBc= X-Google-Smtp-Source: ACHHUZ5CB3DVeNfm262sipaI2hOL0PkC9s6gd+bbso6IJ7S6sTsXf0KW6trV/EeJf6iFYoR6qvG9mt+ndtX0+nETnKQ= X-Received: by 2002:a67:ad04:0:b0:434:6dcf:5e13 with SMTP id t4-20020a67ad04000000b004346dcf5e13mr9582175vsl.18.1683892970425; Fri, 12 May 2023 05:02:50 -0700 (PDT) MIME-Version: 1.0 References: <20230511082519.4168523-1-feifei.wang2@arm.com> In-Reply-To: From: Jerin Jacob Date: Fri, 12 May 2023 17:32:24 +0530 Message-ID: Subject: Re: [PATCH] examples/l3fwd: add hard code to collect empty poll and NIC counters To: Honnappa Nagarahalli Cc: Feifei Wang , "dev@dpdk.org" , nd , Lijian Zhang , Ruifeng Wang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, May 11, 2023 at 7:02=E2=80=AFPM Honnappa Nagarahalli wrote: > > > > > > > On Thu, May 11, 2023 at 1:55=E2=80=AFPM Feifei Wang > > wrote: > > > > > > This patch is to collect empty poll of 'rte_eth_rx_burst' functions i= n > > > dpdk l3fwd application. Empty poll means Rx burst function receives n= o > > > pkts in one loop. > > > > > > Furthermore, we also add 'nic_xstats_display' API to show NIC counter= s. > > > > > > Usage: > > > With this patch, no special settings, just run l3fwd, and when you > > > stoping l3fwd, thread will print the info above. > > > > > > Note: > > > This patch has just a slight impact on performance and can be ignored= . > How much is the regression? > > > > > IMO, We should not introduce regression as l3fwd kind of uses as refere= nce > > application. > > I think, l3fwd should limit to stats exposed by ethdev(i.e directly fro= m NIC, > > without performance regression). > Agree L3fwd is the reference app. Unfortunately, it is not in a state to = debug any problems. May be many are just believing the numbers without unde= rstanding that there are problems. > Can we place these stats under a run time flag and reduce the impact furt= her? I think, example applications, we can have compile time option for new feature addtions in fastpath or add new forwarding mode in testpmd. > > > > > > > > > > > > > dpdk version:23.03 > > > > > > Suggested-by: Lijian Zhang > > > Signed-off-by: Feifei Wang > > > Reviewed-by: Ruifeng Wang > > > Reviewed-by: Honnappa Nagarahalli > > > --- > > > examples/l3fwd/l3fwd.h | 68 > > ++++++++++++++++++++++++++++++++++++++ > > > examples/l3fwd/l3fwd_lpm.c | 26 +++++++++++++-- > > > examples/l3fwd/main.c | 22 ++++++++++++ > > > 3 files changed, 114 insertions(+), 2 deletions(-) > > > > > > diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h index > > > b55855c932..2b3fca62f3 100644 > > > --- a/examples/l3fwd/l3fwd.h > > > +++ b/examples/l3fwd/l3fwd.h > > > @@ -56,6 +56,17 @@ > > > #define L3FWD_HASH_ENTRIES (1024*1024*1) > > > #endif > > > > > > +struct lcore_stats { > > > + uint32_t nb_rx_pkts[16]; > > > + uint32_t num_loop[16]; > > > + uint32_t none_loop[16]; > > > + uint32_t no_full_loop[16]; > > > + float none_loop_per[16]; > > > + float no_full_loop_per[16]; > > > +} __rte_cache_aligned; > > > + > > > +extern struct lcore_stats stats[RTE_MAX_LCORE]; > > > + > > > struct parm_cfg { > > > const char *rule_ipv4_name; > > > const char *rule_ipv6_name; > > > @@ -115,6 +126,63 @@ extern struct acl_algorithms acl_alg[]; > > > > > > extern uint32_t max_pkt_len; > > > > > > +static inline void > > > +nic_xstats_display(uint32_t port_id) > > > +{ > > > + struct rte_eth_xstat *xstats; > > > + int cnt_xstats, idx_xstat; > > > + struct rte_eth_xstat_name *xstats_names; > > > + > > > + printf("###### NIC extended statistics for port %-2d\n", por= t_id); > > > + if (!rte_eth_dev_is_valid_port(port_id)) { > > > + fprintf(stderr, "Error: Invalid port number %i\n", p= ort_id); > > > + return; > > > + } > > > + > > > + /* Get count */ > > > + cnt_xstats =3D rte_eth_xstats_get_names(port_id, NULL, 0); > > > + if (cnt_xstats < 0) { > > > + fprintf(stderr, "Error: Cannot get count of xstats\n= "); > > > + return; > > > + } > > > + > > > + /* Get id-name lookup table */ > > > + xstats_names =3D malloc(sizeof(struct rte_eth_xstat_name) * = cnt_xstats); > > > + if (xstats_names =3D=3D NULL) { > > > + fprintf(stderr, "Cannot allocate memory for xstats l= ookup\n"); > > > + return; > > > + } > > > + if (cnt_xstats !=3D rte_eth_xstats_get_names( > > > + port_id, xstats_names, cnt_xstats)) { > > > + fprintf(stderr, "Error: Cannot get xstats lookup\n")= ; > > > + free(xstats_names); > > > + return; > > > + } > > > + > > > + /* Get stats themselves */ > > > + xstats =3D malloc(sizeof(struct rte_eth_xstat) * cnt_xstats)= ; > > > + if (xstats =3D=3D NULL) { > > > + fprintf(stderr, "Cannot allocate memory for xstats\n= "); > > > + free(xstats_names); > > > + return; > > > + } > > > + if (cnt_xstats !=3D rte_eth_xstats_get(port_id, xstats, cnt_= xstats)) { > > > + fprintf(stderr, "Error: Unable to get xstats\n"); > > > + free(xstats_names); > > > + free(xstats); > > > + return; > > > + } > > > + > > > + /* Display xstats */ > > > + for (idx_xstat =3D 0; idx_xstat < cnt_xstats; idx_xstat++) { > > > + printf("%s: %"PRIu64"\n", > > > + xstats_names[idx_xstat].name, > > > + xstats[idx_xstat].value); > > > + } > > > + free(xstats_names); > > > + free(xstats); > > > +} > > > + > > > /* Send burst of packets on an output interface */ static inline in= t > > > send_burst(struct lcore_conf *qconf, uint16_t n, uint16_t port) diff > > > --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index > > > 4ac1925c84..9e27e954b9 100644 > > > --- a/examples/l3fwd/l3fwd_lpm.c > > > +++ b/examples/l3fwd/l3fwd_lpm.c > > > @@ -41,6 +41,8 @@ > > > static struct rte_lpm *ipv4_l3fwd_lpm_lookup_struct[NB_SOCKETS]; > > > static struct rte_lpm6 *ipv6_l3fwd_lpm_lookup_struct[NB_SOCKETS]; > > > > > > +extern struct lcore_stats stats[RTE_MAX_LCORE]; > > > + > > > /* Performing LPM-based lookups. 8< */ static inline uint16_t > > > lpm_get_ipv4_dst_port(const struct rte_ipv4_hdr *ipv4_hdr, @@ -153,6 > > > +155,7 @@ lpm_main_loop(__rte_unused void *dummy) > > > struct lcore_conf *qconf; > > > const uint64_t drain_tsc =3D (rte_get_tsc_hz() + US_PER_S - 1= ) / > > > US_PER_S * BURST_TX_DRAIN_US; > > > + bool start_count =3D 0; > > > > > > lcore_id =3D rte_lcore_id(); > > > qconf =3D &lcore_conf[lcore_id]; @@ -207,8 +210,22 @@ > > > lpm_main_loop(__rte_unused void *dummy) > > > queueid =3D qconf->rx_queue_list[i].queue_id; > > > nb_rx =3D rte_eth_rx_burst(portid, queueid, p= kts_burst, > > > MAX_PKT_BURST); > > > - if (nb_rx =3D=3D 0) > > > - continue; > > > + if (start_count =3D=3D 0) { > > > + if (nb_rx !=3D 0) > > > + start_count =3D 1; > > > + } > > > + > > > + if (start_count =3D=3D 1) { > > > + stats[lcore_id].nb_rx_pkts[i] +=3D nb= _rx; > > > + stats[lcore_id].num_loop[i]++; > > > + if (nb_rx < MAX_PKT_BURST && nb_rx > = 0) > > > + > > > + stats[lcore_id].no_full_loop[i]++; > > > + > > > + if (nb_rx =3D=3D 0) { > > > + stats[lcore_id].none_loop[i]+= +; > > > + continue; > > > + } > > > + } > > > > > > #if defined RTE_ARCH_X86 || defined __ARM_NEON \ > > > || defined RTE_ARCH_PPC_64 @@ -223,6 +240,11 > > > @@ lpm_main_loop(__rte_unused void *dummy) > > > cur_tsc =3D rte_rdtsc(); > > > } > > > > > > + for (i =3D 0; i < n_rx_q; ++i) { > > > + stats[lcore_id].none_loop_per[i] =3D > > (float)stats[lcore_id].none_loop[i]/stats[lcore_id].num_loop[i]*100; > > > + stats[lcore_id].no_full_loop_per[i] =3D > > (float)stats[lcore_id].no_full_loop[i]/stats[lcore_id].num_loop[i]*100; > > > + } > > > + > > > return 0; > > > } > > > > > > diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index > > > a4f061537e..4727215eae 100644 > > > --- a/examples/l3fwd/main.c > > > +++ b/examples/l3fwd/main.c > > > @@ -53,6 +53,8 @@ > > > > > > #define MAX_LCORE_PARAMS 1024 > > > > > > +struct lcore_stats stats[RTE_MAX_LCORE]; > > > + > > > uint16_t nb_rxd =3D RX_DESC_DEFAULT; > > > uint16_t nb_txd =3D TX_DESC_DEFAULT; > > > > > > @@ -1592,6 +1594,26 @@ main(int argc, char **argv) > > > } else { > > > rte_eal_mp_wait_lcore(); > > > > > > + for (lcore_id =3D 0; lcore_id < RTE_MAX_LCORE; lcore_= id++) { > > > + if (rte_lcore_is_enabled(lcore_id) =3D=3D 0) > > > + continue; > > > + qconf =3D &lcore_conf[lcore_id]; > > > + for (queue =3D 0; queue < qconf->n_rx_queue; = ++queue) { > > > + printf("\nlcore id:%d\n", lcore_id); > > > + printf("queue_id:%d\n",queue); > > > + printf("Rx pkt %d\n", stats[lcore_id]= .nb_rx_pkts[queue]); > > > + printf("loop number: %d, 0 pkts loop:= %d, <32 pkts > > loop:%d\n", > > > + stats[lcore_id].num_loop[queu= e], > > stats[lcore_id].none_loop[queue], stats[lcore_id].no_full_loop[queue]); > > > + printf("0 pkts loop percentage:%.2f%%= , <32 pkts loop > > percentage:%.2f%%\n", > > > + stats[lcore_id].none_loop_per= [queue], > > stats[lcore_id].no_full_loop_per[queue]); > > > + > > > + printf("------------------------------------\n\n"); > > > + > > > + } > > > + } > > > + > > > + nic_xstats_display(0); > > > + nic_xstats_display(1); > > > + > > > RTE_ETH_FOREACH_DEV(portid) { > > > if ((enabled_port_mask & (1 << portid)) =3D= =3D 0) > > > continue; > > > -- > > > 2.25.1 > > >