[dpdk-stable] patch 'ipc: remove panic in async request' has been queued to stable release 18.08.1

Kevin Traynor ktraynor at redhat.com
Fri Nov 23 11:27:06 CET 2018


Hi,

FYI, your patch has been queued to stable release 18.08.1

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/29/18. 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. If the code is different (ie: not only metadata diffs), due for example to
a change in context or macro names, please double check it.

Thanks.

Kevin Traynor

---
>From 13f9973d55a67efb40fd67d2ea3d976d0058db0d Mon Sep 17 00:00:00 2001
From: Anatoly Burakov <anatoly.burakov at intel.com>
Date: Tue, 13 Nov 2018 18:03:52 +0000
Subject: [PATCH] ipc: remove panic in async request

[ upstream commit 45e5f49e87fba07c1e63f1630a3c76fc89a198a4 ]

EAL should not crash when setting alarm fails. Also, remove the
profanity in error message.

Fixes: daf9bfca717e ("ipc: remove thread for async requests")

Signed-off-by: Stephen Hemminger <sthemmin at microsoft.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
 lib/librte_eal/common/eal_common_proc.c | 31 ++++++++++++++++++-------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c
index 97663d3ba..f65ef56c0 100644
--- a/lib/librte_eal/common/eal_common_proc.c
+++ b/lib/librte_eal/common/eal_common_proc.c
@@ -801,5 +801,5 @@ mp_request_async(const char *dst, struct rte_mp_msg *req,
 	struct rte_mp_msg *reply_msg;
 	struct pending_request *pending_req, *exist;
-	int ret;
+	int ret = -1;
 
 	pending_req = calloc(1, sizeof(*pending_req));
@@ -828,4 +828,26 @@ mp_request_async(const char *dst, struct rte_mp_msg *req,
 	}
 
+	/*
+	 * set the alarm before sending message. there are two possible error
+	 * scenarios to consider here:
+	 *
+	 * - if the alarm set fails, we free the memory right there
+	 * - if the alarm set succeeds but sending message fails, then the alarm
+	 *   will trigger and clean up the memory
+	 *
+	 * Even if the alarm triggers too early (i.e. immediately), we're still
+	 * holding the lock to pending requests queue, so the interrupt thread
+	 * will just spin until we release the lock, and either release the
+	 * memory, or doesn't find any pending requests in the queue because we
+	 * never added any due to send message failure.
+	 */
+	if (rte_eal_alarm_set(ts->tv_sec * 1000000 + ts->tv_nsec / 1000,
+			      async_reply_handle, pending_req) < 0) {
+		RTE_LOG(ERR, EAL, "Fail to set alarm for request %s:%s\n",
+			dst, req->name);
+		ret = -1;
+		goto fail;
+	}
+
 	ret = send_msg(dst, req, MP_REQ);
 	if (ret < 0) {
@@ -842,11 +864,4 @@ mp_request_async(const char *dst, struct rte_mp_msg *req,
 	param->user_reply.nb_sent++;
 
-	if (rte_eal_alarm_set(ts->tv_sec * 1000000 + ts->tv_nsec / 1000,
-			      async_reply_handle, pending_req) < 0) {
-		RTE_LOG(ERR, EAL, "Fail to set alarm for request %s:%s\n",
-			dst, req->name);
-		rte_panic("Fix the above shit to properly free all memory\n");
-	}
-
 	return 0;
 fail:
-- 
2.19.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2018-11-23 10:22:55.850275211 +0000
+++ 0062-ipc-remove-panic-in-async-request.patch	2018-11-23 10:22:54.000000000 +0000
@@ -1,13 +1,14 @@
-From 45e5f49e87fba07c1e63f1630a3c76fc89a198a4 Mon Sep 17 00:00:00 2001
+From 13f9973d55a67efb40fd67d2ea3d976d0058db0d Mon Sep 17 00:00:00 2001
 From: Anatoly Burakov <anatoly.burakov at intel.com>
 Date: Tue, 13 Nov 2018 18:03:52 +0000
 Subject: [PATCH] ipc: remove panic in async request
 
+[ upstream commit 45e5f49e87fba07c1e63f1630a3c76fc89a198a4 ]
+
 EAL should not crash when setting alarm fails. Also, remove the
 profanity in error message.
 
 Fixes: daf9bfca717e ("ipc: remove thread for async requests")
-Cc: stable at dpdk.org
 
 Signed-off-by: Stephen Hemminger <sthemmin at microsoft.com>
 Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>


More information about the stable mailing list