return false;
 }
 
+static void idtentry_exit_cond_resched(struct pt_regs *regs, bool may_sched)
+{
+       if (may_sched && !preempt_count()) {
+               /* Sanity check RCU and thread stack */
+               rcu_irq_exit_check_preempt();
+               if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
+                       WARN_ON_ONCE(!on_thread_stack());
+               if (need_resched())
+                       preempt_schedule_irq();
+       }
+       /* Covers both tracing and lockdep */
+       trace_hardirqs_on();
+}
+
 /**
  * idtentry_exit_cond_rcu - Handle return from exception with conditional RCU
  *                         handling
                }
 
                instrumentation_begin();
-
-               /* Check kernel preemption, if enabled */
-               if (IS_ENABLED(CONFIG_PREEMPTION)) {
-                       if (!preempt_count()) {
-                               /* Sanity check RCU and thread stack */
-                               rcu_irq_exit_check_preempt();
-                               if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
-                                       WARN_ON_ONCE(!on_thread_stack());
-                               if (need_resched())
-                                       preempt_schedule_irq();
-                       }
-               }
-               /* Covers both tracing and lockdep */
-               trace_hardirqs_on();
-
+               idtentry_exit_cond_resched(regs, IS_ENABLED(CONFIG_PREEMPTION));
                instrumentation_end();
        } else {
                /*