diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/fork.c | 13 | ||||
-rw-r--r-- | kernel/irq/numa_migrate.c | 1 | ||||
-rw-r--r-- | kernel/kthread.c | 26 | ||||
-rw-r--r-- | kernel/module.c | 3 | ||||
-rw-r--r-- | kernel/posix-cpu-timers.c | 9 | ||||
-rw-r--r-- | kernel/ptrace.c | 16 | ||||
-rw-r--r-- | kernel/sched.c | 160 | ||||
-rw-r--r-- | kernel/sched_cpupri.c | 5 | ||||
-rw-r--r-- | kernel/sched_rt.c | 15 | ||||
-rw-r--r-- | kernel/timer.c | 7 | ||||
-rw-r--r-- | kernel/trace/blktrace.c | 10 | ||||
-rw-r--r-- | kernel/trace/trace_syscalls.c | 2 | ||||
-rw-r--r-- | kernel/workqueue.c | 36 |
13 files changed, 219 insertions, 84 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 989c7c202b3d..b9e2edd00726 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -800,6 +800,12 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig) | |||
800 | sig->cputime_expires.virt_exp = cputime_zero; | 800 | sig->cputime_expires.virt_exp = cputime_zero; |
801 | sig->cputime_expires.sched_exp = 0; | 801 | sig->cputime_expires.sched_exp = 0; |
802 | 802 | ||
803 | if (sig->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY) { | ||
804 | sig->cputime_expires.prof_exp = | ||
805 | secs_to_cputime(sig->rlim[RLIMIT_CPU].rlim_cur); | ||
806 | sig->cputimer.running = 1; | ||
807 | } | ||
808 | |||
803 | /* The timer lists. */ | 809 | /* The timer lists. */ |
804 | INIT_LIST_HEAD(&sig->cpu_timers[0]); | 810 | INIT_LIST_HEAD(&sig->cpu_timers[0]); |
805 | INIT_LIST_HEAD(&sig->cpu_timers[1]); | 811 | INIT_LIST_HEAD(&sig->cpu_timers[1]); |
@@ -815,11 +821,8 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) | |||
815 | atomic_inc(¤t->signal->live); | 821 | atomic_inc(¤t->signal->live); |
816 | return 0; | 822 | return 0; |
817 | } | 823 | } |
818 | sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL); | ||
819 | |||
820 | if (sig) | ||
821 | posix_cpu_timers_init_group(sig); | ||
822 | 824 | ||
825 | sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL); | ||
823 | tsk->signal = sig; | 826 | tsk->signal = sig; |
824 | if (!sig) | 827 | if (!sig) |
825 | return -ENOMEM; | 828 | return -ENOMEM; |
@@ -859,6 +862,8 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) | |||
859 | memcpy(sig->rlim, current->signal->rlim, sizeof sig->rlim); | 862 | memcpy(sig->rlim, current->signal->rlim, sizeof sig->rlim); |
860 | task_unlock(current->group_leader); | 863 | task_unlock(current->group_leader); |
861 | 864 | ||
865 | posix_cpu_timers_init_group(sig); | ||
866 | |||
862 | acct_init_pacct(&sig->pacct); | 867 | acct_init_pacct(&sig->pacct); |
863 | 868 | ||
864 | tty_audit_fork(sig); | 869 | tty_audit_fork(sig); |
diff --git a/kernel/irq/numa_migrate.c b/kernel/irq/numa_migrate.c index 243d6121e50e..44bbdcbaf8d2 100644 --- a/kernel/irq/numa_migrate.c +++ b/kernel/irq/numa_migrate.c | |||
@@ -54,6 +54,7 @@ static bool init_copy_one_irq_desc(int irq, struct irq_desc *old_desc, | |||
54 | static void free_one_irq_desc(struct irq_desc *old_desc, struct irq_desc *desc) | 54 | static void free_one_irq_desc(struct irq_desc *old_desc, struct irq_desc *desc) |
55 | { | 55 | { |
56 | free_kstat_irqs(old_desc, desc); | 56 | free_kstat_irqs(old_desc, desc); |
57 | free_desc_masks(old_desc, desc); | ||
57 | arch_free_chip_data(old_desc, desc); | 58 | arch_free_chip_data(old_desc, desc); |
58 | } | 59 | } |
59 | 60 | ||
diff --git a/kernel/kthread.c b/kernel/kthread.c index 84bbadd4d021..4ebaf8519abf 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c | |||
@@ -76,6 +76,7 @@ static int kthread(void *_create) | |||
76 | 76 | ||
77 | /* OK, tell user we're spawned, wait for stop or wakeup */ | 77 | /* OK, tell user we're spawned, wait for stop or wakeup */ |
78 | __set_current_state(TASK_UNINTERRUPTIBLE); | 78 | __set_current_state(TASK_UNINTERRUPTIBLE); |
79 | create->result = current; | ||
79 | complete(&create->started); | 80 | complete(&create->started); |
80 | schedule(); | 81 | schedule(); |
81 | 82 | ||
@@ -96,22 +97,10 @@ static void create_kthread(struct kthread_create_info *create) | |||
96 | 97 | ||
97 | /* We want our own signal handler (we take no signals by default). */ | 98 | /* We want our own signal handler (we take no signals by default). */ |
98 | pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD); | 99 | pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD); |
99 | if (pid < 0) { | 100 | if (pid < 0) |
100 | create->result = ERR_PTR(pid); | 101 | create->result = ERR_PTR(pid); |
101 | } else { | 102 | else |
102 | struct sched_param param = { .sched_priority = 0 }; | ||
103 | wait_for_completion(&create->started); | 103 | wait_for_completion(&create->started); |
104 | read_lock(&tasklist_lock); | ||
105 | create->result = find_task_by_pid_ns(pid, &init_pid_ns); | ||
106 | read_unlock(&tasklist_lock); | ||
107 | /* | ||
108 | * root may have changed our (kthreadd's) priority or CPU mask. | ||
109 | * The kernel thread should not inherit these properties. | ||
110 | */ | ||
111 | sched_setscheduler(create->result, SCHED_NORMAL, ¶m); | ||
112 | set_user_nice(create->result, KTHREAD_NICE_LEVEL); | ||
113 | set_cpus_allowed_ptr(create->result, cpu_all_mask); | ||
114 | } | ||
115 | complete(&create->done); | 104 | complete(&create->done); |
116 | } | 105 | } |
117 | 106 | ||
@@ -154,11 +143,20 @@ struct task_struct *kthread_create(int (*threadfn)(void *data), | |||
154 | wait_for_completion(&create.done); | 143 | wait_for_completion(&create.done); |
155 | 144 | ||
156 | if (!IS_ERR(create.result)) { | 145 | if (!IS_ERR(create.result)) { |
146 | struct sched_param param = { .sched_priority = 0 }; | ||
157 | va_list args; | 147 | va_list args; |
148 | |||
158 | va_start(args, namefmt); | 149 | va_start(args, namefmt); |
159 | vsnprintf(create.result->comm, sizeof(create.result->comm), | 150 | vsnprintf(create.result->comm, sizeof(create.result->comm), |
160 | namefmt, args); | 151 | namefmt, args); |
161 | va_end(args); | 152 | va_end(args); |
153 | /* | ||
154 | * root may have changed our (kthreadd's) priority or CPU mask. | ||
155 | * The kernel thread should not inherit these properties. | ||
156 | */ | ||
157 | sched_setscheduler_nocheck(create.result, SCHED_NORMAL, ¶m); | ||
158 | set_user_nice(create.result, KTHREAD_NICE_LEVEL); | ||
159 | set_cpus_allowed_ptr(create.result, cpu_all_mask); | ||
162 | } | 160 | } |
163 | return create.result; | 161 | return create.result; |
164 | } | 162 | } |
diff --git a/kernel/module.c b/kernel/module.c index 05f014efa32c..e797812a4d95 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -2388,6 +2388,9 @@ SYSCALL_DEFINE3(init_module, void __user *, umod, | |||
2388 | blocking_notifier_call_chain(&module_notify_list, | 2388 | blocking_notifier_call_chain(&module_notify_list, |
2389 | MODULE_STATE_LIVE, mod); | 2389 | MODULE_STATE_LIVE, mod); |
2390 | 2390 | ||
2391 | /* We need to finish all async code before the module init sequence is done */ | ||
2392 | async_synchronize_full(); | ||
2393 | |||
2391 | mutex_lock(&module_mutex); | 2394 | mutex_lock(&module_mutex); |
2392 | /* Drop initial reference. */ | 2395 | /* Drop initial reference. */ |
2393 | module_put(mod); | 2396 | module_put(mod); |
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index 8e5d9a68b022..c9dcf98b4463 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
@@ -18,7 +18,7 @@ void update_rlimit_cpu(unsigned long rlim_new) | |||
18 | 18 | ||
19 | cputime = secs_to_cputime(rlim_new); | 19 | cputime = secs_to_cputime(rlim_new); |
20 | if (cputime_eq(current->signal->it_prof_expires, cputime_zero) || | 20 | if (cputime_eq(current->signal->it_prof_expires, cputime_zero) || |
21 | cputime_lt(current->signal->it_prof_expires, cputime)) { | 21 | cputime_gt(current->signal->it_prof_expires, cputime)) { |
22 | spin_lock_irq(¤t->sighand->siglock); | 22 | spin_lock_irq(¤t->sighand->siglock); |
23 | set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL); | 23 | set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL); |
24 | spin_unlock_irq(¤t->sighand->siglock); | 24 | spin_unlock_irq(¤t->sighand->siglock); |
@@ -224,7 +224,7 @@ static int cpu_clock_sample(const clockid_t which_clock, struct task_struct *p, | |||
224 | cpu->cpu = virt_ticks(p); | 224 | cpu->cpu = virt_ticks(p); |
225 | break; | 225 | break; |
226 | case CPUCLOCK_SCHED: | 226 | case CPUCLOCK_SCHED: |
227 | cpu->sched = p->se.sum_exec_runtime + task_delta_exec(p); | 227 | cpu->sched = task_sched_runtime(p); |
228 | break; | 228 | break; |
229 | } | 229 | } |
230 | return 0; | 230 | return 0; |
@@ -305,18 +305,19 @@ static int cpu_clock_sample_group(const clockid_t which_clock, | |||
305 | { | 305 | { |
306 | struct task_cputime cputime; | 306 | struct task_cputime cputime; |
307 | 307 | ||
308 | thread_group_cputime(p, &cputime); | ||
309 | switch (CPUCLOCK_WHICH(which_clock)) { | 308 | switch (CPUCLOCK_WHICH(which_clock)) { |
310 | default: | 309 | default: |
311 | return -EINVAL; | 310 | return -EINVAL; |
312 | case CPUCLOCK_PROF: | 311 | case CPUCLOCK_PROF: |
312 | thread_group_cputime(p, &cputime); | ||
313 | cpu->cpu = cputime_add(cputime.utime, cputime.stime); | 313 | cpu->cpu = cputime_add(cputime.utime, cputime.stime); |
314 | break; | 314 | break; |
315 | case CPUCLOCK_VIRT: | 315 | case CPUCLOCK_VIRT: |
316 | thread_group_cputime(p, &cputime); | ||
316 | cpu->cpu = cputime.utime; | 317 | cpu->cpu = cputime.utime; |
317 | break; | 318 | break; |
318 | case CPUCLOCK_SCHED: | 319 | case CPUCLOCK_SCHED: |
319 | cpu->sched = cputime.sum_exec_runtime + task_delta_exec(p); | 320 | cpu->sched = thread_group_sched_runtime(p); |
320 | break; | 321 | break; |
321 | } | 322 | } |
322 | return 0; | 323 | return 0; |
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index aaad0ec34194..64191fa09b7e 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -21,9 +21,7 @@ | |||
21 | #include <linux/audit.h> | 21 | #include <linux/audit.h> |
22 | #include <linux/pid_namespace.h> | 22 | #include <linux/pid_namespace.h> |
23 | #include <linux/syscalls.h> | 23 | #include <linux/syscalls.h> |
24 | 24 | #include <linux/uaccess.h> | |
25 | #include <asm/pgtable.h> | ||
26 | #include <asm/uaccess.h> | ||
27 | 25 | ||
28 | 26 | ||
29 | /* | 27 | /* |
@@ -48,7 +46,7 @@ void __ptrace_link(struct task_struct *child, struct task_struct *new_parent) | |||
48 | list_add(&child->ptrace_entry, &new_parent->ptraced); | 46 | list_add(&child->ptrace_entry, &new_parent->ptraced); |
49 | child->parent = new_parent; | 47 | child->parent = new_parent; |
50 | } | 48 | } |
51 | 49 | ||
52 | /* | 50 | /* |
53 | * Turn a tracing stop into a normal stop now, since with no tracer there | 51 | * Turn a tracing stop into a normal stop now, since with no tracer there |
54 | * would be no way to wake it up with SIGCONT or SIGKILL. If there was a | 52 | * would be no way to wake it up with SIGCONT or SIGKILL. If there was a |
@@ -173,7 +171,7 @@ bool ptrace_may_access(struct task_struct *task, unsigned int mode) | |||
173 | task_lock(task); | 171 | task_lock(task); |
174 | err = __ptrace_may_access(task, mode); | 172 | err = __ptrace_may_access(task, mode); |
175 | task_unlock(task); | 173 | task_unlock(task); |
176 | return (!err ? true : false); | 174 | return !err; |
177 | } | 175 | } |
178 | 176 | ||
179 | int ptrace_attach(struct task_struct *task) | 177 | int ptrace_attach(struct task_struct *task) |
@@ -358,7 +356,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst | |||
358 | copied += retval; | 356 | copied += retval; |
359 | src += retval; | 357 | src += retval; |
360 | dst += retval; | 358 | dst += retval; |
361 | len -= retval; | 359 | len -= retval; |
362 | } | 360 | } |
363 | return copied; | 361 | return copied; |
364 | } | 362 | } |
@@ -383,7 +381,7 @@ int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long ds | |||
383 | copied += retval; | 381 | copied += retval; |
384 | src += retval; | 382 | src += retval; |
385 | dst += retval; | 383 | dst += retval; |
386 | len -= retval; | 384 | len -= retval; |
387 | } | 385 | } |
388 | return copied; | 386 | return copied; |
389 | } | 387 | } |
@@ -496,9 +494,9 @@ static int ptrace_resume(struct task_struct *child, long request, long data) | |||
496 | if (unlikely(!arch_has_single_step())) | 494 | if (unlikely(!arch_has_single_step())) |
497 | return -EIO; | 495 | return -EIO; |
498 | user_enable_single_step(child); | 496 | user_enable_single_step(child); |
499 | } | 497 | } else { |
500 | else | ||
501 | user_disable_single_step(child); | 498 | user_disable_single_step(child); |
499 | } | ||
502 | 500 | ||
503 | child->exit_code = data; | 501 | child->exit_code = data; |
504 | wake_up_process(child); | 502 | wake_up_process(child); |
diff --git a/kernel/sched.c b/kernel/sched.c index 6cc1fd5d5072..5724508c3b66 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -1418,10 +1418,22 @@ iter_move_one_task(struct rq *this_rq, int this_cpu, struct rq *busiest, | |||
1418 | struct rq_iterator *iterator); | 1418 | struct rq_iterator *iterator); |
1419 | #endif | 1419 | #endif |
1420 | 1420 | ||
1421 | /* Time spent by the tasks of the cpu accounting group executing in ... */ | ||
1422 | enum cpuacct_stat_index { | ||
1423 | CPUACCT_STAT_USER, /* ... user mode */ | ||
1424 | CPUACCT_STAT_SYSTEM, /* ... kernel mode */ | ||
1425 | |||
1426 | CPUACCT_STAT_NSTATS, | ||
1427 | }; | ||
1428 | |||
1421 | #ifdef CONFIG_CGROUP_CPUACCT | 1429 | #ifdef CONFIG_CGROUP_CPUACCT |
1422 | static void cpuacct_charge(struct task_struct *tsk, u64 cputime); | 1430 | static void cpuacct_charge(struct task_struct *tsk, u64 cputime); |
1431 | static void cpuacct_update_stats(struct task_struct *tsk, | ||
1432 | enum cpuacct_stat_index idx, cputime_t val); | ||
1423 | #else | 1433 | #else |
1424 | static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime) {} | 1434 | static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime) {} |
1435 | static inline void cpuacct_update_stats(struct task_struct *tsk, | ||
1436 | enum cpuacct_stat_index idx, cputime_t val) {} | ||
1425 | #endif | 1437 | #endif |
1426 | 1438 | ||
1427 | static inline void inc_cpu_load(struct rq *rq, unsigned long load) | 1439 | static inline void inc_cpu_load(struct rq *rq, unsigned long load) |
@@ -4511,9 +4523,25 @@ DEFINE_PER_CPU(struct kernel_stat, kstat); | |||
4511 | EXPORT_PER_CPU_SYMBOL(kstat); | 4523 | EXPORT_PER_CPU_SYMBOL(kstat); |
4512 | 4524 | ||
4513 | /* | 4525 | /* |
4514 | * Return any ns on the sched_clock that have not yet been banked in | 4526 | * Return any ns on the sched_clock that have not yet been accounted in |
4515 | * @p in case that task is currently running. | 4527 | * @p in case that task is currently running. |
4528 | * | ||
4529 | * Called with task_rq_lock() held on @rq. | ||
4516 | */ | 4530 | */ |
4531 | static u64 do_task_delta_exec(struct task_struct *p, struct rq *rq) | ||
4532 | { | ||
4533 | u64 ns = 0; | ||
4534 | |||
4535 | if (task_current(rq, p)) { | ||
4536 | update_rq_clock(rq); | ||
4537 | ns = rq->clock - p->se.exec_start; | ||
4538 | if ((s64)ns < 0) | ||
4539 | ns = 0; | ||
4540 | } | ||
4541 | |||
4542 | return ns; | ||
4543 | } | ||
4544 | |||
4517 | unsigned long long task_delta_exec(struct task_struct *p) | 4545 | unsigned long long task_delta_exec(struct task_struct *p) |
4518 | { | 4546 | { |
4519 | unsigned long flags; | 4547 | unsigned long flags; |
@@ -4521,16 +4549,49 @@ unsigned long long task_delta_exec(struct task_struct *p) | |||
4521 | u64 ns = 0; | 4549 | u64 ns = 0; |
4522 | 4550 | ||
4523 | rq = task_rq_lock(p, &flags); | 4551 | rq = task_rq_lock(p, &flags); |
4552 | ns = do_task_delta_exec(p, rq); | ||
4553 | task_rq_unlock(rq, &flags); | ||
4524 | 4554 | ||
4525 | if (task_current(rq, p)) { | 4555 | return ns; |
4526 | u64 delta_exec; | 4556 | } |
4527 | 4557 | ||
4528 | update_rq_clock(rq); | 4558 | /* |
4529 | delta_exec = rq->clock - p->se.exec_start; | 4559 | * Return accounted runtime for the task. |
4530 | if ((s64)delta_exec > 0) | 4560 | * In case the task is currently running, return the runtime plus current's |
4531 | ns = delta_exec; | 4561 | * pending runtime that have not been accounted yet. |
4532 | } | 4562 | */ |
4563 | unsigned long long task_sched_runtime(struct task_struct *p) | ||
4564 | { | ||
4565 | unsigned long flags; | ||
4566 | struct rq *rq; | ||
4567 | u64 ns = 0; | ||
4568 | |||
4569 | rq = task_rq_lock(p, &flags); | ||
4570 | ns = p->se.sum_exec_runtime + do_task_delta_exec(p, rq); | ||
4571 | task_rq_unlock(rq, &flags); | ||
4572 | |||
4573 | return ns; | ||
4574 | } | ||
4575 | |||
4576 | /* | ||
4577 | * Return sum_exec_runtime for the thread group. | ||
4578 | * In case the task is currently running, return the sum plus current's | ||
4579 | * pending runtime that have not been accounted yet. | ||
4580 | * | ||
4581 | * Note that the thread group might have other running tasks as well, | ||
4582 | * so the return value not includes other pending runtime that other | ||
4583 | * running tasks might have. | ||
4584 | */ | ||
4585 | unsigned long long thread_group_sched_runtime(struct task_struct *p) | ||
4586 | { | ||
4587 | struct task_cputime totals; | ||
4588 | unsigned long flags; | ||
4589 | struct rq *rq; | ||
4590 | u64 ns; | ||
4533 | 4591 | ||
4592 | rq = task_rq_lock(p, &flags); | ||
4593 | thread_group_cputime(p, &totals); | ||
4594 | ns = totals.sum_exec_runtime + do_task_delta_exec(p, rq); | ||
4534 | task_rq_unlock(rq, &flags); | 4595 | task_rq_unlock(rq, &flags); |
4535 | 4596 | ||
4536 | return ns; | 4597 | return ns; |
@@ -4559,6 +4620,8 @@ void account_user_time(struct task_struct *p, cputime_t cputime, | |||
4559 | cpustat->nice = cputime64_add(cpustat->nice, tmp); | 4620 | cpustat->nice = cputime64_add(cpustat->nice, tmp); |
4560 | else | 4621 | else |
4561 | cpustat->user = cputime64_add(cpustat->user, tmp); | 4622 | cpustat->user = cputime64_add(cpustat->user, tmp); |
4623 | |||
4624 | cpuacct_update_stats(p, CPUACCT_STAT_USER, cputime); | ||
4562 | /* Account for user time used */ | 4625 | /* Account for user time used */ |
4563 | acct_update_integrals(p); | 4626 | acct_update_integrals(p); |
4564 | } | 4627 | } |
@@ -4620,6 +4683,8 @@ void account_system_time(struct task_struct *p, int hardirq_offset, | |||
4620 | else | 4683 | else |
4621 | cpustat->system = cputime64_add(cpustat->system, tmp); | 4684 | cpustat->system = cputime64_add(cpustat->system, tmp); |
4622 | 4685 | ||
4686 | cpuacct_update_stats(p, CPUACCT_STAT_SYSTEM, cputime); | ||
4687 | |||
4623 | /* Account for system time used */ | 4688 | /* Account for system time used */ |
4624 | acct_update_integrals(p); | 4689 | acct_update_integrals(p); |
4625 | } | 4690 | } |
@@ -7302,7 +7367,8 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, | |||
7302 | cpumask_or(groupmask, groupmask, sched_group_cpus(group)); | 7367 | cpumask_or(groupmask, groupmask, sched_group_cpus(group)); |
7303 | 7368 | ||
7304 | cpulist_scnprintf(str, sizeof(str), sched_group_cpus(group)); | 7369 | cpulist_scnprintf(str, sizeof(str), sched_group_cpus(group)); |
7305 | printk(KERN_CONT " %s", str); | 7370 | printk(KERN_CONT " %s (__cpu_power = %d)", str, |
7371 | group->__cpu_power); | ||
7306 | 7372 | ||
7307 | group = group->next; | 7373 | group = group->next; |
7308 | } while (group != sd->groups); | 7374 | } while (group != sd->groups); |
@@ -9925,6 +9991,7 @@ struct cpuacct { | |||
9925 | struct cgroup_subsys_state css; | 9991 | struct cgroup_subsys_state css; |
9926 | /* cpuusage holds pointer to a u64-type object on every cpu */ | 9992 | /* cpuusage holds pointer to a u64-type object on every cpu */ |
9927 | u64 *cpuusage; | 9993 | u64 *cpuusage; |
9994 | struct percpu_counter cpustat[CPUACCT_STAT_NSTATS]; | ||
9928 | struct cpuacct *parent; | 9995 | struct cpuacct *parent; |
9929 | }; | 9996 | }; |
9930 | 9997 | ||
@@ -9949,20 +10016,32 @@ static struct cgroup_subsys_state *cpuacct_create( | |||
9949 | struct cgroup_subsys *ss, struct cgroup *cgrp) | 10016 | struct cgroup_subsys *ss, struct cgroup *cgrp) |
9950 | { | 10017 | { |
9951 | struct cpuacct *ca = kzalloc(sizeof(*ca), GFP_KERNEL); | 10018 | struct cpuacct *ca = kzalloc(sizeof(*ca), GFP_KERNEL); |
10019 | int i; | ||
9952 | 10020 | ||
9953 | if (!ca) | 10021 | if (!ca) |
9954 | return ERR_PTR(-ENOMEM); | 10022 | goto out; |
9955 | 10023 | ||
9956 | ca->cpuusage = alloc_percpu(u64); | 10024 | ca->cpuusage = alloc_percpu(u64); |
9957 | if (!ca->cpuusage) { | 10025 | if (!ca->cpuusage) |
9958 | kfree(ca); | 10026 | goto out_free_ca; |
9959 | return ERR_PTR(-ENOMEM); | 10027 | |
9960 | } | 10028 | for (i = 0; i < CPUACCT_STAT_NSTATS; i++) |
10029 | if (percpu_counter_init(&ca->cpustat[i], 0)) | ||
10030 | goto out_free_counters; | ||
9961 | 10031 | ||
9962 | if (cgrp->parent) | 10032 | if (cgrp->parent) |
9963 | ca->parent = cgroup_ca(cgrp->parent); | 10033 | ca->parent = cgroup_ca(cgrp->parent); |
9964 | 10034 | ||
9965 | return &ca->css; | 10035 | return &ca->css; |
10036 | |||
10037 | out_free_counters: | ||
10038 | while (--i >= 0) | ||
10039 | percpu_counter_destroy(&ca->cpustat[i]); | ||
10040 | free_percpu(ca->cpuusage); | ||
10041 | out_free_ca: | ||
10042 | kfree(ca); | ||
10043 | out: | ||
10044 | return ERR_PTR(-ENOMEM); | ||
9966 | } | 10045 | } |
9967 | 10046 | ||
9968 | /* destroy an existing cpu accounting group */ | 10047 | /* destroy an existing cpu accounting group */ |
@@ -9970,7 +10049,10 @@ static void | |||
9970 | cpuacct_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp) | 10049 | cpuacct_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp) |
9971 | { | 10050 | { |
9972 | struct cpuacct *ca = cgroup_ca(cgrp); | 10051 | struct cpuacct *ca = cgroup_ca(cgrp); |
10052 | int i; | ||
9973 | 10053 | ||
10054 | for (i = 0; i < CPUACCT_STAT_NSTATS; i++) | ||
10055 | percpu_counter_destroy(&ca->cpustat[i]); | ||
9974 | free_percpu(ca->cpuusage); | 10056 | free_percpu(ca->cpuusage); |
9975 | kfree(ca); | 10057 | kfree(ca); |
9976 | } | 10058 | } |
@@ -10057,6 +10139,25 @@ static int cpuacct_percpu_seq_read(struct cgroup *cgroup, struct cftype *cft, | |||
10057 | return 0; | 10139 | return 0; |
10058 | } | 10140 | } |
10059 | 10141 | ||
10142 | static const char *cpuacct_stat_desc[] = { | ||
10143 | [CPUACCT_STAT_USER] = "user", | ||
10144 | [CPUACCT_STAT_SYSTEM] = "system", | ||
10145 | }; | ||
10146 | |||
10147 | static int cpuacct_stats_show(struct cgroup *cgrp, struct cftype *cft, | ||
10148 | struct cgroup_map_cb *cb) | ||
10149 | { | ||
10150 | struct cpuacct *ca = cgroup_ca(cgrp); | ||
10151 | int i; | ||
10152 | |||
10153 | for (i = 0; i < CPUACCT_STAT_NSTATS; i++) { | ||
10154 | s64 val = percpu_counter_read(&ca->cpustat[i]); | ||
10155 | val = cputime64_to_clock_t(val); | ||
10156 | cb->fill(cb, cpuacct_stat_desc[i], val); | ||
10157 | } | ||
10158 | return 0; | ||
10159 | } | ||
10160 | |||
10060 | static struct cftype files[] = { | 10161 | static struct cftype files[] = { |
10061 | { | 10162 | { |
10062 | .name = "usage", | 10163 | .name = "usage", |
@@ -10067,7 +10168,10 @@ static struct cftype files[] = { | |||
10067 | .name = "usage_percpu", | 10168 | .name = "usage_percpu", |
10068 | .read_seq_string = cpuacct_percpu_seq_read, | 10169 | .read_seq_string = cpuacct_percpu_seq_read, |
10069 | }, | 10170 | }, |
10070 | 10171 | { | |
10172 | .name = "stat", | ||
10173 | .read_map = cpuacct_stats_show, | ||
10174 | }, | ||
10071 | }; | 10175 | }; |
10072 | 10176 | ||
10073 | static int cpuacct_populate(struct cgroup_subsys *ss, struct cgroup *cgrp) | 10177 | static int cpuacct_populate(struct cgroup_subsys *ss, struct cgroup *cgrp) |
@@ -10089,12 +10193,38 @@ static void cpuacct_charge(struct task_struct *tsk, u64 cputime) | |||
10089 | return; | 10193 | return; |
10090 | 10194 | ||
10091 | cpu = task_cpu(tsk); | 10195 | cpu = task_cpu(tsk); |
10196 | |||
10197 | rcu_read_lock(); | ||
10198 | |||
10092 | ca = task_ca(tsk); | 10199 | ca = task_ca(tsk); |
10093 | 10200 | ||
10094 | for (; ca; ca = ca->parent) { | 10201 | for (; ca; ca = ca->parent) { |
10095 | u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu); | 10202 | u64 *cpuusage = per_cpu_ptr(ca->cpuusage, cpu); |
10096 | *cpuusage += cputime; | 10203 | *cpuusage += cputime; |
10097 | } | 10204 | } |
10205 | |||
10206 | rcu_read_unlock(); | ||
10207 | } | ||
10208 | |||
10209 | /* | ||
10210 | * Charge the system/user time to the task's accounting group. | ||
10211 | */ | ||
10212 | static void cpuacct_update_stats(struct task_struct *tsk, | ||
10213 | enum cpuacct_stat_index idx, cputime_t val) | ||
10214 | { | ||
10215 | struct cpuacct *ca; | ||
10216 | |||
10217 | if (unlikely(!cpuacct_subsys.active)) | ||
10218 | return; | ||
10219 | |||
10220 | rcu_read_lock(); | ||
10221 | ca = task_ca(tsk); | ||
10222 | |||
10223 | do { | ||
10224 | percpu_counter_add(&ca->cpustat[idx], val); | ||
10225 | ca = ca->parent; | ||
10226 | } while (ca); | ||
10227 | rcu_read_unlock(); | ||
10098 | } | 10228 | } |
10099 | 10229 | ||
10100 | struct cgroup_subsys cpuacct_subsys = { | 10230 | struct cgroup_subsys cpuacct_subsys = { |
diff --git a/kernel/sched_cpupri.c b/kernel/sched_cpupri.c index 1e00bfacf9b8..cdd3c89574cd 100644 --- a/kernel/sched_cpupri.c +++ b/kernel/sched_cpupri.c | |||
@@ -55,7 +55,7 @@ static int convert_prio(int prio) | |||
55 | * cpupri_find - find the best (lowest-pri) CPU in the system | 55 | * cpupri_find - find the best (lowest-pri) CPU in the system |
56 | * @cp: The cpupri context | 56 | * @cp: The cpupri context |
57 | * @p: The task | 57 | * @p: The task |
58 | * @lowest_mask: A mask to fill in with selected CPUs | 58 | * @lowest_mask: A mask to fill in with selected CPUs (or NULL) |
59 | * | 59 | * |
60 | * Note: This function returns the recommended CPUs as calculated during the | 60 | * Note: This function returns the recommended CPUs as calculated during the |
61 | * current invokation. By the time the call returns, the CPUs may have in | 61 | * current invokation. By the time the call returns, the CPUs may have in |
@@ -81,7 +81,8 @@ 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 | cpumask_and(lowest_mask, &p->cpus_allowed, vec->mask); | 84 | if (lowest_mask) |
85 | cpumask_and(lowest_mask, &p->cpus_allowed, vec->mask); | ||
85 | return 1; | 86 | return 1; |
86 | } | 87 | } |
87 | 88 | ||
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c index 299d012b4394..f2c66f8f9712 100644 --- a/kernel/sched_rt.c +++ b/kernel/sched_rt.c | |||
@@ -948,20 +948,15 @@ static int select_task_rq_rt(struct task_struct *p, int sync) | |||
948 | 948 | ||
949 | static void check_preempt_equal_prio(struct rq *rq, struct task_struct *p) | 949 | static void check_preempt_equal_prio(struct rq *rq, struct task_struct *p) |
950 | { | 950 | { |
951 | cpumask_var_t mask; | ||
952 | |||
953 | if (rq->curr->rt.nr_cpus_allowed == 1) | 951 | if (rq->curr->rt.nr_cpus_allowed == 1) |
954 | return; | 952 | return; |
955 | 953 | ||
956 | if (!alloc_cpumask_var(&mask, GFP_ATOMIC)) | ||
957 | return; | ||
958 | |||
959 | if (p->rt.nr_cpus_allowed != 1 | 954 | if (p->rt.nr_cpus_allowed != 1 |
960 | && cpupri_find(&rq->rd->cpupri, p, mask)) | 955 | && cpupri_find(&rq->rd->cpupri, p, NULL)) |
961 | goto free; | 956 | return; |
962 | 957 | ||
963 | if (!cpupri_find(&rq->rd->cpupri, rq->curr, mask)) | 958 | if (!cpupri_find(&rq->rd->cpupri, rq->curr, NULL)) |
964 | goto free; | 959 | return; |
965 | 960 | ||
966 | /* | 961 | /* |
967 | * There appears to be other cpus that can accept | 962 | * There appears to be other cpus that can accept |
@@ -970,8 +965,6 @@ static void check_preempt_equal_prio(struct rq *rq, struct task_struct *p) | |||
970 | */ | 965 | */ |
971 | requeue_task_rt(rq, p, 1); | 966 | requeue_task_rt(rq, p, 1); |
972 | resched_task(rq->curr); | 967 | resched_task(rq->curr); |
973 | free: | ||
974 | free_cpumask_var(mask); | ||
975 | } | 968 | } |
976 | 969 | ||
977 | #endif /* CONFIG_SMP */ | 970 | #endif /* CONFIG_SMP */ |
diff --git a/kernel/timer.c b/kernel/timer.c index b4555568b4e4..cffffad01c31 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -531,10 +531,13 @@ static void __init_timer(struct timer_list *timer, | |||
531 | } | 531 | } |
532 | 532 | ||
533 | /** | 533 | /** |
534 | * init_timer - initialize a timer. | 534 | * init_timer_key - initialize a timer |
535 | * @timer: the timer to be initialized | 535 | * @timer: the timer to be initialized |
536 | * @name: name of the timer | ||
537 | * @key: lockdep class key of the fake lock used for tracking timer | ||
538 | * sync lock dependencies | ||
536 | * | 539 | * |
537 | * init_timer() must be done to a timer prior calling *any* of the | 540 | * init_timer_key() must be done to a timer prior calling *any* of the |
538 | * other timer functions. | 541 | * other timer functions. |
539 | */ | 542 | */ |
540 | void init_timer_key(struct timer_list *timer, | 543 | void init_timer_key(struct timer_list *timer, |
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index b32ff446c3fb..921ef5d1f0ba 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
@@ -1377,12 +1377,12 @@ static int blk_trace_str2mask(const char *str) | |||
1377 | { | 1377 | { |
1378 | int i; | 1378 | int i; |
1379 | int mask = 0; | 1379 | int mask = 0; |
1380 | char *s, *token; | 1380 | char *buf, *s, *token; |
1381 | 1381 | ||
1382 | s = kstrdup(str, GFP_KERNEL); | 1382 | buf = kstrdup(str, GFP_KERNEL); |
1383 | if (s == NULL) | 1383 | if (buf == NULL) |
1384 | return -ENOMEM; | 1384 | return -ENOMEM; |
1385 | s = strstrip(s); | 1385 | s = strstrip(buf); |
1386 | 1386 | ||
1387 | while (1) { | 1387 | while (1) { |
1388 | token = strsep(&s, ","); | 1388 | token = strsep(&s, ","); |
@@ -1403,7 +1403,7 @@ static int blk_trace_str2mask(const char *str) | |||
1403 | break; | 1403 | break; |
1404 | } | 1404 | } |
1405 | } | 1405 | } |
1406 | kfree(s); | 1406 | kfree(buf); |
1407 | 1407 | ||
1408 | return mask; | 1408 | return mask; |
1409 | } | 1409 | } |
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index a2a3af29c943..5e579645ac86 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c | |||
@@ -1,5 +1,5 @@ | |||
1 | #include <trace/syscall.h> | ||
1 | #include <linux/kernel.h> | 2 | #include <linux/kernel.h> |
2 | #include <linux/ftrace.h> | ||
3 | #include <asm/syscall.h> | 3 | #include <asm/syscall.h> |
4 | 4 | ||
5 | #include "trace_output.h" | 5 | #include "trace_output.h" |
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index b6b966ce1451..f71fb2a08950 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -966,20 +966,20 @@ undo: | |||
966 | } | 966 | } |
967 | 967 | ||
968 | #ifdef CONFIG_SMP | 968 | #ifdef CONFIG_SMP |
969 | static struct workqueue_struct *work_on_cpu_wq __read_mostly; | ||
970 | 969 | ||
971 | struct work_for_cpu { | 970 | struct work_for_cpu { |
972 | struct work_struct work; | 971 | struct completion completion; |
973 | long (*fn)(void *); | 972 | long (*fn)(void *); |
974 | void *arg; | 973 | void *arg; |
975 | long ret; | 974 | long ret; |
976 | }; | 975 | }; |
977 | 976 | ||
978 | static void do_work_for_cpu(struct work_struct *w) | 977 | static int do_work_for_cpu(void *_wfc) |
979 | { | 978 | { |
980 | struct work_for_cpu *wfc = container_of(w, struct work_for_cpu, work); | 979 | struct work_for_cpu *wfc = _wfc; |
981 | |||
982 | wfc->ret = wfc->fn(wfc->arg); | 980 | wfc->ret = wfc->fn(wfc->arg); |
981 | complete(&wfc->completion); | ||
982 | return 0; | ||
983 | } | 983 | } |
984 | 984 | ||
985 | /** | 985 | /** |
@@ -990,17 +990,23 @@ static void do_work_for_cpu(struct work_struct *w) | |||
990 | * | 990 | * |
991 | * This will return the value @fn returns. | 991 | * This will return the value @fn returns. |
992 | * It is up to the caller to ensure that the cpu doesn't go offline. | 992 | * It is up to the caller to ensure that the cpu doesn't go offline. |
993 | * The caller must not hold any locks which would prevent @fn from completing. | ||
993 | */ | 994 | */ |
994 | long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg) | 995 | long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg) |
995 | { | 996 | { |
996 | struct work_for_cpu wfc; | 997 | struct task_struct *sub_thread; |
997 | 998 | struct work_for_cpu wfc = { | |
998 | INIT_WORK(&wfc.work, do_work_for_cpu); | 999 | .completion = COMPLETION_INITIALIZER_ONSTACK(wfc.completion), |
999 | wfc.fn = fn; | 1000 | .fn = fn, |
1000 | wfc.arg = arg; | 1001 | .arg = arg, |
1001 | queue_work_on(cpu, work_on_cpu_wq, &wfc.work); | 1002 | }; |
1002 | flush_work(&wfc.work); | 1003 | |
1003 | 1004 | sub_thread = kthread_create(do_work_for_cpu, &wfc, "work_for_cpu"); | |
1005 | if (IS_ERR(sub_thread)) | ||
1006 | return PTR_ERR(sub_thread); | ||
1007 | kthread_bind(sub_thread, cpu); | ||
1008 | wake_up_process(sub_thread); | ||
1009 | wait_for_completion(&wfc.completion); | ||
1004 | return wfc.ret; | 1010 | return wfc.ret; |
1005 | } | 1011 | } |
1006 | EXPORT_SYMBOL_GPL(work_on_cpu); | 1012 | EXPORT_SYMBOL_GPL(work_on_cpu); |
@@ -1016,8 +1022,4 @@ void __init init_workqueues(void) | |||
1016 | hotcpu_notifier(workqueue_cpu_callback, 0); | 1022 | hotcpu_notifier(workqueue_cpu_callback, 0); |
1017 | keventd_wq = create_workqueue("events"); | 1023 | keventd_wq = create_workqueue("events"); |
1018 | BUG_ON(!keventd_wq); | 1024 | BUG_ON(!keventd_wq); |
1019 | #ifdef CONFIG_SMP | ||
1020 | work_on_cpu_wq = create_workqueue("work_on_cpu"); | ||
1021 | BUG_ON(!work_on_cpu_wq); | ||
1022 | #endif | ||
1023 | } | 1025 | } |