From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A6F62A0548; Tue, 17 Aug 2021 05:30:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8DF9B4115D; Tue, 17 Aug 2021 05:30:03 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 08B714014E for ; Tue, 17 Aug 2021 05:30:01 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 17H2lc0h006745; Mon, 16 Aug 2021 20:29:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=ZPwb3P4irC5JFR8lS+TqMid+yDeG5AdkBsAeVbdmSf4=; b=Q11MenoiO7zfC+72A7y9WFuUShzO6QjWSmLp+mMaKHyhQvgwg/tm/Rpv+/iI01NK1Cy/ RT69c2q+TEFGjv4CkFPvyGf9QCOLz52TJRKeVH5X7OSzOB8XoVsIpneHECnkLjhIoZgu UGjTnNRhQnXfmhZ/7jca3WBpdtQmsAD/NYG9wNw2BktjNE8bBzjeu1u0MQ6wdSt5cnIx HKJqD8IKTyhluSEWE60/tdujk/kPpTUKNenfEogfioxSwvKq4r7VcGYPzNS/7vTY514Q snXeYpGlpqKWu9hv55J873czLtb51pDAtrKcNIJIe2jTTayd0PPU22p0mi5zHT428pms Fw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com with ESMTP id 3ag4n0r3t0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 16 Aug 2021 20:29:55 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 16 Aug 2021 20:29:54 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 16 Aug 2021 20:29:54 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id B7BB43F70A2; Mon, 16 Aug 2021 20:29:49 -0700 (PDT) From: To: , Bruce Richardson , "Ray Kinsella" CC: , , , , , , , , , , Jerin Jacob Date: Tue, 17 Aug 2021 08:57:18 +0530 Message-ID: <20210817032723.3997054-2-jerinj@marvell.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210817032723.3997054-1-jerinj@marvell.com> References: <20210730084938.2426128-2-jerinj@marvell.com> <20210817032723.3997054-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 7jVWJ-weDPWKQ7PZj3pkESJIn-R_4QJ5 X-Proofpoint-ORIG-GUID: 7jVWJ-weDPWKQ7PZj3pkESJIn-R_4QJ5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-08-17_01,2021-08-16_02,2020-04-07_01 Subject: [dpdk-dev] [PATCH v2 1/6] eal: introduce oops handling API 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 Sender: "dev" From: Jerin Jacob Introducing oops handling API with following specification and enable stub implementation for Linux and FreeBSD. On rte_eal_init() invocation, the EAL library installs the oops handler for the essential signals. The rte_oops_signals_enabled() API provides the list of signals the library installed by the EAL. The default EAL oops handler decodes the oops message using rte_oops_decode() and then calls the signal handler installed by the application before invoking the rte_eal_init(). This scheme will also enable the use of the default coredump handler(for gdb etc.) provided by OS if the application does not install any specific signal handler. The second case where the application installs the signal handler after the rte_eal_init() invocation, rte_oops_decode() provides the means of decoding the oops message in the application's fault handler. Signed-off-by: Jerin Jacob --- doc/api/doxy-api-index.md | 3 +- lib/eal/common/eal_private.h | 3 ++ lib/eal/freebsd/eal.c | 6 +++ lib/eal/include/meson.build | 1 + lib/eal/include/rte_oops.h | 100 +++++++++++++++++++++++++++++++++++ lib/eal/linux/eal.c | 6 +++ lib/eal/unix/eal_oops.c | 36 +++++++++++++ lib/eal/unix/meson.build | 1 + lib/eal/version.map | 4 ++ 9 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 lib/eal/include/rte_oops.h create mode 100644 lib/eal/unix/eal_oops.c diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md index 1992107a03..0d0da35205 100644 --- a/doc/api/doxy-api-index.md +++ b/doc/api/doxy-api-index.md @@ -215,7 +215,8 @@ The public API headers are grouped by topics: [log] (@ref rte_log.h), [errno] (@ref rte_errno.h), [trace] (@ref rte_trace.h), - [trace_point] (@ref rte_trace_point.h) + [trace_point] (@ref rte_trace_point.h), + [oops] (@ref rte_oops.h) - **misc**: [EAL config] (@ref rte_eal.h), diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h index 64cf4e81c8..c3a490d803 100644 --- a/lib/eal/common/eal_private.h +++ b/lib/eal/common/eal_private.h @@ -716,6 +716,9 @@ void __rte_thread_init(unsigned int lcore_id, rte_cpuset_t *cpuset); */ void __rte_thread_uninit(void); +int eal_oops_init(void); +void eal_oops_fini(void); + /** * asprintf(3) replacement for Windows. */ diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 6cee5ae369..3c098708c6 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -692,6 +692,11 @@ rte_eal_init(int argc, char **argv) return -1; } + if (eal_oops_init()) { + rte_eal_init_alert("oops init failed."); + rte_errno = ENOENT; + } + thread_id = pthread_self(); eal_reset_internal_config(internal_conf); @@ -974,6 +979,7 @@ rte_eal_cleanup(void) rte_trace_save(); eal_trace_fini(); eal_cleanup_config(internal_conf); + eal_oops_fini(); return 0; } diff --git a/lib/eal/include/meson.build b/lib/eal/include/meson.build index 88a9eba12f..6c74bdb7b5 100644 --- a/lib/eal/include/meson.build +++ b/lib/eal/include/meson.build @@ -30,6 +30,7 @@ headers += files( 'rte_malloc.h', 'rte_memory.h', 'rte_memzone.h', + 'rte_oops.h', 'rte_pci_dev_feature_defs.h', 'rte_pci_dev_features.h', 'rte_per_lcore.h', diff --git a/lib/eal/include/rte_oops.h b/lib/eal/include/rte_oops.h new file mode 100644 index 0000000000..ff82c409ec --- /dev/null +++ b/lib/eal/include/rte_oops.h @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2020 Marvell. + */ + +#ifndef _RTE_OOPS_H_ +#define _RTE_OOPS_H_ + +#include +#include +#include + +/** + * @file + * + * RTE oops API + * + * This file provides the oops handling APIs to RTE applications. + * + * On rte_eal_init() invocation, the EAL library installs the oops handler for + * the essential signals. The rte_oops_signals_enabled() API provides the list + * of signals the library installed by the EAL. + * + * The default EAL oops handler decodes the oops message using rte_oops_decode() + * and then calls the signal handler installed by the application before + * invoking the rte_eal_init(). This scheme will also enable the use of + * the default coredump handler(for gdb etc.) provided by OS if the application + * does not install any specific signal handler. + * + * The second case where the application installs the signal handler after + * the rte_eal_init() invocation, rte_oops_decode() provides the means of + * decoding the oops message in the application's fault handler. + * + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Maximum number of oops signals enabled in EAL. + * @see rte_oops_signals_enabled() + */ +#define RTE_OOPS_SIGNALS_MAX 32 + +/** + * Get the list of enabled oops signals installed by EAL. + * + * @param [out] signals + * A pointer to store the enabled signals. + * Value NULL is allowed. if not NULL, then the size of this array must be + * at least RTE_OOPS_SIGNALS_MAX. + * + * @return + * Number of enabled oops signals. + */ +__rte_experimental +int rte_oops_signals_enabled(int *signals); + +#if defined(RTE_EXEC_ENV_LINUX) || defined(RTE_EXEC_ENV_FREEBSD) +#include +#include + +/** + * Decode an oops + * + * This prototype is same as sa_sigaction defined in signal.h. + * Application must register signal handler using sigaction() with + * sa_flag as SA_SIGINFO flag to get this information from unix OS. + * + * @param sig + * Signal number + * @param info + * Signal info provided by sa_sigaction. Value NULL is allowed. + * @param uc + * ucontext_t provided when signal installed with SA_SIGINFO flag. + * Value NULL is allowed. + * + */ +__rte_experimental +void rte_oops_decode(int sig, siginfo_t *info, ucontext_t *uc); +#else + +/** + * Decode an oops + * + * @param sig + * Signal number + */ +__rte_experimental +void rte_oops_decode(int sig); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_OOPS_H_ */ diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 3577eaeaa4..3438a96b75 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -991,6 +991,11 @@ rte_eal_init(int argc, char **argv) return -1; } + if (eal_oops_init()) { + rte_eal_init_alert("oops init failed."); + rte_errno = ENOENT; + } + p = strrchr(argv[0], '/'); strlcpy(logid, p ? p + 1 : argv[0], sizeof(logid)); thread_id = pthread_self(); @@ -1371,6 +1376,7 @@ rte_eal_cleanup(void) rte_trace_save(); eal_trace_fini(); eal_cleanup_config(internal_conf); + eal_oops_fini(); return 0; } diff --git a/lib/eal/unix/eal_oops.c b/lib/eal/unix/eal_oops.c new file mode 100644 index 0000000000..53b580f733 --- /dev/null +++ b/lib/eal/unix/eal_oops.c @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2021 Marvell. + */ + + +#include + +#include "eal_private.h" + +void +rte_oops_decode(int sig, siginfo_t *info, ucontext_t *uc) +{ + RTE_SET_USED(sig); + RTE_SET_USED(info); + RTE_SET_USED(uc); + +} + +int +rte_oops_signals_enabled(int *signals) +{ + RTE_SET_USED(signals); + + return 0; +} + +int +eal_oops_init(void) +{ + return 0; +} + +void +eal_oops_fini(void) +{ +} diff --git a/lib/eal/unix/meson.build b/lib/eal/unix/meson.build index e3ecd3e956..cdd3320669 100644 --- a/lib/eal/unix/meson.build +++ b/lib/eal/unix/meson.build @@ -6,5 +6,6 @@ sources += files( 'eal_unix_memory.c', 'eal_unix_timer.c', 'eal_firmware.c', + 'eal_oops.c', 'rte_thread.c', ) diff --git a/lib/eal/version.map b/lib/eal/version.map index 887012d02a..f2841d09fd 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -426,6 +426,10 @@ EXPERIMENTAL { # added in 21.08 rte_power_monitor_multi; # WINDOWS_NO_EXPORT + + # added in 21.11 + rte_oops_signals_enabled; # WINDOWS_NO_EXPORT + rte_oops_decode; # WINDOWS_NO_EXPORT }; INTERNAL { -- 2.32.0