Merge "Enabling kvmfornfv daily job test cases"
[kvmfornfv.git] / kernel / kernel / exit.c
index a0cf72b..e199407 100644 (file)
@@ -436,7 +436,7 @@ static void exit_mm(struct task_struct *tsk)
        mm_update_next_owner(mm);
        mmput(mm);
        if (test_thread_flag(TIF_MEMDIE))
-               unmark_oom_victim();
+               exit_oom_victim();
 }
 
 static struct task_struct *find_alive_thread(struct task_struct *p)
@@ -706,15 +706,17 @@ void do_exit(long code)
        smp_mb();
        raw_spin_unlock_wait(&tsk->pi_lock);
 
-       if (unlikely(in_atomic()))
+       if (unlikely(in_atomic())) {
                pr_info("note: %s[%d] exited with preempt_count %d\n",
                        current->comm, task_pid_nr(current),
                        preempt_count());
+               preempt_count_set(PREEMPT_ENABLED);
+       }
 
-       acct_update_integrals(tsk);
        /* sync mm's RSS info before statistics gathering */
        if (tsk->mm)
                sync_mm_rss(tsk->mm);
+       acct_update_integrals(tsk);
        group_dead = atomic_dec_and_test(&tsk->signal->live);
        if (group_dead) {
                hrtimer_cancel(&tsk->signal->real_timer);
@@ -761,7 +763,9 @@ void do_exit(long code)
         */
        flush_ptrace_hw_breakpoint(tsk);
 
+       TASKS_RCU(preempt_disable());
        TASKS_RCU(tasks_rcu_i = __srcu_read_lock(&tasks_rcu_exit_srcu));
+       TASKS_RCU(preempt_enable());
        exit_notify(tsk, group_dead);
        proc_exit_connector(tsk);
 #ifdef CONFIG_NUMA
@@ -914,17 +918,28 @@ static int eligible_pid(struct wait_opts *wo, struct task_struct *p)
                task_pid_type(p, wo->wo_type) == wo->wo_pid;
 }
 
-static int eligible_child(struct wait_opts *wo, struct task_struct *p)
+static int
+eligible_child(struct wait_opts *wo, bool ptrace, struct task_struct *p)
 {
        if (!eligible_pid(wo, p))
                return 0;
-       /* Wait for all children (clone and not) if __WALL is set;
-        * otherwise, wait for clone children *only* if __WCLONE is
-        * set; otherwise, wait for non-clone children *only*.  (Note:
-        * A "clone" child here is one that reports to its parent
-        * using a signal other than SIGCHLD.) */
-       if (((p->exit_signal != SIGCHLD) ^ !!(wo->wo_flags & __WCLONE))
-           && !(wo->wo_flags & __WALL))
+
+       /*
+        * Wait for all children (clone and not) if __WALL is set or
+        * if it is traced by us.
+        */
+       if (ptrace || (wo->wo_flags & __WALL))
+               return 1;
+
+       /*
+        * Otherwise, wait for clone children *only* if __WCLONE is set;
+        * otherwise, wait for non-clone children *only*.
+        *
+        * Note: a "clone" child here is one that reports to its parent
+        * using a signal other than SIGCHLD, or a non-leader thread which
+        * we can only see if it is traced by us.
+        */
+       if ((p->exit_signal != SIGCHLD) ^ !!(wo->wo_flags & __WCLONE))
                return 0;
 
        return 1;
@@ -1297,7 +1312,7 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
        if (unlikely(exit_state == EXIT_DEAD))
                return 0;
 
-       ret = eligible_child(wo, p);
+       ret = eligible_child(wo, ptrace, p);
        if (!ret)
                return ret;
 
@@ -1471,7 +1486,7 @@ static long do_wait(struct wait_opts *wo)
        add_wait_queue(&current->signal->wait_chldexit, &wo->child_wait);
 repeat:
        /*
-        * If there is nothing that can match our critiera just get out.
+        * If there is nothing that can match our criteria, just get out.
         * We will clear ->notask_error to zero if we see any child that
         * might later match our criteria, even if we are not able to reap
         * it yet.