patch 'app/pipeline: add sigint handler' has been queued to stable release 22.11.4

Xueming Li xuemingl at nvidia.com
Mon Dec 11 11:12:16 CET 2023


Hi,

FYI, your patch has been queued to stable release 22.11.4

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/13/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://git.dpdk.org/dpdk-stable/log/?h=22.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=de38896353c37da406d35eebc64baea20f1b5c6e

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From de38896353c37da406d35eebc64baea20f1b5c6e Mon Sep 17 00:00:00 2001
From: Feifei Wang <feifei.wang2 at arm.com>
Date: Tue, 12 Sep 2023 14:39:02 +0800
Subject: [PATCH] app/pipeline: add sigint handler
Cc: Xueming Li <xuemingl at nvidia.com>

[ 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 <feifei.wang2 at arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang at arm.com>
Reviewed-by: Matthew Dirba <matthew.dirba at arm.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu at intel.com>
---
 .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     | 110 ++++++++++-----------
 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           | 132 ++++++++++++++------------
 9 files changed, 159 insertions(+), 124 deletions(-)

diff --git a/.mailmap b/.mailmap
index 48267a54f2..9b523c9959 100644
--- a/.mailmap
+++ b/.mailmap
@@ -865,6 +865,7 @@ Mateusz Rusinski <mateusz.rusinski at intel.com>
 Matias Elo <matias.elo at nokia.com>
 Mats Liljegren <mats.liljegren at enea.com>
 Matteo Croce <mcroce at redhat.com>
+Matthew Dirba <matthew.dirba at arm.com>
 Matthew Hall <mhall at mhcomputing.net>
 Matthew Smith <mgsmith at netgate.com>
 Matthew Vick <matthew.vick at intel.com>
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
@@ -10,6 +10,7 @@
 #include <string.h>
 #include <sys/queue.h>
 #include <stdarg.h>
+#include <signal.h>
 #include <errno.h>
 #include <getopt.h>
 #include <unistd.h>
@@ -41,6 +42,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)
 {
@@ -54,6 +64,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;
-
-		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
+	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);
+
+			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 d939a85d7e..752f783370 100644
--- a/app/test-pipeline/runtime.c
+++ b/app/test-pipeline/runtime.c
@@ -48,24 +48,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;
-
-		n_mbufs = rte_eth_rx_burst(
-			app.ports[i],
-			0,
-			app.mbuf_rx.array,
-			app.burst_size_rx_read);
-
-		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);
+	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);
+
+			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 && !force_quit);
+		}
 	}
 }
 
@@ -82,25 +84,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;
-
-		ret = rte_ring_sc_dequeue_bulk(
-			app.rings_rx[i],
-			(void **) worker_mbuf->array,
-			app.burst_size_worker_read,
-			NULL);
+	while (!force_quit) {
+		for (i = 0; i < app.n_ports; i++) {
+			int ret;
 
-		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);
+		}
 	}
 }
 
@@ -110,45 +114,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.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-12-11 17:56:26.668231700 +0800
+++ 0111-app-pipeline-add-sigint-handler.patch	2023-12-11 17:56:23.227652300 +0800
@@ -1 +1 @@
-From f6897b23f70b84742129a215ea2be17c8843adb8 Mon Sep 17 00:00:00 2001
+From de38896353c37da406d35eebc64baea20f1b5c6e Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit f6897b23f70b84742129a215ea2be17c8843adb8 ]
@@ -13 +15,0 @@
-Cc: stable at dpdk.org
@@ -32 +34 @@
-index 54e3bf7584..49d3616c4c 100644
+index 48267a54f2..9b523c9959 100644
@@ -35 +37 @@
-@@ -899,6 +899,7 @@ Mateusz Rusinski <mateusz.rusinski at intel.com>
+@@ -865,6 +865,7 @@ Mateusz Rusinski <mateusz.rusinski at intel.com>
@@ -96 +98 @@
-index 2f04868e3e..9eb4053e23 100644
+index 5857bc285f..abde4bf934 100644
@@ -255 +257 @@
-index 854319174b..8a59bd0042 100644
+index 8add5e71b7..e3d4b3fdc5 100644
@@ -278 +280 @@
-index 18d4f018f1..207ffbeff0 100644
+index 26b325180d..f9aca74e4c 100644


More information about the stable mailing list