patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Feifei Wang <feifei.wang2@arm.com>
Cc: Ruifeng Wang <ruifeng.wang@arm.com>,
	Matthew Dirba <matthew.dirba@arm.com>,
	Cristian Dumitrescu <cristian.dumitrescu@intel.com>,
	dpdk stable <stable@dpdk.org>
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	[thread overview]
Message-ID: <20231207112116.769502-12-ktraynor@redhat.com> (raw)
In-Reply-To: <20231207112116.769502-1-ktraynor@redhat.com>

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 <feifei.wang2@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@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Matthew Dirba <matthew.dirba@arm.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@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     | 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 <matias.elo@nokia.com>
 Mats Liljegren <mats.liljegren@enea.com>
 Matteo Croce <mcroce@redhat.com>
+Matthew Dirba <matthew.dirba@arm.com>
 Matthew Hall <mhall@mhcomputing.net>
 Matthew Smith <mgsmith@netgate.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
@@ -11,4 +11,5 @@
 #include <sys/queue.h>
 #include <stdarg.h>
+#include <signal.h>
 #include <errno.h>
 #include <getopt.h>
@@ -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 <matias.elo@nokia.com>
+@@ -867,4 +867,5 @@ Matias Elo <matias.elo@nokia.com>
@@ -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


  parent reply	other threads:[~2023-12-07 11:21 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07 11:20 patch 'net/txgbe: fix out of bound access' " Kevin Traynor
2023-12-07 11:20 ` patch 'doc: fix hns3 build option about max queue number' " Kevin Traynor
2023-12-07 11:20 ` patch 'doc: update features in hns3 guide' " Kevin Traynor
2023-12-07 11:20 ` patch 'doc: fix RSS flow description " Kevin Traynor
2023-12-07 11:20 ` patch 'doc: update versions recommendations for i40e and ice' " Kevin Traynor
2023-12-07 11:20 ` patch 'examples/ipsec-secgw: fix partial overflow' " Kevin Traynor
2023-12-07 11:20 ` patch 'eal/windows: fix build with recent MinGW' " Kevin Traynor
2023-12-07 11:21 ` patch 'pdump: fix error number on IPC response' " Kevin Traynor
2023-12-07 11:21 ` patch 'app/dumpcap: allow multiple invocations' " Kevin Traynor
2023-12-07 11:21 ` patch 'examples/ethtool: fix pause configuration' " Kevin Traynor
2023-12-07 11:21 ` patch 'test/hash: fix creation error log' " Kevin Traynor
2023-12-07 11:21 ` Kevin Traynor [this message]
2023-12-07 11:21 ` patch 'doc: remove restriction on ixgbe vector support' " Kevin Traynor
2023-12-07 11:21 ` patch 'doc: fix some ordered lists' " Kevin Traynor
2023-12-07 11:21 ` patch 'doc: remove number of commands in vDPA guide' " Kevin Traynor
2023-12-07 11:21 ` patch 'mempool: fix get function documentation' " Kevin Traynor
2023-12-07 11:21 ` patch 'mempool: clarify enqueue/dequeue ops " Kevin Traynor
2023-12-07 11:21 ` patch 'ethdev: fix ESP packet type description' " Kevin Traynor
2023-12-07 11:21 ` patch 'net/hns3: fix ignored reset event' " Kevin Traynor
2023-12-07 11:21 ` patch 'net/hns3: fix reset event status' " Kevin Traynor
2023-12-07 11:21 ` patch 'net/hns3: fix VF reset handler interruption' " Kevin Traynor
2023-12-07 11:21 ` patch 'net/af_xdp: make compatible with libbpf 0.8.0' " Kevin Traynor
2023-12-07 14:16   ` Kevin Traynor
2023-12-11 12:44     ` Loftus, Ciara
2023-12-11 15:27       ` Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231207112116.769502-12-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=feifei.wang2@arm.com \
    --cc=matthew.dirba@arm.com \
    --cc=ruifeng.wang@arm.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).