From edb968d04f3a3c8054c12daee1ba557f855055ce Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Mon, 30 Oct 2023 02:18:01 +0000 Subject: [PATCH] LU-17242 debug: remove CFS_CHECK_STACK CFS_CHECK_STACK is primitive, doesn't work on x86_64, and only dumps a stack in kernel log when we are fairly close to passing the stack limit anyway. Admins and developers can grab the same info from debug/tracing/stack_trace and debug/tracing/stack_max_size on a live system. And the kernel will dump a stack if it 'Oops' from going over the stack limit. We don't need an additional Lustre specific stack checking mechanism. Test-Parameters: trivial Signed-off-by: Timothy Day Change-Id: Icc7c82f6a0dcd727de6ce2c2d40ba071ee349c0c Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52883 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Reviewed-by: Neil Brown Tested-by: jenkins Tested-by: Maloo --- libcfs/include/libcfs/libcfs_debug.h | 37 ------------------------------------ libcfs/libcfs/debug.c | 3 --- libcfs/libcfs/tracefile.c | 8 +++----- lnet/klnds/gnilnd/gnilnd.h | 6 ------ lnet/klnds/gnilnd/gnilnd_api_wrap.h | 1 - lustre/include/lustre_dlm.h | 2 -- lustre/include/lustre_net.h | 2 -- lustre/quota/lquota_internal.h | 2 -- 8 files changed, 3 insertions(+), 58 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_debug.h b/libcfs/include/libcfs/libcfs_debug.h index 705e8cd..404bc45 100644 --- a/libcfs/include/libcfs/libcfs_debug.h +++ b/libcfs/include/libcfs/libcfs_debug.h @@ -45,7 +45,6 @@ * Debugging */ extern unsigned int libcfs_subsystem_debug; -extern unsigned int libcfs_stack; extern unsigned int libcfs_debug; extern unsigned int libcfs_printk; extern unsigned int libcfs_watchdog_ratelimit; @@ -113,40 +112,6 @@ do { \ #ifdef CDEBUG_ENABLED -#if !defined(__x86_64__) -# ifdef __ia64__ -# define CDEBUG_STACK() (THREAD_SIZE - \ - ((unsigned long)__builtin_dwarf_cfa() & \ - (THREAD_SIZE - 1))) -# else -# define CDEBUG_STACK() (THREAD_SIZE - \ - ((unsigned long)__builtin_frame_address(0) & \ - (THREAD_SIZE - 1))) -# endif /* __ia64__ */ - -#define __CHECK_STACK_WITH_LOC(file, func, line, msgdata, mask, cdls) \ -do { \ - if (unlikely(CDEBUG_STACK() > libcfs_stack)) { \ - LIBCFS_DEBUG_MSG_DATA_INIT(file, func, line, msgdata, \ - D_WARNING, NULL); \ - libcfs_stack = CDEBUG_STACK(); \ - libcfs_debug_msg(msgdata, "maximum lustre stack %u\n", \ - libcfs_stack); \ - (msgdata)->msg_mask = mask; \ - (msgdata)->msg_cdls = cdls; \ - dump_stack(); \ - /*panic("LBUG");*/ \ - } \ -} while (0) -#else /* __x86_64__ */ -#define CDEBUG_STACK() (0L) -#define __CHECK_STACK_WITH_LOC(file, func, line, msgdata, mask, cdls) \ - do {} while (0) -#endif /* __x86_64__ */ - -#define CFS_CHECK_STACK(msgdata, mask, cdls) \ - __CHECK_STACK_WITH_LOC(__FILE__, __func__, __LINE__, \ - msgdata, mask, cdls) /** * Filters out logging messages based on mask and subsystem. */ @@ -160,8 +125,6 @@ static inline int cfs_cdebug_show(unsigned int mask, unsigned int subsystem) do { \ static struct libcfs_debug_msg_data msgdata; \ \ - __CHECK_STACK_WITH_LOC(file, func, line, &msgdata, mask, cdls); \ - \ if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM)) { \ LIBCFS_DEBUG_MSG_DATA_INIT(file, func, line, \ &msgdata, mask, cdls); \ diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index 38dc64c..93bef6b 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -235,9 +235,6 @@ MODULE_PARM_DESC(libcfs_console_backoff, "Lustre kernel debug console backoff fa unsigned int libcfs_debug_binary = 1; -unsigned int libcfs_stack = 3 * THREAD_SIZE / 4; -EXPORT_SYMBOL(libcfs_stack); - unsigned int libcfs_catastrophe; EXPORT_SYMBOL(libcfs_catastrophe); diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index acb8389..00a68b3 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -305,8 +305,7 @@ static struct cfs_trace_page *cfs_trace_get_tage(struct cfs_trace_cpu_data *tcd, } static void cfs_set_ptldebug_header(struct ptldebug_header *header, - struct libcfs_debug_msg_data *msgdata, - unsigned long stack) + struct libcfs_debug_msg_data *msgdata) { struct timespec64 ts; @@ -321,7 +320,6 @@ static void cfs_set_ptldebug_header(struct ptldebug_header *header, */ header->ph_sec = (u32)ts.tv_sec; header->ph_usec = ts.tv_nsec / NSEC_PER_USEC; - header->ph_stack = stack; header->ph_pid = current->pid; header->ph_line_num = msgdata->msg_line; header->ph_extern_pid = 0; @@ -403,7 +401,7 @@ int libcfs_debug_msg(struct libcfs_debug_msg_data *msgdata, * pins us to a particular CPU. This avoids an smp_processor_id() * warning on Linux when debugging is enabled. */ - cfs_set_ptldebug_header(&header, msgdata, CDEBUG_STACK()); + cfs_set_ptldebug_header(&header, msgdata); if (!tcd) /* arch may not log in IRQ context */ goto console; @@ -573,7 +571,7 @@ cfs_trace_assertion_failed(const char *str, libcfs_catastrophe = 1; smp_mb(); - cfs_set_ptldebug_header(&hdr, msgdata, CDEBUG_STACK()); + cfs_set_ptldebug_header(&hdr, msgdata); cfs_print_to_console(&hdr, D_EMERG, msgdata->msg_file, msgdata->msg_fn, "%s", str); diff --git a/lnet/klnds/gnilnd/gnilnd.h b/lnet/klnds/gnilnd/gnilnd.h index 3dde41f..b9ee43a 100644 --- a/lnet/klnds/gnilnd/gnilnd.h +++ b/lnet/klnds/gnilnd/gnilnd.h @@ -1034,8 +1034,6 @@ _kgnilnd_debug_msg(kgn_msg_t *msg, #define kgnilnd_debug_msg(msgdata, mask, cdls, msg, fmt, a...) \ do { \ - CFS_CHECK_STACK(msgdata, mask, cdls); \ - \ if (((mask) & D_CANTMASK) != 0 || \ ((libcfs_debug & (mask)) != 0 && \ (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) \ @@ -1080,8 +1078,6 @@ _kgnilnd_debug_conn(kgn_conn_t *conn, #define kgnilnd_debug_conn(msgdata, mask, cdls, conn, fmt, a...) \ do { \ - CFS_CHECK_STACK(msgdata, mask, cdls); \ - \ if (((mask) & D_CANTMASK) != 0 || \ ((libcfs_debug & (mask)) != 0 && \ (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) \ @@ -1109,8 +1105,6 @@ _kgnilnd_debug_tx(kgn_tx_t *tx, #define kgnilnd_debug_tx(msgdata, mask, cdls, tx, fmt, a...) \ do { \ - CFS_CHECK_STACK(msgdata, mask, cdls); \ - \ if (((mask) & D_CANTMASK) != 0 || \ ((libcfs_debug & (mask)) != 0 && \ (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) \ diff --git a/lnet/klnds/gnilnd/gnilnd_api_wrap.h b/lnet/klnds/gnilnd/gnilnd_api_wrap.h index b711a0d..91b822c 100644 --- a/lnet/klnds/gnilnd/gnilnd_api_wrap.h +++ b/lnet/klnds/gnilnd/gnilnd_api_wrap.h @@ -112,7 +112,6 @@ _kgnilnd_api_rc_lbug(const char *rcstr, int rc, struct libcfs_debug_msg_data *da #define kgnilnd_api_rc_lbug(msgdata, rc, fmt, a...) \ do { \ - CFS_CHECK_STACK(msgdata, D_ERROR, NULL); \ /* we don't mask this - it is always at D_ERROR */ \ _kgnilnd_api_rc_lbug(kgnilnd_api_rc2str(rc), (rc), msgdata, fmt, ##a); \ } while (0) diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 38776a2..82e7a55 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -1298,8 +1298,6 @@ extern const char *ldlm_it2str(enum ldlm_intent_flags it); */ #ifdef LIBCFS_DEBUG #define ldlm_lock_debug(msgdata, mask, cdls, lock, fmt, a...) do { \ - CFS_CHECK_STACK(msgdata, mask, cdls); \ - \ if (((mask) & D_CANTMASK) != 0 || \ ((libcfs_debug & (mask)) != 0 && \ (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) \ diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index acf8b2a..4b12182 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -1289,8 +1289,6 @@ void _debug_req(struct ptlrpc_request *req, */ #define debug_req(msgdata, mask, cdls, req, fmt, a...) \ do { \ - CFS_CHECK_STACK(msgdata, mask, cdls); \ - \ if (((mask) & D_CANTMASK) != 0 || \ ((libcfs_debug & (mask)) != 0 && \ (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) \ diff --git a/lustre/quota/lquota_internal.h b/lustre/quota/lquota_internal.h index a0b3c6a..734cd1f 100644 --- a/lustre/quota/lquota_internal.h +++ b/lustre/quota/lquota_internal.h @@ -378,8 +378,6 @@ struct lquota_thread_info *lquota_info(const struct lu_env *env) /* debugging macros */ #ifdef LIBCFS_DEBUG #define lquota_lqe_debug(msgdata, mask, cdls, lqe, fmt, a...) do { \ - CFS_CHECK_STACK(msgdata, mask, cdls); \ - \ if (((mask) & D_CANTMASK) != 0 || \ ((libcfs_debug & (mask)) != 0 && \ (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) \ -- 1.8.3.1