From f6908f21a84035f0fb89b897110824e9554e302f Mon Sep 17 00:00:00 2001 From: Tomoki Shirasawa Date: Wed, 13 Jul 2016 14:06:32 +0900 Subject: [PATCH] do_kill: wake PS_INTERRUPTIBLE process when send SIGKILL sched_wakeup_thread: don't change process status if process status is PS_EXITED --- arch/x86/kernel/syscall.c | 2 +- kernel/process.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/syscall.c b/arch/x86/kernel/syscall.c index 782e282b..84797b00 100644 --- a/arch/x86/kernel/syscall.c +++ b/arch/x86/kernel/syscall.c @@ -1302,7 +1302,7 @@ done: if (status != PS_RUNNING) { if(sig == SIGKILL){ /* Wake up the target only when stopped by ptrace-reporting */ - sched_wakeup_thread(tthread, PS_TRACED | PS_STOPPED); + sched_wakeup_thread(tthread, PS_TRACED | PS_STOPPED | PS_INTERRUPTIBLE); } else if(sig == SIGCONT || ptracecont == 1){ /* Wake up the target only when stopped by SIGSTOP */ diff --git a/kernel/process.c b/kernel/process.c index a7c55683..1f63f209 100644 --- a/kernel/process.c +++ b/kernel/process.c @@ -2716,9 +2716,11 @@ sched_wakeup_thread(struct thread *thread, int valid_states) int spin_slept = 0; unsigned long irqstate; struct cpu_local_var *v = get_cpu_local_var(thread->cpu_id); + struct process *proc = thread->proc; + struct mcs_rwlock_node updatelock; dkprintf("sched_wakeup_process,proc->pid=%d,valid_states=%08x,proc->status=%08x,proc->cpu_id=%d,my cpu_id=%d\n", - thread->proc->pid, valid_states, thread->status, thread->cpu_id, ihk_mc_get_processor_id()); + proc->pid, valid_states, thread->status, thread->cpu_id, ihk_mc_get_processor_id()); irqstate = ihk_mc_spinlock_lock(&(thread->spin_sleep_lock)); if (thread->spin_sleep > 0) { @@ -2738,7 +2740,10 @@ sched_wakeup_thread(struct thread *thread, int valid_states) irqstate = ihk_mc_spinlock_lock(&(v->runq_lock)); if (thread->status & valid_states) { - xchg4((int *)(&thread->proc->status), PS_RUNNING); + mcs_rwlock_writer_lock_noirq(&proc->update_lock, &updatelock); + if(proc->status != PS_EXITED) + proc->status = PS_RUNNING; + mcs_rwlock_writer_unlock_noirq(&proc->update_lock, &updatelock); xchg4((int *)(&thread->status), PS_RUNNING); status = 0; }