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 4C86843699 for ; Thu, 7 Dec 2023 12:21:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4618442EFE; Thu, 7 Dec 2023 12:21:45 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 878FA42EF1 for ; Thu, 7 Dec 2023 12:21:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701948103; 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: in-reply-to:in-reply-to:references:references; bh=1iZnlu3MlIRa1thXFp6fDieSfBN7FH3xDf8QXQWYfJ8=; b=URNzmmBHRbPT9gvc3x7uFutYJCqUutKs3APLz3Ms6G2xN8I2ptPyOaK7tJvgT7A8kvqSF7 /I5vUv1Xz9uVxBxe6srB+4ZOcyVQ1Kvyy6jmja2hZSaXnSs1Iq72x+x0Cnzsj6GwIk/4W5 3cxQa5T/WtwQOEKZx2UFvL7/Q396//Y= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76--KJ-SXGUOUeW2e6IZFO6HA-1; Thu, 07 Dec 2023 06:21:40 -0500 X-MC-Unique: -KJ-SXGUOUeW2e6IZFO6HA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A342185A59A; Thu, 7 Dec 2023 11:21:39 +0000 (UTC) Received: from rh.Home (unknown [10.39.192.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52F66C15A0C; Thu, 7 Dec 2023 11:21:38 +0000 (UTC) From: Kevin Traynor To: Feifei Wang Cc: Ruifeng Wang , Matthew Dirba , Cristian Dumitrescu , dpdk stable Subject: patch 'app/pipeline: add sigint handler' has been queued to stable release 21.11.6 Date: Thu, 7 Dec 2023 11:21:04 +0000 Message-ID: <20231207112116.769502-12-ktraynor@redhat.com> In-Reply-To: <20231207112116.769502-1-ktraynor@redhat.com> References: <20231207112116.769502-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/12/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/fab24e72ab032170f162e7755efe7c00b8dea989 Thanks. Kevin --- >From fab24e72ab032170f162e7755efe7c00b8dea989 Mon Sep 17 00:00:00 2001 From: Feifei Wang Date: Tue, 12 Sep 2023 14:39:02 +0800 Subject: [PATCH] app/pipeline: add sigint handler [ upstream commit f6897b23f70b84742129a215ea2be17c8843adb8 ] For test-pipeline, if the main core receive SIGINT signal, it will kill all the threads immediately and not wait other threads to finish their jobs. To fix this, add 'signal_handler' function. Fixes: 48f31ca50cc4 ("app/pipeline: packet framework benchmark") Signed-off-by: Feifei Wang Reviewed-by: Ruifeng Wang Reviewed-by: Matthew Dirba Acked-by: Cristian Dumitrescu --- .mailmap | 1 + app/test-pipeline/main.c | 14 +++ app/test-pipeline/main.h | 2 + app/test-pipeline/pipeline_acl.c | 6 +- app/test-pipeline/pipeline_hash.c | 106 +++++++++++----------- app/test-pipeline/pipeline_lpm.c | 6 +- app/test-pipeline/pipeline_lpm_ipv6.c | 6 +- app/test-pipeline/pipeline_stub.c | 6 +- app/test-pipeline/runtime.c | 126 ++++++++++++++------------ 9 files changed, 154 insertions(+), 119 deletions(-) diff --git a/.mailmap b/.mailmap index 4178218a40..3b6d7a0069 100644 --- a/.mailmap +++ b/.mailmap @@ -867,4 +867,5 @@ Matias Elo Mats Liljegren Matteo Croce +Matthew Dirba Matthew Hall Matthew Smith diff --git a/app/test-pipeline/main.c b/app/test-pipeline/main.c index 1e16794183..8633933fd9 100644 --- a/app/test-pipeline/main.c +++ b/app/test-pipeline/main.c @@ -11,4 +11,5 @@ #include #include +#include #include #include @@ -42,4 +43,13 @@ #include "main.h" +bool force_quit; + +static void +signal_handler(int signum) +{ + if (signum == SIGINT || signum == SIGTERM) + force_quit = true; +} + int main(int argc, char **argv) @@ -55,4 +65,8 @@ main(int argc, char **argv) argv += ret; + force_quit = false; + signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); + /* Parse application arguments (after the EAL ones) */ ret = app_parse_args(argc, argv); diff --git a/app/test-pipeline/main.h b/app/test-pipeline/main.h index 59dcfddbf4..9df157de22 100644 --- a/app/test-pipeline/main.h +++ b/app/test-pipeline/main.h @@ -61,4 +61,6 @@ struct app_params { extern struct app_params app; +extern bool force_quit; + int app_parse_args(int argc, char **argv); void app_print_usage(void); diff --git a/app/test-pipeline/pipeline_acl.c b/app/test-pipeline/pipeline_acl.c index 5857bc285f..abde4bf934 100644 --- a/app/test-pipeline/pipeline_acl.c +++ b/app/test-pipeline/pipeline_acl.c @@ -237,12 +237,14 @@ app_main_loop_worker_pipeline_acl(void) { /* Run-time */ #if APP_FLUSH == 0 - for ( ; ; ) + while (!force_quit) rte_pipeline_run(p); #else - for (i = 0; ; i++) { + i = 0; + while (!force_quit) { rte_pipeline_run(p); if ((i & APP_FLUSH) == 0) rte_pipeline_flush(p); + i++; } #endif diff --git a/app/test-pipeline/pipeline_hash.c b/app/test-pipeline/pipeline_hash.c index 2dd8928d43..cab9c20980 100644 --- a/app/test-pipeline/pipeline_hash.c +++ b/app/test-pipeline/pipeline_hash.c @@ -367,12 +367,14 @@ app_main_loop_worker_pipeline_hash(void) { /* Run-time */ #if APP_FLUSH == 0 - for ( ; ; ) + while (!force_quit) rte_pipeline_run(p); #else - for (i = 0; ; i++) { + i = 0; + while (!force_quit) { rte_pipeline_run(p); if ((i & APP_FLUSH) == 0) rte_pipeline_flush(p); + i++; } #endif @@ -412,58 +414,60 @@ app_main_loop_rx_metadata(void) { rte_lcore_id()); - for (i = 0; ; i = ((i + 1) & (app.n_ports - 1))) { - uint16_t n_mbufs; + while (!force_quit) { + for (i = 0; i < app.n_ports; i++) { + uint16_t n_mbufs; - n_mbufs = rte_eth_rx_burst( - app.ports[i], - 0, - app.mbuf_rx.array, - app.burst_size_rx_read); + n_mbufs = rte_eth_rx_burst( + app.ports[i], + 0, + app.mbuf_rx.array, + app.burst_size_rx_read); - if (n_mbufs == 0) - continue; - - for (j = 0; j < n_mbufs; j++) { - struct rte_mbuf *m; - uint8_t *m_data, *key; - struct rte_ipv4_hdr *ip_hdr; - struct rte_ipv6_hdr *ipv6_hdr; - uint32_t ip_dst; - uint8_t *ipv6_dst; - uint32_t *signature, *k32; - - m = app.mbuf_rx.array[j]; - m_data = rte_pktmbuf_mtod(m, uint8_t *); - signature = RTE_MBUF_METADATA_UINT32_PTR(m, - APP_METADATA_OFFSET(0)); - key = RTE_MBUF_METADATA_UINT8_PTR(m, - APP_METADATA_OFFSET(32)); - - if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) { - ip_hdr = (struct rte_ipv4_hdr *) - &m_data[sizeof(struct rte_ether_hdr)]; - ip_dst = ip_hdr->dst_addr; - - k32 = (uint32_t *) key; - k32[0] = ip_dst & 0xFFFFFF00; - } else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) { - ipv6_hdr = (struct rte_ipv6_hdr *) - &m_data[sizeof(struct rte_ether_hdr)]; - ipv6_dst = ipv6_hdr->dst_addr; - - memcpy(key, ipv6_dst, 16); - } else + if (n_mbufs == 0) continue; - *signature = test_hash(key, NULL, 0, 0); + for (j = 0; j < n_mbufs; j++) { + struct rte_mbuf *m; + uint8_t *m_data, *key; + struct rte_ipv4_hdr *ip_hdr; + struct rte_ipv6_hdr *ipv6_hdr; + uint32_t ip_dst; + uint8_t *ipv6_dst; + uint32_t *signature, *k32; + + m = app.mbuf_rx.array[j]; + m_data = rte_pktmbuf_mtod(m, uint8_t *); + signature = RTE_MBUF_METADATA_UINT32_PTR(m, + APP_METADATA_OFFSET(0)); + key = RTE_MBUF_METADATA_UINT8_PTR(m, + APP_METADATA_OFFSET(32)); + + if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) { + ip_hdr = (struct rte_ipv4_hdr *) + &m_data[sizeof(struct rte_ether_hdr)]; + ip_dst = ip_hdr->dst_addr; + + k32 = (uint32_t *) key; + k32[0] = ip_dst & 0xFFFFFF00; + } else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) { + ipv6_hdr = (struct rte_ipv6_hdr *) + &m_data[sizeof(struct rte_ether_hdr)]; + ipv6_dst = ipv6_hdr->dst_addr; + + memcpy(key, ipv6_dst, 16); + } else + continue; + + *signature = test_hash(key, NULL, 0, 0); + } + + do { + ret = rte_ring_sp_enqueue_bulk( + app.rings_rx[i], + (void **) app.mbuf_rx.array, + n_mbufs, + NULL); + } while (ret == 0 && !force_quit); } - - do { - ret = rte_ring_sp_enqueue_bulk( - app.rings_rx[i], - (void **) app.mbuf_rx.array, - n_mbufs, - NULL); - } while (ret == 0); } } diff --git a/app/test-pipeline/pipeline_lpm.c b/app/test-pipeline/pipeline_lpm.c index 8add5e71b7..e3d4b3fdc5 100644 --- a/app/test-pipeline/pipeline_lpm.c +++ b/app/test-pipeline/pipeline_lpm.c @@ -161,12 +161,14 @@ app_main_loop_worker_pipeline_lpm(void) { /* Run-time */ #if APP_FLUSH == 0 - for ( ; ; ) + while (!force_quit) rte_pipeline_run(p); #else - for (i = 0; ; i++) { + i = 0; + while (!force_quit) { rte_pipeline_run(p); if ((i & APP_FLUSH) == 0) rte_pipeline_flush(p); + i++; } #endif diff --git a/app/test-pipeline/pipeline_lpm_ipv6.c b/app/test-pipeline/pipeline_lpm_ipv6.c index 26b325180d..f9aca74e4c 100644 --- a/app/test-pipeline/pipeline_lpm_ipv6.c +++ b/app/test-pipeline/pipeline_lpm_ipv6.c @@ -159,12 +159,14 @@ app_main_loop_worker_pipeline_lpm_ipv6(void) { /* Run-time */ #if APP_FLUSH == 0 - for ( ; ; ) + while (!force_quit) rte_pipeline_run(p); #else - for (i = 0; ; i++) { + i = 0; + while (!force_quit) { rte_pipeline_run(p); if ((i & APP_FLUSH) == 0) rte_pipeline_flush(p); + i++; } #endif diff --git a/app/test-pipeline/pipeline_stub.c b/app/test-pipeline/pipeline_stub.c index b6750d51bf..48a638aad7 100644 --- a/app/test-pipeline/pipeline_stub.c +++ b/app/test-pipeline/pipeline_stub.c @@ -123,12 +123,14 @@ app_main_loop_worker_pipeline_stub(void) { /* Run-time */ #if APP_FLUSH == 0 - for ( ; ; ) + while (!force_quit) rte_pipeline_run(p); #else - for (i = 0; ; i++) { + i = 0; + while (!force_quit) { rte_pipeline_run(p); if ((i & APP_FLUSH) == 0) rte_pipeline_flush(p); + i++; } #endif diff --git a/app/test-pipeline/runtime.c b/app/test-pipeline/runtime.c index d939a85d7e..752f783370 100644 --- a/app/test-pipeline/runtime.c +++ b/app/test-pipeline/runtime.c @@ -49,22 +49,24 @@ app_main_loop_rx(void) { RTE_LOG(INFO, USER1, "Core %u is doing RX\n", rte_lcore_id()); - for (i = 0; ; i = ((i + 1) & (app.n_ports - 1))) { - uint16_t n_mbufs; + while (!force_quit) { + for (i = 0; i < app.n_ports; i++) { + uint16_t n_mbufs; - n_mbufs = rte_eth_rx_burst( - app.ports[i], - 0, - app.mbuf_rx.array, - app.burst_size_rx_read); + n_mbufs = rte_eth_rx_burst( + app.ports[i], + 0, + app.mbuf_rx.array, + app.burst_size_rx_read); - if (n_mbufs == 0) - continue; + if (n_mbufs == 0) + continue; - do { - ret = rte_ring_sp_enqueue_bulk( - app.rings_rx[i], - (void **) app.mbuf_rx.array, - n_mbufs, NULL); - } while (ret == 0); + do { + ret = rte_ring_sp_enqueue_bulk( + app.rings_rx[i], + (void **) app.mbuf_rx.array, + n_mbufs, NULL); + } while (ret == 0 && !force_quit); + } } } @@ -83,23 +85,25 @@ app_main_loop_worker(void) { rte_panic("Worker thread: cannot allocate buffer space\n"); - for (i = 0; ; i = ((i + 1) & (app.n_ports - 1))) { - int ret; + while (!force_quit) { + for (i = 0; i < app.n_ports; i++) { + int ret; - ret = rte_ring_sc_dequeue_bulk( - app.rings_rx[i], - (void **) worker_mbuf->array, - app.burst_size_worker_read, - NULL); - - if (ret == 0) - continue; - - do { - ret = rte_ring_sp_enqueue_bulk( - app.rings_tx[i ^ 1], + ret = rte_ring_sc_dequeue_bulk( + app.rings_rx[i], (void **) worker_mbuf->array, - app.burst_size_worker_write, + app.burst_size_worker_read, NULL); - } while (ret == 0); + + if (ret == 0) + continue; + + do { + ret = rte_ring_sp_enqueue_bulk( + app.rings_tx[i ^ 1], + (void **) worker_mbuf->array, + app.burst_size_worker_write, + NULL); + } while (ret == 0 && !force_quit); + } } } @@ -111,44 +115,46 @@ app_main_loop_tx(void) { RTE_LOG(INFO, USER1, "Core %u is doing TX\n", rte_lcore_id()); - for (i = 0; ; i = ((i + 1) & (app.n_ports - 1))) { - uint16_t n_mbufs, n_pkts; - int ret; + while (!force_quit) { + for (i = 0; i < app.n_ports; i++) { + uint16_t n_mbufs, n_pkts; + int ret; - n_mbufs = app.mbuf_tx[i].n_mbufs; + n_mbufs = app.mbuf_tx[i].n_mbufs; - ret = rte_ring_sc_dequeue_bulk( - app.rings_tx[i], - (void **) &app.mbuf_tx[i].array[n_mbufs], - app.burst_size_tx_read, - NULL); + ret = rte_ring_sc_dequeue_bulk( + app.rings_tx[i], + (void **) &app.mbuf_tx[i].array[n_mbufs], + app.burst_size_tx_read, + NULL); - if (ret == 0) - continue; + if (ret == 0) + continue; - n_mbufs += app.burst_size_tx_read; + n_mbufs += app.burst_size_tx_read; - if (n_mbufs < app.burst_size_tx_write) { - app.mbuf_tx[i].n_mbufs = n_mbufs; - continue; - } + if (n_mbufs < app.burst_size_tx_write) { + app.mbuf_tx[i].n_mbufs = n_mbufs; + continue; + } - n_pkts = rte_eth_tx_burst( - app.ports[i], - 0, - app.mbuf_tx[i].array, - n_mbufs); + n_pkts = rte_eth_tx_burst( + app.ports[i], + 0, + app.mbuf_tx[i].array, + n_mbufs); - if (n_pkts < n_mbufs) { - uint16_t k; + if (n_pkts < n_mbufs) { + uint16_t k; - for (k = n_pkts; k < n_mbufs; k++) { - struct rte_mbuf *pkt_to_free; + for (k = n_pkts; k < n_mbufs; k++) { + struct rte_mbuf *pkt_to_free; - pkt_to_free = app.mbuf_tx[i].array[k]; - rte_pktmbuf_free(pkt_to_free); + pkt_to_free = app.mbuf_tx[i].array[k]; + rte_pktmbuf_free(pkt_to_free); + } } - } - app.mbuf_tx[i].n_mbufs = 0; + app.mbuf_tx[i].n_mbufs = 0; + } } } -- 2.43.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-12-07 11:18:59.901047143 +0000 +++ 0012-app-pipeline-add-sigint-handler.patch 2023-12-07 11:18:59.628873931 +0000 @@ -1 +1 @@ -From f6897b23f70b84742129a215ea2be17c8843adb8 Mon Sep 17 00:00:00 2001 +From fab24e72ab032170f162e7755efe7c00b8dea989 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit f6897b23f70b84742129a215ea2be17c8843adb8 ] + @@ -13 +14,0 @@ -Cc: stable@dpdk.org @@ -32 +33 @@ -index 54e3bf7584..49d3616c4c 100644 +index 4178218a40..3b6d7a0069 100644 @@ -35 +36 @@ -@@ -900,4 +900,5 @@ Matias Elo +@@ -867,4 +867,5 @@ Matias Elo @@ -86 +87 @@ -index 2f04868e3e..9eb4053e23 100644 +index 5857bc285f..abde4bf934 100644 @@ -238 +239 @@ -index 854319174b..8a59bd0042 100644 +index 8add5e71b7..e3d4b3fdc5 100644 @@ -259 +260 @@ -index 18d4f018f1..207ffbeff0 100644 +index 26b325180d..f9aca74e4c 100644