diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/exit.c | 17 | ||||
-rw-r--r-- | kernel/fork.c | 1 | ||||
-rw-r--r-- | kernel/futex.c | 31 | ||||
-rw-r--r-- | kernel/irq/proc.c | 2 | ||||
-rw-r--r-- | kernel/latencytop.c | 17 | ||||
-rw-r--r-- | kernel/perf_event.c | 30 | ||||
-rw-r--r-- | kernel/pm_qos_params.c | 4 | ||||
-rw-r--r-- | kernel/power/hibernate.c | 22 | ||||
-rw-r--r-- | kernel/power/suspend.c | 5 | ||||
-rw-r--r-- | kernel/power/user.c | 4 | ||||
-rw-r--r-- | kernel/printk.c | 4 | ||||
-rw-r--r-- | kernel/ptrace.c | 2 | ||||
-rw-r--r-- | kernel/sched.c | 181 | ||||
-rw-r--r-- | kernel/smp.c | 30 | ||||
-rw-r--r-- | kernel/sys.c | 3 | ||||
-rw-r--r-- | kernel/timer.c | 8 | ||||
-rw-r--r-- | kernel/trace/trace.c | 10 | ||||
-rw-r--r-- | kernel/user.c | 1 | ||||
-rw-r--r-- | kernel/watchdog.c | 26 |
19 files changed, 314 insertions, 84 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index b9d3bc6c21ec..ad7e51488291 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -97,6 +97,14 @@ static void __exit_signal(struct task_struct *tsk) | |||
97 | sig->tty = NULL; | 97 | sig->tty = NULL; |
98 | } else { | 98 | } else { |
99 | /* | 99 | /* |
100 | * This can only happen if the caller is de_thread(). | ||
101 | * FIXME: this is the temporary hack, we should teach | ||
102 | * posix-cpu-timers to handle this case correctly. | ||
103 | */ | ||
104 | if (unlikely(has_group_leader_pid(tsk))) | ||
105 | posix_cpu_timers_exit_group(tsk); | ||
106 | |||
107 | /* | ||
100 | * If there is any task waiting for the group exit | 108 | * If there is any task waiting for the group exit |
101 | * then notify it: | 109 | * then notify it: |
102 | */ | 110 | */ |
@@ -905,6 +913,15 @@ NORET_TYPE void do_exit(long code) | |||
905 | if (unlikely(!tsk->pid)) | 913 | if (unlikely(!tsk->pid)) |
906 | panic("Attempted to kill the idle task!"); | 914 | panic("Attempted to kill the idle task!"); |
907 | 915 | ||
916 | /* | ||
917 | * If do_exit is called because this processes oopsed, it's possible | ||
918 | * that get_fs() was left as KERNEL_DS, so reset it to USER_DS before | ||
919 | * continuing. Amongst other possible reasons, this is to prevent | ||
920 | * mm_release()->clear_child_tid() from writing to a user-controlled | ||
921 | * kernel address. | ||
922 | */ | ||
923 | set_fs(USER_DS); | ||
924 | |||
908 | tracehook_report_exit(&code); | 925 | tracehook_report_exit(&code); |
909 | 926 | ||
910 | validate_creds_for_do_exit(tsk); | 927 | validate_creds_for_do_exit(tsk); |
diff --git a/kernel/fork.c b/kernel/fork.c index ab7f29d906c7..d01a7514125b 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -279,6 +279,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) | |||
279 | 279 | ||
280 | setup_thread_stack(tsk, orig); | 280 | setup_thread_stack(tsk, orig); |
281 | clear_user_return_notifier(tsk); | 281 | clear_user_return_notifier(tsk); |
282 | clear_tsk_need_resched(tsk); | ||
282 | stackend = end_of_stack(tsk); | 283 | stackend = end_of_stack(tsk); |
283 | *stackend = STACK_END_MAGIC; /* for overflow detection */ | 284 | *stackend = STACK_END_MAGIC; /* for overflow detection */ |
284 | 285 | ||
diff --git a/kernel/futex.c b/kernel/futex.c index 6a3a5fa1526d..e328f574c97c 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -1363,7 +1363,6 @@ static inline struct futex_hash_bucket *queue_lock(struct futex_q *q) | |||
1363 | { | 1363 | { |
1364 | struct futex_hash_bucket *hb; | 1364 | struct futex_hash_bucket *hb; |
1365 | 1365 | ||
1366 | get_futex_key_refs(&q->key); | ||
1367 | hb = hash_futex(&q->key); | 1366 | hb = hash_futex(&q->key); |
1368 | q->lock_ptr = &hb->lock; | 1367 | q->lock_ptr = &hb->lock; |
1369 | 1368 | ||
@@ -1375,7 +1374,6 @@ static inline void | |||
1375 | queue_unlock(struct futex_q *q, struct futex_hash_bucket *hb) | 1374 | queue_unlock(struct futex_q *q, struct futex_hash_bucket *hb) |
1376 | { | 1375 | { |
1377 | spin_unlock(&hb->lock); | 1376 | spin_unlock(&hb->lock); |
1378 | drop_futex_key_refs(&q->key); | ||
1379 | } | 1377 | } |
1380 | 1378 | ||
1381 | /** | 1379 | /** |
@@ -1480,8 +1478,6 @@ static void unqueue_me_pi(struct futex_q *q) | |||
1480 | q->pi_state = NULL; | 1478 | q->pi_state = NULL; |
1481 | 1479 | ||
1482 | spin_unlock(q->lock_ptr); | 1480 | spin_unlock(q->lock_ptr); |
1483 | |||
1484 | drop_futex_key_refs(&q->key); | ||
1485 | } | 1481 | } |
1486 | 1482 | ||
1487 | /* | 1483 | /* |
@@ -1812,7 +1808,10 @@ static int futex_wait(u32 __user *uaddr, int fshared, | |||
1812 | } | 1808 | } |
1813 | 1809 | ||
1814 | retry: | 1810 | retry: |
1815 | /* Prepare to wait on uaddr. */ | 1811 | /* |
1812 | * Prepare to wait on uaddr. On success, holds hb lock and increments | ||
1813 | * q.key refs. | ||
1814 | */ | ||
1816 | ret = futex_wait_setup(uaddr, val, fshared, &q, &hb); | 1815 | ret = futex_wait_setup(uaddr, val, fshared, &q, &hb); |
1817 | if (ret) | 1816 | if (ret) |
1818 | goto out; | 1817 | goto out; |
@@ -1822,24 +1821,23 @@ retry: | |||
1822 | 1821 | ||
1823 | /* If we were woken (and unqueued), we succeeded, whatever. */ | 1822 | /* If we were woken (and unqueued), we succeeded, whatever. */ |
1824 | ret = 0; | 1823 | ret = 0; |
1824 | /* unqueue_me() drops q.key ref */ | ||
1825 | if (!unqueue_me(&q)) | 1825 | if (!unqueue_me(&q)) |
1826 | goto out_put_key; | 1826 | goto out; |
1827 | ret = -ETIMEDOUT; | 1827 | ret = -ETIMEDOUT; |
1828 | if (to && !to->task) | 1828 | if (to && !to->task) |
1829 | goto out_put_key; | 1829 | goto out; |
1830 | 1830 | ||
1831 | /* | 1831 | /* |
1832 | * We expect signal_pending(current), but we might be the | 1832 | * We expect signal_pending(current), but we might be the |
1833 | * victim of a spurious wakeup as well. | 1833 | * victim of a spurious wakeup as well. |
1834 | */ | 1834 | */ |
1835 | if (!signal_pending(current)) { | 1835 | if (!signal_pending(current)) |
1836 | put_futex_key(fshared, &q.key); | ||
1837 | goto retry; | 1836 | goto retry; |
1838 | } | ||
1839 | 1837 | ||
1840 | ret = -ERESTARTSYS; | 1838 | ret = -ERESTARTSYS; |
1841 | if (!abs_time) | 1839 | if (!abs_time) |
1842 | goto out_put_key; | 1840 | goto out; |
1843 | 1841 | ||
1844 | restart = ¤t_thread_info()->restart_block; | 1842 | restart = ¤t_thread_info()->restart_block; |
1845 | restart->fn = futex_wait_restart; | 1843 | restart->fn = futex_wait_restart; |
@@ -1856,8 +1854,6 @@ retry: | |||
1856 | 1854 | ||
1857 | ret = -ERESTART_RESTARTBLOCK; | 1855 | ret = -ERESTART_RESTARTBLOCK; |
1858 | 1856 | ||
1859 | out_put_key: | ||
1860 | put_futex_key(fshared, &q.key); | ||
1861 | out: | 1857 | out: |
1862 | if (to) { | 1858 | if (to) { |
1863 | hrtimer_cancel(&to->timer); | 1859 | hrtimer_cancel(&to->timer); |
@@ -2236,7 +2232,10 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared, | |||
2236 | q.rt_waiter = &rt_waiter; | 2232 | q.rt_waiter = &rt_waiter; |
2237 | q.requeue_pi_key = &key2; | 2233 | q.requeue_pi_key = &key2; |
2238 | 2234 | ||
2239 | /* Prepare to wait on uaddr. */ | 2235 | /* |
2236 | * Prepare to wait on uaddr. On success, increments q.key (key1) ref | ||
2237 | * count. | ||
2238 | */ | ||
2240 | ret = futex_wait_setup(uaddr, val, fshared, &q, &hb); | 2239 | ret = futex_wait_setup(uaddr, val, fshared, &q, &hb); |
2241 | if (ret) | 2240 | if (ret) |
2242 | goto out_key2; | 2241 | goto out_key2; |
@@ -2254,7 +2253,9 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared, | |||
2254 | * In order for us to be here, we know our q.key == key2, and since | 2253 | * In order for us to be here, we know our q.key == key2, and since |
2255 | * we took the hb->lock above, we also know that futex_requeue() has | 2254 | * we took the hb->lock above, we also know that futex_requeue() has |
2256 | * completed and we no longer have to concern ourselves with a wakeup | 2255 | * completed and we no longer have to concern ourselves with a wakeup |
2257 | * race with the atomic proxy lock acquition by the requeue code. | 2256 | * race with the atomic proxy lock acquisition by the requeue code. The |
2257 | * futex_requeue dropped our key1 reference and incremented our key2 | ||
2258 | * reference count. | ||
2258 | */ | 2259 | */ |
2259 | 2260 | ||
2260 | /* Check if the requeue code acquired the second futex for us. */ | 2261 | /* Check if the requeue code acquired the second futex for us. */ |
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 09a2ee540bd2..345e0b75fe1e 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c | |||
@@ -214,7 +214,7 @@ static int irq_spurious_proc_show(struct seq_file *m, void *v) | |||
214 | 214 | ||
215 | static int irq_spurious_proc_open(struct inode *inode, struct file *file) | 215 | static int irq_spurious_proc_open(struct inode *inode, struct file *file) |
216 | { | 216 | { |
217 | return single_open(file, irq_spurious_proc_show, NULL); | 217 | return single_open(file, irq_spurious_proc_show, PDE(inode)->data); |
218 | } | 218 | } |
219 | 219 | ||
220 | static const struct file_operations irq_spurious_proc_fops = { | 220 | static const struct file_operations irq_spurious_proc_fops = { |
diff --git a/kernel/latencytop.c b/kernel/latencytop.c index 877fb306d415..17110a4a4fc2 100644 --- a/kernel/latencytop.c +++ b/kernel/latencytop.c | |||
@@ -194,14 +194,7 @@ __account_scheduler_latency(struct task_struct *tsk, int usecs, int inter) | |||
194 | 194 | ||
195 | account_global_scheduler_latency(tsk, &lat); | 195 | account_global_scheduler_latency(tsk, &lat); |
196 | 196 | ||
197 | /* | 197 | for (i = 0; i < tsk->latency_record_count; i++) { |
198 | * short term hack; if we're > 32 we stop; future we recycle: | ||
199 | */ | ||
200 | tsk->latency_record_count++; | ||
201 | if (tsk->latency_record_count >= LT_SAVECOUNT) | ||
202 | goto out_unlock; | ||
203 | |||
204 | for (i = 0; i < LT_SAVECOUNT; i++) { | ||
205 | struct latency_record *mylat; | 198 | struct latency_record *mylat; |
206 | int same = 1; | 199 | int same = 1; |
207 | 200 | ||
@@ -227,8 +220,14 @@ __account_scheduler_latency(struct task_struct *tsk, int usecs, int inter) | |||
227 | } | 220 | } |
228 | } | 221 | } |
229 | 222 | ||
223 | /* | ||
224 | * short term hack; if we're > 32 we stop; future we recycle: | ||
225 | */ | ||
226 | if (tsk->latency_record_count >= LT_SAVECOUNT) | ||
227 | goto out_unlock; | ||
228 | |||
230 | /* Allocated a new one: */ | 229 | /* Allocated a new one: */ |
231 | i = tsk->latency_record_count; | 230 | i = tsk->latency_record_count++; |
232 | memcpy(&tsk->latency_record[i], &lat, sizeof(struct latency_record)); | 231 | memcpy(&tsk->latency_record[i], &lat, sizeof(struct latency_record)); |
233 | 232 | ||
234 | out_unlock: | 233 | out_unlock: |
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index b98bed3d8182..65b09a836cc3 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -1620,8 +1620,12 @@ static void rotate_ctx(struct perf_event_context *ctx) | |||
1620 | { | 1620 | { |
1621 | raw_spin_lock(&ctx->lock); | 1621 | raw_spin_lock(&ctx->lock); |
1622 | 1622 | ||
1623 | /* Rotate the first entry last of non-pinned groups */ | 1623 | /* |
1624 | list_rotate_left(&ctx->flexible_groups); | 1624 | * Rotate the first entry last of non-pinned groups. Rotation might be |
1625 | * disabled by the inheritance code. | ||
1626 | */ | ||
1627 | if (!ctx->rotate_disable) | ||
1628 | list_rotate_left(&ctx->flexible_groups); | ||
1625 | 1629 | ||
1626 | raw_spin_unlock(&ctx->lock); | 1630 | raw_spin_unlock(&ctx->lock); |
1627 | } | 1631 | } |
@@ -1773,7 +1777,13 @@ static u64 perf_event_read(struct perf_event *event) | |||
1773 | unsigned long flags; | 1777 | unsigned long flags; |
1774 | 1778 | ||
1775 | raw_spin_lock_irqsave(&ctx->lock, flags); | 1779 | raw_spin_lock_irqsave(&ctx->lock, flags); |
1776 | update_context_time(ctx); | 1780 | /* |
1781 | * may read while context is not active | ||
1782 | * (e.g., thread is blocked), in that case | ||
1783 | * we cannot update context time | ||
1784 | */ | ||
1785 | if (ctx->is_active) | ||
1786 | update_context_time(ctx); | ||
1777 | update_event_times(event); | 1787 | update_event_times(event); |
1778 | raw_spin_unlock_irqrestore(&ctx->lock, flags); | 1788 | raw_spin_unlock_irqrestore(&ctx->lock, flags); |
1779 | } | 1789 | } |
@@ -5616,6 +5626,7 @@ int perf_event_init_task(struct task_struct *child) | |||
5616 | struct perf_event *event; | 5626 | struct perf_event *event; |
5617 | struct task_struct *parent = current; | 5627 | struct task_struct *parent = current; |
5618 | int inherited_all = 1; | 5628 | int inherited_all = 1; |
5629 | unsigned long flags; | ||
5619 | int ret = 0; | 5630 | int ret = 0; |
5620 | 5631 | ||
5621 | child->perf_event_ctxp = NULL; | 5632 | child->perf_event_ctxp = NULL; |
@@ -5656,6 +5667,15 @@ int perf_event_init_task(struct task_struct *child) | |||
5656 | break; | 5667 | break; |
5657 | } | 5668 | } |
5658 | 5669 | ||
5670 | /* | ||
5671 | * We can't hold ctx->lock when iterating the ->flexible_group list due | ||
5672 | * to allocations, but we need to prevent rotation because | ||
5673 | * rotate_ctx() will change the list from interrupt context. | ||
5674 | */ | ||
5675 | raw_spin_lock_irqsave(&parent_ctx->lock, flags); | ||
5676 | parent_ctx->rotate_disable = 1; | ||
5677 | raw_spin_unlock_irqrestore(&parent_ctx->lock, flags); | ||
5678 | |||
5659 | list_for_each_entry(event, &parent_ctx->flexible_groups, group_entry) { | 5679 | list_for_each_entry(event, &parent_ctx->flexible_groups, group_entry) { |
5660 | ret = inherit_task_group(event, parent, parent_ctx, child, | 5680 | ret = inherit_task_group(event, parent, parent_ctx, child, |
5661 | &inherited_all); | 5681 | &inherited_all); |
@@ -5663,6 +5683,10 @@ int perf_event_init_task(struct task_struct *child) | |||
5663 | break; | 5683 | break; |
5664 | } | 5684 | } |
5665 | 5685 | ||
5686 | raw_spin_lock_irqsave(&parent_ctx->lock, flags); | ||
5687 | parent_ctx->rotate_disable = 0; | ||
5688 | raw_spin_unlock_irqrestore(&parent_ctx->lock, flags); | ||
5689 | |||
5666 | child_ctx = child->perf_event_ctxp; | 5690 | child_ctx = child->perf_event_ctxp; |
5667 | 5691 | ||
5668 | if (child_ctx && inherited_all) { | 5692 | if (child_ctx && inherited_all) { |
diff --git a/kernel/pm_qos_params.c b/kernel/pm_qos_params.c index 645e541a45f6..0da2837416eb 100644 --- a/kernel/pm_qos_params.c +++ b/kernel/pm_qos_params.c | |||
@@ -120,10 +120,10 @@ static inline int pm_qos_get_value(struct pm_qos_object *o) | |||
120 | 120 | ||
121 | switch (o->type) { | 121 | switch (o->type) { |
122 | case PM_QOS_MIN: | 122 | case PM_QOS_MIN: |
123 | return plist_last(&o->requests)->prio; | 123 | return plist_first(&o->requests)->prio; |
124 | 124 | ||
125 | case PM_QOS_MAX: | 125 | case PM_QOS_MAX: |
126 | return plist_first(&o->requests)->prio; | 126 | return plist_last(&o->requests)->prio; |
127 | 127 | ||
128 | default: | 128 | default: |
129 | /* runtime check for not using enum */ | 129 | /* runtime check for not using enum */ |
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 8dc31e02ae12..7a931a90e4a2 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c | |||
@@ -326,7 +326,6 @@ static int create_image(int platform_mode) | |||
326 | int hibernation_snapshot(int platform_mode) | 326 | int hibernation_snapshot(int platform_mode) |
327 | { | 327 | { |
328 | int error; | 328 | int error; |
329 | gfp_t saved_mask; | ||
330 | 329 | ||
331 | error = platform_begin(platform_mode); | 330 | error = platform_begin(platform_mode); |
332 | if (error) | 331 | if (error) |
@@ -338,7 +337,7 @@ int hibernation_snapshot(int platform_mode) | |||
338 | goto Close; | 337 | goto Close; |
339 | 338 | ||
340 | suspend_console(); | 339 | suspend_console(); |
341 | saved_mask = clear_gfp_allowed_mask(GFP_IOFS); | 340 | pm_restrict_gfp_mask(); |
342 | error = dpm_suspend_start(PMSG_FREEZE); | 341 | error = dpm_suspend_start(PMSG_FREEZE); |
343 | if (error) | 342 | if (error) |
344 | goto Recover_platform; | 343 | goto Recover_platform; |
@@ -347,7 +346,10 @@ int hibernation_snapshot(int platform_mode) | |||
347 | goto Recover_platform; | 346 | goto Recover_platform; |
348 | 347 | ||
349 | error = create_image(platform_mode); | 348 | error = create_image(platform_mode); |
350 | /* Control returns here after successful restore */ | 349 | /* |
350 | * Control returns here (1) after the image has been created or the | ||
351 | * image creation has failed and (2) after a successful restore. | ||
352 | */ | ||
351 | 353 | ||
352 | Resume_devices: | 354 | Resume_devices: |
353 | /* We may need to release the preallocated image pages here. */ | 355 | /* We may need to release the preallocated image pages here. */ |
@@ -356,7 +358,10 @@ int hibernation_snapshot(int platform_mode) | |||
356 | 358 | ||
357 | dpm_resume_end(in_suspend ? | 359 | dpm_resume_end(in_suspend ? |
358 | (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE); | 360 | (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE); |
359 | set_gfp_allowed_mask(saved_mask); | 361 | |
362 | if (error || !in_suspend) | ||
363 | pm_restore_gfp_mask(); | ||
364 | |||
360 | resume_console(); | 365 | resume_console(); |
361 | Close: | 366 | Close: |
362 | platform_end(platform_mode); | 367 | platform_end(platform_mode); |
@@ -451,17 +456,16 @@ static int resume_target_kernel(bool platform_mode) | |||
451 | int hibernation_restore(int platform_mode) | 456 | int hibernation_restore(int platform_mode) |
452 | { | 457 | { |
453 | int error; | 458 | int error; |
454 | gfp_t saved_mask; | ||
455 | 459 | ||
456 | pm_prepare_console(); | 460 | pm_prepare_console(); |
457 | suspend_console(); | 461 | suspend_console(); |
458 | saved_mask = clear_gfp_allowed_mask(GFP_IOFS); | 462 | pm_restrict_gfp_mask(); |
459 | error = dpm_suspend_start(PMSG_QUIESCE); | 463 | error = dpm_suspend_start(PMSG_QUIESCE); |
460 | if (!error) { | 464 | if (!error) { |
461 | error = resume_target_kernel(platform_mode); | 465 | error = resume_target_kernel(platform_mode); |
462 | dpm_resume_end(PMSG_RECOVER); | 466 | dpm_resume_end(PMSG_RECOVER); |
463 | } | 467 | } |
464 | set_gfp_allowed_mask(saved_mask); | 468 | pm_restore_gfp_mask(); |
465 | resume_console(); | 469 | resume_console(); |
466 | pm_restore_console(); | 470 | pm_restore_console(); |
467 | return error; | 471 | return error; |
@@ -475,7 +479,6 @@ int hibernation_restore(int platform_mode) | |||
475 | int hibernation_platform_enter(void) | 479 | int hibernation_platform_enter(void) |
476 | { | 480 | { |
477 | int error; | 481 | int error; |
478 | gfp_t saved_mask; | ||
479 | 482 | ||
480 | if (!hibernation_ops) | 483 | if (!hibernation_ops) |
481 | return -ENOSYS; | 484 | return -ENOSYS; |
@@ -491,7 +494,6 @@ int hibernation_platform_enter(void) | |||
491 | 494 | ||
492 | entering_platform_hibernation = true; | 495 | entering_platform_hibernation = true; |
493 | suspend_console(); | 496 | suspend_console(); |
494 | saved_mask = clear_gfp_allowed_mask(GFP_IOFS); | ||
495 | error = dpm_suspend_start(PMSG_HIBERNATE); | 497 | error = dpm_suspend_start(PMSG_HIBERNATE); |
496 | if (error) { | 498 | if (error) { |
497 | if (hibernation_ops->recover) | 499 | if (hibernation_ops->recover) |
@@ -535,7 +537,6 @@ int hibernation_platform_enter(void) | |||
535 | Resume_devices: | 537 | Resume_devices: |
536 | entering_platform_hibernation = false; | 538 | entering_platform_hibernation = false; |
537 | dpm_resume_end(PMSG_RESTORE); | 539 | dpm_resume_end(PMSG_RESTORE); |
538 | set_gfp_allowed_mask(saved_mask); | ||
539 | resume_console(); | 540 | resume_console(); |
540 | 541 | ||
541 | Close: | 542 | Close: |
@@ -643,6 +644,7 @@ int hibernate(void) | |||
643 | swsusp_free(); | 644 | swsusp_free(); |
644 | if (!error) | 645 | if (!error) |
645 | power_down(); | 646 | power_down(); |
647 | pm_restore_gfp_mask(); | ||
646 | } else { | 648 | } else { |
647 | pr_debug("PM: Image restored successfully.\n"); | 649 | pr_debug("PM: Image restored successfully.\n"); |
648 | } | 650 | } |
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 7335952ee473..ecf770509d0d 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c | |||
@@ -197,7 +197,6 @@ static int suspend_enter(suspend_state_t state) | |||
197 | int suspend_devices_and_enter(suspend_state_t state) | 197 | int suspend_devices_and_enter(suspend_state_t state) |
198 | { | 198 | { |
199 | int error; | 199 | int error; |
200 | gfp_t saved_mask; | ||
201 | 200 | ||
202 | if (!suspend_ops) | 201 | if (!suspend_ops) |
203 | return -ENOSYS; | 202 | return -ENOSYS; |
@@ -208,7 +207,7 @@ int suspend_devices_and_enter(suspend_state_t state) | |||
208 | goto Close; | 207 | goto Close; |
209 | } | 208 | } |
210 | suspend_console(); | 209 | suspend_console(); |
211 | saved_mask = clear_gfp_allowed_mask(GFP_IOFS); | 210 | pm_restrict_gfp_mask(); |
212 | suspend_test_start(); | 211 | suspend_test_start(); |
213 | error = dpm_suspend_start(PMSG_SUSPEND); | 212 | error = dpm_suspend_start(PMSG_SUSPEND); |
214 | if (error) { | 213 | if (error) { |
@@ -225,7 +224,7 @@ int suspend_devices_and_enter(suspend_state_t state) | |||
225 | suspend_test_start(); | 224 | suspend_test_start(); |
226 | dpm_resume_end(PMSG_RESUME); | 225 | dpm_resume_end(PMSG_RESUME); |
227 | suspend_test_finish("resume devices"); | 226 | suspend_test_finish("resume devices"); |
228 | set_gfp_allowed_mask(saved_mask); | 227 | pm_restore_gfp_mask(); |
229 | resume_console(); | 228 | resume_console(); |
230 | Close: | 229 | Close: |
231 | if (suspend_ops->end) | 230 | if (suspend_ops->end) |
diff --git a/kernel/power/user.c b/kernel/power/user.c index e819e17877ca..c36c3b9e8a84 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c | |||
@@ -137,7 +137,7 @@ static int snapshot_release(struct inode *inode, struct file *filp) | |||
137 | free_all_swap_pages(data->swap); | 137 | free_all_swap_pages(data->swap); |
138 | if (data->frozen) | 138 | if (data->frozen) |
139 | thaw_processes(); | 139 | thaw_processes(); |
140 | pm_notifier_call_chain(data->mode == O_WRONLY ? | 140 | pm_notifier_call_chain(data->mode == O_RDONLY ? |
141 | PM_POST_HIBERNATION : PM_POST_RESTORE); | 141 | PM_POST_HIBERNATION : PM_POST_RESTORE); |
142 | atomic_inc(&snapshot_device_available); | 142 | atomic_inc(&snapshot_device_available); |
143 | 143 | ||
@@ -263,6 +263,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, | |||
263 | case SNAPSHOT_UNFREEZE: | 263 | case SNAPSHOT_UNFREEZE: |
264 | if (!data->frozen || data->ready) | 264 | if (!data->frozen || data->ready) |
265 | break; | 265 | break; |
266 | pm_restore_gfp_mask(); | ||
266 | thaw_processes(); | 267 | thaw_processes(); |
267 | usermodehelper_enable(); | 268 | usermodehelper_enable(); |
268 | data->frozen = 0; | 269 | data->frozen = 0; |
@@ -275,6 +276,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, | |||
275 | error = -EPERM; | 276 | error = -EPERM; |
276 | break; | 277 | break; |
277 | } | 278 | } |
279 | pm_restore_gfp_mask(); | ||
278 | error = hibernation_snapshot(data->platform_support); | 280 | error = hibernation_snapshot(data->platform_support); |
279 | if (!error) | 281 | if (!error) |
280 | error = put_user(in_suspend, (int __user *)arg); | 282 | error = put_user(in_suspend, (int __user *)arg); |
diff --git a/kernel/printk.c b/kernel/printk.c index 9dc8ea140426..2dc36b49d2d2 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
@@ -1072,13 +1072,15 @@ void printk_tick(void) | |||
1072 | 1072 | ||
1073 | int printk_needs_cpu(int cpu) | 1073 | int printk_needs_cpu(int cpu) |
1074 | { | 1074 | { |
1075 | if (unlikely(cpu_is_offline(cpu))) | ||
1076 | printk_tick(); | ||
1075 | return per_cpu(printk_pending, cpu); | 1077 | return per_cpu(printk_pending, cpu); |
1076 | } | 1078 | } |
1077 | 1079 | ||
1078 | void wake_up_klogd(void) | 1080 | void wake_up_klogd(void) |
1079 | { | 1081 | { |
1080 | if (!trace_override && waitqueue_active(&log_wait)) | 1082 | if (!trace_override && waitqueue_active(&log_wait)) |
1081 | __raw_get_cpu_var(printk_pending) = 1; | 1083 | this_cpu_write(printk_pending, 1); |
1082 | } | 1084 | } |
1083 | 1085 | ||
1084 | /** | 1086 | /** |
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index f34d798ef4a2..bf768d739e7d 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -313,7 +313,7 @@ int ptrace_detach(struct task_struct *child, unsigned int data) | |||
313 | child->exit_code = data; | 313 | child->exit_code = data; |
314 | dead = __ptrace_detach(current, child); | 314 | dead = __ptrace_detach(current, child); |
315 | if (!child->exit_state) | 315 | if (!child->exit_state) |
316 | wake_up_process(child); | 316 | wake_up_state(child, TASK_TRACED | TASK_STOPPED); |
317 | } | 317 | } |
318 | write_unlock_irq(&tasklist_lock); | 318 | write_unlock_irq(&tasklist_lock); |
319 | 319 | ||
diff --git a/kernel/sched.c b/kernel/sched.c index 093df593e45d..b3f2b4187859 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -583,7 +583,7 @@ void check_preempt_curr(struct rq *rq, struct task_struct *p, int flags) | |||
583 | * cases. LITMUS^RT amplifies the effects of this problem. Hence, we | 583 | * cases. LITMUS^RT amplifies the effects of this problem. Hence, we |
584 | * turn it off to avoid stalling clocks. */ | 584 | * turn it off to avoid stalling clocks. */ |
585 | /* | 585 | /* |
586 | if (test_tsk_need_resched(p)) | 586 | if (rq->curr->se.on_rq && test_tsk_need_resched(p)) |
587 | rq->skip_clock_update = 1; | 587 | rq->skip_clock_update = 1; |
588 | */ | 588 | */ |
589 | } | 589 | } |
@@ -741,7 +741,7 @@ sched_feat_write(struct file *filp, const char __user *ubuf, | |||
741 | size_t cnt, loff_t *ppos) | 741 | size_t cnt, loff_t *ppos) |
742 | { | 742 | { |
743 | char buf[64]; | 743 | char buf[64]; |
744 | char *cmp = buf; | 744 | char *cmp; |
745 | int neg = 0; | 745 | int neg = 0; |
746 | int i; | 746 | int i; |
747 | 747 | ||
@@ -752,6 +752,7 @@ sched_feat_write(struct file *filp, const char __user *ubuf, | |||
752 | return -EFAULT; | 752 | return -EFAULT; |
753 | 753 | ||
754 | buf[cnt] = 0; | 754 | buf[cnt] = 0; |
755 | cmp = strstrip(buf); | ||
755 | 756 | ||
756 | if (strncmp(buf, "NO_", 3) == 0) { | 757 | if (strncmp(buf, "NO_", 3) == 0) { |
757 | neg = 1; | 758 | neg = 1; |
@@ -759,9 +760,7 @@ sched_feat_write(struct file *filp, const char __user *ubuf, | |||
759 | } | 760 | } |
760 | 761 | ||
761 | for (i = 0; sched_feat_names[i]; i++) { | 762 | for (i = 0; sched_feat_names[i]; i++) { |
762 | int len = strlen(sched_feat_names[i]); | 763 | if (strcmp(cmp, sched_feat_names[i]) == 0) { |
763 | |||
764 | if (strncmp(cmp, sched_feat_names[i], len) == 0) { | ||
765 | if (neg) | 764 | if (neg) |
766 | sysctl_sched_features &= ~(1UL << i); | 765 | sysctl_sched_features &= ~(1UL << i); |
767 | else | 766 | else |
@@ -1877,12 +1876,6 @@ static void dec_nr_running(struct rq *rq) | |||
1877 | 1876 | ||
1878 | static void set_load_weight(struct task_struct *p) | 1877 | static void set_load_weight(struct task_struct *p) |
1879 | { | 1878 | { |
1880 | if (task_has_rt_policy(p)) { | ||
1881 | p->se.load.weight = 0; | ||
1882 | p->se.load.inv_weight = WMULT_CONST; | ||
1883 | return; | ||
1884 | } | ||
1885 | |||
1886 | /* | 1879 | /* |
1887 | * SCHED_IDLE tasks get minimal weight: | 1880 | * SCHED_IDLE tasks get minimal weight: |
1888 | */ | 1881 | */ |
@@ -3011,6 +3004,15 @@ static long calc_load_fold_active(struct rq *this_rq) | |||
3011 | return delta; | 3004 | return delta; |
3012 | } | 3005 | } |
3013 | 3006 | ||
3007 | static unsigned long | ||
3008 | calc_load(unsigned long load, unsigned long exp, unsigned long active) | ||
3009 | { | ||
3010 | load *= exp; | ||
3011 | load += active * (FIXED_1 - exp); | ||
3012 | load += 1UL << (FSHIFT - 1); | ||
3013 | return load >> FSHIFT; | ||
3014 | } | ||
3015 | |||
3014 | #ifdef CONFIG_NO_HZ | 3016 | #ifdef CONFIG_NO_HZ |
3015 | /* | 3017 | /* |
3016 | * For NO_HZ we delay the active fold to the next LOAD_FREQ update. | 3018 | * For NO_HZ we delay the active fold to the next LOAD_FREQ update. |
@@ -3040,6 +3042,128 @@ static long calc_load_fold_idle(void) | |||
3040 | 3042 | ||
3041 | return delta; | 3043 | return delta; |
3042 | } | 3044 | } |
3045 | |||
3046 | /** | ||
3047 | * fixed_power_int - compute: x^n, in O(log n) time | ||
3048 | * | ||
3049 | * @x: base of the power | ||
3050 | * @frac_bits: fractional bits of @x | ||
3051 | * @n: power to raise @x to. | ||
3052 | * | ||
3053 | * By exploiting the relation between the definition of the natural power | ||
3054 | * function: x^n := x*x*...*x (x multiplied by itself for n times), and | ||
3055 | * the binary encoding of numbers used by computers: n := \Sum n_i * 2^i, | ||
3056 | * (where: n_i \elem {0, 1}, the binary vector representing n), | ||
3057 | * we find: x^n := x^(\Sum n_i * 2^i) := \Prod x^(n_i * 2^i), which is | ||
3058 | * of course trivially computable in O(log_2 n), the length of our binary | ||
3059 | * vector. | ||
3060 | */ | ||
3061 | static unsigned long | ||
3062 | fixed_power_int(unsigned long x, unsigned int frac_bits, unsigned int n) | ||
3063 | { | ||
3064 | unsigned long result = 1UL << frac_bits; | ||
3065 | |||
3066 | if (n) for (;;) { | ||
3067 | if (n & 1) { | ||
3068 | result *= x; | ||
3069 | result += 1UL << (frac_bits - 1); | ||
3070 | result >>= frac_bits; | ||
3071 | } | ||
3072 | n >>= 1; | ||
3073 | if (!n) | ||
3074 | break; | ||
3075 | x *= x; | ||
3076 | x += 1UL << (frac_bits - 1); | ||
3077 | x >>= frac_bits; | ||
3078 | } | ||
3079 | |||
3080 | return result; | ||
3081 | } | ||
3082 | |||
3083 | /* | ||
3084 | * a1 = a0 * e + a * (1 - e) | ||
3085 | * | ||
3086 | * a2 = a1 * e + a * (1 - e) | ||
3087 | * = (a0 * e + a * (1 - e)) * e + a * (1 - e) | ||
3088 | * = a0 * e^2 + a * (1 - e) * (1 + e) | ||
3089 | * | ||
3090 | * a3 = a2 * e + a * (1 - e) | ||
3091 | * = (a0 * e^2 + a * (1 - e) * (1 + e)) * e + a * (1 - e) | ||
3092 | * = a0 * e^3 + a * (1 - e) * (1 + e + e^2) | ||
3093 | * | ||
3094 | * ... | ||
3095 | * | ||
3096 | * an = a0 * e^n + a * (1 - e) * (1 + e + ... + e^n-1) [1] | ||
3097 | * = a0 * e^n + a * (1 - e) * (1 - e^n)/(1 - e) | ||
3098 | * = a0 * e^n + a * (1 - e^n) | ||
3099 | * | ||
3100 | * [1] application of the geometric series: | ||
3101 | * | ||
3102 | * n 1 - x^(n+1) | ||
3103 | * S_n := \Sum x^i = ------------- | ||
3104 | * i=0 1 - x | ||
3105 | */ | ||
3106 | static unsigned long | ||
3107 | calc_load_n(unsigned long load, unsigned long exp, | ||
3108 | unsigned long active, unsigned int n) | ||
3109 | { | ||
3110 | |||
3111 | return calc_load(load, fixed_power_int(exp, FSHIFT, n), active); | ||
3112 | } | ||
3113 | |||
3114 | /* | ||
3115 | * NO_HZ can leave us missing all per-cpu ticks calling | ||
3116 | * calc_load_account_active(), but since an idle CPU folds its delta into | ||
3117 | * calc_load_tasks_idle per calc_load_account_idle(), all we need to do is fold | ||
3118 | * in the pending idle delta if our idle period crossed a load cycle boundary. | ||
3119 | * | ||
3120 | * Once we've updated the global active value, we need to apply the exponential | ||
3121 | * weights adjusted to the number of cycles missed. | ||
3122 | */ | ||
3123 | static void calc_global_nohz(unsigned long ticks) | ||
3124 | { | ||
3125 | long delta, active, n; | ||
3126 | |||
3127 | if (time_before(jiffies, calc_load_update)) | ||
3128 | return; | ||
3129 | |||
3130 | /* | ||
3131 | * If we crossed a calc_load_update boundary, make sure to fold | ||
3132 | * any pending idle changes, the respective CPUs might have | ||
3133 | * missed the tick driven calc_load_account_active() update | ||
3134 | * due to NO_HZ. | ||
3135 | */ | ||
3136 | delta = calc_load_fold_idle(); | ||
3137 | if (delta) | ||
3138 | atomic_long_add(delta, &calc_load_tasks); | ||
3139 | |||
3140 | /* | ||
3141 | * If we were idle for multiple load cycles, apply them. | ||
3142 | */ | ||
3143 | if (ticks >= LOAD_FREQ) { | ||
3144 | n = ticks / LOAD_FREQ; | ||
3145 | |||
3146 | active = atomic_long_read(&calc_load_tasks); | ||
3147 | active = active > 0 ? active * FIXED_1 : 0; | ||
3148 | |||
3149 | avenrun[0] = calc_load_n(avenrun[0], EXP_1, active, n); | ||
3150 | avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n); | ||
3151 | avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n); | ||
3152 | |||
3153 | calc_load_update += n * LOAD_FREQ; | ||
3154 | } | ||
3155 | |||
3156 | /* | ||
3157 | * Its possible the remainder of the above division also crosses | ||
3158 | * a LOAD_FREQ period, the regular check in calc_global_load() | ||
3159 | * which comes after this will take care of that. | ||
3160 | * | ||
3161 | * Consider us being 11 ticks before a cycle completion, and us | ||
3162 | * sleeping for 4*LOAD_FREQ + 22 ticks, then the above code will | ||
3163 | * age us 4 cycles, and the test in calc_global_load() will | ||
3164 | * pick up the final one. | ||
3165 | */ | ||
3166 | } | ||
3043 | #else | 3167 | #else |
3044 | static void calc_load_account_idle(struct rq *this_rq) | 3168 | static void calc_load_account_idle(struct rq *this_rq) |
3045 | { | 3169 | { |
@@ -3049,6 +3173,10 @@ static inline long calc_load_fold_idle(void) | |||
3049 | { | 3173 | { |
3050 | return 0; | 3174 | return 0; |
3051 | } | 3175 | } |
3176 | |||
3177 | static void calc_global_nohz(unsigned long ticks) | ||
3178 | { | ||
3179 | } | ||
3052 | #endif | 3180 | #endif |
3053 | 3181 | ||
3054 | /** | 3182 | /** |
@@ -3066,24 +3194,17 @@ void get_avenrun(unsigned long *loads, unsigned long offset, int shift) | |||
3066 | loads[2] = (avenrun[2] + offset) << shift; | 3194 | loads[2] = (avenrun[2] + offset) << shift; |
3067 | } | 3195 | } |
3068 | 3196 | ||
3069 | static unsigned long | ||
3070 | calc_load(unsigned long load, unsigned long exp, unsigned long active) | ||
3071 | { | ||
3072 | load *= exp; | ||
3073 | load += active * (FIXED_1 - exp); | ||
3074 | return load >> FSHIFT; | ||
3075 | } | ||
3076 | |||
3077 | /* | 3197 | /* |
3078 | * calc_load - update the avenrun load estimates 10 ticks after the | 3198 | * calc_load - update the avenrun load estimates 10 ticks after the |
3079 | * CPUs have updated calc_load_tasks. | 3199 | * CPUs have updated calc_load_tasks. |
3080 | */ | 3200 | */ |
3081 | void calc_global_load(void) | 3201 | void calc_global_load(unsigned long ticks) |
3082 | { | 3202 | { |
3083 | unsigned long upd = calc_load_update + 10; | ||
3084 | long active; | 3203 | long active; |
3085 | 3204 | ||
3086 | if (time_before(jiffies, upd)) | 3205 | calc_global_nohz(ticks); |
3206 | |||
3207 | if (time_before(jiffies, calc_load_update + 10)) | ||
3087 | return; | 3208 | return; |
3088 | 3209 | ||
3089 | active = atomic_long_read(&calc_load_tasks); | 3210 | active = atomic_long_read(&calc_load_tasks); |
@@ -3745,7 +3866,6 @@ static void put_prev_task(struct rq *rq, struct task_struct *prev) | |||
3745 | { | 3866 | { |
3746 | if (prev->se.on_rq) | 3867 | if (prev->se.on_rq) |
3747 | update_rq_clock(rq); | 3868 | update_rq_clock(rq); |
3748 | rq->skip_clock_update = 0; | ||
3749 | prev->sched_class->put_prev_task(rq, prev); | 3869 | prev->sched_class->put_prev_task(rq, prev); |
3750 | } | 3870 | } |
3751 | 3871 | ||
@@ -3821,7 +3941,6 @@ need_resched_nonpreemptible: | |||
3821 | hrtick_clear(rq); | 3941 | hrtick_clear(rq); |
3822 | 3942 | ||
3823 | raw_spin_lock_irq(&rq->lock); | 3943 | raw_spin_lock_irq(&rq->lock); |
3824 | clear_tsk_need_resched(prev); | ||
3825 | 3944 | ||
3826 | switch_count = &prev->nivcsw; | 3945 | switch_count = &prev->nivcsw; |
3827 | if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) { | 3946 | if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) { |
@@ -3853,6 +3972,8 @@ need_resched_nonpreemptible: | |||
3853 | 3972 | ||
3854 | put_prev_task(rq, prev); | 3973 | put_prev_task(rq, prev); |
3855 | next = pick_next_task(rq); | 3974 | next = pick_next_task(rq); |
3975 | clear_tsk_need_resched(prev); | ||
3976 | rq->skip_clock_update = 0; | ||
3856 | 3977 | ||
3857 | if (likely(prev != next)) { | 3978 | if (likely(prev != next)) { |
3858 | sched_info_switch(prev, next); | 3979 | sched_info_switch(prev, next); |
@@ -5439,7 +5560,19 @@ void __cpuinit init_idle(struct task_struct *idle, int cpu) | |||
5439 | idle->se.exec_start = sched_clock(); | 5560 | idle->se.exec_start = sched_clock(); |
5440 | 5561 | ||
5441 | cpumask_copy(&idle->cpus_allowed, cpumask_of(cpu)); | 5562 | cpumask_copy(&idle->cpus_allowed, cpumask_of(cpu)); |
5563 | /* | ||
5564 | * We're having a chicken and egg problem, even though we are | ||
5565 | * holding rq->lock, the cpu isn't yet set to this cpu so the | ||
5566 | * lockdep check in task_group() will fail. | ||
5567 | * | ||
5568 | * Similar case to sched_fork(). / Alternatively we could | ||
5569 | * use task_rq_lock() here and obtain the other rq->lock. | ||
5570 | * | ||
5571 | * Silence PROVE_RCU | ||
5572 | */ | ||
5573 | rcu_read_lock(); | ||
5442 | __set_task_cpu(idle, cpu); | 5574 | __set_task_cpu(idle, cpu); |
5575 | rcu_read_unlock(); | ||
5443 | 5576 | ||
5444 | rq->curr = rq->idle = idle; | 5577 | rq->curr = rq->idle = idle; |
5445 | #if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW) | 5578 | #if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW) |
diff --git a/kernel/smp.c b/kernel/smp.c index ed6aacfcb7ef..1ba1ba4b42f8 100644 --- a/kernel/smp.c +++ b/kernel/smp.c | |||
@@ -194,6 +194,24 @@ void generic_smp_call_function_interrupt(void) | |||
194 | list_for_each_entry_rcu(data, &call_function.queue, csd.list) { | 194 | list_for_each_entry_rcu(data, &call_function.queue, csd.list) { |
195 | int refs; | 195 | int refs; |
196 | 196 | ||
197 | /* | ||
198 | * Since we walk the list without any locks, we might | ||
199 | * see an entry that was completed, removed from the | ||
200 | * list and is in the process of being reused. | ||
201 | * | ||
202 | * We must check that the cpu is in the cpumask before | ||
203 | * checking the refs, and both must be set before | ||
204 | * executing the callback on this cpu. | ||
205 | */ | ||
206 | |||
207 | if (!cpumask_test_cpu(cpu, data->cpumask)) | ||
208 | continue; | ||
209 | |||
210 | smp_rmb(); | ||
211 | |||
212 | if (atomic_read(&data->refs) == 0) | ||
213 | continue; | ||
214 | |||
197 | if (!cpumask_test_and_clear_cpu(cpu, data->cpumask)) | 215 | if (!cpumask_test_and_clear_cpu(cpu, data->cpumask)) |
198 | continue; | 216 | continue; |
199 | 217 | ||
@@ -202,6 +220,8 @@ void generic_smp_call_function_interrupt(void) | |||
202 | refs = atomic_dec_return(&data->refs); | 220 | refs = atomic_dec_return(&data->refs); |
203 | WARN_ON(refs < 0); | 221 | WARN_ON(refs < 0); |
204 | if (!refs) { | 222 | if (!refs) { |
223 | WARN_ON(!cpumask_empty(data->cpumask)); | ||
224 | |||
205 | raw_spin_lock(&call_function.lock); | 225 | raw_spin_lock(&call_function.lock); |
206 | list_del_rcu(&data->csd.list); | 226 | list_del_rcu(&data->csd.list); |
207 | raw_spin_unlock(&call_function.lock); | 227 | raw_spin_unlock(&call_function.lock); |
@@ -453,11 +473,21 @@ void smp_call_function_many(const struct cpumask *mask, | |||
453 | 473 | ||
454 | data = &__get_cpu_var(cfd_data); | 474 | data = &__get_cpu_var(cfd_data); |
455 | csd_lock(&data->csd); | 475 | csd_lock(&data->csd); |
476 | BUG_ON(atomic_read(&data->refs) || !cpumask_empty(data->cpumask)); | ||
456 | 477 | ||
457 | data->csd.func = func; | 478 | data->csd.func = func; |
458 | data->csd.info = info; | 479 | data->csd.info = info; |
459 | cpumask_and(data->cpumask, mask, cpu_online_mask); | 480 | cpumask_and(data->cpumask, mask, cpu_online_mask); |
460 | cpumask_clear_cpu(this_cpu, data->cpumask); | 481 | cpumask_clear_cpu(this_cpu, data->cpumask); |
482 | |||
483 | /* | ||
484 | * To ensure the interrupt handler gets an complete view | ||
485 | * we order the cpumask and refs writes and order the read | ||
486 | * of them in the interrupt handler. In addition we may | ||
487 | * only clear our own cpu bit from the mask. | ||
488 | */ | ||
489 | smp_wmb(); | ||
490 | |||
461 | atomic_set(&data->refs, cpumask_weight(data->cpumask)); | 491 | atomic_set(&data->refs, cpumask_weight(data->cpumask)); |
462 | 492 | ||
463 | raw_spin_lock_irqsave(&call_function.lock, flags); | 493 | raw_spin_lock_irqsave(&call_function.lock, flags); |
diff --git a/kernel/sys.c b/kernel/sys.c index 7f5a0cd296a9..66136ca33a7b 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -1377,7 +1377,8 @@ static int check_prlimit_permission(struct task_struct *task) | |||
1377 | const struct cred *cred = current_cred(), *tcred; | 1377 | const struct cred *cred = current_cred(), *tcred; |
1378 | 1378 | ||
1379 | tcred = __task_cred(task); | 1379 | tcred = __task_cred(task); |
1380 | if ((cred->uid != tcred->euid || | 1380 | if (current != task && |
1381 | (cred->uid != tcred->euid || | ||
1381 | cred->uid != tcred->suid || | 1382 | cred->uid != tcred->suid || |
1382 | cred->uid != tcred->uid || | 1383 | cred->uid != tcred->uid || |
1383 | cred->gid != tcred->egid || | 1384 | cred->gid != tcred->egid || |
diff --git a/kernel/timer.c b/kernel/timer.c index 97bf05baade7..102ad370dddb 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -1252,6 +1252,12 @@ unsigned long get_next_timer_interrupt(unsigned long now) | |||
1252 | struct tvec_base *base = __get_cpu_var(tvec_bases); | 1252 | struct tvec_base *base = __get_cpu_var(tvec_bases); |
1253 | unsigned long expires; | 1253 | unsigned long expires; |
1254 | 1254 | ||
1255 | /* | ||
1256 | * Pretend that there is no timer pending if the cpu is offline. | ||
1257 | * Possible pending timers will be migrated later to an active cpu. | ||
1258 | */ | ||
1259 | if (cpu_is_offline(smp_processor_id())) | ||
1260 | return now + NEXT_TIMER_MAX_DELTA; | ||
1255 | spin_lock(&base->lock); | 1261 | spin_lock(&base->lock); |
1256 | if (time_before_eq(base->next_timer, base->timer_jiffies)) | 1262 | if (time_before_eq(base->next_timer, base->timer_jiffies)) |
1257 | base->next_timer = __next_timer_interrupt(base); | 1263 | base->next_timer = __next_timer_interrupt(base); |
@@ -1316,7 +1322,7 @@ void do_timer(unsigned long ticks) | |||
1316 | { | 1322 | { |
1317 | jiffies_64 += ticks; | 1323 | jiffies_64 += ticks; |
1318 | update_wall_time(); | 1324 | update_wall_time(); |
1319 | calc_global_load(); | 1325 | calc_global_load(ticks); |
1320 | } | 1326 | } |
1321 | 1327 | ||
1322 | #ifdef __ARCH_WANT_SYS_ALARM | 1328 | #ifdef __ARCH_WANT_SYS_ALARM |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 9ec59f541156..7702f5aecd07 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -2320,11 +2320,19 @@ tracing_write_stub(struct file *filp, const char __user *ubuf, | |||
2320 | return count; | 2320 | return count; |
2321 | } | 2321 | } |
2322 | 2322 | ||
2323 | static loff_t tracing_seek(struct file *file, loff_t offset, int origin) | ||
2324 | { | ||
2325 | if (file->f_mode & FMODE_READ) | ||
2326 | return seq_lseek(file, offset, origin); | ||
2327 | else | ||
2328 | return 0; | ||
2329 | } | ||
2330 | |||
2323 | static const struct file_operations tracing_fops = { | 2331 | static const struct file_operations tracing_fops = { |
2324 | .open = tracing_open, | 2332 | .open = tracing_open, |
2325 | .read = seq_read, | 2333 | .read = seq_read, |
2326 | .write = tracing_write_stub, | 2334 | .write = tracing_write_stub, |
2327 | .llseek = seq_lseek, | 2335 | .llseek = tracing_seek, |
2328 | .release = tracing_release, | 2336 | .release = tracing_release, |
2329 | }; | 2337 | }; |
2330 | 2338 | ||
diff --git a/kernel/user.c b/kernel/user.c index 7e72614b736d..8ce395f74d47 100644 --- a/kernel/user.c +++ b/kernel/user.c | |||
@@ -157,6 +157,7 @@ struct user_struct *alloc_uid(struct user_namespace *ns, uid_t uid) | |||
157 | spin_lock_irq(&uidhash_lock); | 157 | spin_lock_irq(&uidhash_lock); |
158 | up = uid_hash_find(uid, hashent); | 158 | up = uid_hash_find(uid, hashent); |
159 | if (up) { | 159 | if (up) { |
160 | put_user_ns(ns); | ||
160 | key_put(new->uid_keyring); | 161 | key_put(new->uid_keyring); |
161 | key_put(new->session_keyring); | 162 | key_put(new->session_keyring); |
162 | kmem_cache_free(uid_cachep, new); | 163 | kmem_cache_free(uid_cachep, new); |
diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 7f9c3c52ecc1..e359b2e7e7d5 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c | |||
@@ -377,7 +377,8 @@ static int watchdog_nmi_enable(int cpu) | |||
377 | goto out_save; | 377 | goto out_save; |
378 | } | 378 | } |
379 | 379 | ||
380 | printk(KERN_ERR "NMI watchdog failed to create perf event on cpu%i: %p\n", cpu, event); | 380 | printk(KERN_ERR "NMI watchdog disabled for cpu%i: unable to create perf event: %ld\n", |
381 | cpu, PTR_ERR(event)); | ||
381 | return -1; | 382 | return -1; |
382 | 383 | ||
383 | /* success path */ | 384 | /* success path */ |
@@ -440,9 +441,6 @@ static int watchdog_enable(int cpu) | |||
440 | wake_up_process(p); | 441 | wake_up_process(p); |
441 | } | 442 | } |
442 | 443 | ||
443 | /* if any cpu succeeds, watchdog is considered enabled for the system */ | ||
444 | watchdog_enabled = 1; | ||
445 | |||
446 | return 0; | 444 | return 0; |
447 | } | 445 | } |
448 | 446 | ||
@@ -470,12 +468,16 @@ static void watchdog_disable(int cpu) | |||
470 | static void watchdog_enable_all_cpus(void) | 468 | static void watchdog_enable_all_cpus(void) |
471 | { | 469 | { |
472 | int cpu; | 470 | int cpu; |
473 | int result = 0; | 471 | |
472 | watchdog_enabled = 0; | ||
474 | 473 | ||
475 | for_each_online_cpu(cpu) | 474 | for_each_online_cpu(cpu) |
476 | result += watchdog_enable(cpu); | 475 | if (!watchdog_enable(cpu)) |
476 | /* if any cpu succeeds, watchdog is considered | ||
477 | enabled for the system */ | ||
478 | watchdog_enabled = 1; | ||
477 | 479 | ||
478 | if (result) | 480 | if (!watchdog_enabled) |
479 | printk(KERN_ERR "watchdog: failed to be enabled on some cpus\n"); | 481 | printk(KERN_ERR "watchdog: failed to be enabled on some cpus\n"); |
480 | 482 | ||
481 | } | 483 | } |
@@ -503,10 +505,12 @@ int proc_dowatchdog_enabled(struct ctl_table *table, int write, | |||
503 | { | 505 | { |
504 | proc_dointvec(table, write, buffer, length, ppos); | 506 | proc_dointvec(table, write, buffer, length, ppos); |
505 | 507 | ||
506 | if (watchdog_enabled) | 508 | if (write) { |
507 | watchdog_enable_all_cpus(); | 509 | if (watchdog_enabled) |
508 | else | 510 | watchdog_enable_all_cpus(); |
509 | watchdog_disable_all_cpus(); | 511 | else |
512 | watchdog_disable_all_cpus(); | ||
513 | } | ||
510 | return 0; | 514 | return 0; |
511 | } | 515 | } |
512 | 516 | ||