From patchwork Thu Sep 29 10:51:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 117125 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AC84BA00C4; Thu, 29 Sep 2022 12:51:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8BA5B40694; Thu, 29 Sep 2022 12:51:23 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 701D440395 for ; Thu, 29 Sep 2022 12:51:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664448682; x=1695984682; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=z3KU8O1lc1YEGfK2dQBdflpyv9fwW2Ar96wCESf9BO8=; b=mYnUKP/qyg0DtBOEeaEC/XRM5L3jL3AJwdlL2khXnOplvTWC5Uv63MF/ Lv1xgNbtml2Ys/mJsWE7krP5at7y5i2DXxne9iYQUGOBKtBY0kN56CgxT h1+YlrNQ00p1GH/DDyQIhD5qrNONivsE8nxopPnSUNPWcFfTz5+Rayio1 g2bTvd15r+6f1GjeCeQwEU/NTovLyjGXF2X+fh47fXQLl8bBtcokEXB7Z mW5lWQgbaiHosMUwyCkLGdYMhzWYRagyscnc/TrEptC1xL5nFl0K6x5aE fZWwdGveDkdPMd/GXY/c54JHLc+vGLDFLTmtmiF96vPqMoAQdekw1jwS/ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10484"; a="299459667" X-IronPort-AV: E=Sophos;i="5.93,354,1654585200"; d="scan'208";a="299459667" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2022 03:51:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10484"; a="622312699" X-IronPort-AV: E=Sophos;i="5.93,354,1654585200"; d="scan'208";a="622312699" Received: from silpixa00401385.ir.intel.com ([10.237.214.41]) by orsmga002.jf.intel.com with ESMTP; 29 Sep 2022 03:51:18 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: thomas@monjalon.net, Bruce Richardson , Ray Kinsella , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Subject: [PATCH] eal: remove panic on remote launch failure Date: Thu, 29 Sep 2022 11:51:01 +0100 Message-Id: <20220929105101.406724-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Library functions should not cause the app to exit or panic. Replace the existing panic call in the EAL remote launch functions with an error code return instead. Signed-off-by: Bruce Richardson Reviewed-by: David Marchand --- doc/guides/rel_notes/deprecation.rst | 3 --- lib/eal/common/eal_common_launch.c | 3 +-- lib/eal/common/eal_thread.h | 4 +++- lib/eal/include/rte_launch.h | 1 + lib/eal/unix/eal_unix_thread.c | 7 ++++--- lib/eal/windows/eal_thread.c | 7 ++++--- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 688b8c2606..71c0d0137a 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -18,9 +18,6 @@ Deprecation Notices in the future. Applications can use ``devtools/cocci/func_or_ret.cocci`` to update their code. -* eal: The function ``rte_eal_remote_launch`` will return new error codes - after read or write error on the pipe, instead of calling ``rte_panic``. - * rte_atomicNN_xxx: These APIs do not take memory order parameter. This does not allow for writing optimized code for all the CPU architectures supported in DPDK. DPDK has adopted the atomic operations from diff --git a/lib/eal/common/eal_common_launch.c b/lib/eal/common/eal_common_launch.c index 462c886e30..487e58c124 100644 --- a/lib/eal/common/eal_common_launch.c +++ b/lib/eal/common/eal_common_launch.c @@ -49,8 +49,7 @@ rte_eal_remote_launch(lcore_function_t *f, void *arg, unsigned int worker_id) */ __atomic_store_n(&lcore_config[worker_id].f, f, __ATOMIC_RELEASE); - eal_thread_wake_worker(worker_id); - rc = 0; + rc = eal_thread_wake_worker(worker_id); finish: rte_eal_trace_thread_remote_launch(f, arg, worker_id, rc); diff --git a/lib/eal/common/eal_thread.h b/lib/eal/common/eal_thread.h index e0240ccc60..32bfe5c977 100644 --- a/lib/eal/common/eal_thread.h +++ b/lib/eal/common/eal_thread.h @@ -67,8 +67,10 @@ eal_thread_dump_current_affinity(char *str, unsigned int size); * * @param worker_id * The lcore_id of a worker thread. + * @return + * 0 on success, negative errno on error */ -void +int eal_thread_wake_worker(unsigned int worker_id); /** diff --git a/lib/eal/include/rte_launch.h b/lib/eal/include/rte_launch.h index 295584668e..f7bf9f6b2d 100644 --- a/lib/eal/include/rte_launch.h +++ b/lib/eal/include/rte_launch.h @@ -62,6 +62,7 @@ typedef int (lcore_function_t)(void *); * @return * - 0: Success. Execution of function f started on the remote lcore. * - (-EBUSY): The remote lcore is not in a WAIT state. + * - (-EPIPE): Error reading or writing pipe to worker thread */ int rte_eal_remote_launch(lcore_function_t *f, void *arg, unsigned worker_id); diff --git a/lib/eal/unix/eal_unix_thread.c b/lib/eal/unix/eal_unix_thread.c index 70b5ba6b98..ef6cbff0ee 100644 --- a/lib/eal/unix/eal_unix_thread.c +++ b/lib/eal/unix/eal_unix_thread.c @@ -9,7 +9,7 @@ #include "eal_private.h" -void +int eal_thread_wake_worker(unsigned int worker_id) { int m2w = lcore_config[worker_id].pipe_main2worker[1]; @@ -21,13 +21,14 @@ eal_thread_wake_worker(unsigned int worker_id) n = write(m2w, &c, 1); } while (n == 0 || (n < 0 && errno == EINTR)); if (n < 0) - rte_panic("cannot write on configuration pipe\n"); + return -EPIPE; do { n = read(w2m, &c, 1); } while (n < 0 && errno == EINTR); if (n <= 0) - rte_panic("cannot read on configuration pipe\n"); + return -EPIPE; + return 0; } void diff --git a/lib/eal/windows/eal_thread.c b/lib/eal/windows/eal_thread.c index f3c61b4456..caffe68d19 100644 --- a/lib/eal/windows/eal_thread.c +++ b/lib/eal/windows/eal_thread.c @@ -16,7 +16,7 @@ #include "eal_thread.h" #include "eal_windows.h" -void +int eal_thread_wake_worker(unsigned int worker_id) { int m2w = lcore_config[worker_id].pipe_main2worker[1]; @@ -28,13 +28,14 @@ eal_thread_wake_worker(unsigned int worker_id) n = _write(m2w, &c, 1); } while (n == 0 || (n < 0 && errno == EINTR)); if (n < 0) - rte_panic("cannot write on configuration pipe\n"); + return -EPIPE; do { n = _read(w2m, &c, 1); } while (n < 0 && errno == EINTR); if (n <= 0) - rte_panic("cannot read on configuration pipe\n"); + return -EPIPE; + return 0; } void