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 1E443A0C45; Tue, 26 Oct 2021 16:59:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D441140E0F; Tue, 26 Oct 2021 16:59:13 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 16300407FF for ; Tue, 26 Oct 2021 16:59:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635260351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=z5LwdNpNkqtpxnYkPzlmc70/GQ4JIHAWBLB6LjyMWkU=; b=HOhmFD7IWJ/zSlTzhuFLDzmxQC7D+EANFZzEg1EvBGTxDEPZqB+nYxb2gtHZRtSyxkA3RP loVOQDdT3gJiks8knD3xtLtJxdNlJbxK6wIPQ7uB0jPF9bwoDmlQk13TgG9T8NziGyrfFi Cpf/v3vAW83m6HmG+K05kDDD5KDvlEY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-115-_AsrO4DEOKGBm2Sf8IUQCw-1; Tue, 26 Oct 2021 10:59:08 -0400 X-MC-Unique: _AsrO4DEOKGBm2Sf8IUQCw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 95CDE10247C7; Tue, 26 Oct 2021 14:59:06 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.192.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCE0917DBA; Tue, 26 Oct 2021 14:59:03 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, ferruh.yigit@intel.com, andrew.rybchenko@oktetlabs.ru, thomas@monjalon.net, bingz@nvidia.com, Xiaoyun Li Date: Tue, 26 Oct 2021 16:58:51 +0200 Message-Id: <20211026145851.21944-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] ethdev: warn only once for badly behaving applications 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 Sender: "dev" Warning continuously is a pain when developping or if a unit test is/gets broken. It could also be a problem if application behaves badly only in some corner cases and a DoS results of those logs being continuously displayed. Let's warn once per port and per rx/tx. Getting such a log is scary, but let's make it more eye catching by dumping a backtrace with it. Tested by introducing a bug in testpmd: --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -610,7 +610,7 @@ eth_dev_configure_mp(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, static int eth_dev_start_mp(uint16_t port_id) { - if (is_proc_primary()) + if (!is_proc_primary()) return rte_eth_dev_start(port_id); return 0; Then, running a basic null test: $ ./devtools/test-null.sh ... Start automatic packet forwarding io packet forwarding - ports=2 - cores=1 - streams=2 - NUMA support enabled, MP allocation mode: native Logical Core 1 (socket 0) forwards packets on 2 streams: RX P=0/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:01 RX P=1/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00 lcore 0 called rx_pkt_burst for not ready port 0 8: [build/app/dpdk-testpmd() [0x59e839]] 7: [/lib64/libc.so.6(__libc_start_main+0xf5) [0x7ff481b69555]] 6: [build/app/dpdk-testpmd(main+0x54b) [0x662d24]] 5: [build/app/dpdk-testpmd(start_packet_forwarding+0x263) [0x65e795]] 4: [build/app/dpdk-testpmd() [0x65e1be]] 3: [build/app/dpdk-testpmd() [0x65a996]] 2: [build/app/dpdk-testpmd() [0xa6cbc7]] 1: [build/app/dpdk-testpmd(rte_dump_stack+0x27) [0xaee796]] lcore 0 called rx_pkt_burst for not ready port 1 8: [build/app/dpdk-testpmd() [0x59e839]] 7: [/lib64/libc.so.6(__libc_start_main+0xf5) [0x7ff481b69555]] 6: [build/app/dpdk-testpmd(main+0x54b) [0x662d24]] 5: [build/app/dpdk-testpmd(start_packet_forwarding+0x263) [0x65e795]] 4: [build/app/dpdk-testpmd() [0x65e1be]] 3: [build/app/dpdk-testpmd() [0x65a996]] 2: [build/app/dpdk-testpmd() [0xa6cbc7]] 1: [build/app/dpdk-testpmd(rte_dump_stack+0x27) [0xaee796]] io packet forwarding packets/burst=32 nb forwarding cores=1 - nb forwarding ports=2 port 0: RX queue number: 1 Tx queue number: 1 Rx offloads=0x0 Tx offloads=0x0 Fixes: c87d435a4d79 ("ethdev: copy fast-path API into separate structure") Signed-off-by: David Marchand --- lib/ethdev/ethdev_private.c | 63 +++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/lib/ethdev/ethdev_private.c b/lib/ethdev/ethdev_private.c index c905c2df6f..7a5d05ff43 100644 --- a/lib/ethdev/ethdev_private.c +++ b/lib/ethdev/ethdev_private.c @@ -2,6 +2,7 @@ * Copyright(c) 2018 Gaƫtan Rivet */ +#include #include "rte_ethdev.h" #include "ethdev_driver.h" #include "ethdev_private.h" @@ -175,22 +176,58 @@ rte_eth_devargs_parse_representor_ports(char *str, void *data) return str == NULL ? -1 : 0; } +struct dummy_queue { + bool rx_warn_once; + bool tx_warn_once; +}; +static struct dummy_queue *dummy_queues_ref[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT]; +static struct dummy_queue dummy_queues[RTE_MAX_ETHPORTS]; +RTE_INIT(dummy_queue_init) +{ + uint16_t port_id; + + for (port_id = 0; port_id < RTE_DIM(dummy_queues); port_id++) { + unsigned int i; + + for (i = 0; i < RTE_DIM(dummy_queues_ref[port_id]); i++) + dummy_queues_ref[port_id][i] = &dummy_queues[port_id]; + } +} + static uint16_t -dummy_eth_rx_burst(__rte_unused void *rxq, +dummy_eth_rx_burst(void *rxq, __rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts) { - RTE_ETHDEV_LOG(ERR, "rx_pkt_burst for not ready port\n"); + struct dummy_queue *q = rxq; + + if (!q->rx_warn_once) { + uint16_t port_id = q - dummy_queues; + + RTE_ETHDEV_LOG(ERR, "lcore %u called rx_pkt_burst for not ready port %"PRIu16"\n", + rte_lcore_id(), port_id); + rte_dump_stack(); + q->rx_warn_once = true; + } rte_errno = ENOTSUP; return 0; } static uint16_t -dummy_eth_tx_burst(__rte_unused void *txq, +dummy_eth_tx_burst(void *txq, __rte_unused struct rte_mbuf **tx_pkts, __rte_unused uint16_t nb_pkts) { - RTE_ETHDEV_LOG(ERR, "tx_pkt_burst for not ready port\n"); + struct dummy_queue *q = txq; + + if (!q->tx_warn_once) { + uint16_t port_id = q - dummy_queues; + + RTE_ETHDEV_LOG(ERR, "lcore %u called tx_pkt_burst for not ready port %"PRIu16"\n", + rte_lcore_id(), port_id); + rte_dump_stack(); + q->tx_warn_once = true; + } rte_errno = ENOTSUP; return 0; } @@ -199,14 +236,22 @@ void eth_dev_fp_ops_reset(struct rte_eth_fp_ops *fpo) { static void *dummy_data[RTE_MAX_QUEUES_PER_PORT]; - static const struct rte_eth_fp_ops dummy_ops = { + uint16_t port_id = fpo - rte_eth_fp_ops; + + dummy_queues[port_id].rx_warn_once = false; + dummy_queues[port_id].tx_warn_once = false; + *fpo = (struct rte_eth_fp_ops) { .rx_pkt_burst = dummy_eth_rx_burst, .tx_pkt_burst = dummy_eth_tx_burst, - .rxq = {.data = dummy_data, .clbk = dummy_data,}, - .txq = {.data = dummy_data, .clbk = dummy_data,}, + .rxq = (struct rte_ethdev_qdata) { + .data = (void **)&dummy_queues_ref[port_id], + .clbk = dummy_data, + }, + .txq = (struct rte_ethdev_qdata) { + .data = (void **)&dummy_queues_ref[port_id], + .clbk = dummy_data, + }, }; - - *fpo = dummy_ops; } void -- 2.23.0