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 E5E32433AC for ; Thu, 23 Nov 2023 17:17:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E143242FD9; Thu, 23 Nov 2023 17:17:38 +0100 (CET) Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by mails.dpdk.org (Postfix) with ESMTP id DEA0042F21 for ; Thu, 23 Nov 2023 17:17:37 +0100 (CET) Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-507a98517f3so1332030e87.0 for ; Thu, 23 Nov 2023 08:17:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700756257; x=1701361057; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/2OJGBOrUYMQknMA5Qj8Qs19xwWpzD3xe6z27W7jneU=; b=LsH2OOkMMjM1XdkoozPhpKhuQifi9Ck1STsIw7aMxDnsLioZZmlJ8fednuAQT9P1ro 84YDMKDfh8RdfPZD/t1QBIAy0kfhf7LkQW5jiigySkvY1bhzQItHpbXfvqeo560ETYOi a8w0ANe0fdCkPpJULKqeYnuH/dZIs8EHBXkWCTuKEMmRYfBrkRkQN10GcL1EWEn96D4n 7Z7QxSipUXWZhUoKM0nvrxrJBfVo9muCRpK1TqzF8pzIyryKsH+ilswzguinFb9XWu6t +8CuQG85RO56yBtppPU5rZny8bQ85S3qoOJe1XZXkCYIZjsFP1yjZn6g/as1dAIPgTT7 cp/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700756257; x=1701361057; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/2OJGBOrUYMQknMA5Qj8Qs19xwWpzD3xe6z27W7jneU=; b=AHqiV/8Sh5KdhXu6szVg0iKfMFmNCvOh96k49YnzdbJ7VT0ZTGqow8ovPwL2vdnLeA iu74Gclk5zreKG1tF9WLlAFUmTvkud0SSbYmGbKj1bQMxKPRAT2/42jt6c5GpbpaLq5c LMSsnOres1nL6y7AvTIgZuYKszHGdh7NV6r9FTojbgnBVcQJM14heXq92mDytGB/c7sH 433ddclMaa5GCbyon3cby/PoVFzNeJJo7B0lYn4LVHwNIxp3OIr5RanB73lZk5/rFASO RFPsNSsH2014x/yrOVqpI/7+A52yFKh2nITvhMvT4PhZ091tI2ONkv6E+tBec3eKCz7X m4+A== X-Gm-Message-State: AOJu0Yxte37Mz68/OrdIc7JIFCVrWm94VXLPdo/NehpJ1xH/mMrk2N/s 4VtPPrjNfJ7bD9o0anR2ZsE= X-Google-Smtp-Source: AGHT+IFDMCDPiihWHjv1vXO+0fXXpArPp1/LYAxmbud+IYWZlirNRQp0HAcX0WHsdbWzxTNd5s/dUA== X-Received: by 2002:ac2:4e4c:0:b0:500:9dd4:2969 with SMTP id f12-20020ac24e4c000000b005009dd42969mr3496638lfr.59.1700756257135; Thu, 23 Nov 2023 08:17:37 -0800 (PST) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id je4-20020a05600c1f8400b00407460234f9sm2486725wmb.21.2023.11.23.08.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 08:17:36 -0800 (PST) From: luca.boccassi@gmail.com 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 20.11.10 Date: Thu, 23 Nov 2023 16:17:09 +0000 Message-Id: <20231123161709.670852-9-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123161709.670852-1-luca.boccassi@gmail.com> References: <20231115114515.2355140-16-luca.boccassi@gmail.com> <20231123161709.670852-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 20.11.10 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/25/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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/dfd5276c01eca734b0b0e3c8bef72f515cc700d4 Thanks. Luca Boccassi --- >From dfd5276c01eca734b0b0e3c8bef72f515cc700d4 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 --- 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 ++++++++++++++------------ 8 files changed, 153 insertions(+), 119 deletions(-) diff --git a/app/test-pipeline/main.c b/app/test-pipeline/main.c index 72e4797ff2..f16237db3e 100644 --- a/app/test-pipeline/main.c +++ b/app/test-pipeline/main.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,15 @@ #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,6 +65,10 @@ main(int argc, char **argv) argc -= ret; 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); if (ret < 0) { 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 @@ -60,6 +60,8 @@ 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); void app_init(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 @@ -236,14 +236,16 @@ 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 @@ -366,14 +366,16 @@ 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 } @@ -411,59 +413,61 @@ app_main_loop_rx_metadata(void) { RTE_LOG(INFO, USER1, "Core %u is doing RX (with meta-data)\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; - - 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 @@ -160,14 +160,16 @@ 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 @@ -158,14 +158,16 @@ 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 @@ -122,14 +122,16 @@ 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 159192bcd8..68d2a36dd6 100644 --- a/app/test-pipeline/runtime.c +++ b/app/test-pipeline/runtime.c @@ -49,24 +49,26 @@ 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,25 +85,27 @@ app_main_loop_worker(void) { if (worker_mbuf == NULL) 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,45 +115,47 @@ 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.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-11-23 16:15:19.580815967 +0000 +++ 0009-app-pipeline-add-sigint-handler.patch 2023-11-23 16:15:19.223058548 +0000 @@ -1 +1 @@ -From f6897b23f70b84742129a215ea2be17c8843adb8 Mon Sep 17 00:00:00 2001 +From dfd5276c01eca734b0b0e3c8bef72f515cc700d4 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit f6897b23f70b84742129a215ea2be17c8843adb8 ] + @@ -13 +14,0 @@ -Cc: stable@dpdk.org @@ -20 +20,0 @@ - .mailmap | 1 + @@ -29 +29 @@ - 9 files changed, 154 insertions(+), 119 deletions(-) + 8 files changed, 153 insertions(+), 119 deletions(-) @@ -31,12 +30,0 @@ -diff --git a/.mailmap b/.mailmap -index 54e3bf7584..49d3616c4c 100644 ---- a/.mailmap -+++ b/.mailmap -@@ -899,6 +899,7 @@ Mateusz Rusinski - Matias Elo - Mats Liljegren - Matteo Croce -+Matthew Dirba - Matthew Hall - Matthew Smith - Matthew Vick @@ -44 +32 @@ -index 1e16794183..8633933fd9 100644 +index 72e4797ff2..f16237db3e 100644 @@ -55 +43 @@ -@@ -41,6 +42,15 @@ +@@ -42,6 +43,15 @@ @@ -71 +59 @@ -@@ -54,6 +64,10 @@ main(int argc, char **argv) +@@ -55,6 +65,10 @@ main(int argc, char **argv) @@ -96 +84 @@ -index 2f04868e3e..9eb4053e23 100644 +index 5857bc285f..abde4bf934 100644 @@ -253 +241 @@ -index 854319174b..8a59bd0042 100644 +index 8add5e71b7..e3d4b3fdc5 100644 @@ -276 +264 @@ -index 18d4f018f1..207ffbeff0 100644 +index 26b325180d..f9aca74e4c 100644 @@ -322 +310 @@ -index d939a85d7e..752f783370 100644 +index 159192bcd8..68d2a36dd6 100644 @@ -325 +313 @@ -@@ -48,24 +48,26 @@ app_main_loop_rx(void) { +@@ -49,24 +49,26 @@ app_main_loop_rx(void) { @@ -367 +355 @@ -@@ -82,25 +84,27 @@ app_main_loop_worker(void) { +@@ -83,25 +85,27 @@ app_main_loop_worker(void) { @@ -411 +399 @@ -@@ -110,45 +114,47 @@ app_main_loop_tx(void) { +@@ -111,45 +115,47 @@ app_main_loop_tx(void) {