aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/timer.c')
-rw-r--r--kernel/timer.c84
1 files changed, 46 insertions, 38 deletions
diff --git a/kernel/timer.c b/kernel/timer.c
index c2a8ccfc2882..8533c3796082 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -85,7 +85,7 @@ static DEFINE_PER_CPU(tvec_base_t *, tvec_bases) = &boot_tvec_bases;
85 * @j: the time in (absolute) jiffies that should be rounded 85 * @j: the time in (absolute) jiffies that should be rounded
86 * @cpu: the processor number on which the timeout will happen 86 * @cpu: the processor number on which the timeout will happen
87 * 87 *
88 * __round_jiffies rounds an absolute time in the future (in jiffies) 88 * __round_jiffies() rounds an absolute time in the future (in jiffies)
89 * up or down to (approximately) full seconds. This is useful for timers 89 * up or down to (approximately) full seconds. This is useful for timers
90 * for which the exact time they fire does not matter too much, as long as 90 * for which the exact time they fire does not matter too much, as long as
91 * they fire approximately every X seconds. 91 * they fire approximately every X seconds.
@@ -98,7 +98,7 @@ static DEFINE_PER_CPU(tvec_base_t *, tvec_bases) = &boot_tvec_bases;
98 * processors firing at the exact same time, which could lead 98 * processors firing at the exact same time, which could lead
99 * to lock contention or spurious cache line bouncing. 99 * to lock contention or spurious cache line bouncing.
100 * 100 *
101 * The return value is the rounded version of the "j" parameter. 101 * The return value is the rounded version of the @j parameter.
102 */ 102 */
103unsigned long __round_jiffies(unsigned long j, int cpu) 103unsigned long __round_jiffies(unsigned long j, int cpu)
104{ 104{
@@ -142,7 +142,7 @@ EXPORT_SYMBOL_GPL(__round_jiffies);
142 * @j: the time in (relative) jiffies that should be rounded 142 * @j: the time in (relative) jiffies that should be rounded
143 * @cpu: the processor number on which the timeout will happen 143 * @cpu: the processor number on which the timeout will happen
144 * 144 *
145 * __round_jiffies_relative rounds a time delta in the future (in jiffies) 145 * __round_jiffies_relative() rounds a time delta in the future (in jiffies)
146 * up or down to (approximately) full seconds. This is useful for timers 146 * up or down to (approximately) full seconds. This is useful for timers
147 * for which the exact time they fire does not matter too much, as long as 147 * for which the exact time they fire does not matter too much, as long as
148 * they fire approximately every X seconds. 148 * they fire approximately every X seconds.
@@ -155,7 +155,7 @@ EXPORT_SYMBOL_GPL(__round_jiffies);
155 * processors firing at the exact same time, which could lead 155 * processors firing at the exact same time, which could lead
156 * to lock contention or spurious cache line bouncing. 156 * to lock contention or spurious cache line bouncing.
157 * 157 *
158 * The return value is the rounded version of the "j" parameter. 158 * The return value is the rounded version of the @j parameter.
159 */ 159 */
160unsigned long __round_jiffies_relative(unsigned long j, int cpu) 160unsigned long __round_jiffies_relative(unsigned long j, int cpu)
161{ 161{
@@ -173,7 +173,7 @@ EXPORT_SYMBOL_GPL(__round_jiffies_relative);
173 * round_jiffies - function to round jiffies to a full second 173 * round_jiffies - function to round jiffies to a full second
174 * @j: the time in (absolute) jiffies that should be rounded 174 * @j: the time in (absolute) jiffies that should be rounded
175 * 175 *
176 * round_jiffies rounds an absolute time in the future (in jiffies) 176 * round_jiffies() rounds an absolute time in the future (in jiffies)
177 * up or down to (approximately) full seconds. This is useful for timers 177 * up or down to (approximately) full seconds. This is useful for timers
178 * for which the exact time they fire does not matter too much, as long as 178 * for which the exact time they fire does not matter too much, as long as
179 * they fire approximately every X seconds. 179 * they fire approximately every X seconds.
@@ -182,7 +182,7 @@ EXPORT_SYMBOL_GPL(__round_jiffies_relative);
182 * at the same time, rather than at various times spread out. The goal 182 * at the same time, rather than at various times spread out. The goal
183 * of this is to have the CPU wake up less, which saves power. 183 * of this is to have the CPU wake up less, which saves power.
184 * 184 *
185 * The return value is the rounded version of the "j" parameter. 185 * The return value is the rounded version of the @j parameter.
186 */ 186 */
187unsigned long round_jiffies(unsigned long j) 187unsigned long round_jiffies(unsigned long j)
188{ 188{
@@ -194,7 +194,7 @@ EXPORT_SYMBOL_GPL(round_jiffies);
194 * round_jiffies_relative - function to round jiffies to a full second 194 * round_jiffies_relative - function to round jiffies to a full second
195 * @j: the time in (relative) jiffies that should be rounded 195 * @j: the time in (relative) jiffies that should be rounded
196 * 196 *
197 * round_jiffies_relative rounds a time delta in the future (in jiffies) 197 * round_jiffies_relative() rounds a time delta in the future (in jiffies)
198 * up or down to (approximately) full seconds. This is useful for timers 198 * up or down to (approximately) full seconds. This is useful for timers
199 * for which the exact time they fire does not matter too much, as long as 199 * for which the exact time they fire does not matter too much, as long as
200 * they fire approximately every X seconds. 200 * they fire approximately every X seconds.
@@ -203,7 +203,7 @@ EXPORT_SYMBOL_GPL(round_jiffies);
203 * at the same time, rather than at various times spread out. The goal 203 * at the same time, rather than at various times spread out. The goal
204 * of this is to have the CPU wake up less, which saves power. 204 * of this is to have the CPU wake up less, which saves power.
205 * 205 *
206 * The return value is the rounded version of the "j" parameter. 206 * The return value is the rounded version of the @j parameter.
207 */ 207 */
208unsigned long round_jiffies_relative(unsigned long j) 208unsigned long round_jiffies_relative(unsigned long j)
209{ 209{
@@ -387,7 +387,7 @@ void add_timer_on(struct timer_list *timer, int cpu)
387 * @timer: the timer to be modified 387 * @timer: the timer to be modified
388 * @expires: new timeout in jiffies 388 * @expires: new timeout in jiffies
389 * 389 *
390 * mod_timer is a more efficient way to update the expire field of an 390 * mod_timer() is a more efficient way to update the expire field of an
391 * active timer (if the timer is inactive it will be activated) 391 * active timer (if the timer is inactive it will be activated)
392 * 392 *
393 * mod_timer(timer, expires) is equivalent to: 393 * mod_timer(timer, expires) is equivalent to:
@@ -490,7 +490,7 @@ out:
490 * the timer it also makes sure the handler has finished executing on other 490 * the timer it also makes sure the handler has finished executing on other
491 * CPUs. 491 * CPUs.
492 * 492 *
493 * Synchronization rules: callers must prevent restarting of the timer, 493 * Synchronization rules: Callers must prevent restarting of the timer,
494 * otherwise this function is meaningless. It must not be called from 494 * otherwise this function is meaningless. It must not be called from
495 * interrupt contexts. The caller must not hold locks which would prevent 495 * interrupt contexts. The caller must not hold locks which would prevent
496 * completion of the timer's handler. The timer's handler must not call 496 * completion of the timer's handler. The timer's handler must not call
@@ -1392,17 +1392,16 @@ asmlinkage long sys_gettid(void)
1392} 1392}
1393 1393
1394/** 1394/**
1395 * sys_sysinfo - fill in sysinfo struct 1395 * do_sysinfo - fill in sysinfo struct
1396 * @info: pointer to buffer to fill 1396 * @info: pointer to buffer to fill
1397 */ 1397 */
1398asmlinkage long sys_sysinfo(struct sysinfo __user *info) 1398int do_sysinfo(struct sysinfo *info)
1399{ 1399{
1400 struct sysinfo val;
1401 unsigned long mem_total, sav_total; 1400 unsigned long mem_total, sav_total;
1402 unsigned int mem_unit, bitcount; 1401 unsigned int mem_unit, bitcount;
1403 unsigned long seq; 1402 unsigned long seq;
1404 1403
1405 memset((char *)&val, 0, sizeof(struct sysinfo)); 1404 memset(info, 0, sizeof(struct sysinfo));
1406 1405
1407 do { 1406 do {
1408 struct timespec tp; 1407 struct timespec tp;
@@ -1422,17 +1421,17 @@ asmlinkage long sys_sysinfo(struct sysinfo __user *info)
1422 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC; 1421 tp.tv_nsec = tp.tv_nsec - NSEC_PER_SEC;
1423 tp.tv_sec++; 1422 tp.tv_sec++;
1424 } 1423 }
1425 val.uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0); 1424 info->uptime = tp.tv_sec + (tp.tv_nsec ? 1 : 0);
1426 1425
1427 val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT); 1426 info->loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT);
1428 val.loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT); 1427 info->loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT);
1429 val.loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT); 1428 info->loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT);
1430 1429
1431 val.procs = nr_threads; 1430 info->procs = nr_threads;
1432 } while (read_seqretry(&xtime_lock, seq)); 1431 } while (read_seqretry(&xtime_lock, seq));
1433 1432
1434 si_meminfo(&val); 1433 si_meminfo(info);
1435 si_swapinfo(&val); 1434 si_swapinfo(info);
1436 1435
1437 /* 1436 /*
1438 * If the sum of all the available memory (i.e. ram + swap) 1437 * If the sum of all the available memory (i.e. ram + swap)
@@ -1443,11 +1442,11 @@ asmlinkage long sys_sysinfo(struct sysinfo __user *info)
1443 * -Erik Andersen <andersee@debian.org> 1442 * -Erik Andersen <andersee@debian.org>
1444 */ 1443 */
1445 1444
1446 mem_total = val.totalram + val.totalswap; 1445 mem_total = info->totalram + info->totalswap;
1447 if (mem_total < val.totalram || mem_total < val.totalswap) 1446 if (mem_total < info->totalram || mem_total < info->totalswap)
1448 goto out; 1447 goto out;
1449 bitcount = 0; 1448 bitcount = 0;
1450 mem_unit = val.mem_unit; 1449 mem_unit = info->mem_unit;
1451 while (mem_unit > 1) { 1450 while (mem_unit > 1) {
1452 bitcount++; 1451 bitcount++;
1453 mem_unit >>= 1; 1452 mem_unit >>= 1;
@@ -1459,22 +1458,31 @@ asmlinkage long sys_sysinfo(struct sysinfo __user *info)
1459 1458
1460 /* 1459 /*
1461 * If mem_total did not overflow, multiply all memory values by 1460 * If mem_total did not overflow, multiply all memory values by
1462 * val.mem_unit and set it to 1. This leaves things compatible 1461 * info->mem_unit and set it to 1. This leaves things compatible
1463 * with 2.2.x, and also retains compatibility with earlier 2.4.x 1462 * with 2.2.x, and also retains compatibility with earlier 2.4.x
1464 * kernels... 1463 * kernels...
1465 */ 1464 */
1466 1465
1467 val.mem_unit = 1; 1466 info->mem_unit = 1;
1468 val.totalram <<= bitcount; 1467 info->totalram <<= bitcount;
1469 val.freeram <<= bitcount; 1468 info->freeram <<= bitcount;
1470 val.sharedram <<= bitcount; 1469 info->sharedram <<= bitcount;
1471 val.bufferram <<= bitcount; 1470 info->bufferram <<= bitcount;
1472 val.totalswap <<= bitcount; 1471 info->totalswap <<= bitcount;
1473 val.freeswap <<= bitcount; 1472 info->freeswap <<= bitcount;
1474 val.totalhigh <<= bitcount; 1473 info->totalhigh <<= bitcount;
1475 val.freehigh <<= bitcount; 1474 info->freehigh <<= bitcount;
1475
1476out:
1477 return 0;
1478}
1479
1480asmlinkage long sys_sysinfo(struct sysinfo __user *info)
1481{
1482 struct sysinfo val;
1483
1484 do_sysinfo(&val);
1476 1485
1477 out:
1478 if (copy_to_user(info, &val, sizeof(struct sysinfo))) 1486 if (copy_to_user(info, &val, sizeof(struct sysinfo)))
1479 return -EFAULT; 1487 return -EFAULT;
1480 1488
@@ -1624,7 +1632,7 @@ struct time_interpolator *time_interpolator __read_mostly;
1624static struct time_interpolator *time_interpolator_list __read_mostly; 1632static struct time_interpolator *time_interpolator_list __read_mostly;
1625static DEFINE_SPINLOCK(time_interpolator_lock); 1633static DEFINE_SPINLOCK(time_interpolator_lock);
1626 1634
1627static inline u64 time_interpolator_get_cycles(unsigned int src) 1635static inline cycles_t time_interpolator_get_cycles(unsigned int src)
1628{ 1636{
1629 unsigned long (*x)(void); 1637 unsigned long (*x)(void);
1630 1638
@@ -1650,8 +1658,8 @@ static inline u64 time_interpolator_get_counter(int writelock)
1650 1658
1651 if (time_interpolator->jitter) 1659 if (time_interpolator->jitter)
1652 { 1660 {
1653 u64 lcycle; 1661 cycles_t lcycle;
1654 u64 now; 1662 cycles_t now;
1655 1663
1656 do { 1664 do {
1657 lcycle = time_interpolator->last_cycle; 1665 lcycle = time_interpolator->last_cycle;