diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-03-01 02:55:20 -0500 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-03-01 02:55:20 -0500 |
| commit | 35858adbfca13678af99fb31618ef4428d6dedb0 (patch) | |
| tree | 3336feaa61324486945816cb52c347733e7c0821 /kernel/time | |
| parent | 197d4db752e67160d79fed09968c2140376a80a3 (diff) | |
| parent | 4b70858ba8d4537daf782defebe5f2ff80ccef2b (diff) | |
Merge branch 'next' into for-linus
Diffstat (limited to 'kernel/time')
| -rw-r--r-- | kernel/time/clockevents.c | 32 | ||||
| -rw-r--r-- | kernel/time/tick-broadcast.c | 42 | ||||
| -rw-r--r-- | kernel/time/tick-common.c | 20 | ||||
| -rw-r--r-- | kernel/time/tick-internal.h | 1 | ||||
| -rw-r--r-- | kernel/time/timecompare.c | 2 | ||||
| -rw-r--r-- | kernel/time/timekeeping.c | 27 | ||||
| -rw-r--r-- | kernel/time/timer_list.c | 10 | ||||
| -rw-r--r-- | kernel/time/timer_stats.c | 17 |
8 files changed, 91 insertions, 60 deletions
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index 20a8920029ee..6f740d9f0948 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c | |||
| @@ -30,7 +30,7 @@ static LIST_HEAD(clockevents_released); | |||
| 30 | static RAW_NOTIFIER_HEAD(clockevents_chain); | 30 | static RAW_NOTIFIER_HEAD(clockevents_chain); |
| 31 | 31 | ||
| 32 | /* Protection for the above */ | 32 | /* Protection for the above */ |
| 33 | static DEFINE_SPINLOCK(clockevents_lock); | 33 | static DEFINE_RAW_SPINLOCK(clockevents_lock); |
| 34 | 34 | ||
| 35 | /** | 35 | /** |
| 36 | * clockevents_delta2ns - Convert a latch value (device ticks) to nanoseconds | 36 | * clockevents_delta2ns - Convert a latch value (device ticks) to nanoseconds |
| @@ -141,9 +141,9 @@ int clockevents_register_notifier(struct notifier_block *nb) | |||
| 141 | unsigned long flags; | 141 | unsigned long flags; |
| 142 | int ret; | 142 | int ret; |
| 143 | 143 | ||
| 144 | spin_lock_irqsave(&clockevents_lock, flags); | 144 | raw_spin_lock_irqsave(&clockevents_lock, flags); |
| 145 | ret = raw_notifier_chain_register(&clockevents_chain, nb); | 145 | ret = raw_notifier_chain_register(&clockevents_chain, nb); |
| 146 | spin_unlock_irqrestore(&clockevents_lock, flags); | 146 | raw_spin_unlock_irqrestore(&clockevents_lock, flags); |
| 147 | 147 | ||
| 148 | return ret; | 148 | return ret; |
| 149 | } | 149 | } |
| @@ -185,13 +185,13 @@ void clockevents_register_device(struct clock_event_device *dev) | |||
| 185 | BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED); | 185 | BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED); |
| 186 | BUG_ON(!dev->cpumask); | 186 | BUG_ON(!dev->cpumask); |
| 187 | 187 | ||
| 188 | spin_lock_irqsave(&clockevents_lock, flags); | 188 | raw_spin_lock_irqsave(&clockevents_lock, flags); |
| 189 | 189 | ||
| 190 | list_add(&dev->list, &clockevent_devices); | 190 | list_add(&dev->list, &clockevent_devices); |
| 191 | clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev); | 191 | clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev); |
| 192 | clockevents_notify_released(); | 192 | clockevents_notify_released(); |
| 193 | 193 | ||
| 194 | spin_unlock_irqrestore(&clockevents_lock, flags); | 194 | raw_spin_unlock_irqrestore(&clockevents_lock, flags); |
| 195 | } | 195 | } |
| 196 | EXPORT_SYMBOL_GPL(clockevents_register_device); | 196 | EXPORT_SYMBOL_GPL(clockevents_register_device); |
| 197 | 197 | ||
| @@ -238,10 +238,11 @@ void clockevents_exchange_device(struct clock_event_device *old, | |||
| 238 | */ | 238 | */ |
| 239 | void clockevents_notify(unsigned long reason, void *arg) | 239 | void clockevents_notify(unsigned long reason, void *arg) |
| 240 | { | 240 | { |
| 241 | struct list_head *node, *tmp; | 241 | struct clock_event_device *dev, *tmp; |
| 242 | unsigned long flags; | 242 | unsigned long flags; |
| 243 | int cpu; | ||
| 243 | 244 | ||
| 244 | spin_lock_irqsave(&clockevents_lock, flags); | 245 | raw_spin_lock_irqsave(&clockevents_lock, flags); |
| 245 | clockevents_do_notify(reason, arg); | 246 | clockevents_do_notify(reason, arg); |
| 246 | 247 | ||
| 247 | switch (reason) { | 248 | switch (reason) { |
| @@ -250,13 +251,24 @@ void clockevents_notify(unsigned long reason, void *arg) | |||
| 250 | * Unregister the clock event devices which were | 251 | * Unregister the clock event devices which were |
| 251 | * released from the users in the notify chain. | 252 | * released from the users in the notify chain. |
| 252 | */ | 253 | */ |
| 253 | list_for_each_safe(node, tmp, &clockevents_released) | 254 | list_for_each_entry_safe(dev, tmp, &clockevents_released, list) |
| 254 | list_del(node); | 255 | list_del(&dev->list); |
| 256 | /* | ||
| 257 | * Now check whether the CPU has left unused per cpu devices | ||
| 258 | */ | ||
| 259 | cpu = *((int *)arg); | ||
| 260 | list_for_each_entry_safe(dev, tmp, &clockevent_devices, list) { | ||
| 261 | if (cpumask_test_cpu(cpu, dev->cpumask) && | ||
| 262 | cpumask_weight(dev->cpumask) == 1) { | ||
| 263 | BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED); | ||
| 264 | list_del(&dev->list); | ||
| 265 | } | ||
| 266 | } | ||
| 255 | break; | 267 | break; |
| 256 | default: | 268 | default: |
| 257 | break; | 269 | break; |
| 258 | } | 270 | } |
| 259 | spin_unlock_irqrestore(&clockevents_lock, flags); | 271 | raw_spin_unlock_irqrestore(&clockevents_lock, flags); |
| 260 | } | 272 | } |
| 261 | EXPORT_SYMBOL_GPL(clockevents_notify); | 273 | EXPORT_SYMBOL_GPL(clockevents_notify); |
| 262 | #endif | 274 | #endif |
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c index c2ec25087a35..b3bafd5fc66d 100644 --- a/kernel/time/tick-broadcast.c +++ b/kernel/time/tick-broadcast.c | |||
| @@ -31,7 +31,7 @@ static struct tick_device tick_broadcast_device; | |||
| 31 | /* FIXME: Use cpumask_var_t. */ | 31 | /* FIXME: Use cpumask_var_t. */ |
| 32 | static DECLARE_BITMAP(tick_broadcast_mask, NR_CPUS); | 32 | static DECLARE_BITMAP(tick_broadcast_mask, NR_CPUS); |
| 33 | static DECLARE_BITMAP(tmpmask, NR_CPUS); | 33 | static DECLARE_BITMAP(tmpmask, NR_CPUS); |
| 34 | static DEFINE_SPINLOCK(tick_broadcast_lock); | 34 | static DEFINE_RAW_SPINLOCK(tick_broadcast_lock); |
| 35 | static int tick_broadcast_force; | 35 | static int tick_broadcast_force; |
| 36 | 36 | ||
| 37 | #ifdef CONFIG_TICK_ONESHOT | 37 | #ifdef CONFIG_TICK_ONESHOT |
| @@ -96,7 +96,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu) | |||
| 96 | unsigned long flags; | 96 | unsigned long flags; |
| 97 | int ret = 0; | 97 | int ret = 0; |
| 98 | 98 | ||
| 99 | spin_lock_irqsave(&tick_broadcast_lock, flags); | 99 | raw_spin_lock_irqsave(&tick_broadcast_lock, flags); |
| 100 | 100 | ||
| 101 | /* | 101 | /* |
| 102 | * Devices might be registered with both periodic and oneshot | 102 | * Devices might be registered with both periodic and oneshot |
| @@ -122,7 +122,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu) | |||
| 122 | tick_broadcast_clear_oneshot(cpu); | 122 | tick_broadcast_clear_oneshot(cpu); |
| 123 | } | 123 | } |
| 124 | } | 124 | } |
| 125 | spin_unlock_irqrestore(&tick_broadcast_lock, flags); | 125 | raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags); |
| 126 | return ret; | 126 | return ret; |
| 127 | } | 127 | } |
| 128 | 128 | ||
| @@ -161,13 +161,13 @@ static void tick_do_broadcast(struct cpumask *mask) | |||
| 161 | */ | 161 | */ |
| 162 | static void tick_do_periodic_broadcast(void) | 162 | static void tick_do_periodic_broadcast(void) |
| 163 | { | 163 | { |
| 164 | spin_lock(&tick_broadcast_lock); | 164 | raw_spin_lock(&tick_broadcast_lock); |
| 165 | 165 | ||
| 166 | cpumask_and(to_cpumask(tmpmask), | 166 | cpumask_and(to_cpumask(tmpmask), |
| 167 | cpu_online_mask, tick_get_broadcast_mask()); | 167 | cpu_online_mask, tick_get_broadcast_mask()); |
| 168 | tick_do_broadcast(to_cpumask(tmpmask)); | 168 | tick_do_broadcast(to_cpumask(tmpmask)); |
| 169 | 169 | ||
| 170 | spin_unlock(&tick_broadcast_lock); | 170 | raw_spin_unlock(&tick_broadcast_lock); |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | /* | 173 | /* |
| @@ -212,7 +212,7 @@ static void tick_do_broadcast_on_off(unsigned long *reason) | |||
| 212 | unsigned long flags; | 212 | unsigned long flags; |
| 213 | int cpu, bc_stopped; | 213 | int cpu, bc_stopped; |
| 214 | 214 | ||
| 215 | spin_lock_irqsave(&tick_broadcast_lock, flags); | 215 | raw_spin_lock_irqsave(&tick_broadcast_lock, flags); |
| 216 | 216 | ||
| 217 | cpu = smp_processor_id(); | 217 | cpu = smp_processor_id(); |
| 218 | td = &per_cpu(tick_cpu_device, cpu); | 218 | td = &per_cpu(tick_cpu_device, cpu); |
| @@ -263,7 +263,7 @@ static void tick_do_broadcast_on_off(unsigned long *reason) | |||
| 263 | tick_broadcast_setup_oneshot(bc); | 263 | tick_broadcast_setup_oneshot(bc); |
| 264 | } | 264 | } |
| 265 | out: | 265 | out: |
| 266 | spin_unlock_irqrestore(&tick_broadcast_lock, flags); | 266 | raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags); |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | /* | 269 | /* |
| @@ -299,7 +299,7 @@ void tick_shutdown_broadcast(unsigned int *cpup) | |||
| 299 | unsigned long flags; | 299 | unsigned long flags; |
| 300 | unsigned int cpu = *cpup; | 300 | unsigned int cpu = *cpup; |
| 301 | 301 | ||
| 302 | spin_lock_irqsave(&tick_broadcast_lock, flags); | 302 | raw_spin_lock_irqsave(&tick_broadcast_lock, flags); |
| 303 | 303 | ||
| 304 | bc = tick_broadcast_device.evtdev; | 304 | bc = tick_broadcast_device.evtdev; |
| 305 | cpumask_clear_cpu(cpu, tick_get_broadcast_mask()); | 305 | cpumask_clear_cpu(cpu, tick_get_broadcast_mask()); |
| @@ -309,7 +309,7 @@ void tick_shutdown_broadcast(unsigned int *cpup) | |||
| 309 | clockevents_shutdown(bc); | 309 | clockevents_shutdown(bc); |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | spin_unlock_irqrestore(&tick_broadcast_lock, flags); | 312 | raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags); |
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | void tick_suspend_broadcast(void) | 315 | void tick_suspend_broadcast(void) |
| @@ -317,13 +317,13 @@ void tick_suspend_broadcast(void) | |||
| 317 | struct clock_event_device *bc; | 317 | struct clock_event_device *bc; |
| 318 | unsigned long flags; | 318 | unsigned long flags; |
| 319 | 319 | ||
| 320 | spin_lock_irqsave(&tick_broadcast_lock, flags); | 320 | raw_spin_lock_irqsave(&tick_broadcast_lock, flags); |
| 321 | 321 | ||
| 322 | bc = tick_broadcast_device.evtdev; | 322 | bc = tick_broadcast_device.evtdev; |
| 323 | if (bc) | 323 | if (bc) |
| 324 | clockevents_shutdown(bc); | 324 | clockevents_shutdown(bc); |
| 325 | 325 | ||
| 326 | spin_unlock_irqrestore(&tick_broadcast_lock, flags); | 326 | raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags); |
| 327 | } | 327 | } |
| 328 | 328 | ||
| 329 | int tick_resume_broadcast(void) | 329 | int tick_resume_broadcast(void) |
| @@ -332,7 +332,7 @@ int tick_resume_broadcast(void) | |||
| 332 | unsigned long flags; | 332 | unsigned long flags; |
| 333 | int broadcast = 0; | 333 | int broadcast = 0; |
| 334 | 334 | ||
| 335 | spin_lock_irqsave(&tick_broadcast_lock, flags); | 335 | raw_spin_lock_irqsave(&tick_broadcast_lock, flags); |
| 336 | 336 | ||
| 337 | bc = tick_broadcast_device.evtdev; | 337 | bc = tick_broadcast_device.evtdev; |
| 338 | 338 | ||
| @@ -351,7 +351,7 @@ int tick_resume_broadcast(void) | |||
| 351 | break; | 351 | break; |
| 352 | } | 352 | } |
| 353 | } | 353 | } |
| 354 | spin_unlock_irqrestore(&tick_broadcast_lock, flags); | 354 | raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags); |
| 355 | 355 | ||
| 356 | return broadcast; | 356 | return broadcast; |
| 357 | } | 357 | } |
| @@ -405,7 +405,7 @@ static void tick_handle_oneshot_broadcast(struct clock_event_device *dev) | |||
| 405 | ktime_t now, next_event; | 405 | ktime_t now, next_event; |
| 406 | int cpu; | 406 | int cpu; |
| 407 | 407 | ||
| 408 | spin_lock(&tick_broadcast_lock); | 408 | raw_spin_lock(&tick_broadcast_lock); |
| 409 | again: | 409 | again: |
| 410 | dev->next_event.tv64 = KTIME_MAX; | 410 | dev->next_event.tv64 = KTIME_MAX; |
| 411 | next_event.tv64 = KTIME_MAX; | 411 | next_event.tv64 = KTIME_MAX; |
| @@ -443,7 +443,7 @@ again: | |||
| 443 | if (tick_broadcast_set_event(next_event, 0)) | 443 | if (tick_broadcast_set_event(next_event, 0)) |
| 444 | goto again; | 444 | goto again; |
| 445 | } | 445 | } |
| 446 | spin_unlock(&tick_broadcast_lock); | 446 | raw_spin_unlock(&tick_broadcast_lock); |
| 447 | } | 447 | } |
| 448 | 448 | ||
| 449 | /* | 449 | /* |
| @@ -457,7 +457,7 @@ void tick_broadcast_oneshot_control(unsigned long reason) | |||
| 457 | unsigned long flags; | 457 | unsigned long flags; |
| 458 | int cpu; | 458 | int cpu; |
| 459 | 459 | ||
| 460 | spin_lock_irqsave(&tick_broadcast_lock, flags); | 460 | raw_spin_lock_irqsave(&tick_broadcast_lock, flags); |
| 461 | 461 | ||
| 462 | /* | 462 | /* |
| 463 | * Periodic mode does not care about the enter/exit of power | 463 | * Periodic mode does not care about the enter/exit of power |
| @@ -492,7 +492,7 @@ void tick_broadcast_oneshot_control(unsigned long reason) | |||
| 492 | } | 492 | } |
| 493 | 493 | ||
| 494 | out: | 494 | out: |
| 495 | spin_unlock_irqrestore(&tick_broadcast_lock, flags); | 495 | raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags); |
| 496 | } | 496 | } |
| 497 | 497 | ||
| 498 | /* | 498 | /* |
| @@ -563,13 +563,13 @@ void tick_broadcast_switch_to_oneshot(void) | |||
| 563 | struct clock_event_device *bc; | 563 | struct clock_event_device *bc; |
| 564 | unsigned long flags; | 564 | unsigned long flags; |
| 565 | 565 | ||
| 566 | spin_lock_irqsave(&tick_broadcast_lock, flags); | 566 | raw_spin_lock_irqsave(&tick_broadcast_lock, flags); |
| 567 | 567 | ||
| 568 | tick_broadcast_device.mode = TICKDEV_MODE_ONESHOT; | 568 | tick_broadcast_device.mode = TICKDEV_MODE_ONESHOT; |
| 569 | bc = tick_broadcast_device.evtdev; | 569 | bc = tick_broadcast_device.evtdev; |
| 570 | if (bc) | 570 | if (bc) |
| 571 | tick_broadcast_setup_oneshot(bc); | 571 | tick_broadcast_setup_oneshot(bc); |
| 572 | spin_unlock_irqrestore(&tick_broadcast_lock, flags); | 572 | raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags); |
| 573 | } | 573 | } |
| 574 | 574 | ||
| 575 | 575 | ||
| @@ -581,7 +581,7 @@ void tick_shutdown_broadcast_oneshot(unsigned int *cpup) | |||
| 581 | unsigned long flags; | 581 | unsigned long flags; |
| 582 | unsigned int cpu = *cpup; | 582 | unsigned int cpu = *cpup; |
| 583 | 583 | ||
| 584 | spin_lock_irqsave(&tick_broadcast_lock, flags); | 584 | raw_spin_lock_irqsave(&tick_broadcast_lock, flags); |
| 585 | 585 | ||
| 586 | /* | 586 | /* |
| 587 | * Clear the broadcast mask flag for the dead cpu, but do not | 587 | * Clear the broadcast mask flag for the dead cpu, but do not |
| @@ -589,7 +589,7 @@ void tick_shutdown_broadcast_oneshot(unsigned int *cpup) | |||
| 589 | */ | 589 | */ |
| 590 | cpumask_clear_cpu(cpu, tick_get_broadcast_oneshot_mask()); | 590 | cpumask_clear_cpu(cpu, tick_get_broadcast_oneshot_mask()); |
| 591 | 591 | ||
| 592 | spin_unlock_irqrestore(&tick_broadcast_lock, flags); | 592 | raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags); |
| 593 | } | 593 | } |
| 594 | 594 | ||
| 595 | /* | 595 | /* |
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c index 83c4417b6a3c..b6b898d2eeef 100644 --- a/kernel/time/tick-common.c +++ b/kernel/time/tick-common.c | |||
| @@ -34,7 +34,7 @@ DEFINE_PER_CPU(struct tick_device, tick_cpu_device); | |||
| 34 | ktime_t tick_next_period; | 34 | ktime_t tick_next_period; |
| 35 | ktime_t tick_period; | 35 | ktime_t tick_period; |
| 36 | int tick_do_timer_cpu __read_mostly = TICK_DO_TIMER_BOOT; | 36 | int tick_do_timer_cpu __read_mostly = TICK_DO_TIMER_BOOT; |
| 37 | DEFINE_SPINLOCK(tick_device_lock); | 37 | static DEFINE_RAW_SPINLOCK(tick_device_lock); |
| 38 | 38 | ||
| 39 | /* | 39 | /* |
| 40 | * Debugging: see timer_list.c | 40 | * Debugging: see timer_list.c |
| @@ -209,7 +209,7 @@ static int tick_check_new_device(struct clock_event_device *newdev) | |||
| 209 | int cpu, ret = NOTIFY_OK; | 209 | int cpu, ret = NOTIFY_OK; |
| 210 | unsigned long flags; | 210 | unsigned long flags; |
| 211 | 211 | ||
| 212 | spin_lock_irqsave(&tick_device_lock, flags); | 212 | raw_spin_lock_irqsave(&tick_device_lock, flags); |
| 213 | 213 | ||
| 214 | cpu = smp_processor_id(); | 214 | cpu = smp_processor_id(); |
| 215 | if (!cpumask_test_cpu(cpu, newdev->cpumask)) | 215 | if (!cpumask_test_cpu(cpu, newdev->cpumask)) |
| @@ -268,7 +268,7 @@ static int tick_check_new_device(struct clock_event_device *newdev) | |||
| 268 | if (newdev->features & CLOCK_EVT_FEAT_ONESHOT) | 268 | if (newdev->features & CLOCK_EVT_FEAT_ONESHOT) |
| 269 | tick_oneshot_notify(); | 269 | tick_oneshot_notify(); |
| 270 | 270 | ||
| 271 | spin_unlock_irqrestore(&tick_device_lock, flags); | 271 | raw_spin_unlock_irqrestore(&tick_device_lock, flags); |
| 272 | return NOTIFY_STOP; | 272 | return NOTIFY_STOP; |
| 273 | 273 | ||
| 274 | out_bc: | 274 | out_bc: |
| @@ -278,7 +278,7 @@ out_bc: | |||
| 278 | if (tick_check_broadcast_device(newdev)) | 278 | if (tick_check_broadcast_device(newdev)) |
| 279 | ret = NOTIFY_STOP; | 279 | ret = NOTIFY_STOP; |
| 280 | 280 | ||
| 281 | spin_unlock_irqrestore(&tick_device_lock, flags); | 281 | raw_spin_unlock_irqrestore(&tick_device_lock, flags); |
| 282 | 282 | ||
| 283 | return ret; | 283 | return ret; |
| 284 | } | 284 | } |
| @@ -311,7 +311,7 @@ static void tick_shutdown(unsigned int *cpup) | |||
| 311 | struct clock_event_device *dev = td->evtdev; | 311 | struct clock_event_device *dev = td->evtdev; |
| 312 | unsigned long flags; | 312 | unsigned long flags; |
| 313 | 313 | ||
| 314 | spin_lock_irqsave(&tick_device_lock, flags); | 314 | raw_spin_lock_irqsave(&tick_device_lock, flags); |
| 315 | td->mode = TICKDEV_MODE_PERIODIC; | 315 | td->mode = TICKDEV_MODE_PERIODIC; |
| 316 | if (dev) { | 316 | if (dev) { |
| 317 | /* | 317 | /* |
| @@ -322,7 +322,7 @@ static void tick_shutdown(unsigned int *cpup) | |||
| 322 | clockevents_exchange_device(dev, NULL); | 322 | clockevents_exchange_device(dev, NULL); |
| 323 | td->evtdev = NULL; | 323 | td->evtdev = NULL; |
| 324 | } | 324 | } |
| 325 | spin_unlock_irqrestore(&tick_device_lock, flags); | 325 | raw_spin_unlock_irqrestore(&tick_device_lock, flags); |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | static void tick_suspend(void) | 328 | static void tick_suspend(void) |
| @@ -330,9 +330,9 @@ static void tick_suspend(void) | |||
| 330 | struct tick_device *td = &__get_cpu_var(tick_cpu_device); | 330 | struct tick_device *td = &__get_cpu_var(tick_cpu_device); |
| 331 | unsigned long flags; | 331 | unsigned long flags; |
| 332 | 332 | ||
| 333 | spin_lock_irqsave(&tick_device_lock, flags); | 333 | raw_spin_lock_irqsave(&tick_device_lock, flags); |
| 334 | clockevents_shutdown(td->evtdev); | 334 | clockevents_shutdown(td->evtdev); |
| 335 | spin_unlock_irqrestore(&tick_device_lock, flags); | 335 | raw_spin_unlock_irqrestore(&tick_device_lock, flags); |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | static void tick_resume(void) | 338 | static void tick_resume(void) |
| @@ -341,7 +341,7 @@ static void tick_resume(void) | |||
| 341 | unsigned long flags; | 341 | unsigned long flags; |
| 342 | int broadcast = tick_resume_broadcast(); | 342 | int broadcast = tick_resume_broadcast(); |
| 343 | 343 | ||
| 344 | spin_lock_irqsave(&tick_device_lock, flags); | 344 | raw_spin_lock_irqsave(&tick_device_lock, flags); |
| 345 | clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_RESUME); | 345 | clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_RESUME); |
| 346 | 346 | ||
| 347 | if (!broadcast) { | 347 | if (!broadcast) { |
| @@ -350,7 +350,7 @@ static void tick_resume(void) | |||
| 350 | else | 350 | else |
| 351 | tick_resume_oneshot(); | 351 | tick_resume_oneshot(); |
| 352 | } | 352 | } |
| 353 | spin_unlock_irqrestore(&tick_device_lock, flags); | 353 | raw_spin_unlock_irqrestore(&tick_device_lock, flags); |
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | /* | 356 | /* |
diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h index b1c05bf75ee0..290eefbc1f60 100644 --- a/kernel/time/tick-internal.h +++ b/kernel/time/tick-internal.h | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | #define TICK_DO_TIMER_BOOT -2 | 6 | #define TICK_DO_TIMER_BOOT -2 |
| 7 | 7 | ||
| 8 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device); | 8 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device); |
| 9 | extern spinlock_t tick_device_lock; | ||
| 10 | extern ktime_t tick_next_period; | 9 | extern ktime_t tick_next_period; |
| 11 | extern ktime_t tick_period; | 10 | extern ktime_t tick_period; |
| 12 | extern int tick_do_timer_cpu __read_mostly; | 11 | extern int tick_do_timer_cpu __read_mostly; |
diff --git a/kernel/time/timecompare.c b/kernel/time/timecompare.c index 96ff643a5a59..12f5c55090be 100644 --- a/kernel/time/timecompare.c +++ b/kernel/time/timecompare.c | |||
| @@ -89,7 +89,7 @@ int timecompare_offset(struct timecompare *sync, | |||
| 89 | * source time | 89 | * source time |
| 90 | */ | 90 | */ |
| 91 | sample.offset = | 91 | sample.offset = |
| 92 | ktime_to_ns(ktime_add(end, start)) / 2 - | 92 | (ktime_to_ns(end) + ktime_to_ns(start)) / 2 - |
| 93 | ts; | 93 | ts; |
| 94 | 94 | ||
| 95 | /* simple insertion sort based on duration */ | 95 | /* simple insertion sort based on duration */ |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index af4135f05825..7faaa32fbf4f 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
| @@ -165,6 +165,13 @@ struct timespec raw_time; | |||
| 165 | /* flag for if timekeeping is suspended */ | 165 | /* flag for if timekeeping is suspended */ |
| 166 | int __read_mostly timekeeping_suspended; | 166 | int __read_mostly timekeeping_suspended; |
| 167 | 167 | ||
| 168 | static struct timespec xtime_cache __attribute__ ((aligned (16))); | ||
| 169 | void update_xtime_cache(u64 nsec) | ||
| 170 | { | ||
| 171 | xtime_cache = xtime; | ||
| 172 | timespec_add_ns(&xtime_cache, nsec); | ||
| 173 | } | ||
| 174 | |||
| 168 | /* must hold xtime_lock */ | 175 | /* must hold xtime_lock */ |
| 169 | void timekeeping_leap_insert(int leapsecond) | 176 | void timekeeping_leap_insert(int leapsecond) |
| 170 | { | 177 | { |
| @@ -325,6 +332,8 @@ int do_settimeofday(struct timespec *tv) | |||
| 325 | 332 | ||
| 326 | xtime = *tv; | 333 | xtime = *tv; |
| 327 | 334 | ||
| 335 | update_xtime_cache(0); | ||
| 336 | |||
| 328 | timekeeper.ntp_error = 0; | 337 | timekeeper.ntp_error = 0; |
| 329 | ntp_clear(); | 338 | ntp_clear(); |
| 330 | 339 | ||
| @@ -550,6 +559,7 @@ void __init timekeeping_init(void) | |||
| 550 | } | 559 | } |
| 551 | set_normalized_timespec(&wall_to_monotonic, | 560 | set_normalized_timespec(&wall_to_monotonic, |
| 552 | -boot.tv_sec, -boot.tv_nsec); | 561 | -boot.tv_sec, -boot.tv_nsec); |
| 562 | update_xtime_cache(0); | ||
| 553 | total_sleep_time.tv_sec = 0; | 563 | total_sleep_time.tv_sec = 0; |
| 554 | total_sleep_time.tv_nsec = 0; | 564 | total_sleep_time.tv_nsec = 0; |
| 555 | write_sequnlock_irqrestore(&xtime_lock, flags); | 565 | write_sequnlock_irqrestore(&xtime_lock, flags); |
| @@ -583,6 +593,7 @@ static int timekeeping_resume(struct sys_device *dev) | |||
| 583 | wall_to_monotonic = timespec_sub(wall_to_monotonic, ts); | 593 | wall_to_monotonic = timespec_sub(wall_to_monotonic, ts); |
| 584 | total_sleep_time = timespec_add_safe(total_sleep_time, ts); | 594 | total_sleep_time = timespec_add_safe(total_sleep_time, ts); |
| 585 | } | 595 | } |
| 596 | update_xtime_cache(0); | ||
| 586 | /* re-base the last cycle value */ | 597 | /* re-base the last cycle value */ |
| 587 | timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock); | 598 | timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock); |
| 588 | timekeeper.ntp_error = 0; | 599 | timekeeper.ntp_error = 0; |
| @@ -722,6 +733,7 @@ static void timekeeping_adjust(s64 offset) | |||
| 722 | timekeeper.ntp_error_shift; | 733 | timekeeper.ntp_error_shift; |
| 723 | } | 734 | } |
| 724 | 735 | ||
| 736 | |||
| 725 | /** | 737 | /** |
| 726 | * logarithmic_accumulation - shifted accumulation of cycles | 738 | * logarithmic_accumulation - shifted accumulation of cycles |
| 727 | * | 739 | * |
| @@ -765,6 +777,7 @@ static cycle_t logarithmic_accumulation(cycle_t offset, int shift) | |||
| 765 | return offset; | 777 | return offset; |
| 766 | } | 778 | } |
| 767 | 779 | ||
| 780 | |||
| 768 | /** | 781 | /** |
| 769 | * update_wall_time - Uses the current clocksource to increment the wall time | 782 | * update_wall_time - Uses the current clocksource to increment the wall time |
| 770 | * | 783 | * |
| @@ -774,6 +787,7 @@ void update_wall_time(void) | |||
| 774 | { | 787 | { |
| 775 | struct clocksource *clock; | 788 | struct clocksource *clock; |
| 776 | cycle_t offset; | 789 | cycle_t offset; |
| 790 | u64 nsecs; | ||
| 777 | int shift = 0, maxshift; | 791 | int shift = 0, maxshift; |
| 778 | 792 | ||
| 779 | /* Make sure we're fully resumed: */ | 793 | /* Make sure we're fully resumed: */ |
| @@ -839,6 +853,9 @@ void update_wall_time(void) | |||
| 839 | timekeeper.ntp_error += timekeeper.xtime_nsec << | 853 | timekeeper.ntp_error += timekeeper.xtime_nsec << |
| 840 | timekeeper.ntp_error_shift; | 854 | timekeeper.ntp_error_shift; |
| 841 | 855 | ||
| 856 | nsecs = clocksource_cyc2ns(offset, timekeeper.mult, timekeeper.shift); | ||
| 857 | update_xtime_cache(nsecs); | ||
| 858 | |||
| 842 | /* check to see if there is a new clocksource to use */ | 859 | /* check to see if there is a new clocksource to use */ |
| 843 | update_vsyscall(&xtime, timekeeper.clock, timekeeper.mult); | 860 | update_vsyscall(&xtime, timekeeper.clock, timekeeper.mult); |
| 844 | } | 861 | } |
| @@ -875,13 +892,13 @@ void monotonic_to_bootbased(struct timespec *ts) | |||
| 875 | 892 | ||
| 876 | unsigned long get_seconds(void) | 893 | unsigned long get_seconds(void) |
| 877 | { | 894 | { |
| 878 | return xtime.tv_sec; | 895 | return xtime_cache.tv_sec; |
| 879 | } | 896 | } |
| 880 | EXPORT_SYMBOL(get_seconds); | 897 | EXPORT_SYMBOL(get_seconds); |
| 881 | 898 | ||
| 882 | struct timespec __current_kernel_time(void) | 899 | struct timespec __current_kernel_time(void) |
| 883 | { | 900 | { |
| 884 | return xtime; | 901 | return xtime_cache; |
| 885 | } | 902 | } |
| 886 | 903 | ||
| 887 | struct timespec current_kernel_time(void) | 904 | struct timespec current_kernel_time(void) |
| @@ -891,7 +908,8 @@ struct timespec current_kernel_time(void) | |||
| 891 | 908 | ||
| 892 | do { | 909 | do { |
| 893 | seq = read_seqbegin(&xtime_lock); | 910 | seq = read_seqbegin(&xtime_lock); |
| 894 | now = xtime; | 911 | |
| 912 | now = xtime_cache; | ||
| 895 | } while (read_seqretry(&xtime_lock, seq)); | 913 | } while (read_seqretry(&xtime_lock, seq)); |
| 896 | 914 | ||
| 897 | return now; | 915 | return now; |
| @@ -905,7 +923,8 @@ struct timespec get_monotonic_coarse(void) | |||
| 905 | 923 | ||
| 906 | do { | 924 | do { |
| 907 | seq = read_seqbegin(&xtime_lock); | 925 | seq = read_seqbegin(&xtime_lock); |
| 908 | now = xtime; | 926 | |
| 927 | now = xtime_cache; | ||
| 909 | mono = wall_to_monotonic; | 928 | mono = wall_to_monotonic; |
| 910 | } while (read_seqretry(&xtime_lock, seq)); | 929 | } while (read_seqretry(&xtime_lock, seq)); |
| 911 | 930 | ||
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c index 9d80db4747d4..bdfb8dd1050c 100644 --- a/kernel/time/timer_list.c +++ b/kernel/time/timer_list.c | |||
| @@ -84,7 +84,7 @@ print_active_timers(struct seq_file *m, struct hrtimer_clock_base *base, | |||
| 84 | 84 | ||
| 85 | next_one: | 85 | next_one: |
| 86 | i = 0; | 86 | i = 0; |
| 87 | spin_lock_irqsave(&base->cpu_base->lock, flags); | 87 | raw_spin_lock_irqsave(&base->cpu_base->lock, flags); |
| 88 | 88 | ||
| 89 | curr = base->first; | 89 | curr = base->first; |
| 90 | /* | 90 | /* |
| @@ -100,13 +100,13 @@ next_one: | |||
| 100 | 100 | ||
| 101 | timer = rb_entry(curr, struct hrtimer, node); | 101 | timer = rb_entry(curr, struct hrtimer, node); |
| 102 | tmp = *timer; | 102 | tmp = *timer; |
| 103 | spin_unlock_irqrestore(&base->cpu_base->lock, flags); | 103 | raw_spin_unlock_irqrestore(&base->cpu_base->lock, flags); |
| 104 | 104 | ||
| 105 | print_timer(m, timer, &tmp, i, now); | 105 | print_timer(m, timer, &tmp, i, now); |
| 106 | next++; | 106 | next++; |
| 107 | goto next_one; | 107 | goto next_one; |
| 108 | } | 108 | } |
| 109 | spin_unlock_irqrestore(&base->cpu_base->lock, flags); | 109 | raw_spin_unlock_irqrestore(&base->cpu_base->lock, flags); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | static void | 112 | static void |
| @@ -237,10 +237,10 @@ static void timer_list_show_tickdevices(struct seq_file *m) | |||
| 237 | #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST | 237 | #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST |
| 238 | print_tickdevice(m, tick_get_broadcast_device(), -1); | 238 | print_tickdevice(m, tick_get_broadcast_device(), -1); |
| 239 | SEQ_printf(m, "tick_broadcast_mask: %08lx\n", | 239 | SEQ_printf(m, "tick_broadcast_mask: %08lx\n", |
| 240 | tick_get_broadcast_mask()->bits[0]); | 240 | cpumask_bits(tick_get_broadcast_mask())[0]); |
| 241 | #ifdef CONFIG_TICK_ONESHOT | 241 | #ifdef CONFIG_TICK_ONESHOT |
| 242 | SEQ_printf(m, "tick_broadcast_oneshot_mask: %08lx\n", | 242 | SEQ_printf(m, "tick_broadcast_oneshot_mask: %08lx\n", |
| 243 | tick_get_broadcast_oneshot_mask()->bits[0]); | 243 | cpumask_bits(tick_get_broadcast_oneshot_mask())[0]); |
| 244 | #endif | 244 | #endif |
| 245 | SEQ_printf(m, "\n"); | 245 | SEQ_printf(m, "\n"); |
| 246 | #endif | 246 | #endif |
diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c index 63b117e9eba1..2f3b585b8d7d 100644 --- a/kernel/time/timer_stats.c +++ b/kernel/time/timer_stats.c | |||
| @@ -86,7 +86,7 @@ static DEFINE_SPINLOCK(table_lock); | |||
| 86 | /* | 86 | /* |
| 87 | * Per-CPU lookup locks for fast hash lookup: | 87 | * Per-CPU lookup locks for fast hash lookup: |
| 88 | */ | 88 | */ |
| 89 | static DEFINE_PER_CPU(spinlock_t, tstats_lookup_lock); | 89 | static DEFINE_PER_CPU(raw_spinlock_t, tstats_lookup_lock); |
| 90 | 90 | ||
| 91 | /* | 91 | /* |
| 92 | * Mutex to serialize state changes with show-stats activities: | 92 | * Mutex to serialize state changes with show-stats activities: |
| @@ -238,7 +238,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf, | |||
| 238 | /* | 238 | /* |
| 239 | * It doesnt matter which lock we take: | 239 | * It doesnt matter which lock we take: |
| 240 | */ | 240 | */ |
| 241 | spinlock_t *lock; | 241 | raw_spinlock_t *lock; |
| 242 | struct entry *entry, input; | 242 | struct entry *entry, input; |
| 243 | unsigned long flags; | 243 | unsigned long flags; |
| 244 | 244 | ||
| @@ -253,7 +253,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf, | |||
| 253 | input.pid = pid; | 253 | input.pid = pid; |
| 254 | input.timer_flag = timer_flag; | 254 | input.timer_flag = timer_flag; |
| 255 | 255 | ||
| 256 | spin_lock_irqsave(lock, flags); | 256 | raw_spin_lock_irqsave(lock, flags); |
| 257 | if (!timer_stats_active) | 257 | if (!timer_stats_active) |
| 258 | goto out_unlock; | 258 | goto out_unlock; |
| 259 | 259 | ||
| @@ -264,7 +264,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf, | |||
| 264 | atomic_inc(&overflow_count); | 264 | atomic_inc(&overflow_count); |
| 265 | 265 | ||
| 266 | out_unlock: | 266 | out_unlock: |
| 267 | spin_unlock_irqrestore(lock, flags); | 267 | raw_spin_unlock_irqrestore(lock, flags); |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | static void print_name_offset(struct seq_file *m, unsigned long addr) | 270 | static void print_name_offset(struct seq_file *m, unsigned long addr) |
| @@ -348,10 +348,11 @@ static void sync_access(void) | |||
| 348 | int cpu; | 348 | int cpu; |
| 349 | 349 | ||
| 350 | for_each_online_cpu(cpu) { | 350 | for_each_online_cpu(cpu) { |
| 351 | spinlock_t *lock = &per_cpu(tstats_lookup_lock, cpu); | 351 | raw_spinlock_t *lock = &per_cpu(tstats_lookup_lock, cpu); |
| 352 | spin_lock_irqsave(lock, flags); | 352 | |
| 353 | raw_spin_lock_irqsave(lock, flags); | ||
| 353 | /* nothing */ | 354 | /* nothing */ |
| 354 | spin_unlock_irqrestore(lock, flags); | 355 | raw_spin_unlock_irqrestore(lock, flags); |
| 355 | } | 356 | } |
| 356 | } | 357 | } |
| 357 | 358 | ||
| @@ -409,7 +410,7 @@ void __init init_timer_stats(void) | |||
| 409 | int cpu; | 410 | int cpu; |
| 410 | 411 | ||
| 411 | for_each_possible_cpu(cpu) | 412 | for_each_possible_cpu(cpu) |
| 412 | spin_lock_init(&per_cpu(tstats_lookup_lock, cpu)); | 413 | raw_spin_lock_init(&per_cpu(tstats_lookup_lock, cpu)); |
| 413 | } | 414 | } |
| 414 | 415 | ||
| 415 | static int __init init_tstats_procfs(void) | 416 | static int __init init_tstats_procfs(void) |
