static inline void sched_clock_idle_wakeup_event(u64 delta_ns)
 {
 }
-#else
+
+#ifdef CONFIG_NO_HZ
+static inline void sched_clock_tick_stop(int cpu)
+{
+}
+
+static inline void sched_clock_tick_start(int cpu)
+{
+}
+#endif
+
+#else /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
 extern void sched_clock_init(void);
 extern u64 sched_clock_cpu(int cpu);
 extern void sched_clock_tick(void);
 extern void sched_clock_idle_sleep_event(void);
 extern void sched_clock_idle_wakeup_event(u64 delta_ns);
+#ifdef CONFIG_NO_HZ
+extern void sched_clock_tick_stop(int cpu);
+extern void sched_clock_tick_start(int cpu);
 #endif
+#endif /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
 
 /*
  * For kernel-internal use: high-speed (but slightly incorrect) per-cpu
 
        u64                     tick_raw;
        u64                     tick_gtod;
        u64                     clock;
+#ifdef CONFIG_NO_HZ
+       int                     check_max;
+#endif
 };
 
 static DEFINE_PER_CPU_SHARED_ALIGNED(struct sched_clock_data, sched_clock_data);
                scd->tick_raw = 0;
                scd->tick_gtod = ktime_now;
                scd->clock = ktime_now;
+#ifdef CONFIG_NO_HZ
+               scd->check_max = 1;
+#endif
        }
 
        sched_clock_running = 1;
 }
 
+#ifdef CONFIG_NO_HZ
+/*
+ * The dynamic ticks makes the delta jiffies inaccurate. This
+ * prevents us from checking the maximum time update.
+ * Disable the maximum check during stopped ticks.
+ */
+void sched_clock_tick_stop(int cpu)
+{
+       struct sched_clock_data *scd = cpu_sdc(cpu);
+
+       scd->check_max = 0;
+}
+
+void sched_clock_tick_start(int cpu)
+{
+       struct sched_clock_data *scd = cpu_sdc(cpu);
+
+       scd->check_max = 1;
+}
+
+static int check_max(struct sched_clock_data *scd)
+{
+       return scd->check_max;
+}
+#else
+static int check_max(struct sched_clock_data *scd)
+{
+       return 1;
+}
+#endif /* CONFIG_NO_HZ */
+
 /*
  * update the percpu scd from the raw @now value
  *
         */
        max_clock = scd->tick_gtod + (2 + delta_jiffies) * TICK_NSEC;
 
-       if (unlikely(clock + delta > max_clock)) {
+       if (unlikely(clock + delta > max_clock) && check_max(scd)) {
                if (clock < max_clock)
                        clock = max_clock;
                else
 
                        ts->tick_stopped = 1;
                        ts->idle_jiffies = last_jiffies;
                        rcu_enter_nohz();
+                       sched_clock_tick_stop(cpu);
                }
 
                /*
        select_nohz_load_balancer(0);
        now = ktime_get();
        tick_do_update_jiffies64(now);
+       sched_clock_tick_start(cpu);
        cpu_clear(cpu, nohz_cpu_mask);
 
        /*