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

luca.boccassi at gmail.com luca.boccassi at gmail.com
Thu Nov 23 17:17:09 CET 2023


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 <feifei.wang2 at arm.com>
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 <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>
---
 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 <string.h>
 #include <sys/queue.h>
 #include <stdarg.h>
+#include <signal.h>
 #include <errno.h>
 #include <getopt.h>
 #include <unistd.h>
@@ -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 at 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 <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>
@@ -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) {


More information about the stable mailing list