diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/fork.c | 4 | ||||
| -rw-r--r-- | kernel/panic.c | 1 | ||||
| -rw-r--r-- | kernel/perf_counter.c | 101 | ||||
| -rw-r--r-- | kernel/posix-timers.c | 7 | ||||
| -rw-r--r-- | kernel/sched_cpupri.c | 15 | ||||
| -rw-r--r-- | kernel/sched_fair.c | 32 | ||||
| -rw-r--r-- | kernel/signal.c | 25 | ||||
| -rw-r--r-- | kernel/trace/ftrace.c | 4 | ||||
| -rw-r--r-- | kernel/trace/trace.c | 12 | ||||
| -rw-r--r-- | kernel/trace/trace_events.c | 2 | ||||
| -rw-r--r-- | kernel/trace/trace_functions_graph.c | 11 | ||||
| -rw-r--r-- | kernel/trace/trace_printk.c | 2 |
12 files changed, 148 insertions, 68 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 29b532e718f7..466531eb92cc 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
| @@ -1269,6 +1269,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1269 | write_unlock_irq(&tasklist_lock); | 1269 | write_unlock_irq(&tasklist_lock); |
| 1270 | proc_fork_connector(p); | 1270 | proc_fork_connector(p); |
| 1271 | cgroup_post_fork(p); | 1271 | cgroup_post_fork(p); |
| 1272 | perf_counter_fork(p); | ||
| 1272 | return p; | 1273 | return p; |
| 1273 | 1274 | ||
| 1274 | bad_fork_free_pid: | 1275 | bad_fork_free_pid: |
| @@ -1410,9 +1411,6 @@ long do_fork(unsigned long clone_flags, | |||
| 1410 | init_completion(&vfork); | 1411 | init_completion(&vfork); |
| 1411 | } | 1412 | } |
| 1412 | 1413 | ||
| 1413 | if (!(clone_flags & CLONE_THREAD)) | ||
| 1414 | perf_counter_fork(p); | ||
| 1415 | |||
| 1416 | audit_finish_fork(p); | 1414 | audit_finish_fork(p); |
| 1417 | tracehook_report_clone(regs, clone_flags, nr, p); | 1415 | tracehook_report_clone(regs, clone_flags, nr, p); |
| 1418 | 1416 | ||
diff --git a/kernel/panic.c b/kernel/panic.c index 984b3ecbd72c..512ab73b0ca3 100644 --- a/kernel/panic.c +++ b/kernel/panic.c | |||
| @@ -301,6 +301,7 @@ int oops_may_print(void) | |||
| 301 | */ | 301 | */ |
| 302 | void oops_enter(void) | 302 | void oops_enter(void) |
| 303 | { | 303 | { |
| 304 | tracing_off(); | ||
| 304 | /* can't trust the integrity of the kernel anymore: */ | 305 | /* can't trust the integrity of the kernel anymore: */ |
| 305 | debug_locks_off(); | 306 | debug_locks_off(); |
| 306 | do_oops_enter_exit(); | 307 | do_oops_enter_exit(); |
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c index 950931041954..199ed4771315 100644 --- a/kernel/perf_counter.c +++ b/kernel/perf_counter.c | |||
| @@ -42,6 +42,7 @@ static int perf_overcommit __read_mostly = 1; | |||
| 42 | static atomic_t nr_counters __read_mostly; | 42 | static atomic_t nr_counters __read_mostly; |
| 43 | static atomic_t nr_mmap_counters __read_mostly; | 43 | static atomic_t nr_mmap_counters __read_mostly; |
| 44 | static atomic_t nr_comm_counters __read_mostly; | 44 | static atomic_t nr_comm_counters __read_mostly; |
| 45 | static atomic_t nr_task_counters __read_mostly; | ||
| 45 | 46 | ||
| 46 | /* | 47 | /* |
| 47 | * perf counter paranoia level: | 48 | * perf counter paranoia level: |
| @@ -1654,6 +1655,8 @@ static void free_counter(struct perf_counter *counter) | |||
| 1654 | atomic_dec(&nr_mmap_counters); | 1655 | atomic_dec(&nr_mmap_counters); |
| 1655 | if (counter->attr.comm) | 1656 | if (counter->attr.comm) |
| 1656 | atomic_dec(&nr_comm_counters); | 1657 | atomic_dec(&nr_comm_counters); |
| 1658 | if (counter->attr.task) | ||
| 1659 | atomic_dec(&nr_task_counters); | ||
| 1657 | } | 1660 | } |
| 1658 | 1661 | ||
| 1659 | if (counter->destroy) | 1662 | if (counter->destroy) |
| @@ -1688,6 +1691,18 @@ static int perf_release(struct inode *inode, struct file *file) | |||
| 1688 | return 0; | 1691 | return 0; |
| 1689 | } | 1692 | } |
| 1690 | 1693 | ||
| 1694 | static u64 perf_counter_read_tree(struct perf_counter *counter) | ||
| 1695 | { | ||
| 1696 | struct perf_counter *child; | ||
| 1697 | u64 total = 0; | ||
| 1698 | |||
| 1699 | total += perf_counter_read(counter); | ||
| 1700 | list_for_each_entry(child, &counter->child_list, child_list) | ||
| 1701 | total += perf_counter_read(child); | ||
| 1702 | |||
| 1703 | return total; | ||
| 1704 | } | ||
| 1705 | |||
| 1691 | /* | 1706 | /* |
| 1692 | * Read the performance counter - simple non blocking version for now | 1707 | * Read the performance counter - simple non blocking version for now |
| 1693 | */ | 1708 | */ |
| @@ -1707,7 +1722,7 @@ perf_read_hw(struct perf_counter *counter, char __user *buf, size_t count) | |||
| 1707 | 1722 | ||
| 1708 | WARN_ON_ONCE(counter->ctx->parent_ctx); | 1723 | WARN_ON_ONCE(counter->ctx->parent_ctx); |
| 1709 | mutex_lock(&counter->child_mutex); | 1724 | mutex_lock(&counter->child_mutex); |
| 1710 | values[0] = perf_counter_read(counter); | 1725 | values[0] = perf_counter_read_tree(counter); |
| 1711 | n = 1; | 1726 | n = 1; |
| 1712 | if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) | 1727 | if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) |
| 1713 | values[n++] = counter->total_time_enabled + | 1728 | values[n++] = counter->total_time_enabled + |
| @@ -2819,10 +2834,12 @@ perf_counter_read_event(struct perf_counter *counter, | |||
| 2819 | } | 2834 | } |
| 2820 | 2835 | ||
| 2821 | /* | 2836 | /* |
| 2822 | * fork tracking | 2837 | * task tracking -- fork/exit |
| 2838 | * | ||
| 2839 | * enabled by: attr.comm | attr.mmap | attr.task | ||
| 2823 | */ | 2840 | */ |
| 2824 | 2841 | ||
| 2825 | struct perf_fork_event { | 2842 | struct perf_task_event { |
| 2826 | struct task_struct *task; | 2843 | struct task_struct *task; |
| 2827 | 2844 | ||
| 2828 | struct { | 2845 | struct { |
| @@ -2830,37 +2847,42 @@ struct perf_fork_event { | |||
| 2830 | 2847 | ||
| 2831 | u32 pid; | 2848 | u32 pid; |
| 2832 | u32 ppid; | 2849 | u32 ppid; |
| 2850 | u32 tid; | ||
| 2851 | u32 ptid; | ||
| 2833 | } event; | 2852 | } event; |
| 2834 | }; | 2853 | }; |
| 2835 | 2854 | ||
| 2836 | static void perf_counter_fork_output(struct perf_counter *counter, | 2855 | static void perf_counter_task_output(struct perf_counter *counter, |
| 2837 | struct perf_fork_event *fork_event) | 2856 | struct perf_task_event *task_event) |
| 2838 | { | 2857 | { |
| 2839 | struct perf_output_handle handle; | 2858 | struct perf_output_handle handle; |
| 2840 | int size = fork_event->event.header.size; | 2859 | int size = task_event->event.header.size; |
| 2841 | struct task_struct *task = fork_event->task; | 2860 | struct task_struct *task = task_event->task; |
| 2842 | int ret = perf_output_begin(&handle, counter, size, 0, 0); | 2861 | int ret = perf_output_begin(&handle, counter, size, 0, 0); |
| 2843 | 2862 | ||
| 2844 | if (ret) | 2863 | if (ret) |
| 2845 | return; | 2864 | return; |
| 2846 | 2865 | ||
| 2847 | fork_event->event.pid = perf_counter_pid(counter, task); | 2866 | task_event->event.pid = perf_counter_pid(counter, task); |
| 2848 | fork_event->event.ppid = perf_counter_pid(counter, task->real_parent); | 2867 | task_event->event.ppid = perf_counter_pid(counter, task->real_parent); |
| 2849 | 2868 | ||
| 2850 | perf_output_put(&handle, fork_event->event); | 2869 | task_event->event.tid = perf_counter_tid(counter, task); |
| 2870 | task_event->event.ptid = perf_counter_tid(counter, task->real_parent); | ||
| 2871 | |||
| 2872 | perf_output_put(&handle, task_event->event); | ||
| 2851 | perf_output_end(&handle); | 2873 | perf_output_end(&handle); |
| 2852 | } | 2874 | } |
| 2853 | 2875 | ||
| 2854 | static int perf_counter_fork_match(struct perf_counter *counter) | 2876 | static int perf_counter_task_match(struct perf_counter *counter) |
| 2855 | { | 2877 | { |
| 2856 | if (counter->attr.comm || counter->attr.mmap) | 2878 | if (counter->attr.comm || counter->attr.mmap || counter->attr.task) |
| 2857 | return 1; | 2879 | return 1; |
| 2858 | 2880 | ||
| 2859 | return 0; | 2881 | return 0; |
| 2860 | } | 2882 | } |
| 2861 | 2883 | ||
| 2862 | static void perf_counter_fork_ctx(struct perf_counter_context *ctx, | 2884 | static void perf_counter_task_ctx(struct perf_counter_context *ctx, |
| 2863 | struct perf_fork_event *fork_event) | 2885 | struct perf_task_event *task_event) |
| 2864 | { | 2886 | { |
| 2865 | struct perf_counter *counter; | 2887 | struct perf_counter *counter; |
| 2866 | 2888 | ||
| @@ -2869,19 +2891,19 @@ static void perf_counter_fork_ctx(struct perf_counter_context *ctx, | |||
| 2869 | 2891 | ||
| 2870 | rcu_read_lock(); | 2892 | rcu_read_lock(); |
| 2871 | list_for_each_entry_rcu(counter, &ctx->event_list, event_entry) { | 2893 | list_for_each_entry_rcu(counter, &ctx->event_list, event_entry) { |
| 2872 | if (perf_counter_fork_match(counter)) | 2894 | if (perf_counter_task_match(counter)) |
| 2873 | perf_counter_fork_output(counter, fork_event); | 2895 | perf_counter_task_output(counter, task_event); |
| 2874 | } | 2896 | } |
| 2875 | rcu_read_unlock(); | 2897 | rcu_read_unlock(); |
| 2876 | } | 2898 | } |
| 2877 | 2899 | ||
| 2878 | static void perf_counter_fork_event(struct perf_fork_event *fork_event) | 2900 | static void perf_counter_task_event(struct perf_task_event *task_event) |
| 2879 | { | 2901 | { |
| 2880 | struct perf_cpu_context *cpuctx; | 2902 | struct perf_cpu_context *cpuctx; |
| 2881 | struct perf_counter_context *ctx; | 2903 | struct perf_counter_context *ctx; |
| 2882 | 2904 | ||
| 2883 | cpuctx = &get_cpu_var(perf_cpu_context); | 2905 | cpuctx = &get_cpu_var(perf_cpu_context); |
| 2884 | perf_counter_fork_ctx(&cpuctx->ctx, fork_event); | 2906 | perf_counter_task_ctx(&cpuctx->ctx, task_event); |
| 2885 | put_cpu_var(perf_cpu_context); | 2907 | put_cpu_var(perf_cpu_context); |
| 2886 | 2908 | ||
| 2887 | rcu_read_lock(); | 2909 | rcu_read_lock(); |
| @@ -2891,32 +2913,40 @@ static void perf_counter_fork_event(struct perf_fork_event *fork_event) | |||
| 2891 | */ | 2913 | */ |
| 2892 | ctx = rcu_dereference(current->perf_counter_ctxp); | 2914 | ctx = rcu_dereference(current->perf_counter_ctxp); |
| 2893 | if (ctx) | 2915 | if (ctx) |
| 2894 | perf_counter_fork_ctx(ctx, fork_event); | 2916 | perf_counter_task_ctx(ctx, task_event); |
| 2895 | rcu_read_unlock(); | 2917 | rcu_read_unlock(); |
| 2896 | } | 2918 | } |
| 2897 | 2919 | ||
| 2898 | void perf_counter_fork(struct task_struct *task) | 2920 | static void perf_counter_task(struct task_struct *task, int new) |
| 2899 | { | 2921 | { |
| 2900 | struct perf_fork_event fork_event; | 2922 | struct perf_task_event task_event; |
| 2901 | 2923 | ||
| 2902 | if (!atomic_read(&nr_comm_counters) && | 2924 | if (!atomic_read(&nr_comm_counters) && |
| 2903 | !atomic_read(&nr_mmap_counters)) | 2925 | !atomic_read(&nr_mmap_counters) && |
| 2926 | !atomic_read(&nr_task_counters)) | ||
| 2904 | return; | 2927 | return; |
| 2905 | 2928 | ||
| 2906 | fork_event = (struct perf_fork_event){ | 2929 | task_event = (struct perf_task_event){ |
| 2907 | .task = task, | 2930 | .task = task, |
| 2908 | .event = { | 2931 | .event = { |
| 2909 | .header = { | 2932 | .header = { |
| 2910 | .type = PERF_EVENT_FORK, | 2933 | .type = new ? PERF_EVENT_FORK : PERF_EVENT_EXIT, |
| 2911 | .misc = 0, | 2934 | .misc = 0, |
| 2912 | .size = sizeof(fork_event.event), | 2935 | .size = sizeof(task_event.event), |
| 2913 | }, | 2936 | }, |
| 2914 | /* .pid */ | 2937 | /* .pid */ |
| 2915 | /* .ppid */ | 2938 | /* .ppid */ |
| 2939 | /* .tid */ | ||
| 2940 | /* .ptid */ | ||
| 2916 | }, | 2941 | }, |
| 2917 | }; | 2942 | }; |
| 2918 | 2943 | ||
| 2919 | perf_counter_fork_event(&fork_event); | 2944 | perf_counter_task_event(&task_event); |
| 2945 | } | ||
| 2946 | |||
| 2947 | void perf_counter_fork(struct task_struct *task) | ||
| 2948 | { | ||
| 2949 | perf_counter_task(task, 1); | ||
| 2920 | } | 2950 | } |
| 2921 | 2951 | ||
| 2922 | /* | 2952 | /* |
| @@ -3875,6 +3905,8 @@ done: | |||
| 3875 | atomic_inc(&nr_mmap_counters); | 3905 | atomic_inc(&nr_mmap_counters); |
| 3876 | if (counter->attr.comm) | 3906 | if (counter->attr.comm) |
| 3877 | atomic_inc(&nr_comm_counters); | 3907 | atomic_inc(&nr_comm_counters); |
| 3908 | if (counter->attr.task) | ||
| 3909 | atomic_inc(&nr_task_counters); | ||
| 3878 | } | 3910 | } |
| 3879 | 3911 | ||
| 3880 | return counter; | 3912 | return counter; |
| @@ -4236,8 +4268,10 @@ void perf_counter_exit_task(struct task_struct *child) | |||
| 4236 | struct perf_counter_context *child_ctx; | 4268 | struct perf_counter_context *child_ctx; |
| 4237 | unsigned long flags; | 4269 | unsigned long flags; |
| 4238 | 4270 | ||
| 4239 | if (likely(!child->perf_counter_ctxp)) | 4271 | if (likely(!child->perf_counter_ctxp)) { |
| 4272 | perf_counter_task(child, 0); | ||
| 4240 | return; | 4273 | return; |
| 4274 | } | ||
| 4241 | 4275 | ||
| 4242 | local_irq_save(flags); | 4276 | local_irq_save(flags); |
| 4243 | /* | 4277 | /* |
| @@ -4255,15 +4289,22 @@ void perf_counter_exit_task(struct task_struct *child) | |||
| 4255 | * incremented the context's refcount before we do put_ctx below. | 4289 | * incremented the context's refcount before we do put_ctx below. |
| 4256 | */ | 4290 | */ |
| 4257 | spin_lock(&child_ctx->lock); | 4291 | spin_lock(&child_ctx->lock); |
| 4258 | child->perf_counter_ctxp = NULL; | ||
| 4259 | /* | 4292 | /* |
| 4260 | * If this context is a clone; unclone it so it can't get | 4293 | * If this context is a clone; unclone it so it can't get |
| 4261 | * swapped to another process while we're removing all | 4294 | * swapped to another process while we're removing all |
| 4262 | * the counters from it. | 4295 | * the counters from it. |
| 4263 | */ | 4296 | */ |
| 4264 | unclone_ctx(child_ctx); | 4297 | unclone_ctx(child_ctx); |
| 4265 | spin_unlock(&child_ctx->lock); | 4298 | spin_unlock_irqrestore(&child_ctx->lock, flags); |
| 4266 | local_irq_restore(flags); | 4299 | |
| 4300 | /* | ||
| 4301 | * Report the task dead after unscheduling the counters so that we | ||
| 4302 | * won't get any samples after PERF_EVENT_EXIT. We can however still | ||
| 4303 | * get a few PERF_EVENT_READ events. | ||
| 4304 | */ | ||
| 4305 | perf_counter_task(child, 0); | ||
| 4306 | |||
| 4307 | child->perf_counter_ctxp = NULL; | ||
| 4267 | 4308 | ||
| 4268 | /* | 4309 | /* |
| 4269 | * We can recurse on the same lock type through: | 4310 | * We can recurse on the same lock type through: |
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index 052ec4d195c7..d089d052c4a9 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
| @@ -202,6 +202,12 @@ static int no_timer_create(struct k_itimer *new_timer) | |||
| 202 | return -EOPNOTSUPP; | 202 | return -EOPNOTSUPP; |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | static int no_nsleep(const clockid_t which_clock, int flags, | ||
| 206 | struct timespec *tsave, struct timespec __user *rmtp) | ||
| 207 | { | ||
| 208 | return -EOPNOTSUPP; | ||
| 209 | } | ||
| 210 | |||
| 205 | /* | 211 | /* |
| 206 | * Return nonzero if we know a priori this clockid_t value is bogus. | 212 | * Return nonzero if we know a priori this clockid_t value is bogus. |
| 207 | */ | 213 | */ |
| @@ -254,6 +260,7 @@ static __init int init_posix_timers(void) | |||
| 254 | .clock_get = posix_get_monotonic_raw, | 260 | .clock_get = posix_get_monotonic_raw, |
| 255 | .clock_set = do_posix_clock_nosettime, | 261 | .clock_set = do_posix_clock_nosettime, |
| 256 | .timer_create = no_timer_create, | 262 | .timer_create = no_timer_create, |
| 263 | .nsleep = no_nsleep, | ||
| 257 | }; | 264 | }; |
| 258 | 265 | ||
| 259 | register_posix_clock(CLOCK_REALTIME, &clock_realtime); | 266 | register_posix_clock(CLOCK_REALTIME, &clock_realtime); |
diff --git a/kernel/sched_cpupri.c b/kernel/sched_cpupri.c index e6c251790dde..d014efbf947a 100644 --- a/kernel/sched_cpupri.c +++ b/kernel/sched_cpupri.c | |||
| @@ -81,8 +81,21 @@ int cpupri_find(struct cpupri *cp, struct task_struct *p, | |||
| 81 | if (cpumask_any_and(&p->cpus_allowed, vec->mask) >= nr_cpu_ids) | 81 | if (cpumask_any_and(&p->cpus_allowed, vec->mask) >= nr_cpu_ids) |
| 82 | continue; | 82 | continue; |
| 83 | 83 | ||
| 84 | if (lowest_mask) | 84 | if (lowest_mask) { |
| 85 | cpumask_and(lowest_mask, &p->cpus_allowed, vec->mask); | 85 | cpumask_and(lowest_mask, &p->cpus_allowed, vec->mask); |
| 86 | |||
| 87 | /* | ||
| 88 | * We have to ensure that we have at least one bit | ||
| 89 | * still set in the array, since the map could have | ||
| 90 | * been concurrently emptied between the first and | ||
| 91 | * second reads of vec->mask. If we hit this | ||
| 92 | * condition, simply act as though we never hit this | ||
| 93 | * priority level and continue on. | ||
| 94 | */ | ||
| 95 | if (cpumask_any(lowest_mask) >= nr_cpu_ids) | ||
| 96 | continue; | ||
| 97 | } | ||
| 98 | |||
| 86 | return 1; | 99 | return 1; |
| 87 | } | 100 | } |
| 88 | 101 | ||
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index 9ffb2b2ceba4..652e8bdef9aa 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c | |||
| @@ -611,9 +611,13 @@ account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se) | |||
| 611 | static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se) | 611 | static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se) |
| 612 | { | 612 | { |
| 613 | #ifdef CONFIG_SCHEDSTATS | 613 | #ifdef CONFIG_SCHEDSTATS |
| 614 | struct task_struct *tsk = NULL; | ||
| 615 | |||
| 616 | if (entity_is_task(se)) | ||
| 617 | tsk = task_of(se); | ||
| 618 | |||
| 614 | if (se->sleep_start) { | 619 | if (se->sleep_start) { |
| 615 | u64 delta = rq_of(cfs_rq)->clock - se->sleep_start; | 620 | u64 delta = rq_of(cfs_rq)->clock - se->sleep_start; |
| 616 | struct task_struct *tsk = task_of(se); | ||
| 617 | 621 | ||
| 618 | if ((s64)delta < 0) | 622 | if ((s64)delta < 0) |
| 619 | delta = 0; | 623 | delta = 0; |
| @@ -624,11 +628,11 @@ static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se) | |||
| 624 | se->sleep_start = 0; | 628 | se->sleep_start = 0; |
| 625 | se->sum_sleep_runtime += delta; | 629 | se->sum_sleep_runtime += delta; |
| 626 | 630 | ||
| 627 | account_scheduler_latency(tsk, delta >> 10, 1); | 631 | if (tsk) |
| 632 | account_scheduler_latency(tsk, delta >> 10, 1); | ||
| 628 | } | 633 | } |
| 629 | if (se->block_start) { | 634 | if (se->block_start) { |
| 630 | u64 delta = rq_of(cfs_rq)->clock - se->block_start; | 635 | u64 delta = rq_of(cfs_rq)->clock - se->block_start; |
| 631 | struct task_struct *tsk = task_of(se); | ||
| 632 | 636 | ||
| 633 | if ((s64)delta < 0) | 637 | if ((s64)delta < 0) |
| 634 | delta = 0; | 638 | delta = 0; |
| @@ -639,17 +643,19 @@ static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se) | |||
| 639 | se->block_start = 0; | 643 | se->block_start = 0; |
| 640 | se->sum_sleep_runtime += delta; | 644 | se->sum_sleep_runtime += delta; |
| 641 | 645 | ||
| 642 | /* | 646 | if (tsk) { |
| 643 | * Blocking time is in units of nanosecs, so shift by 20 to | 647 | /* |
| 644 | * get a milliseconds-range estimation of the amount of | 648 | * Blocking time is in units of nanosecs, so shift by |
| 645 | * time that the task spent sleeping: | 649 | * 20 to get a milliseconds-range estimation of the |
| 646 | */ | 650 | * amount of time that the task spent sleeping: |
| 647 | if (unlikely(prof_on == SLEEP_PROFILING)) { | 651 | */ |
| 648 | 652 | if (unlikely(prof_on == SLEEP_PROFILING)) { | |
| 649 | profile_hits(SLEEP_PROFILING, (void *)get_wchan(tsk), | 653 | profile_hits(SLEEP_PROFILING, |
| 650 | delta >> 20); | 654 | (void *)get_wchan(tsk), |
| 655 | delta >> 20); | ||
| 656 | } | ||
| 657 | account_scheduler_latency(tsk, delta >> 10, 0); | ||
| 651 | } | 658 | } |
| 652 | account_scheduler_latency(tsk, delta >> 10, 0); | ||
| 653 | } | 659 | } |
| 654 | #endif | 660 | #endif |
| 655 | } | 661 | } |
diff --git a/kernel/signal.c b/kernel/signal.c index ccf1ceedaebe..64c5deeaca5d 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
| @@ -2454,11 +2454,9 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s | |||
| 2454 | stack_t oss; | 2454 | stack_t oss; |
| 2455 | int error; | 2455 | int error; |
| 2456 | 2456 | ||
| 2457 | if (uoss) { | 2457 | oss.ss_sp = (void __user *) current->sas_ss_sp; |
| 2458 | oss.ss_sp = (void __user *) current->sas_ss_sp; | 2458 | oss.ss_size = current->sas_ss_size; |
| 2459 | oss.ss_size = current->sas_ss_size; | 2459 | oss.ss_flags = sas_ss_flags(sp); |
| 2460 | oss.ss_flags = sas_ss_flags(sp); | ||
| 2461 | } | ||
| 2462 | 2460 | ||
| 2463 | if (uss) { | 2461 | if (uss) { |
| 2464 | void __user *ss_sp; | 2462 | void __user *ss_sp; |
| @@ -2466,10 +2464,12 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s | |||
| 2466 | int ss_flags; | 2464 | int ss_flags; |
| 2467 | 2465 | ||
| 2468 | error = -EFAULT; | 2466 | error = -EFAULT; |
| 2469 | if (!access_ok(VERIFY_READ, uss, sizeof(*uss)) | 2467 | if (!access_ok(VERIFY_READ, uss, sizeof(*uss))) |
| 2470 | || __get_user(ss_sp, &uss->ss_sp) | 2468 | goto out; |
| 2471 | || __get_user(ss_flags, &uss->ss_flags) | 2469 | error = __get_user(ss_sp, &uss->ss_sp) | |
| 2472 | || __get_user(ss_size, &uss->ss_size)) | 2470 | __get_user(ss_flags, &uss->ss_flags) | |
| 2471 | __get_user(ss_size, &uss->ss_size); | ||
| 2472 | if (error) | ||
| 2473 | goto out; | 2473 | goto out; |
| 2474 | 2474 | ||
| 2475 | error = -EPERM; | 2475 | error = -EPERM; |
| @@ -2501,13 +2501,16 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s | |||
| 2501 | current->sas_ss_size = ss_size; | 2501 | current->sas_ss_size = ss_size; |
| 2502 | } | 2502 | } |
| 2503 | 2503 | ||
| 2504 | error = 0; | ||
| 2504 | if (uoss) { | 2505 | if (uoss) { |
| 2505 | error = -EFAULT; | 2506 | error = -EFAULT; |
| 2506 | if (copy_to_user(uoss, &oss, sizeof(oss))) | 2507 | if (!access_ok(VERIFY_WRITE, uoss, sizeof(*uoss))) |
| 2507 | goto out; | 2508 | goto out; |
| 2509 | error = __put_user(oss.ss_sp, &uoss->ss_sp) | | ||
| 2510 | __put_user(oss.ss_size, &uoss->ss_size) | | ||
| 2511 | __put_user(oss.ss_flags, &uoss->ss_flags); | ||
| 2508 | } | 2512 | } |
| 2509 | 2513 | ||
| 2510 | error = 0; | ||
| 2511 | out: | 2514 | out: |
| 2512 | return error; | 2515 | return error; |
| 2513 | } | 2516 | } |
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 1f3ec2afa511..1e1d23c26308 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
| @@ -1662,7 +1662,7 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable) | |||
| 1662 | 1662 | ||
| 1663 | mutex_lock(&ftrace_regex_lock); | 1663 | mutex_lock(&ftrace_regex_lock); |
| 1664 | if ((file->f_mode & FMODE_WRITE) && | 1664 | if ((file->f_mode & FMODE_WRITE) && |
| 1665 | !(file->f_flags & O_APPEND)) | 1665 | (file->f_flags & O_TRUNC)) |
| 1666 | ftrace_filter_reset(enable); | 1666 | ftrace_filter_reset(enable); |
| 1667 | 1667 | ||
| 1668 | if (file->f_mode & FMODE_READ) { | 1668 | if (file->f_mode & FMODE_READ) { |
| @@ -2577,7 +2577,7 @@ ftrace_graph_open(struct inode *inode, struct file *file) | |||
| 2577 | 2577 | ||
| 2578 | mutex_lock(&graph_lock); | 2578 | mutex_lock(&graph_lock); |
| 2579 | if ((file->f_mode & FMODE_WRITE) && | 2579 | if ((file->f_mode & FMODE_WRITE) && |
| 2580 | !(file->f_flags & O_APPEND)) { | 2580 | (file->f_flags & O_TRUNC)) { |
| 2581 | ftrace_graph_count = 0; | 2581 | ftrace_graph_count = 0; |
| 2582 | memset(ftrace_graph_funcs, 0, sizeof(ftrace_graph_funcs)); | 2582 | memset(ftrace_graph_funcs, 0, sizeof(ftrace_graph_funcs)); |
| 2583 | } | 2583 | } |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 8bc8d8afea6a..8930e39b9d8c 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
| @@ -2031,7 +2031,7 @@ static int tracing_open(struct inode *inode, struct file *file) | |||
| 2031 | 2031 | ||
| 2032 | /* If this file was open for write, then erase contents */ | 2032 | /* If this file was open for write, then erase contents */ |
| 2033 | if ((file->f_mode & FMODE_WRITE) && | 2033 | if ((file->f_mode & FMODE_WRITE) && |
| 2034 | !(file->f_flags & O_APPEND)) { | 2034 | (file->f_flags & O_TRUNC)) { |
| 2035 | long cpu = (long) inode->i_private; | 2035 | long cpu = (long) inode->i_private; |
| 2036 | 2036 | ||
| 2037 | if (cpu == TRACE_PIPE_ALL_CPU) | 2037 | if (cpu == TRACE_PIPE_ALL_CPU) |
| @@ -3085,7 +3085,8 @@ tracing_fill_pipe_page(size_t rem, struct trace_iterator *iter) | |||
| 3085 | break; | 3085 | break; |
| 3086 | } | 3086 | } |
| 3087 | 3087 | ||
| 3088 | trace_consume(iter); | 3088 | if (ret != TRACE_TYPE_NO_CONSUME) |
| 3089 | trace_consume(iter); | ||
| 3089 | rem -= count; | 3090 | rem -= count; |
| 3090 | if (!find_next_entry_inc(iter)) { | 3091 | if (!find_next_entry_inc(iter)) { |
| 3091 | rem = 0; | 3092 | rem = 0; |
| @@ -4233,8 +4234,11 @@ static void __ftrace_dump(bool disable_tracing) | |||
| 4233 | iter.pos = -1; | 4234 | iter.pos = -1; |
| 4234 | 4235 | ||
| 4235 | if (find_next_entry_inc(&iter) != NULL) { | 4236 | if (find_next_entry_inc(&iter) != NULL) { |
| 4236 | print_trace_line(&iter); | 4237 | int ret; |
| 4237 | trace_consume(&iter); | 4238 | |
| 4239 | ret = print_trace_line(&iter); | ||
| 4240 | if (ret != TRACE_TYPE_NO_CONSUME) | ||
| 4241 | trace_consume(&iter); | ||
| 4238 | } | 4242 | } |
| 4239 | 4243 | ||
| 4240 | trace_printk_seq(&iter.seq); | 4244 | trace_printk_seq(&iter.seq); |
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 53c8fd376a88..23d2972b22d6 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
| @@ -376,7 +376,7 @@ ftrace_event_seq_open(struct inode *inode, struct file *file) | |||
| 376 | const struct seq_operations *seq_ops; | 376 | const struct seq_operations *seq_ops; |
| 377 | 377 | ||
| 378 | if ((file->f_mode & FMODE_WRITE) && | 378 | if ((file->f_mode & FMODE_WRITE) && |
| 379 | !(file->f_flags & O_APPEND)) | 379 | (file->f_flags & O_TRUNC)) |
| 380 | ftrace_clear_events(); | 380 | ftrace_clear_events(); |
| 381 | 381 | ||
| 382 | seq_ops = inode->i_private; | 382 | seq_ops = inode->i_private; |
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c index d2249abafb53..420ec3487579 100644 --- a/kernel/trace/trace_functions_graph.c +++ b/kernel/trace/trace_functions_graph.c | |||
| @@ -843,9 +843,16 @@ print_graph_function(struct trace_iterator *iter) | |||
| 843 | 843 | ||
| 844 | switch (entry->type) { | 844 | switch (entry->type) { |
| 845 | case TRACE_GRAPH_ENT: { | 845 | case TRACE_GRAPH_ENT: { |
| 846 | struct ftrace_graph_ent_entry *field; | 846 | /* |
| 847 | * print_graph_entry() may consume the current event, | ||
| 848 | * thus @field may become invalid, so we need to save it. | ||
| 849 | * sizeof(struct ftrace_graph_ent_entry) is very small, | ||
| 850 | * it can be safely saved at the stack. | ||
| 851 | */ | ||
| 852 | struct ftrace_graph_ent_entry *field, saved; | ||
| 847 | trace_assign_type(field, entry); | 853 | trace_assign_type(field, entry); |
| 848 | return print_graph_entry(field, s, iter); | 854 | saved = *field; |
| 855 | return print_graph_entry(&saved, s, iter); | ||
| 849 | } | 856 | } |
| 850 | case TRACE_GRAPH_RET: { | 857 | case TRACE_GRAPH_RET: { |
| 851 | struct ftrace_graph_ret_entry *field; | 858 | struct ftrace_graph_ret_entry *field; |
diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c index 7b6278110827..687699d365ae 100644 --- a/kernel/trace/trace_printk.c +++ b/kernel/trace/trace_printk.c | |||
| @@ -176,7 +176,7 @@ static int t_show(struct seq_file *m, void *v) | |||
| 176 | const char *str = *fmt; | 176 | const char *str = *fmt; |
| 177 | int i; | 177 | int i; |
| 178 | 178 | ||
| 179 | seq_printf(m, "0x%lx : \"", (unsigned long)fmt); | 179 | seq_printf(m, "0x%lx : \"", *(unsigned long *)fmt); |
| 180 | 180 | ||
| 181 | /* | 181 | /* |
| 182 | * Tabs and new lines need to be converted. | 182 | * Tabs and new lines need to be converted. |
