tick/common: Align tick period during sched_timer setup
[platform/kernel/linux-starfive.git] / kernel / time / tick-sched.c
index b0e3c92..d6fb6a6 100644 (file)
@@ -161,8 +161,19 @@ static ktime_t tick_init_jiffy_update(void)
        raw_spin_lock(&jiffies_lock);
        write_seqcount_begin(&jiffies_seq);
        /* Did we start the jiffies update yet ? */
-       if (last_jiffies_update == 0)
+       if (last_jiffies_update == 0) {
+               u32 rem;
+
+               /*
+                * Ensure that the tick is aligned to a multiple of
+                * TICK_NSEC.
+                */
+               div_u64_rem(tick_next_period, TICK_NSEC, &rem);
+               if (rem)
+                       tick_next_period += TICK_NSEC - rem;
+
                last_jiffies_update = tick_next_period;
+       }
        period = last_jiffies_update;
        write_seqcount_end(&jiffies_seq);
        raw_spin_unlock(&jiffies_lock);
@@ -281,6 +292,11 @@ static bool check_tick_dependency(atomic_t *dep)
                return true;
        }
 
+       if (val & TICK_DEP_MASK_RCU_EXP) {
+               trace_tick_stop(0, TICK_DEP_MASK_RCU_EXP);
+               return true;
+       }
+
        return false;
 }
 
@@ -527,7 +543,7 @@ void __init tick_nohz_full_setup(cpumask_var_t cpumask)
        tick_nohz_full_running = true;
 }
 
-static int tick_nohz_cpu_down(unsigned int cpu)
+bool tick_nohz_cpu_hotpluggable(unsigned int cpu)
 {
        /*
         * The tick_do_timer_cpu CPU handles housekeeping duty (unbound
@@ -535,8 +551,13 @@ static int tick_nohz_cpu_down(unsigned int cpu)
         * CPUs. It must remain online when nohz full is enabled.
         */
        if (tick_nohz_full_running && tick_do_timer_cpu == cpu)
-               return -EBUSY;
-       return 0;
+               return false;
+       return true;
+}
+
+static int tick_nohz_cpu_down(unsigned int cpu)
+{
+       return tick_nohz_cpu_hotpluggable(cpu) ? 0 : -EBUSY;
 }
 
 void __init tick_nohz_init(void)