rename back status field

This commit is contained in:
Tomoki Shirasawa
2015-10-22 20:26:50 +09:00
parent 4e4f1208f7
commit 343bfbd30a
10 changed files with 77 additions and 77 deletions

View File

@ -1332,7 +1332,7 @@ ihk_mc_user_context_t *lookup_user_context(struct thread *thread)
{
ihk_mc_user_context_t *uctx = thread->uctx;
if ((!(thread->tstatus & (PS_INTERRUPTIBLE | PS_UNINTERRUPTIBLE
if ((!(thread->status & (PS_INTERRUPTIBLE | PS_UNINTERRUPTIBLE
| PS_STOPPED | PS_TRACED))
&& (thread != cpu_local_var(current)))
|| !uctx->is_gpr_valid) {

View File

@ -176,7 +176,7 @@ void fill_prpsinfo(struct note *head, struct thread *thread, void *regs)
memcpy(name, "CORE", sizeof("CORE"));
prpsinfo = (struct elf_prpsinfo64 *)(name + align32(sizeof("CORE")));
prpsinfo->pr_state = thread->tstatus;
prpsinfo->pr_state = thread->status;
prpsinfo->pr_pid = thread->proc->pid;
/*

View File

@ -49,7 +49,7 @@ uintptr_t debug_constants[] = {
offsetof(struct thread, ctx),
offsetof(struct thread, sched_list),
offsetof(struct thread, proc),
offsetof(struct thread, tstatus),
offsetof(struct thread, status),
offsetof(struct process, pid),
offsetof(struct thread, tid),
-1,
@ -445,8 +445,8 @@ void ptrace_report_signal(struct thread *thread, int sig)
}
proc->exit_status = sig;
/* Transition thread state */
proc->pstatus = PS_TRACED;
thread->tstatus = PS_TRACED;
proc->status = PS_TRACED;
thread->status = PS_TRACED;
proc->ptrace &= ~PT_TRACE_SYSCALL_MASK;
if (sig == SIGSTOP || sig == SIGTSTP ||
sig == SIGTTIN || sig == SIGTTOU) {
@ -636,8 +636,8 @@ do_signal(unsigned long rc, void *regs0, struct thread *thread, struct sig_pendi
/* Reap and set new signal_flags */
proc->signal_flags = SIGNAL_STOP_STOPPED;
proc->pstatus = PS_STOPPED;
thread->tstatus = PS_STOPPED;
proc->status = PS_STOPPED;
thread->status = PS_STOPPED;
mcs_rwlock_writer_unlock(&proc->update_lock, &lock);
/* Wake up the parent who tried wait4 and sleeping */
@ -658,8 +658,8 @@ do_signal(unsigned long rc, void *regs0, struct thread *thread, struct sig_pendi
/* Update thread state in fork tree */
mcs_rwlock_writer_lock(&proc->update_lock, &lock);
proc->exit_status = SIGTRAP;
proc->pstatus = PS_TRACED;
thread->tstatus = PS_TRACED;
proc->status = PS_TRACED;
thread->status = PS_TRACED;
mcs_rwlock_writer_unlock(&proc->update_lock, &lock);
/* Wake up the parent who tried wait4 and sleeping */
@ -774,9 +774,9 @@ check_signal(unsigned long rc, void *regs0, int num)
list_for_each_entry(t, &(cpu_local_var(runq)), sched_list){
if(t == &cpu_local_var(idle))
continue;
if(t->tstatus == PS_INTERRUPTIBLE &&
if(t->status == PS_INTERRUPTIBLE &&
hassigpending(t)){
t->tstatus = PS_RUNNING;
t->status = PS_RUNNING;
break;
}
}
@ -900,13 +900,13 @@ do_kill(struct thread *thread, int pid, int tid, int sig, siginfo_t *info,
}
mcs_rwlock_reader_lock_noirq(&tproc->update_lock, &updatelock);
if(tproc->pstatus == PS_EXITED || tproc->pstatus == PS_ZOMBIE){
if(tproc->status == PS_EXITED || tproc->status == PS_ZOMBIE){
goto done;
}
mcs_rwlock_reader_lock_noirq(&tproc->threads_lock, &lock);
list_for_each_entry(t, &tproc->threads_list, siblings_list){
if(t->tid == pid || tthread == NULL){
if(t->tstatus == PS_EXITED){
if(t->status == PS_EXITED){
continue;
}
if(!(mask & t->sigmask.__val[0])){
@ -922,7 +922,7 @@ do_kill(struct thread *thread, int pid, int tid, int sig, siginfo_t *info,
if(tthread == NULL){
tthread = tthread0;
}
if(tthread && tthread->tstatus != PS_EXITED){
if(tthread && tthread->status != PS_EXITED){
savelock = &tthread->sigcommon->lock;
head = &tthread->sigcommon->sigpending;
hold_thread(tthread);
@ -959,9 +959,9 @@ done:
savelock = &tthread->sigpendinglock;
head = &tthread->sigpending;
if(sig == SIGKILL ||
(tproc->pstatus != PS_EXITED &&
tproc->pstatus != PS_ZOMBIE &&
tthread->tstatus != PS_EXITED)){
(tproc->status != PS_EXITED &&
tproc->status != PS_ZOMBIE &&
tthread->status != PS_EXITED)){
hold_thread(tthread);
}
else{
@ -985,7 +985,7 @@ done:
return -EPERM;
}
if(sig == 0 || tthread == NULL || tthread->tstatus == PS_EXITED){
if(sig == 0 || tthread == NULL || tthread->status == PS_EXITED){
if(tthread)
release_thread(tthread);
cpu_restore_interrupt(irqstate);
@ -1039,7 +1039,7 @@ done:
if (doint && !(mask & tthread->sigmask.__val[0])) {
int cpuid = tthread->cpu_id;
int pid = tproc->pid;
int status = tthread->tstatus;
int status = tthread->status;
if (thread != tthread) {
dkprintf("do_kill,ipi,pid=%d,cpu_id=%d\n",

View File

@ -658,7 +658,7 @@ static uint64_t futex_wait_queue_me(struct futex_hash_bucket *hb, struct futex_q
* queue_me() calls spin_unlock() upon completion, both serializing
* access to the hash list and forcing another memory barrier.
*/
xchg4(&(cpu_local_var(current)->tstatus), PS_INTERRUPTIBLE);
xchg4(&(cpu_local_var(current)->status), PS_INTERRUPTIBLE);
queue_me(q, hb);
if (!plist_node_empty(&q->list)) {
@ -674,7 +674,7 @@ static uint64_t futex_wait_queue_me(struct futex_hash_bucket *hb, struct futex_q
}
/* This does not need to be serialized */
cpu_local_var(current)->tstatus = PS_RUNNING;
cpu_local_var(current)->status = PS_RUNNING;
return time_remain;
}

View File

@ -551,8 +551,8 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
proc = thread->proc;
settid(thread, 0, cpuid, -1);
proc->pstatus = PS_RUNNING;
thread->tstatus = PS_RUNNING;
proc->status = PS_RUNNING;
thread->status = PS_RUNNING;
chain_thread(thread);
chain_process(proc);
runq_add_thread(thread, cpuid);

View File

@ -363,7 +363,7 @@ struct process {
ihk_atomic_t refcount;
// process status and exit status
int pstatus; // PS_RUNNING -> PS_EXITED -> PS_ZOMBIE
int status; // PS_RUNNING -> PS_EXITED -> PS_ZOMBIE
// | ^ ^
// | |---+ |
// V | |
@ -455,7 +455,7 @@ struct thread {
// thread info
int cpu_id;
int tid;
int tstatus; // PS_RUNNING -> PS_EXITED
int status; // PS_RUNNING -> PS_EXITED
// | ^ ^
// | | |
// V | |

View File

@ -73,7 +73,7 @@ init_process(struct process *proc, struct process *parent)
/* These will be filled out when changing status */
proc->pid = -1;
proc->exit_status = -1;
proc->pstatus = PS_RUNNING;
proc->status = PS_RUNNING;
if(parent){
proc->parent = parent;
@ -2089,7 +2089,7 @@ out:
void hold_thread(struct thread *thread)
{
if (thread->tstatus == PS_EXITED) {
if (thread->status == PS_EXITED) {
panic("hold_thread: already exited process");
}
@ -2260,7 +2260,7 @@ static void idle(void)
s = ihk_mc_spinlock_lock(&v->runq_lock);
list_for_each_entry(t, &v->runq, sched_list) {
if (t->tstatus == PS_RUNNING) {
if (t->status == PS_RUNNING) {
v->status = CPU_STATUS_RUNNING;
break;
}
@ -2512,7 +2512,7 @@ redo:
--v->runq_len;
/* Round-robin if not exited yet */
if (prev->tstatus != PS_EXITED) {
if (prev->status != PS_EXITED) {
list_add_tail(&prev->sched_list, &(v->runq));
++v->runq_len;
}
@ -2537,7 +2537,7 @@ redo:
} else {
/* Pick a new running process */
list_for_each_entry_safe(thread, tmp, &(v->runq), sched_list) {
if (thread->tstatus == PS_RUNNING) {
if (thread->status == PS_RUNNING) {
next = thread;
break;
}
@ -2609,7 +2609,7 @@ redo:
goto redo;
}
if ((last != NULL) && (last->tstatus == PS_EXITED)) {
if ((last != NULL) && (last->status == PS_EXITED)) {
release_thread(last);
}
}
@ -2654,7 +2654,7 @@ sched_wakeup_thread(struct thread *thread, int valid_states)
struct cpu_local_var *v = get_cpu_local_var(thread->cpu_id);
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->tstatus, thread->cpu_id, ihk_mc_get_processor_id());
thread->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) {
@ -2673,8 +2673,8 @@ sched_wakeup_thread(struct thread *thread, int valid_states)
irqstate = ihk_mc_spinlock_lock(&(v->runq_lock));
if (thread->tstatus & valid_states) {
xchg4((int *)(&thread->tstatus), PS_RUNNING);
if (thread->status & valid_states) {
xchg4((int *)(&thread->status), PS_RUNNING);
status = 0;
}
else {
@ -2868,7 +2868,7 @@ debug_log(unsigned long arg)
__mcs_rwlock_reader_lock(&phash->lock[i], &lock);
list_for_each_entry(p, &phash->list[i], hash_list){
kprintf("pid=%d ppid=%d status=%d\n",
p->pid, p->ppid_parent->pid, p->pstatus);
p->pid, p->ppid_parent->pid, p->status);
}
__mcs_rwlock_reader_unlock(&phash->lock[i], &lock);
}
@ -2879,7 +2879,7 @@ debug_log(unsigned long arg)
list_for_each_entry(t, &thash->list[i], hash_list){
kprintf("cpu=%d pid=%d tid=%d status=%d offload=%d\n",
t->cpu_id, t->proc->pid, t->tid,
t->tstatus, t->in_syscall_offload);
t->status, t->in_syscall_offload);
}
__mcs_rwlock_reader_unlock(&thash->lock[i], &lock);
}
@ -2890,7 +2890,7 @@ debug_log(unsigned long arg)
kprintf("phash[i] is locked\n");
list_for_each_entry(p, &phash->list[i], hash_list){
kprintf("pid=%d ppid=%d status=%d\n",
p->pid, p->ppid_parent->pid, p->pstatus);
p->pid, p->ppid_parent->pid, p->status);
}
}
break;
@ -2901,7 +2901,7 @@ debug_log(unsigned long arg)
list_for_each_entry(t, &thash->list[i], hash_list){
kprintf("cpu=%d pid=%d tid=%d status=%d\n",
t->cpu_id, t->proc->pid, t->tid,
t->tstatus);
t->status);
}
}
break;

View File

@ -304,7 +304,7 @@ static int wait_stopped(struct thread *thread, struct process *child, int *statu
int ret;
/* Copy exit_status created in do_signal */
int *exit_status = child->pstatus == PS_STOPPED ?
int *exit_status = child->status == PS_STOPPED ?
&child->group_exit_status :
&child->exit_status;
@ -384,7 +384,7 @@ do_wait(int pid, int *status, int options, void *rusage)
empty = 0;
if((options & WEXITED) &&
child->pstatus == PS_ZOMBIE) {
child->status == PS_ZOMBIE) {
ret = wait_zombie(thread, child, status, options);
if(ret == child->pid){
mcs_rwlock_writer_unlock_noirq(&thread->proc->children_lock, &lock);
@ -410,7 +410,7 @@ do_wait(int pid, int *status, int options, void *rusage)
}
if((child->ptrace & PT_TRACED) &&
(child->pstatus & (PS_STOPPED | PS_TRACED))) {
(child->status & (PS_STOPPED | PS_TRACED))) {
ret = wait_stopped(thread, child, status, options);
if(ret == child->pid){
if(!(options & WNOWAIT)){
@ -566,17 +566,17 @@ terminate(int rc, int sig)
// clean up threads
mcs_rwlock_reader_lock(&proc->threads_lock, &lock); // conflict clone
mcs_rwlock_writer_lock_noirq(&proc->update_lock, &updatelock);
if(proc->pstatus == PS_EXITED){
if(proc->status == PS_EXITED){
mcs_rwlock_writer_unlock_noirq(&proc->update_lock, &updatelock);
mcs_rwlock_reader_unlock(&proc->threads_lock, &lock);
mythread->tstatus = PS_EXITED;
mythread->status = PS_EXITED;
release_thread(mythread);
schedule();
// no return
return;
}
proc->exit_status = ((rc & 0x00ff) << 8) | (sig & 0xff);
proc->pstatus = PS_EXITED;
proc->status = PS_EXITED;
mcs_rwlock_writer_unlock_noirq(&proc->update_lock, &updatelock);
mcs_rwlock_reader_unlock(&proc->threads_lock, &lock);
@ -672,7 +672,7 @@ terminate(int rc, int sig)
mcs_rwlock_writer_lock_noirq(&child->update_lock,
&updatelock);
if(child->ppid_parent == proc &&
child->pstatus == PS_ZOMBIE){
child->status == PS_ZOMBIE){
list_del(&child->hash_list);
list_del(&child->siblings_list);
kfree(child);
@ -721,11 +721,11 @@ terminate(int rc, int sig)
// Send signal to parent
if (proc->parent == pid1) {
proc->pstatus = PS_ZOMBIE;
proc->status = PS_ZOMBIE;
release_process(proc);
}
else {
proc->pstatus = PS_ZOMBIE;
proc->status = PS_ZOMBIE;
dkprintf("terminate,wakeup\n");
@ -749,7 +749,7 @@ terminate(int rc, int sig)
waitq_wakeup(&proc->parent->waitpid_q);
}
mythread->tstatus = PS_EXITED;
mythread->status = PS_EXITED;
release_thread(mythread);
schedule();
// no return
@ -1578,8 +1578,8 @@ static int ptrace_report_clone(struct thread *thread, struct thread *new, int ev
mcs_rwlock_writer_lock_noirq(&thread->proc->update_lock, &lock);
thread->proc->exit_status = (SIGTRAP | (event << 8));
/* Transition process state */
thread->proc->pstatus = PS_TRACED;
thread->tstatus = PS_TRACED;
thread->proc->status = PS_TRACED;
thread->status = PS_TRACED;
thread->proc->ptrace_eventmsg = new->tid;
thread->proc->ptrace &= ~PT_TRACE_SYSCALL_MASK;
parent_pid = thread->proc->parent->pid;
@ -1623,8 +1623,8 @@ static int ptrace_report_clone(struct thread *thread, struct thread *new, int ev
/* trace and SIGSTOP */
new->proc->exit_status = SIGSTOP;
new->proc->pstatus = PS_TRACED;
new->tstatus = PS_TRACED;
new->proc->status = PS_TRACED;
new->status = PS_TRACED;
mcs_rwlock_writer_unlock_noirq(&new->proc->update_lock, &updatelock);
}
@ -1925,10 +1925,10 @@ unsigned long do_fork(int clone_flags, unsigned long newsp,
}
}
new->tstatus = PS_RUNNING;
new->status = PS_RUNNING;
chain_thread(new);
if (!(clone_flags & CLONE_VM)) {
new->proc->pstatus = PS_RUNNING;
new->proc->status = PS_RUNNING;
chain_process(new->proc);
}
@ -3509,12 +3509,12 @@ SYSCALL_DECLARE(exit)
}
mcs_rwlock_reader_lock(&proc->threads_lock, &lock);
if(proc->pstatus == PS_EXITED){
if(proc->status == PS_EXITED){
mcs_rwlock_reader_unlock(&proc->threads_lock, &lock);
terminate(exit_status, 0);
return 0;
}
thread->tstatus = PS_EXITED;
thread->status = PS_EXITED;
mcs_rwlock_reader_unlock(&proc->threads_lock, &lock);
release_thread(thread);
@ -3722,7 +3722,7 @@ static long ptrace_pokeuser(int pid, long addr, long data)
child = find_thread(pid, pid, &lock);
if (!child)
return -ESRCH;
if(child->proc->pstatus == PS_TRACED){
if(child->proc->status == PS_TRACED){
rc = ptrace_write_user(child, addr, (unsigned long)data);
}
thread_unlock(child, &lock);
@ -3742,7 +3742,7 @@ static long ptrace_peekuser(int pid, long addr, long data)
child = find_thread(pid, pid, &lock);
if (!child)
return -ESRCH;
if(child->proc->pstatus == PS_TRACED){
if(child->proc->status == PS_TRACED){
unsigned long value;
rc = ptrace_read_user(child, addr, &value);
if (rc == 0) {
@ -3764,7 +3764,7 @@ static long ptrace_getregs(int pid, long data)
child = find_thread(pid, pid, &lock);
if (!child)
return -ESRCH;
if(child->proc->pstatus == PS_TRACED){
if(child->proc->status == PS_TRACED){
struct user_regs_struct user_regs;
long addr;
unsigned long *p;
@ -3794,7 +3794,7 @@ static long ptrace_setregs(int pid, long data)
child = find_thread(pid, pid, &lock);
if (!child)
return -ESRCH;
if(child->proc->pstatus == PS_TRACED){
if(child->proc->status == PS_TRACED){
struct user_regs_struct user_regs;
rc = copy_from_user(&user_regs, regs, sizeof(struct user_regs_struct));
if (rc == 0) {
@ -3824,7 +3824,7 @@ static long ptrace_arch_prctl(int pid, long code, long addr)
child = find_thread(pid, pid, &lock);
if (!child)
return -ESRCH;
if (child->proc->pstatus == PS_TRACED) {
if (child->proc->status == PS_TRACED) {
switch (code) {
case ARCH_GET_FS: {
unsigned long value;
@ -3880,7 +3880,7 @@ static long ptrace_getfpregs(int pid, long data)
child = find_thread(pid, pid, &lock);
if (!child)
return -ESRCH;
if (child->proc->pstatus == PS_TRACED) {
if (child->proc->status == PS_TRACED) {
rc = ptrace_read_fpregs(child, (void *)data);
}
thread_unlock(child, &lock);
@ -3897,7 +3897,7 @@ static long ptrace_setfpregs(int pid, long data)
child = find_thread(pid, pid, &lock);
if (!child)
return -ESRCH;
if (child->proc->pstatus == PS_TRACED) {
if (child->proc->status == PS_TRACED) {
rc = ptrace_write_fpregs(child, (void *)data);
}
thread_unlock(child, &lock);
@ -3917,7 +3917,7 @@ static long ptrace_getregset(int pid, long type, long data)
child = find_thread(pid, pid, &lock);
if (!child)
return -ESRCH;
if (child->proc->pstatus == PS_TRACED) {
if (child->proc->status == PS_TRACED) {
struct iovec iov;
rc = copy_from_user(&iov, (struct iovec *)data, sizeof(iov));
@ -3943,7 +3943,7 @@ static long ptrace_setregset(int pid, long type, long data)
child = find_thread(pid, pid, &lock);
if (!child)
return -ESRCH;
if (child->proc->pstatus == PS_TRACED) {
if (child->proc->status == PS_TRACED) {
struct iovec iov;
rc = copy_from_user(&iov, (struct iovec *)data, sizeof(iov));
@ -3970,7 +3970,7 @@ static long ptrace_peektext(int pid, long addr, long data)
child = find_thread(pid, pid, &lock);
if (!child)
return -ESRCH;
if(child->proc->pstatus == PS_TRACED){
if(child->proc->status == PS_TRACED){
unsigned long value;
rc = read_process_vm(child->vm, &value, (void *)addr, sizeof(value));
if (rc != 0) {
@ -3993,7 +3993,7 @@ static long ptrace_poketext(int pid, long addr, long data)
child = find_thread(pid, pid, &lock);
if (!child)
return -ESRCH;
if(child->proc->pstatus == PS_TRACED){
if(child->proc->status == PS_TRACED){
rc = patch_process_vm(child->vm, (void *)addr, &data, sizeof(data));
if (rc) {
dkprintf("ptrace_poketext: bad address 0x%llx\n", addr);
@ -4203,7 +4203,7 @@ static long ptrace_geteventmsg(int pid, long data)
if (!child) {
return -ESRCH;
}
if (child->proc->pstatus == PS_TRACED) {
if (child->proc->status == PS_TRACED) {
if (copy_to_user(msg_p, &child->proc->ptrace_eventmsg, sizeof(*msg_p))) {
rc = -EFAULT;
} else {
@ -4227,7 +4227,7 @@ ptrace_getsiginfo(int pid, siginfo_t *data)
return -ESRCH;
}
if (child->proc->pstatus != PS_TRACED) {
if (child->proc->status != PS_TRACED) {
rc = -ESRCH;
}
else if (child->ptrace_recvsig) {
@ -4254,7 +4254,7 @@ ptrace_setsiginfo(int pid, siginfo_t *data)
return -ESRCH;
}
if (child->proc->pstatus != PS_TRACED) {
if (child->proc->status != PS_TRACED) {
rc = -ESRCH;
}
else {
@ -6054,7 +6054,7 @@ long syscall(int num, ihk_mc_user_context_t *ctx)
{
long l;
if(cpu_local_var(current)->proc->pstatus == PS_EXITED &&
if(cpu_local_var(current)->proc->status == PS_EXITED &&
(num != __NR_exit && num != __NR_exit_group)){
check_signal(-EINVAL, NULL, 0);
return -EINVAL;

View File

@ -100,9 +100,9 @@ uint64_t schedule_timeout(uint64_t timeout)
/* Give a chance to another thread (if any) in case the core is
* oversubscribed, but make sure we will be re-scheduled */
if (need_schedule) {
xchg4(&(cpu_local_var(current)->tstatus), PS_RUNNING);
xchg4(&(cpu_local_var(current)->status), PS_RUNNING);
schedule();
xchg4(&(cpu_local_var(current)->tstatus),
xchg4(&(cpu_local_var(current)->status),
PS_INTERRUPTIBLE);
}
else {
@ -137,9 +137,9 @@ uint64_t schedule_timeout(uint64_t timeout)
ihk_mc_spinlock_unlock(&(v->runq_lock), irqstate);
if (need_schedule) {
xchg4(&(cpu_local_var(current)->tstatus), PS_RUNNING);
xchg4(&(cpu_local_var(current)->status), PS_RUNNING);
schedule();
xchg4(&(cpu_local_var(current)->tstatus),
xchg4(&(cpu_local_var(current)->status),
PS_INTERRUPTIBLE);
}
}

View File

@ -89,14 +89,14 @@ waitq_prepare_to_wait(waitq_t *waitq, waitq_entry_t *entry, int state)
ihk_mc_spinlock_lock_noirq(&waitq->lock);
if (list_empty(&entry->link))
list_add(&entry->link, &waitq->waitq);
cpu_local_var(current)->tstatus = state;
cpu_local_var(current)->status = state;
ihk_mc_spinlock_unlock_noirq(&waitq->lock);
}
void
waitq_finish_wait(waitq_t *waitq, waitq_entry_t *entry)
{
cpu_local_var(current)->tstatus = PS_RUNNING;
cpu_local_var(current)->status = PS_RUNNING;
waitq_remove_entry(waitq, entry);
}