do {                                           \
        __this_cpu_dec(hardirq_context);        \
 } while (0)
-# define lockdep_softirq_enter()               \
-do {                                           \
-       current->softirq_context++;             \
-} while (0)
-# define lockdep_softirq_exit()                        \
-do {                                           \
-       current->softirq_context--;             \
-} while (0)
 
 # define lockdep_hrtimer_enter(__hrtimer)              \
 ({                                                     \
 # define lockdep_irq_work_exit(__work)         do { } while (0)
 #endif
 
+#if defined(CONFIG_TRACE_IRQFLAGS) && !defined(CONFIG_PREEMPT_RT)
+# define lockdep_softirq_enter()               \
+do {                                           \
+       current->softirq_context++;             \
+} while (0)
+# define lockdep_softirq_exit()                        \
+do {                                           \
+       current->softirq_context--;             \
+} while (0)
+
+#else
+# define lockdep_softirq_enter()               do { } while (0)
+# define lockdep_softirq_exit()                        do { } while (0)
+#endif
+
 #if defined(CONFIG_IRQSOFF_TRACER) || \
        defined(CONFIG_PREEMPT_TRACER)
  extern void stop_critical_timings(void);
 
                }
        }
 
+#ifndef CONFIG_PREEMPT_RT
        /*
         * We dont accurately track softirq state in e.g.
         * hardirq contexts (such as on 4KSTACKS), so only
                        DEBUG_LOCKS_WARN_ON(!current->softirqs_enabled);
                }
        }
+#endif
 
        if (!debug_locks)
                print_irqtrace_events(current);