Whamcloud - gitweb
LU-17242 debug: remove CFS_CHECK_STACK 83/52883/3
authorTimothy Day <timday@amazon.com>
Mon, 30 Oct 2023 02:18:01 +0000 (02:18 +0000)
committerOleg Drokin <green@whamcloud.com>
Wed, 8 Nov 2023 22:06:26 +0000 (22:06 +0000)
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 <timday@amazon.com>
Change-Id: Icc7c82f6a0dcd727de6ce2c2d40ba071ee349c0c
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52883
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
libcfs/include/libcfs/libcfs_debug.h
libcfs/libcfs/debug.c
libcfs/libcfs/tracefile.c
lnet/klnds/gnilnd/gnilnd.h
lnet/klnds/gnilnd/gnilnd_api_wrap.h
lustre/include/lustre_dlm.h
lustre/include/lustre_net.h
lustre/quota/lquota_internal.h

index 705e8cd..404bc45 100644 (file)
@@ -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);       \
index 38dc64c..93bef6b 100644 (file)
@@ -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);
 
index acb8389..00a68b3 100644 (file)
@@ -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);
index 3dde41f..b9ee43a 100644 (file)
@@ -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))                 \
index b711a0d..91b822c 100644 (file)
@@ -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)
index 38776a2..82e7a55 100644 (file)
@@ -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))          \
index acf8b2a..4b12182 100644 (file)
@@ -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))                \
index a0b3c6a..734cd1f 100644 (file)
@@ -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))          \