aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2012-03-12 15:44:07 -0400
committerIngo Molnar <mingo@elte.hu>2012-03-12 15:44:11 -0400
commit35239e23c66f1614c76739b62a299c3c92d6eb68 (patch)
tree7b1e068df888ec9a00b43c1dd7517a6490da6a94 /kernel
parent3f33ab1c0c741bfab2138c14ba1918a7905a1e8b (diff)
parent87e24f4b67e68d9fd8df16e0bf9c66d1ad2a2533 (diff)
Merge branch 'perf/urgent' into perf/core
Merge reason: We are going to queue up a dependent patch. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/fork.c60
-rw-r--r--kernel/hung_task.c11
-rw-r--r--kernel/irq/manage.c44
-rw-r--r--kernel/kprobes.c12
-rw-r--r--kernel/printk.c6
5 files changed, 97 insertions, 36 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index e2cd3e2a5ae8..26a7a6707fa7 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -668,6 +668,38 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
668 return mm; 668 return mm;
669} 669}
670 670
671static void complete_vfork_done(struct task_struct *tsk)
672{
673 struct completion *vfork;
674
675 task_lock(tsk);
676 vfork = tsk->vfork_done;
677 if (likely(vfork)) {
678 tsk->vfork_done = NULL;
679 complete(vfork);
680 }
681 task_unlock(tsk);
682}
683
684static int wait_for_vfork_done(struct task_struct *child,
685 struct completion *vfork)
686{
687 int killed;
688
689 freezer_do_not_count();
690 killed = wait_for_completion_killable(vfork);
691 freezer_count();
692
693 if (killed) {
694 task_lock(child);
695 child->vfork_done = NULL;
696 task_unlock(child);
697 }
698
699 put_task_struct(child);
700 return killed;
701}
702
671/* Please note the differences between mmput and mm_release. 703/* Please note the differences between mmput and mm_release.
672 * mmput is called whenever we stop holding onto a mm_struct, 704 * mmput is called whenever we stop holding onto a mm_struct,
673 * error success whatever. 705 * error success whatever.
@@ -683,8 +715,6 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
683 */ 715 */
684void mm_release(struct task_struct *tsk, struct mm_struct *mm) 716void mm_release(struct task_struct *tsk, struct mm_struct *mm)
685{ 717{
686 struct completion *vfork_done = tsk->vfork_done;
687
688 /* Get rid of any futexes when releasing the mm */ 718 /* Get rid of any futexes when releasing the mm */
689#ifdef CONFIG_FUTEX 719#ifdef CONFIG_FUTEX
690 if (unlikely(tsk->robust_list)) { 720 if (unlikely(tsk->robust_list)) {
@@ -704,17 +734,15 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
704 /* Get rid of any cached register state */ 734 /* Get rid of any cached register state */
705 deactivate_mm(tsk, mm); 735 deactivate_mm(tsk, mm);
706 736
707 /* notify parent sleeping on vfork() */ 737 if (tsk->vfork_done)
708 if (vfork_done) { 738 complete_vfork_done(tsk);
709 tsk->vfork_done = NULL;
710 complete(vfork_done);
711 }
712 739
713 /* 740 /*
714 * If we're exiting normally, clear a user-space tid field if 741 * If we're exiting normally, clear a user-space tid field if
715 * requested. We leave this alone when dying by signal, to leave 742 * requested. We leave this alone when dying by signal, to leave
716 * the value intact in a core dump, and to save the unnecessary 743 * the value intact in a core dump, and to save the unnecessary
717 * trouble otherwise. Userland only wants this done for a sys_exit. 744 * trouble, say, a killed vfork parent shouldn't touch this mm.
745 * Userland only wants this done for a sys_exit.
718 */ 746 */
719 if (tsk->clear_child_tid) { 747 if (tsk->clear_child_tid) {
720 if (!(tsk->flags & PF_SIGNALED) && 748 if (!(tsk->flags & PF_SIGNALED) &&
@@ -1018,7 +1046,6 @@ static void copy_flags(unsigned long clone_flags, struct task_struct *p)
1018 1046
1019 new_flags &= ~(PF_SUPERPRIV | PF_WQ_WORKER); 1047 new_flags &= ~(PF_SUPERPRIV | PF_WQ_WORKER);
1020 new_flags |= PF_FORKNOEXEC; 1048 new_flags |= PF_FORKNOEXEC;
1021 new_flags |= PF_STARTING;
1022 p->flags = new_flags; 1049 p->flags = new_flags;
1023} 1050}
1024 1051
@@ -1548,16 +1575,9 @@ long do_fork(unsigned long clone_flags,
1548 if (clone_flags & CLONE_VFORK) { 1575 if (clone_flags & CLONE_VFORK) {
1549 p->vfork_done = &vfork; 1576 p->vfork_done = &vfork;
1550 init_completion(&vfork); 1577 init_completion(&vfork);
1578 get_task_struct(p);
1551 } 1579 }
1552 1580
1553 /*
1554 * We set PF_STARTING at creation in case tracing wants to
1555 * use this to distinguish a fully live task from one that
1556 * hasn't finished SIGSTOP raising yet. Now we clear it
1557 * and set the child going.
1558 */
1559 p->flags &= ~PF_STARTING;
1560
1561 wake_up_new_task(p); 1581 wake_up_new_task(p);
1562 1582
1563 /* forking complete and child started to run, tell ptracer */ 1583 /* forking complete and child started to run, tell ptracer */
@@ -1565,10 +1585,8 @@ long do_fork(unsigned long clone_flags,
1565 ptrace_event(trace, nr); 1585 ptrace_event(trace, nr);
1566 1586
1567 if (clone_flags & CLONE_VFORK) { 1587 if (clone_flags & CLONE_VFORK) {
1568 freezer_do_not_count(); 1588 if (!wait_for_vfork_done(p, &vfork))
1569 wait_for_completion(&vfork); 1589 ptrace_event(PTRACE_EVENT_VFORK_DONE, nr);
1570 freezer_count();
1571 ptrace_event(PTRACE_EVENT_VFORK_DONE, nr);
1572 } 1590 }
1573 } else { 1591 } else {
1574 nr = PTR_ERR(p); 1592 nr = PTR_ERR(p);
diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index 2e48ec0c2e91..c21449f85a2a 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -119,15 +119,20 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
119 * For preemptible RCU it is sufficient to call rcu_read_unlock in order 119 * For preemptible RCU it is sufficient to call rcu_read_unlock in order
120 * to exit the grace period. For classic RCU, a reschedule is required. 120 * to exit the grace period. For classic RCU, a reschedule is required.
121 */ 121 */
122static void rcu_lock_break(struct task_struct *g, struct task_struct *t) 122static bool rcu_lock_break(struct task_struct *g, struct task_struct *t)
123{ 123{
124 bool can_cont;
125
124 get_task_struct(g); 126 get_task_struct(g);
125 get_task_struct(t); 127 get_task_struct(t);
126 rcu_read_unlock(); 128 rcu_read_unlock();
127 cond_resched(); 129 cond_resched();
128 rcu_read_lock(); 130 rcu_read_lock();
131 can_cont = pid_alive(g) && pid_alive(t);
129 put_task_struct(t); 132 put_task_struct(t);
130 put_task_struct(g); 133 put_task_struct(g);
134
135 return can_cont;
131} 136}
132 137
133/* 138/*
@@ -154,9 +159,7 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
154 goto unlock; 159 goto unlock;
155 if (!--batch_count) { 160 if (!--batch_count) {
156 batch_count = HUNG_TASK_BATCHING; 161 batch_count = HUNG_TASK_BATCHING;
157 rcu_lock_break(g, t); 162 if (!rcu_lock_break(g, t))
158 /* Exit if t or g was unhashed during refresh. */
159 if (t->state == TASK_DEAD || g->state == TASK_DEAD)
160 goto unlock; 163 goto unlock;
161 } 164 }
162 /* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */ 165 /* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 32313c084442..0f0d4704ddd8 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -985,6 +985,11 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
985 985
986 /* add new interrupt at end of irq queue */ 986 /* add new interrupt at end of irq queue */
987 do { 987 do {
988 /*
989 * Or all existing action->thread_mask bits,
990 * so we can find the next zero bit for this
991 * new action.
992 */
988 thread_mask |= old->thread_mask; 993 thread_mask |= old->thread_mask;
989 old_ptr = &old->next; 994 old_ptr = &old->next;
990 old = *old_ptr; 995 old = *old_ptr;
@@ -993,14 +998,41 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
993 } 998 }
994 999
995 /* 1000 /*
996 * Setup the thread mask for this irqaction. Unlikely to have 1001 * Setup the thread mask for this irqaction for ONESHOT. For
997 * 32 resp 64 irqs sharing one line, but who knows. 1002 * !ONESHOT irqs the thread mask is 0 so we can avoid a
1003 * conditional in irq_wake_thread().
998 */ 1004 */
999 if (new->flags & IRQF_ONESHOT && thread_mask == ~0UL) { 1005 if (new->flags & IRQF_ONESHOT) {
1000 ret = -EBUSY; 1006 /*
1001 goto out_mask; 1007 * Unlikely to have 32 resp 64 irqs sharing one line,
1008 * but who knows.
1009 */
1010 if (thread_mask == ~0UL) {
1011 ret = -EBUSY;
1012 goto out_mask;
1013 }
1014 /*
1015 * The thread_mask for the action is or'ed to
1016 * desc->thread_active to indicate that the
1017 * IRQF_ONESHOT thread handler has been woken, but not
1018 * yet finished. The bit is cleared when a thread
1019 * completes. When all threads of a shared interrupt
1020 * line have completed desc->threads_active becomes
1021 * zero and the interrupt line is unmasked. See
1022 * handle.c:irq_wake_thread() for further information.
1023 *
1024 * If no thread is woken by primary (hard irq context)
1025 * interrupt handlers, then desc->threads_active is
1026 * also checked for zero to unmask the irq line in the
1027 * affected hard irq flow handlers
1028 * (handle_[fasteoi|level]_irq).
1029 *
1030 * The new action gets the first zero bit of
1031 * thread_mask assigned. See the loop above which or's
1032 * all existing action->thread_mask bits.
1033 */
1034 new->thread_mask = 1 << ffz(thread_mask);
1002 } 1035 }
1003 new->thread_mask = 1 << ffz(thread_mask);
1004 1036
1005 if (!shared) { 1037 if (!shared) {
1006 init_waitqueue_head(&desc->wait_for_threads); 1038 init_waitqueue_head(&desc->wait_for_threads);
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 9788c0ec6f43..c62b8546cc90 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1334,8 +1334,10 @@ int __kprobes register_kprobe(struct kprobe *p)
1334 if (!kernel_text_address((unsigned long) p->addr) || 1334 if (!kernel_text_address((unsigned long) p->addr) ||
1335 in_kprobes_functions((unsigned long) p->addr) || 1335 in_kprobes_functions((unsigned long) p->addr) ||
1336 ftrace_text_reserved(p->addr, p->addr) || 1336 ftrace_text_reserved(p->addr, p->addr) ||
1337 jump_label_text_reserved(p->addr, p->addr)) 1337 jump_label_text_reserved(p->addr, p->addr)) {
1338 goto fail_with_jump_label; 1338 ret = -EINVAL;
1339 goto cannot_probe;
1340 }
1339 1341
1340 /* User can pass only KPROBE_FLAG_DISABLED to register_kprobe */ 1342 /* User can pass only KPROBE_FLAG_DISABLED to register_kprobe */
1341 p->flags &= KPROBE_FLAG_DISABLED; 1343 p->flags &= KPROBE_FLAG_DISABLED;
@@ -1352,7 +1354,7 @@ int __kprobes register_kprobe(struct kprobe *p)
1352 * its code to prohibit unexpected unloading. 1354 * its code to prohibit unexpected unloading.
1353 */ 1355 */
1354 if (unlikely(!try_module_get(probed_mod))) 1356 if (unlikely(!try_module_get(probed_mod)))
1355 goto fail_with_jump_label; 1357 goto cannot_probe;
1356 1358
1357 /* 1359 /*
1358 * If the module freed .init.text, we couldn't insert 1360 * If the module freed .init.text, we couldn't insert
@@ -1361,7 +1363,7 @@ int __kprobes register_kprobe(struct kprobe *p)
1361 if (within_module_init((unsigned long)p->addr, probed_mod) && 1363 if (within_module_init((unsigned long)p->addr, probed_mod) &&
1362 probed_mod->state != MODULE_STATE_COMING) { 1364 probed_mod->state != MODULE_STATE_COMING) {
1363 module_put(probed_mod); 1365 module_put(probed_mod);
1364 goto fail_with_jump_label; 1366 goto cannot_probe;
1365 } 1367 }
1366 /* ret will be updated by following code */ 1368 /* ret will be updated by following code */
1367 } 1369 }
@@ -1409,7 +1411,7 @@ out:
1409 1411
1410 return ret; 1412 return ret;
1411 1413
1412fail_with_jump_label: 1414cannot_probe:
1413 preempt_enable(); 1415 preempt_enable();
1414 jump_label_unlock(); 1416 jump_label_unlock();
1415 return ret; 1417 return ret;
diff --git a/kernel/printk.c b/kernel/printk.c
index cb8a6bd697c6..0b3ea2cbd5fb 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -707,6 +707,9 @@ static bool printk_time = 0;
707#endif 707#endif
708module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR); 708module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
709 709
710static bool always_kmsg_dump;
711module_param_named(always_kmsg_dump, always_kmsg_dump, bool, S_IRUGO | S_IWUSR);
712
710/* Check if we have any console registered that can be called early in boot. */ 713/* Check if we have any console registered that can be called early in boot. */
711static int have_callable_console(void) 714static int have_callable_console(void)
712{ 715{
@@ -1737,6 +1740,9 @@ void kmsg_dump(enum kmsg_dump_reason reason)
1737 unsigned long l1, l2; 1740 unsigned long l1, l2;
1738 unsigned long flags; 1741 unsigned long flags;
1739 1742
1743 if ((reason > KMSG_DUMP_OOPS) && !always_kmsg_dump)
1744 return;
1745
1740 /* Theoretically, the log could move on after we do this, but 1746 /* Theoretically, the log could move on after we do this, but
1741 there's not a lot we can do about that. The new messages 1747 there's not a lot we can do about that. The new messages
1742 will overwrite the start of what we dump. */ 1748 will overwrite the start of what we dump. */