diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/audit.c | 5 | ||||
-rw-r--r-- | kernel/cgroup.c | 14 | ||||
-rw-r--r-- | kernel/context_tracking.c | 12 | ||||
-rw-r--r-- | kernel/events/core.c | 31 | ||||
-rw-r--r-- | kernel/kmod.c | 4 | ||||
-rw-r--r-- | kernel/mutex.c | 32 | ||||
-rw-r--r-- | kernel/params.c | 6 | ||||
-rw-r--r-- | kernel/pid.c | 5 | ||||
-rw-r--r-- | kernel/power/hibernate.c | 2 | ||||
-rw-r--r-- | kernel/power/snapshot.c | 5 | ||||
-rw-r--r-- | kernel/power/user.c | 8 | ||||
-rw-r--r-- | kernel/reboot.c | 9 | ||||
-rw-r--r-- | kernel/sched/debug.c | 6 | ||||
-rw-r--r-- | kernel/sched/fair.c | 23 | ||||
-rw-r--r-- | kernel/sched/stats.h | 5 | ||||
-rw-r--r-- | kernel/softirq.c | 15 | ||||
-rw-r--r-- | kernel/time/clockevents.c | 65 | ||||
-rw-r--r-- | kernel/time/ntp.c | 6 | ||||
-rw-r--r-- | kernel/time/timekeeping.c | 2 | ||||
-rw-r--r-- | kernel/watchdog.c | 60 |
20 files changed, 239 insertions, 76 deletions
diff --git a/kernel/audit.c b/kernel/audit.c index 91e53d04b6a9..7b0e23a740ce 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -1117,9 +1117,10 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, | |||
1117 | 1117 | ||
1118 | sleep_time = timeout_start + audit_backlog_wait_time - | 1118 | sleep_time = timeout_start + audit_backlog_wait_time - |
1119 | jiffies; | 1119 | jiffies; |
1120 | if ((long)sleep_time > 0) | 1120 | if ((long)sleep_time > 0) { |
1121 | wait_for_auditd(sleep_time); | 1121 | wait_for_auditd(sleep_time); |
1122 | continue; | 1122 | continue; |
1123 | } | ||
1123 | } | 1124 | } |
1124 | if (audit_rate_check() && printk_ratelimit()) | 1125 | if (audit_rate_check() && printk_ratelimit()) |
1125 | printk(KERN_WARNING | 1126 | printk(KERN_WARNING |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 2418b6e71a85..8bd9cfdc70d7 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -2039,7 +2039,7 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk, | |||
2039 | 2039 | ||
2040 | /* @tsk either already exited or can't exit until the end */ | 2040 | /* @tsk either already exited or can't exit until the end */ |
2041 | if (tsk->flags & PF_EXITING) | 2041 | if (tsk->flags & PF_EXITING) |
2042 | continue; | 2042 | goto next; |
2043 | 2043 | ||
2044 | /* as per above, nr_threads may decrease, but not increase. */ | 2044 | /* as per above, nr_threads may decrease, but not increase. */ |
2045 | BUG_ON(i >= group_size); | 2045 | BUG_ON(i >= group_size); |
@@ -2047,7 +2047,7 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk, | |||
2047 | ent.cgrp = task_cgroup_from_root(tsk, root); | 2047 | ent.cgrp = task_cgroup_from_root(tsk, root); |
2048 | /* nothing to do if this task is already in the cgroup */ | 2048 | /* nothing to do if this task is already in the cgroup */ |
2049 | if (ent.cgrp == cgrp) | 2049 | if (ent.cgrp == cgrp) |
2050 | continue; | 2050 | goto next; |
2051 | /* | 2051 | /* |
2052 | * saying GFP_ATOMIC has no effect here because we did prealloc | 2052 | * saying GFP_ATOMIC has no effect here because we did prealloc |
2053 | * earlier, but it's good form to communicate our expectations. | 2053 | * earlier, but it's good form to communicate our expectations. |
@@ -2055,7 +2055,7 @@ static int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk, | |||
2055 | retval = flex_array_put(group, i, &ent, GFP_ATOMIC); | 2055 | retval = flex_array_put(group, i, &ent, GFP_ATOMIC); |
2056 | BUG_ON(retval != 0); | 2056 | BUG_ON(retval != 0); |
2057 | i++; | 2057 | i++; |
2058 | 2058 | next: | |
2059 | if (!threadgroup) | 2059 | if (!threadgroup) |
2060 | break; | 2060 | break; |
2061 | } while_each_thread(leader, tsk); | 2061 | } while_each_thread(leader, tsk); |
@@ -3188,11 +3188,9 @@ css_next_descendant_post(struct cgroup_subsys_state *pos, | |||
3188 | 3188 | ||
3189 | WARN_ON_ONCE(!rcu_read_lock_held()); | 3189 | WARN_ON_ONCE(!rcu_read_lock_held()); |
3190 | 3190 | ||
3191 | /* if first iteration, visit the leftmost descendant */ | 3191 | /* if first iteration, visit leftmost descendant which may be @root */ |
3192 | if (!pos) { | 3192 | if (!pos) |
3193 | next = css_leftmost_descendant(root); | 3193 | return css_leftmost_descendant(root); |
3194 | return next != root ? next : NULL; | ||
3195 | } | ||
3196 | 3194 | ||
3197 | /* if we visited @root, we're done */ | 3195 | /* if we visited @root, we're done */ |
3198 | if (pos == root) | 3196 | if (pos == root) |
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c index 247091bf0587..859c8dfd78a1 100644 --- a/kernel/context_tracking.c +++ b/kernel/context_tracking.c | |||
@@ -51,6 +51,15 @@ void context_tracking_user_enter(void) | |||
51 | unsigned long flags; | 51 | unsigned long flags; |
52 | 52 | ||
53 | /* | 53 | /* |
54 | * Repeat the user_enter() check here because some archs may be calling | ||
55 | * this from asm and if no CPU needs context tracking, they shouldn't | ||
56 | * go further. Repeat the check here until they support the static key | ||
57 | * check. | ||
58 | */ | ||
59 | if (!static_key_false(&context_tracking_enabled)) | ||
60 | return; | ||
61 | |||
62 | /* | ||
54 | * Some contexts may involve an exception occuring in an irq, | 63 | * Some contexts may involve an exception occuring in an irq, |
55 | * leading to that nesting: | 64 | * leading to that nesting: |
56 | * rcu_irq_enter() rcu_user_exit() rcu_user_exit() rcu_irq_exit() | 65 | * rcu_irq_enter() rcu_user_exit() rcu_user_exit() rcu_irq_exit() |
@@ -151,6 +160,9 @@ void context_tracking_user_exit(void) | |||
151 | { | 160 | { |
152 | unsigned long flags; | 161 | unsigned long flags; |
153 | 162 | ||
163 | if (!static_key_false(&context_tracking_enabled)) | ||
164 | return; | ||
165 | |||
154 | if (in_interrupt()) | 166 | if (in_interrupt()) |
155 | return; | 167 | return; |
156 | 168 | ||
diff --git a/kernel/events/core.c b/kernel/events/core.c index dd236b66ca3a..953c14348375 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -3660,6 +3660,26 @@ static void calc_timer_values(struct perf_event *event, | |||
3660 | *running = ctx_time - event->tstamp_running; | 3660 | *running = ctx_time - event->tstamp_running; |
3661 | } | 3661 | } |
3662 | 3662 | ||
3663 | static void perf_event_init_userpage(struct perf_event *event) | ||
3664 | { | ||
3665 | struct perf_event_mmap_page *userpg; | ||
3666 | struct ring_buffer *rb; | ||
3667 | |||
3668 | rcu_read_lock(); | ||
3669 | rb = rcu_dereference(event->rb); | ||
3670 | if (!rb) | ||
3671 | goto unlock; | ||
3672 | |||
3673 | userpg = rb->user_page; | ||
3674 | |||
3675 | /* Allow new userspace to detect that bit 0 is deprecated */ | ||
3676 | userpg->cap_bit0_is_deprecated = 1; | ||
3677 | userpg->size = offsetof(struct perf_event_mmap_page, __reserved); | ||
3678 | |||
3679 | unlock: | ||
3680 | rcu_read_unlock(); | ||
3681 | } | ||
3682 | |||
3663 | void __weak arch_perf_update_userpage(struct perf_event_mmap_page *userpg, u64 now) | 3683 | void __weak arch_perf_update_userpage(struct perf_event_mmap_page *userpg, u64 now) |
3664 | { | 3684 | { |
3665 | } | 3685 | } |
@@ -4044,6 +4064,7 @@ again: | |||
4044 | ring_buffer_attach(event, rb); | 4064 | ring_buffer_attach(event, rb); |
4045 | rcu_assign_pointer(event->rb, rb); | 4065 | rcu_assign_pointer(event->rb, rb); |
4046 | 4066 | ||
4067 | perf_event_init_userpage(event); | ||
4047 | perf_event_update_userpage(event); | 4068 | perf_event_update_userpage(event); |
4048 | 4069 | ||
4049 | unlock: | 4070 | unlock: |
@@ -6746,6 +6767,10 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr, | |||
6746 | if (ret) | 6767 | if (ret) |
6747 | return -EFAULT; | 6768 | return -EFAULT; |
6748 | 6769 | ||
6770 | /* disabled for now */ | ||
6771 | if (attr->mmap2) | ||
6772 | return -EINVAL; | ||
6773 | |||
6749 | if (attr->__reserved_1) | 6774 | if (attr->__reserved_1) |
6750 | return -EINVAL; | 6775 | return -EINVAL; |
6751 | 6776 | ||
@@ -7213,15 +7238,15 @@ void perf_pmu_migrate_context(struct pmu *pmu, int src_cpu, int dst_cpu) | |||
7213 | perf_remove_from_context(event); | 7238 | perf_remove_from_context(event); |
7214 | unaccount_event_cpu(event, src_cpu); | 7239 | unaccount_event_cpu(event, src_cpu); |
7215 | put_ctx(src_ctx); | 7240 | put_ctx(src_ctx); |
7216 | list_add(&event->event_entry, &events); | 7241 | list_add(&event->migrate_entry, &events); |
7217 | } | 7242 | } |
7218 | mutex_unlock(&src_ctx->mutex); | 7243 | mutex_unlock(&src_ctx->mutex); |
7219 | 7244 | ||
7220 | synchronize_rcu(); | 7245 | synchronize_rcu(); |
7221 | 7246 | ||
7222 | mutex_lock(&dst_ctx->mutex); | 7247 | mutex_lock(&dst_ctx->mutex); |
7223 | list_for_each_entry_safe(event, tmp, &events, event_entry) { | 7248 | list_for_each_entry_safe(event, tmp, &events, migrate_entry) { |
7224 | list_del(&event->event_entry); | 7249 | list_del(&event->migrate_entry); |
7225 | if (event->state >= PERF_EVENT_STATE_OFF) | 7250 | if (event->state >= PERF_EVENT_STATE_OFF) |
7226 | event->state = PERF_EVENT_STATE_INACTIVE; | 7251 | event->state = PERF_EVENT_STATE_INACTIVE; |
7227 | account_event_cpu(event, dst_cpu); | 7252 | account_event_cpu(event, dst_cpu); |
diff --git a/kernel/kmod.c b/kernel/kmod.c index fb326365b694..b086006c59e7 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
@@ -571,6 +571,10 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait) | |||
571 | DECLARE_COMPLETION_ONSTACK(done); | 571 | DECLARE_COMPLETION_ONSTACK(done); |
572 | int retval = 0; | 572 | int retval = 0; |
573 | 573 | ||
574 | if (!sub_info->path) { | ||
575 | call_usermodehelper_freeinfo(sub_info); | ||
576 | return -EINVAL; | ||
577 | } | ||
574 | helper_lock(); | 578 | helper_lock(); |
575 | if (!khelper_wq || usermodehelper_disabled) { | 579 | if (!khelper_wq || usermodehelper_disabled) { |
576 | retval = -EBUSY; | 580 | retval = -EBUSY; |
diff --git a/kernel/mutex.c b/kernel/mutex.c index 6d647aedffea..d24105b1b794 100644 --- a/kernel/mutex.c +++ b/kernel/mutex.c | |||
@@ -410,7 +410,7 @@ ww_mutex_set_context_fastpath(struct ww_mutex *lock, | |||
410 | static __always_inline int __sched | 410 | static __always_inline int __sched |
411 | __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, | 411 | __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, |
412 | struct lockdep_map *nest_lock, unsigned long ip, | 412 | struct lockdep_map *nest_lock, unsigned long ip, |
413 | struct ww_acquire_ctx *ww_ctx) | 413 | struct ww_acquire_ctx *ww_ctx, const bool use_ww_ctx) |
414 | { | 414 | { |
415 | struct task_struct *task = current; | 415 | struct task_struct *task = current; |
416 | struct mutex_waiter waiter; | 416 | struct mutex_waiter waiter; |
@@ -450,7 +450,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, | |||
450 | struct task_struct *owner; | 450 | struct task_struct *owner; |
451 | struct mspin_node node; | 451 | struct mspin_node node; |
452 | 452 | ||
453 | if (!__builtin_constant_p(ww_ctx == NULL) && ww_ctx->acquired > 0) { | 453 | if (use_ww_ctx && ww_ctx->acquired > 0) { |
454 | struct ww_mutex *ww; | 454 | struct ww_mutex *ww; |
455 | 455 | ||
456 | ww = container_of(lock, struct ww_mutex, base); | 456 | ww = container_of(lock, struct ww_mutex, base); |
@@ -480,7 +480,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, | |||
480 | if ((atomic_read(&lock->count) == 1) && | 480 | if ((atomic_read(&lock->count) == 1) && |
481 | (atomic_cmpxchg(&lock->count, 1, 0) == 1)) { | 481 | (atomic_cmpxchg(&lock->count, 1, 0) == 1)) { |
482 | lock_acquired(&lock->dep_map, ip); | 482 | lock_acquired(&lock->dep_map, ip); |
483 | if (!__builtin_constant_p(ww_ctx == NULL)) { | 483 | if (use_ww_ctx) { |
484 | struct ww_mutex *ww; | 484 | struct ww_mutex *ww; |
485 | ww = container_of(lock, struct ww_mutex, base); | 485 | ww = container_of(lock, struct ww_mutex, base); |
486 | 486 | ||
@@ -551,7 +551,7 @@ slowpath: | |||
551 | goto err; | 551 | goto err; |
552 | } | 552 | } |
553 | 553 | ||
554 | if (!__builtin_constant_p(ww_ctx == NULL) && ww_ctx->acquired > 0) { | 554 | if (use_ww_ctx && ww_ctx->acquired > 0) { |
555 | ret = __mutex_lock_check_stamp(lock, ww_ctx); | 555 | ret = __mutex_lock_check_stamp(lock, ww_ctx); |
556 | if (ret) | 556 | if (ret) |
557 | goto err; | 557 | goto err; |
@@ -575,7 +575,7 @@ skip_wait: | |||
575 | lock_acquired(&lock->dep_map, ip); | 575 | lock_acquired(&lock->dep_map, ip); |
576 | mutex_set_owner(lock); | 576 | mutex_set_owner(lock); |
577 | 577 | ||
578 | if (!__builtin_constant_p(ww_ctx == NULL)) { | 578 | if (use_ww_ctx) { |
579 | struct ww_mutex *ww = container_of(lock, struct ww_mutex, base); | 579 | struct ww_mutex *ww = container_of(lock, struct ww_mutex, base); |
580 | struct mutex_waiter *cur; | 580 | struct mutex_waiter *cur; |
581 | 581 | ||
@@ -615,7 +615,7 @@ mutex_lock_nested(struct mutex *lock, unsigned int subclass) | |||
615 | { | 615 | { |
616 | might_sleep(); | 616 | might_sleep(); |
617 | __mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, | 617 | __mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, |
618 | subclass, NULL, _RET_IP_, NULL); | 618 | subclass, NULL, _RET_IP_, NULL, 0); |
619 | } | 619 | } |
620 | 620 | ||
621 | EXPORT_SYMBOL_GPL(mutex_lock_nested); | 621 | EXPORT_SYMBOL_GPL(mutex_lock_nested); |
@@ -625,7 +625,7 @@ _mutex_lock_nest_lock(struct mutex *lock, struct lockdep_map *nest) | |||
625 | { | 625 | { |
626 | might_sleep(); | 626 | might_sleep(); |
627 | __mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, | 627 | __mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, |
628 | 0, nest, _RET_IP_, NULL); | 628 | 0, nest, _RET_IP_, NULL, 0); |
629 | } | 629 | } |
630 | 630 | ||
631 | EXPORT_SYMBOL_GPL(_mutex_lock_nest_lock); | 631 | EXPORT_SYMBOL_GPL(_mutex_lock_nest_lock); |
@@ -635,7 +635,7 @@ mutex_lock_killable_nested(struct mutex *lock, unsigned int subclass) | |||
635 | { | 635 | { |
636 | might_sleep(); | 636 | might_sleep(); |
637 | return __mutex_lock_common(lock, TASK_KILLABLE, | 637 | return __mutex_lock_common(lock, TASK_KILLABLE, |
638 | subclass, NULL, _RET_IP_, NULL); | 638 | subclass, NULL, _RET_IP_, NULL, 0); |
639 | } | 639 | } |
640 | EXPORT_SYMBOL_GPL(mutex_lock_killable_nested); | 640 | EXPORT_SYMBOL_GPL(mutex_lock_killable_nested); |
641 | 641 | ||
@@ -644,7 +644,7 @@ mutex_lock_interruptible_nested(struct mutex *lock, unsigned int subclass) | |||
644 | { | 644 | { |
645 | might_sleep(); | 645 | might_sleep(); |
646 | return __mutex_lock_common(lock, TASK_INTERRUPTIBLE, | 646 | return __mutex_lock_common(lock, TASK_INTERRUPTIBLE, |
647 | subclass, NULL, _RET_IP_, NULL); | 647 | subclass, NULL, _RET_IP_, NULL, 0); |
648 | } | 648 | } |
649 | 649 | ||
650 | EXPORT_SYMBOL_GPL(mutex_lock_interruptible_nested); | 650 | EXPORT_SYMBOL_GPL(mutex_lock_interruptible_nested); |
@@ -682,7 +682,7 @@ __ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) | |||
682 | 682 | ||
683 | might_sleep(); | 683 | might_sleep(); |
684 | ret = __mutex_lock_common(&lock->base, TASK_UNINTERRUPTIBLE, | 684 | ret = __mutex_lock_common(&lock->base, TASK_UNINTERRUPTIBLE, |
685 | 0, &ctx->dep_map, _RET_IP_, ctx); | 685 | 0, &ctx->dep_map, _RET_IP_, ctx, 1); |
686 | if (!ret && ctx->acquired > 1) | 686 | if (!ret && ctx->acquired > 1) |
687 | return ww_mutex_deadlock_injection(lock, ctx); | 687 | return ww_mutex_deadlock_injection(lock, ctx); |
688 | 688 | ||
@@ -697,7 +697,7 @@ __ww_mutex_lock_interruptible(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) | |||
697 | 697 | ||
698 | might_sleep(); | 698 | might_sleep(); |
699 | ret = __mutex_lock_common(&lock->base, TASK_INTERRUPTIBLE, | 699 | ret = __mutex_lock_common(&lock->base, TASK_INTERRUPTIBLE, |
700 | 0, &ctx->dep_map, _RET_IP_, ctx); | 700 | 0, &ctx->dep_map, _RET_IP_, ctx, 1); |
701 | 701 | ||
702 | if (!ret && ctx->acquired > 1) | 702 | if (!ret && ctx->acquired > 1) |
703 | return ww_mutex_deadlock_injection(lock, ctx); | 703 | return ww_mutex_deadlock_injection(lock, ctx); |
@@ -809,28 +809,28 @@ __mutex_lock_slowpath(atomic_t *lock_count) | |||
809 | struct mutex *lock = container_of(lock_count, struct mutex, count); | 809 | struct mutex *lock = container_of(lock_count, struct mutex, count); |
810 | 810 | ||
811 | __mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, 0, | 811 | __mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, 0, |
812 | NULL, _RET_IP_, NULL); | 812 | NULL, _RET_IP_, NULL, 0); |
813 | } | 813 | } |
814 | 814 | ||
815 | static noinline int __sched | 815 | static noinline int __sched |
816 | __mutex_lock_killable_slowpath(struct mutex *lock) | 816 | __mutex_lock_killable_slowpath(struct mutex *lock) |
817 | { | 817 | { |
818 | return __mutex_lock_common(lock, TASK_KILLABLE, 0, | 818 | return __mutex_lock_common(lock, TASK_KILLABLE, 0, |
819 | NULL, _RET_IP_, NULL); | 819 | NULL, _RET_IP_, NULL, 0); |
820 | } | 820 | } |
821 | 821 | ||
822 | static noinline int __sched | 822 | static noinline int __sched |
823 | __mutex_lock_interruptible_slowpath(struct mutex *lock) | 823 | __mutex_lock_interruptible_slowpath(struct mutex *lock) |
824 | { | 824 | { |
825 | return __mutex_lock_common(lock, TASK_INTERRUPTIBLE, 0, | 825 | return __mutex_lock_common(lock, TASK_INTERRUPTIBLE, 0, |
826 | NULL, _RET_IP_, NULL); | 826 | NULL, _RET_IP_, NULL, 0); |
827 | } | 827 | } |
828 | 828 | ||
829 | static noinline int __sched | 829 | static noinline int __sched |
830 | __ww_mutex_lock_slowpath(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) | 830 | __ww_mutex_lock_slowpath(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) |
831 | { | 831 | { |
832 | return __mutex_lock_common(&lock->base, TASK_UNINTERRUPTIBLE, 0, | 832 | return __mutex_lock_common(&lock->base, TASK_UNINTERRUPTIBLE, 0, |
833 | NULL, _RET_IP_, ctx); | 833 | NULL, _RET_IP_, ctx, 1); |
834 | } | 834 | } |
835 | 835 | ||
836 | static noinline int __sched | 836 | static noinline int __sched |
@@ -838,7 +838,7 @@ __ww_mutex_lock_interruptible_slowpath(struct ww_mutex *lock, | |||
838 | struct ww_acquire_ctx *ctx) | 838 | struct ww_acquire_ctx *ctx) |
839 | { | 839 | { |
840 | return __mutex_lock_common(&lock->base, TASK_INTERRUPTIBLE, 0, | 840 | return __mutex_lock_common(&lock->base, TASK_INTERRUPTIBLE, 0, |
841 | NULL, _RET_IP_, ctx); | 841 | NULL, _RET_IP_, ctx, 1); |
842 | } | 842 | } |
843 | 843 | ||
844 | #endif | 844 | #endif |
diff --git a/kernel/params.c b/kernel/params.c index 81c4e78c8f4c..c00d5b502aa4 100644 --- a/kernel/params.c +++ b/kernel/params.c | |||
@@ -254,11 +254,11 @@ int parse_args(const char *doing, | |||
254 | 254 | ||
255 | 255 | ||
256 | STANDARD_PARAM_DEF(byte, unsigned char, "%hhu", unsigned long, kstrtoul); | 256 | STANDARD_PARAM_DEF(byte, unsigned char, "%hhu", unsigned long, kstrtoul); |
257 | STANDARD_PARAM_DEF(short, short, "%hi", long, kstrtoul); | 257 | STANDARD_PARAM_DEF(short, short, "%hi", long, kstrtol); |
258 | STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", unsigned long, kstrtoul); | 258 | STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", unsigned long, kstrtoul); |
259 | STANDARD_PARAM_DEF(int, int, "%i", long, kstrtoul); | 259 | STANDARD_PARAM_DEF(int, int, "%i", long, kstrtol); |
260 | STANDARD_PARAM_DEF(uint, unsigned int, "%u", unsigned long, kstrtoul); | 260 | STANDARD_PARAM_DEF(uint, unsigned int, "%u", unsigned long, kstrtoul); |
261 | STANDARD_PARAM_DEF(long, long, "%li", long, kstrtoul); | 261 | STANDARD_PARAM_DEF(long, long, "%li", long, kstrtol); |
262 | STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", unsigned long, kstrtoul); | 262 | STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", unsigned long, kstrtoul); |
263 | 263 | ||
264 | int param_set_charp(const char *val, const struct kernel_param *kp) | 264 | int param_set_charp(const char *val, const struct kernel_param *kp) |
diff --git a/kernel/pid.c b/kernel/pid.c index ebe5e80b10f8..9b9a26698144 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -273,6 +273,11 @@ void free_pid(struct pid *pid) | |||
273 | */ | 273 | */ |
274 | wake_up_process(ns->child_reaper); | 274 | wake_up_process(ns->child_reaper); |
275 | break; | 275 | break; |
276 | case PIDNS_HASH_ADDING: | ||
277 | /* Handle a fork failure of the first process */ | ||
278 | WARN_ON(ns->child_reaper); | ||
279 | ns->nr_hashed = 0; | ||
280 | /* fall through */ | ||
276 | case 0: | 281 | case 0: |
277 | schedule_work(&ns->proc_work); | 282 | schedule_work(&ns->proc_work); |
278 | break; | 283 | break; |
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index c9c759d5a15c..0121dab83f43 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c | |||
@@ -846,7 +846,7 @@ static int software_resume(void) | |||
846 | goto Finish; | 846 | goto Finish; |
847 | } | 847 | } |
848 | 848 | ||
849 | late_initcall(software_resume); | 849 | late_initcall_sync(software_resume); |
850 | 850 | ||
851 | 851 | ||
852 | static const char * const hibernation_modes[] = { | 852 | static const char * const hibernation_modes[] = { |
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index 358a146fd4da..98c3b34a4cff 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c | |||
@@ -743,7 +743,10 @@ int create_basic_memory_bitmaps(void) | |||
743 | struct memory_bitmap *bm1, *bm2; | 743 | struct memory_bitmap *bm1, *bm2; |
744 | int error = 0; | 744 | int error = 0; |
745 | 745 | ||
746 | BUG_ON(forbidden_pages_map || free_pages_map); | 746 | if (forbidden_pages_map && free_pages_map) |
747 | return 0; | ||
748 | else | ||
749 | BUG_ON(forbidden_pages_map || free_pages_map); | ||
747 | 750 | ||
748 | bm1 = kzalloc(sizeof(struct memory_bitmap), GFP_KERNEL); | 751 | bm1 = kzalloc(sizeof(struct memory_bitmap), GFP_KERNEL); |
749 | if (!bm1) | 752 | if (!bm1) |
diff --git a/kernel/power/user.c b/kernel/power/user.c index 72e8f4fd616d..957f06164ad1 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c | |||
@@ -39,6 +39,7 @@ static struct snapshot_data { | |||
39 | char frozen; | 39 | char frozen; |
40 | char ready; | 40 | char ready; |
41 | char platform_support; | 41 | char platform_support; |
42 | bool free_bitmaps; | ||
42 | } snapshot_state; | 43 | } snapshot_state; |
43 | 44 | ||
44 | atomic_t snapshot_device_available = ATOMIC_INIT(1); | 45 | atomic_t snapshot_device_available = ATOMIC_INIT(1); |
@@ -82,6 +83,10 @@ static int snapshot_open(struct inode *inode, struct file *filp) | |||
82 | data->swap = -1; | 83 | data->swap = -1; |
83 | data->mode = O_WRONLY; | 84 | data->mode = O_WRONLY; |
84 | error = pm_notifier_call_chain(PM_RESTORE_PREPARE); | 85 | error = pm_notifier_call_chain(PM_RESTORE_PREPARE); |
86 | if (!error) { | ||
87 | error = create_basic_memory_bitmaps(); | ||
88 | data->free_bitmaps = !error; | ||
89 | } | ||
85 | if (error) | 90 | if (error) |
86 | pm_notifier_call_chain(PM_POST_RESTORE); | 91 | pm_notifier_call_chain(PM_POST_RESTORE); |
87 | } | 92 | } |
@@ -111,6 +116,8 @@ static int snapshot_release(struct inode *inode, struct file *filp) | |||
111 | pm_restore_gfp_mask(); | 116 | pm_restore_gfp_mask(); |
112 | free_basic_memory_bitmaps(); | 117 | free_basic_memory_bitmaps(); |
113 | thaw_processes(); | 118 | thaw_processes(); |
119 | } else if (data->free_bitmaps) { | ||
120 | free_basic_memory_bitmaps(); | ||
114 | } | 121 | } |
115 | pm_notifier_call_chain(data->mode == O_RDONLY ? | 122 | pm_notifier_call_chain(data->mode == O_RDONLY ? |
116 | PM_POST_HIBERNATION : PM_POST_RESTORE); | 123 | PM_POST_HIBERNATION : PM_POST_RESTORE); |
@@ -231,6 +238,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd, | |||
231 | break; | 238 | break; |
232 | pm_restore_gfp_mask(); | 239 | pm_restore_gfp_mask(); |
233 | free_basic_memory_bitmaps(); | 240 | free_basic_memory_bitmaps(); |
241 | data->free_bitmaps = false; | ||
234 | thaw_processes(); | 242 | thaw_processes(); |
235 | data->frozen = 0; | 243 | data->frozen = 0; |
236 | break; | 244 | break; |
diff --git a/kernel/reboot.c b/kernel/reboot.c index 269ed9384cc4..f813b3474646 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c | |||
@@ -32,7 +32,14 @@ EXPORT_SYMBOL(cad_pid); | |||
32 | #endif | 32 | #endif |
33 | enum reboot_mode reboot_mode DEFAULT_REBOOT_MODE; | 33 | enum reboot_mode reboot_mode DEFAULT_REBOOT_MODE; |
34 | 34 | ||
35 | int reboot_default; | 35 | /* |
36 | * This variable is used privately to keep track of whether or not | ||
37 | * reboot_type is still set to its default value (i.e., reboot= hasn't | ||
38 | * been set on the command line). This is needed so that we can | ||
39 | * suppress DMI scanning for reboot quirks. Without it, it's | ||
40 | * impossible to override a faulty reboot quirk without recompiling. | ||
41 | */ | ||
42 | int reboot_default = 1; | ||
36 | int reboot_cpu; | 43 | int reboot_cpu; |
37 | enum reboot_type reboot_type = BOOT_ACPI; | 44 | enum reboot_type reboot_type = BOOT_ACPI; |
38 | int reboot_force; | 45 | int reboot_force; |
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index e076bddd4c66..196559994f7c 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c | |||
@@ -124,7 +124,7 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) | |||
124 | SEQ_printf(m, " "); | 124 | SEQ_printf(m, " "); |
125 | 125 | ||
126 | SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ", | 126 | SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ", |
127 | p->comm, p->pid, | 127 | p->comm, task_pid_nr(p), |
128 | SPLIT_NS(p->se.vruntime), | 128 | SPLIT_NS(p->se.vruntime), |
129 | (long long)(p->nvcsw + p->nivcsw), | 129 | (long long)(p->nvcsw + p->nivcsw), |
130 | p->prio); | 130 | p->prio); |
@@ -289,7 +289,7 @@ do { \ | |||
289 | P(nr_load_updates); | 289 | P(nr_load_updates); |
290 | P(nr_uninterruptible); | 290 | P(nr_uninterruptible); |
291 | PN(next_balance); | 291 | PN(next_balance); |
292 | P(curr->pid); | 292 | SEQ_printf(m, " .%-30s: %ld\n", "curr->pid", (long)(task_pid_nr(rq->curr))); |
293 | PN(clock); | 293 | PN(clock); |
294 | P(cpu_load[0]); | 294 | P(cpu_load[0]); |
295 | P(cpu_load[1]); | 295 | P(cpu_load[1]); |
@@ -492,7 +492,7 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m) | |||
492 | { | 492 | { |
493 | unsigned long nr_switches; | 493 | unsigned long nr_switches; |
494 | 494 | ||
495 | SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, p->pid, | 495 | SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, task_pid_nr(p), |
496 | get_nr_threads(p)); | 496 | get_nr_threads(p)); |
497 | SEQ_printf(m, | 497 | SEQ_printf(m, |
498 | "---------------------------------------------------------" | 498 | "---------------------------------------------------------" |
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 9b3fe1cd8f40..7c70201fbc61 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
@@ -4242,7 +4242,7 @@ static void update_cfs_rq_h_load(struct cfs_rq *cfs_rq) | |||
4242 | } | 4242 | } |
4243 | 4243 | ||
4244 | if (!se) { | 4244 | if (!se) { |
4245 | cfs_rq->h_load = rq->avg.load_avg_contrib; | 4245 | cfs_rq->h_load = cfs_rq->runnable_load_avg; |
4246 | cfs_rq->last_h_load_update = now; | 4246 | cfs_rq->last_h_load_update = now; |
4247 | } | 4247 | } |
4248 | 4248 | ||
@@ -4823,8 +4823,8 @@ void fix_small_imbalance(struct lb_env *env, struct sd_lb_stats *sds) | |||
4823 | (busiest->load_per_task * SCHED_POWER_SCALE) / | 4823 | (busiest->load_per_task * SCHED_POWER_SCALE) / |
4824 | busiest->group_power; | 4824 | busiest->group_power; |
4825 | 4825 | ||
4826 | if (busiest->avg_load - local->avg_load + scaled_busy_load_per_task >= | 4826 | if (busiest->avg_load + scaled_busy_load_per_task >= |
4827 | (scaled_busy_load_per_task * imbn)) { | 4827 | local->avg_load + (scaled_busy_load_per_task * imbn)) { |
4828 | env->imbalance = busiest->load_per_task; | 4828 | env->imbalance = busiest->load_per_task; |
4829 | return; | 4829 | return; |
4830 | } | 4830 | } |
@@ -4896,7 +4896,8 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s | |||
4896 | * max load less than avg load(as we skip the groups at or below | 4896 | * max load less than avg load(as we skip the groups at or below |
4897 | * its cpu_power, while calculating max_load..) | 4897 | * its cpu_power, while calculating max_load..) |
4898 | */ | 4898 | */ |
4899 | if (busiest->avg_load < sds->avg_load) { | 4899 | if (busiest->avg_load <= sds->avg_load || |
4900 | local->avg_load >= sds->avg_load) { | ||
4900 | env->imbalance = 0; | 4901 | env->imbalance = 0; |
4901 | return fix_small_imbalance(env, sds); | 4902 | return fix_small_imbalance(env, sds); |
4902 | } | 4903 | } |
@@ -5928,11 +5929,15 @@ static void task_fork_fair(struct task_struct *p) | |||
5928 | cfs_rq = task_cfs_rq(current); | 5929 | cfs_rq = task_cfs_rq(current); |
5929 | curr = cfs_rq->curr; | 5930 | curr = cfs_rq->curr; |
5930 | 5931 | ||
5931 | if (unlikely(task_cpu(p) != this_cpu)) { | 5932 | /* |
5932 | rcu_read_lock(); | 5933 | * Not only the cpu but also the task_group of the parent might have |
5933 | __set_task_cpu(p, this_cpu); | 5934 | * been changed after parent->se.parent,cfs_rq were copied to |
5934 | rcu_read_unlock(); | 5935 | * child->se.parent,cfs_rq. So call __set_task_cpu() to make those |
5935 | } | 5936 | * of child point to valid ones. |
5937 | */ | ||
5938 | rcu_read_lock(); | ||
5939 | __set_task_cpu(p, this_cpu); | ||
5940 | rcu_read_unlock(); | ||
5936 | 5941 | ||
5937 | update_curr(cfs_rq); | 5942 | update_curr(cfs_rq); |
5938 | 5943 | ||
diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h index 5aef494fc8b4..c7edee71bce8 100644 --- a/kernel/sched/stats.h +++ b/kernel/sched/stats.h | |||
@@ -104,8 +104,9 @@ static inline void sched_info_queued(struct task_struct *t) | |||
104 | } | 104 | } |
105 | 105 | ||
106 | /* | 106 | /* |
107 | * Called when a process ceases being the active-running process, either | 107 | * Called when a process ceases being the active-running process involuntarily |
108 | * voluntarily or involuntarily. Now we can calculate how long we ran. | 108 | * due, typically, to expiring its time slice (this may also be called when |
109 | * switching to the idle task). Now we can calculate how long we ran. | ||
109 | * Also, if the process is still in the TASK_RUNNING state, call | 110 | * Also, if the process is still in the TASK_RUNNING state, call |
110 | * sched_info_queued() to mark that it has now again started waiting on | 111 | * sched_info_queued() to mark that it has now again started waiting on |
111 | * the runqueue. | 112 | * the runqueue. |
diff --git a/kernel/softirq.c b/kernel/softirq.c index 53cc09ceb0b8..d7d498d8cc4f 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c | |||
@@ -328,10 +328,19 @@ void irq_enter(void) | |||
328 | 328 | ||
329 | static inline void invoke_softirq(void) | 329 | static inline void invoke_softirq(void) |
330 | { | 330 | { |
331 | if (!force_irqthreads) | 331 | if (!force_irqthreads) { |
332 | __do_softirq(); | 332 | /* |
333 | else | 333 | * We can safely execute softirq on the current stack if |
334 | * it is the irq stack, because it should be near empty | ||
335 | * at this stage. But we have no way to know if the arch | ||
336 | * calls irq_exit() on the irq stack. So call softirq | ||
337 | * in its own stack to prevent from any overrun on top | ||
338 | * of a potentially deep task stack. | ||
339 | */ | ||
340 | do_softirq(); | ||
341 | } else { | ||
334 | wakeup_softirqd(); | 342 | wakeup_softirqd(); |
343 | } | ||
335 | } | 344 | } |
336 | 345 | ||
337 | static inline void tick_irq_exit(void) | 346 | static inline void tick_irq_exit(void) |
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index 38959c866789..662c5798a685 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c | |||
@@ -33,29 +33,64 @@ struct ce_unbind { | |||
33 | int res; | 33 | int res; |
34 | }; | 34 | }; |
35 | 35 | ||
36 | /** | 36 | static u64 cev_delta2ns(unsigned long latch, struct clock_event_device *evt, |
37 | * clockevents_delta2ns - Convert a latch value (device ticks) to nanoseconds | 37 | bool ismax) |
38 | * @latch: value to convert | ||
39 | * @evt: pointer to clock event device descriptor | ||
40 | * | ||
41 | * Math helper, returns latch value converted to nanoseconds (bound checked) | ||
42 | */ | ||
43 | u64 clockevent_delta2ns(unsigned long latch, struct clock_event_device *evt) | ||
44 | { | 38 | { |
45 | u64 clc = (u64) latch << evt->shift; | 39 | u64 clc = (u64) latch << evt->shift; |
40 | u64 rnd; | ||
46 | 41 | ||
47 | if (unlikely(!evt->mult)) { | 42 | if (unlikely(!evt->mult)) { |
48 | evt->mult = 1; | 43 | evt->mult = 1; |
49 | WARN_ON(1); | 44 | WARN_ON(1); |
50 | } | 45 | } |
46 | rnd = (u64) evt->mult - 1; | ||
47 | |||
48 | /* | ||
49 | * Upper bound sanity check. If the backwards conversion is | ||
50 | * not equal latch, we know that the above shift overflowed. | ||
51 | */ | ||
52 | if ((clc >> evt->shift) != (u64)latch) | ||
53 | clc = ~0ULL; | ||
54 | |||
55 | /* | ||
56 | * Scaled math oddities: | ||
57 | * | ||
58 | * For mult <= (1 << shift) we can safely add mult - 1 to | ||
59 | * prevent integer rounding loss. So the backwards conversion | ||
60 | * from nsec to device ticks will be correct. | ||
61 | * | ||
62 | * For mult > (1 << shift), i.e. device frequency is > 1GHz we | ||
63 | * need to be careful. Adding mult - 1 will result in a value | ||
64 | * which when converted back to device ticks can be larger | ||
65 | * than latch by up to (mult - 1) >> shift. For the min_delta | ||
66 | * calculation we still want to apply this in order to stay | ||
67 | * above the minimum device ticks limit. For the upper limit | ||
68 | * we would end up with a latch value larger than the upper | ||
69 | * limit of the device, so we omit the add to stay below the | ||
70 | * device upper boundary. | ||
71 | * | ||
72 | * Also omit the add if it would overflow the u64 boundary. | ||
73 | */ | ||
74 | if ((~0ULL - clc > rnd) && | ||
75 | (!ismax || evt->mult <= (1U << evt->shift))) | ||
76 | clc += rnd; | ||
51 | 77 | ||
52 | do_div(clc, evt->mult); | 78 | do_div(clc, evt->mult); |
53 | if (clc < 1000) | ||
54 | clc = 1000; | ||
55 | if (clc > KTIME_MAX) | ||
56 | clc = KTIME_MAX; | ||
57 | 79 | ||
58 | return clc; | 80 | /* Deltas less than 1usec are pointless noise */ |
81 | return clc > 1000 ? clc : 1000; | ||
82 | } | ||
83 | |||
84 | /** | ||
85 | * clockevents_delta2ns - Convert a latch value (device ticks) to nanoseconds | ||
86 | * @latch: value to convert | ||
87 | * @evt: pointer to clock event device descriptor | ||
88 | * | ||
89 | * Math helper, returns latch value converted to nanoseconds (bound checked) | ||
90 | */ | ||
91 | u64 clockevent_delta2ns(unsigned long latch, struct clock_event_device *evt) | ||
92 | { | ||
93 | return cev_delta2ns(latch, evt, false); | ||
59 | } | 94 | } |
60 | EXPORT_SYMBOL_GPL(clockevent_delta2ns); | 95 | EXPORT_SYMBOL_GPL(clockevent_delta2ns); |
61 | 96 | ||
@@ -380,8 +415,8 @@ void clockevents_config(struct clock_event_device *dev, u32 freq) | |||
380 | sec = 600; | 415 | sec = 600; |
381 | 416 | ||
382 | clockevents_calc_mult_shift(dev, freq, sec); | 417 | clockevents_calc_mult_shift(dev, freq, sec); |
383 | dev->min_delta_ns = clockevent_delta2ns(dev->min_delta_ticks, dev); | 418 | dev->min_delta_ns = cev_delta2ns(dev->min_delta_ticks, dev, false); |
384 | dev->max_delta_ns = clockevent_delta2ns(dev->max_delta_ticks, dev); | 419 | dev->max_delta_ns = cev_delta2ns(dev->max_delta_ticks, dev, true); |
385 | } | 420 | } |
386 | 421 | ||
387 | /** | 422 | /** |
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 8f5b3b98577b..bb2215174f05 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c | |||
@@ -516,13 +516,13 @@ static void sync_cmos_clock(struct work_struct *work) | |||
516 | schedule_delayed_work(&sync_cmos_work, timespec_to_jiffies(&next)); | 516 | schedule_delayed_work(&sync_cmos_work, timespec_to_jiffies(&next)); |
517 | } | 517 | } |
518 | 518 | ||
519 | static void notify_cmos_timer(void) | 519 | void ntp_notify_cmos_timer(void) |
520 | { | 520 | { |
521 | schedule_delayed_work(&sync_cmos_work, 0); | 521 | schedule_delayed_work(&sync_cmos_work, 0); |
522 | } | 522 | } |
523 | 523 | ||
524 | #else | 524 | #else |
525 | static inline void notify_cmos_timer(void) { } | 525 | void ntp_notify_cmos_timer(void) { } |
526 | #endif | 526 | #endif |
527 | 527 | ||
528 | 528 | ||
@@ -687,8 +687,6 @@ int __do_adjtimex(struct timex *txc, struct timespec *ts, s32 *time_tai) | |||
687 | if (!(time_status & STA_NANO)) | 687 | if (!(time_status & STA_NANO)) |
688 | txc->time.tv_usec /= NSEC_PER_USEC; | 688 | txc->time.tv_usec /= NSEC_PER_USEC; |
689 | 689 | ||
690 | notify_cmos_timer(); | ||
691 | |||
692 | return result; | 690 | return result; |
693 | } | 691 | } |
694 | 692 | ||
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 48b9fffabdc2..947ba25a95a0 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -1703,6 +1703,8 @@ int do_adjtimex(struct timex *txc) | |||
1703 | write_seqcount_end(&timekeeper_seq); | 1703 | write_seqcount_end(&timekeeper_seq); |
1704 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | 1704 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
1705 | 1705 | ||
1706 | ntp_notify_cmos_timer(); | ||
1707 | |||
1706 | return ret; | 1708 | return ret; |
1707 | } | 1709 | } |
1708 | 1710 | ||
diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 51c4f34d258e..4431610f049a 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c | |||
@@ -486,7 +486,52 @@ static struct smp_hotplug_thread watchdog_threads = { | |||
486 | .unpark = watchdog_enable, | 486 | .unpark = watchdog_enable, |
487 | }; | 487 | }; |
488 | 488 | ||
489 | static int watchdog_enable_all_cpus(void) | 489 | static void restart_watchdog_hrtimer(void *info) |
490 | { | ||
491 | struct hrtimer *hrtimer = &__raw_get_cpu_var(watchdog_hrtimer); | ||
492 | int ret; | ||
493 | |||
494 | /* | ||
495 | * No need to cancel and restart hrtimer if it is currently executing | ||
496 | * because it will reprogram itself with the new period now. | ||
497 | * We should never see it unqueued here because we are running per-cpu | ||
498 | * with interrupts disabled. | ||
499 | */ | ||
500 | ret = hrtimer_try_to_cancel(hrtimer); | ||
501 | if (ret == 1) | ||
502 | hrtimer_start(hrtimer, ns_to_ktime(sample_period), | ||
503 | HRTIMER_MODE_REL_PINNED); | ||
504 | } | ||
505 | |||
506 | static void update_timers(int cpu) | ||
507 | { | ||
508 | struct call_single_data data = {.func = restart_watchdog_hrtimer}; | ||
509 | /* | ||
510 | * Make sure that perf event counter will adopt to a new | ||
511 | * sampling period. Updating the sampling period directly would | ||
512 | * be much nicer but we do not have an API for that now so | ||
513 | * let's use a big hammer. | ||
514 | * Hrtimer will adopt the new period on the next tick but this | ||
515 | * might be late already so we have to restart the timer as well. | ||
516 | */ | ||
517 | watchdog_nmi_disable(cpu); | ||
518 | __smp_call_function_single(cpu, &data, 1); | ||
519 | watchdog_nmi_enable(cpu); | ||
520 | } | ||
521 | |||
522 | static void update_timers_all_cpus(void) | ||
523 | { | ||
524 | int cpu; | ||
525 | |||
526 | get_online_cpus(); | ||
527 | preempt_disable(); | ||
528 | for_each_online_cpu(cpu) | ||
529 | update_timers(cpu); | ||
530 | preempt_enable(); | ||
531 | put_online_cpus(); | ||
532 | } | ||
533 | |||
534 | static int watchdog_enable_all_cpus(bool sample_period_changed) | ||
490 | { | 535 | { |
491 | int err = 0; | 536 | int err = 0; |
492 | 537 | ||
@@ -496,6 +541,8 @@ static int watchdog_enable_all_cpus(void) | |||
496 | pr_err("Failed to create watchdog threads, disabled\n"); | 541 | pr_err("Failed to create watchdog threads, disabled\n"); |
497 | else | 542 | else |
498 | watchdog_running = 1; | 543 | watchdog_running = 1; |
544 | } else if (sample_period_changed) { | ||
545 | update_timers_all_cpus(); | ||
499 | } | 546 | } |
500 | 547 | ||
501 | return err; | 548 | return err; |
@@ -520,13 +567,15 @@ int proc_dowatchdog(struct ctl_table *table, int write, | |||
520 | void __user *buffer, size_t *lenp, loff_t *ppos) | 567 | void __user *buffer, size_t *lenp, loff_t *ppos) |
521 | { | 568 | { |
522 | int err, old_thresh, old_enabled; | 569 | int err, old_thresh, old_enabled; |
570 | static DEFINE_MUTEX(watchdog_proc_mutex); | ||
523 | 571 | ||
572 | mutex_lock(&watchdog_proc_mutex); | ||
524 | old_thresh = ACCESS_ONCE(watchdog_thresh); | 573 | old_thresh = ACCESS_ONCE(watchdog_thresh); |
525 | old_enabled = ACCESS_ONCE(watchdog_user_enabled); | 574 | old_enabled = ACCESS_ONCE(watchdog_user_enabled); |
526 | 575 | ||
527 | err = proc_dointvec_minmax(table, write, buffer, lenp, ppos); | 576 | err = proc_dointvec_minmax(table, write, buffer, lenp, ppos); |
528 | if (err || !write) | 577 | if (err || !write) |
529 | return err; | 578 | goto out; |
530 | 579 | ||
531 | set_sample_period(); | 580 | set_sample_period(); |
532 | /* | 581 | /* |
@@ -535,7 +584,7 @@ int proc_dowatchdog(struct ctl_table *table, int write, | |||
535 | * watchdog_*_all_cpus() function takes care of this. | 584 | * watchdog_*_all_cpus() function takes care of this. |
536 | */ | 585 | */ |
537 | if (watchdog_user_enabled && watchdog_thresh) | 586 | if (watchdog_user_enabled && watchdog_thresh) |
538 | err = watchdog_enable_all_cpus(); | 587 | err = watchdog_enable_all_cpus(old_thresh != watchdog_thresh); |
539 | else | 588 | else |
540 | watchdog_disable_all_cpus(); | 589 | watchdog_disable_all_cpus(); |
541 | 590 | ||
@@ -544,7 +593,8 @@ int proc_dowatchdog(struct ctl_table *table, int write, | |||
544 | watchdog_thresh = old_thresh; | 593 | watchdog_thresh = old_thresh; |
545 | watchdog_user_enabled = old_enabled; | 594 | watchdog_user_enabled = old_enabled; |
546 | } | 595 | } |
547 | 596 | out: | |
597 | mutex_unlock(&watchdog_proc_mutex); | ||
548 | return err; | 598 | return err; |
549 | } | 599 | } |
550 | #endif /* CONFIG_SYSCTL */ | 600 | #endif /* CONFIG_SYSCTL */ |
@@ -554,5 +604,5 @@ void __init lockup_detector_init(void) | |||
554 | set_sample_period(); | 604 | set_sample_period(); |
555 | 605 | ||
556 | if (watchdog_user_enabled) | 606 | if (watchdog_user_enabled) |
557 | watchdog_enable_all_cpus(); | 607 | watchdog_enable_all_cpus(false); |
558 | } | 608 | } |