Merge ../linux-2.6-watchdog-mm
[firefly-linux-kernel-4.4.55.git] / kernel / timer.c
index b1f40f256eb09c131f27bb8ab6d854e396572bb3..c2a8ccfc288210fb45a3ae199c94572edbbc72b4 100644 (file)
@@ -846,7 +846,7 @@ static int change_clocksource(void)
                clock = new;
                clock->cycle_last = now;
                printk(KERN_INFO "Time: %s clocksource has been installed.\n",
-                                       clock->name);
+                      clock->name);
                return 1;
        } else if (clock->update_callback) {
                return clock->update_callback();
@@ -854,7 +854,10 @@ static int change_clocksource(void)
        return 0;
 }
 #else
-#define change_clocksource() (0)
+static inline int change_clocksource(void)
+{
+       return 0;
+}
 #endif
 
 /**
@@ -952,7 +955,8 @@ device_initcall(timekeeping_init_device);
  * If the error is already larger, we look ahead even further
  * to compensate for late or lost adjustments.
  */
-static __always_inline int clocksource_bigadjust(s64 error, s64 *interval, s64 *offset)
+static __always_inline int clocksource_bigadjust(s64 error, s64 *interval,
+                                                s64 *offset)
 {
        s64 tick_error, i;
        u32 look_ahead, adj;
@@ -976,7 +980,8 @@ static __always_inline int clocksource_bigadjust(s64 error, s64 *interval, s64 *
         * Now calculate the error in (1 << look_ahead) ticks, but first
         * remove the single look ahead already included in the error.
         */
-       tick_error = current_tick_length() >> (TICK_LENGTH_SHIFT - clock->shift + 1);
+       tick_error = current_tick_length() >>
+               (TICK_LENGTH_SHIFT - clock->shift + 1);
        tick_error -= clock->xtime_interval >> 1;
        error = ((error - tick_error) >> look_ahead) + tick_error;
 
@@ -1028,7 +1033,8 @@ static void clocksource_adjust(struct clocksource *clock, s64 offset)
        clock->mult += adj;
        clock->xtime_interval += interval;
        clock->xtime_nsec -= offset;
-       clock->error -= (interval - offset) << (TICK_LENGTH_SHIFT - clock->shift);
+       clock->error -= (interval - offset) <<
+                       (TICK_LENGTH_SHIFT - clock->shift);
 }
 
 /**
@@ -1140,11 +1146,15 @@ static inline void calc_load(unsigned long ticks)
        unsigned long active_tasks; /* fixed-point */
        static int count = LOAD_FREQ;
 
-       active_tasks = count_active_tasks();
-       for (count -= ticks; count < 0; count += LOAD_FREQ) {
-               CALC_LOAD(avenrun[0], EXP_1, active_tasks);
-               CALC_LOAD(avenrun[1], EXP_5, active_tasks);
-               CALC_LOAD(avenrun[2], EXP_15, active_tasks);
+       count -= ticks;
+       if (unlikely(count < 0)) {
+               active_tasks = count_active_tasks();
+               do {
+                       CALC_LOAD(avenrun[0], EXP_1, active_tasks);
+                       CALC_LOAD(avenrun[1], EXP_5, active_tasks);
+                       CALC_LOAD(avenrun[2], EXP_15, active_tasks);
+                       count += LOAD_FREQ;
+               } while (count < 0);
        }
 }
 
@@ -1334,11 +1344,10 @@ fastcall signed long __sched schedule_timeout(signed long timeout)
                 * should never happens anyway). You just have the printk()
                 * that will tell you if something is gone wrong and where.
                 */
-               if (timeout < 0)
-               {
+               if (timeout < 0) {
                        printk(KERN_ERR "schedule_timeout: wrong timeout "
-                               "value %lx from %p\n", timeout,
-                               __builtin_return_address(0));
+                               "value %lx\n", timeout);
+                       dump_stack();
                        current->state = TASK_RUNNING;
                        goto out;
                }