Whamcloud - gitweb
LU-8130 libcfs: prepare rhashtable support
[fs/lustre-release.git] / libcfs / include / libcfs / libcfs_debug.h
index 67d76cd..e847b90 100644 (file)
@@ -38,6 +38,8 @@
 #ifndef __LIBCFS_DEBUG_H__
 #define __LIBCFS_DEBUG_H__
 
+#include <stdarg.h>
+#include <linux/limits.h>
 #include <uapi/linux/lnet/libcfs_debug.h>
 
 /*
@@ -105,6 +107,37 @@ 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(msgdata, mask, cdls)                             \
+do {                                                                   \
+       if (unlikely(CDEBUG_STACK() > libcfs_stack)) {                  \
+               LIBCFS_DEBUG_MSG_DATA_INIT(msgdata, D_WARNING, NULL);   \
+               libcfs_stack = CDEBUG_STACK();                          \
+               libcfs_debug_msg(msgdata,                               \
+                                "maximum lustre stack %lu\n",          \
+                                CDEBUG_STACK());                       \
+               (msgdata)->msg_mask = mask;                             \
+               (msgdata)->msg_cdls = cdls;                             \
+               dump_stack();                                           \
+               /*panic("LBUG");*/                                      \
+       }                                                               \
+} while (0)
+#define CFS_CHECK_STACK(msgdata, mask, cdls)  __CHECK_STACK(msgdata, mask, cdls)
+#else /* __x86_64__ */
+#define CFS_CHECK_STACK(msgdata, mask, cdls) do {} while (0)
+#define CDEBUG_STACK() (0L)
+#endif /* __x86_64__ */
+
 /**
  * Filters out logging messages based on mask and subsystem.
  */