aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/timer.c')
-rw-r--r--kernel/timer.c90
1 files changed, 12 insertions, 78 deletions
diff --git a/kernel/timer.c b/kernel/timer.c
index cffffad01c31..faf2db897de4 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -37,6 +37,7 @@
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/tick.h> 38#include <linux/tick.h>
39#include <linux/kallsyms.h> 39#include <linux/kallsyms.h>
40#include <linux/perf_counter.h>
40 41
41#include <asm/uaccess.h> 42#include <asm/uaccess.h>
42#include <asm/unistd.h> 43#include <asm/unistd.h>
@@ -756,6 +757,7 @@ void add_timer_on(struct timer_list *timer, int cpu)
756 wake_up_idle_cpu(cpu); 757 wake_up_idle_cpu(cpu);
757 spin_unlock_irqrestore(&base->lock, flags); 758 spin_unlock_irqrestore(&base->lock, flags);
758} 759}
760EXPORT_SYMBOL_GPL(add_timer_on);
759 761
760/** 762/**
761 * del_timer - deactive a timer. 763 * del_timer - deactive a timer.
@@ -1123,53 +1125,14 @@ void update_process_times(int user_tick)
1123} 1125}
1124 1126
1125/* 1127/*
1126 * Nr of active tasks - counted in fixed-point numbers
1127 */
1128static unsigned long count_active_tasks(void)
1129{
1130 return nr_active() * FIXED_1;
1131}
1132
1133/*
1134 * Hmm.. Changed this, as the GNU make sources (load.c) seems to
1135 * imply that avenrun[] is the standard name for this kind of thing.
1136 * Nothing else seems to be standardized: the fractional size etc
1137 * all seem to differ on different machines.
1138 *
1139 * Requires xtime_lock to access.
1140 */
1141unsigned long avenrun[3];
1142
1143EXPORT_SYMBOL(avenrun);
1144
1145/*
1146 * calc_load - given tick count, update the avenrun load estimates.
1147 * This is called while holding a write_lock on xtime_lock.
1148 */
1149static inline void calc_load(unsigned long ticks)
1150{
1151 unsigned long active_tasks; /* fixed-point */
1152 static int count = LOAD_FREQ;
1153
1154 count -= ticks;
1155 if (unlikely(count < 0)) {
1156 active_tasks = count_active_tasks();
1157 do {
1158 CALC_LOAD(avenrun[0], EXP_1, active_tasks);
1159 CALC_LOAD(avenrun[1], EXP_5, active_tasks);
1160 CALC_LOAD(avenrun[2], EXP_15, active_tasks);
1161 count += LOAD_FREQ;
1162 } while (count < 0);
1163 }
1164}
1165
1166/*
1167 * This function runs timers and the timer-tq in bottom half context. 1128 * This function runs timers and the timer-tq in bottom half context.
1168 */ 1129 */
1169static void run_timer_softirq(struct softirq_action *h) 1130static void run_timer_softirq(struct softirq_action *h)
1170{ 1131{
1171 struct tvec_base *base = __get_cpu_var(tvec_bases); 1132 struct tvec_base *base = __get_cpu_var(tvec_bases);
1172 1133
1134 perf_counter_do_pending();
1135
1173 hrtimer_run_pending(); 1136 hrtimer_run_pending();
1174 1137
1175 if (time_after_eq(jiffies, base->timer_jiffies)) 1138 if (time_after_eq(jiffies, base->timer_jiffies))
@@ -1187,16 +1150,6 @@ void run_local_timers(void)
1187} 1150}
1188 1151
1189/* 1152/*
1190 * Called by the timer interrupt. xtime_lock must already be taken
1191 * by the timer IRQ!
1192 */
1193static inline void update_times(unsigned long ticks)
1194{
1195 update_wall_time();
1196 calc_load(ticks);
1197}
1198
1199/*
1200 * The 64-bit jiffies value is not atomic - you MUST NOT read it 1153 * The 64-bit jiffies value is not atomic - you MUST NOT read it
1201 * without sampling the sequence number in xtime_lock. 1154 * without sampling the sequence number in xtime_lock.
1202 * jiffies is defined in the linker script... 1155 * jiffies is defined in the linker script...
@@ -1205,7 +1158,8 @@ static inline void update_times(unsigned long ticks)
1205void do_timer(unsigned long ticks) 1158void do_timer(unsigned long ticks)
1206{ 1159{
1207 jiffies_64 += ticks; 1160 jiffies_64 += ticks;
1208 update_times(ticks); 1161 update_wall_time();
1162 calc_global_load();
1209} 1163}
1210 1164
1211#ifdef __ARCH_WANT_SYS_ALARM 1165#ifdef __ARCH_WANT_SYS_ALARM
@@ -1406,37 +1360,17 @@ int do_sysinfo(struct sysinfo *info)
1406{ 1360{
1407 unsigned long mem_total, sav_total; 1361 unsigned long mem_total, sav_total;
1408 unsigned int mem_unit, bitcount; 1362 unsigned int mem_unit, bitcount;
1409 unsigned long seq; 1363 struct timespec tp;
1410 1364
1411 memset(info, 0, sizeof(struct sysinfo)); 1365 memset(info, 0, sizeof(struct sysinfo));
1412 1366
1413 do { 1367 ktime_get_ts(&tp);
1414 struct timespec tp; 1368 monotonic_to_bootbased(&tp);
1415 seq = read_seqbegin(&xtime_lock); 1369 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
1416
1417 /*
1418 * This is annoying. The below is the same thing
1419 * posix_get_clock_monotonic() does, but it wants to
1420 * take the lock which we want to cover the loads stuff
1421 * too.
1422 */
1423
1424 getnstimeofday(&tp);
1425 tp.tv_sec += wall_to_monotonic.tv_sec;
1426 tp.tv_nsec += wall_to_monotonic.tv_nsec;
1427 monotonic_to_bootbased(&tp);
1428 if (tp.tv_nsec - NSEC_PER_SEC >= 0) {
1429 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
1430 tp.tv_sec++;
1431 }
1432 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
1433 1370
1434 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT); 1371 get_avenrun(info->loads, 0, SI_LOAD_SHIFT - FSHIFT);
1435 info->loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT);
1436 info->loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT);
1437 1372
1438 info->procs = nr_threads; 1373 info->procs = nr_threads;
1439 } while (read_seqretry(&xtime_lock, seq));
1440 1374
1441 si_meminfo(info); 1375 si_meminfo(info);
1442 si_swapinfo(info); 1376 si_swapinfo(info);