terminate(): do not iterate process hash if no children processes exist

This commit is contained in:
Balazs Gerofi
2017-06-08 14:53:57 +09:00
parent 5758dba7cf
commit 66fad4c7a4
2 changed files with 40 additions and 38 deletions

View File

@@ -625,7 +625,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
syscall_channel_send(resp_channel, &pckt); syscall_channel_send(resp_channel, &pckt);
rc = do_kill(NULL, info.pid, info.tid, info.sig, &info.info, 0); rc = do_kill(NULL, info.pid, info.tid, info.sig, &info.info, 0);
kprintf("SCD_MSG_SEND_SIGNAL: do_kill(pid=%d, tid=%d, sig=%d)=%d\n", info.pid, info.tid, info.sig, rc); dkprintf("SCD_MSG_SEND_SIGNAL: do_kill(pid=%d, tid=%d, sig=%d)=%d\n", info.pid, info.tid, info.sig, rc);
ret = 0; ret = 0;
break; break;

View File

@@ -811,48 +811,50 @@ terminate(int rc, int sig)
kfree(ids); kfree(ids);
} }
// clean up children if (!list_empty(&proc->children_list)) {
for(i = 0; i < HASH_SIZE; i++){ // clean up children
mcs_rwlock_writer_lock(&resource_set->process_hash->lock[i], for(i = 0; i < HASH_SIZE; i++){
&lock); mcs_rwlock_writer_lock(&resource_set->process_hash->lock[i],
list_for_each_entry_safe(child, next, &lock);
&resource_set->process_hash->list[i], list_for_each_entry_safe(child, next,
hash_list){ &resource_set->process_hash->list[i],
mcs_rwlock_writer_lock_noirq(&child->update_lock, hash_list){
&updatelock); mcs_rwlock_writer_lock_noirq(&child->update_lock,
if(child->ppid_parent == proc && &updatelock);
child->status == PS_ZOMBIE){ if(child->ppid_parent == proc &&
list_del(&child->hash_list); child->status == PS_ZOMBIE){
list_del(&child->siblings_list); list_del(&child->hash_list);
kfree(child);
}
else if(child->ppid_parent == proc){
mcs_rwlock_writer_lock_noirq(&proc->children_lock,
&childlock);
mcs_rwlock_writer_lock_noirq(&pid1->children_lock,
&childlock1);
child->ppid_parent = pid1;
if(child->parent == proc){
child->parent = pid1;
list_del(&child->siblings_list); list_del(&child->siblings_list);
list_add_tail(&child->siblings_list, kfree(child);
&pid1->children_list);
} }
else{ else if(child->ppid_parent == proc){
list_del(&child->ptraced_siblings_list); mcs_rwlock_writer_lock_noirq(&proc->children_lock,
list_add_tail(&child->ptraced_siblings_list, &childlock);
&pid1->ptraced_children_list); mcs_rwlock_writer_lock_noirq(&pid1->children_lock,
&childlock1);
child->ppid_parent = pid1;
if(child->parent == proc){
child->parent = pid1;
list_del(&child->siblings_list);
list_add_tail(&child->siblings_list,
&pid1->children_list);
}
else{
list_del(&child->ptraced_siblings_list);
list_add_tail(&child->ptraced_siblings_list,
&pid1->ptraced_children_list);
}
mcs_rwlock_writer_unlock_noirq(&pid1->children_lock,
&childlock1);
mcs_rwlock_writer_unlock_noirq(&proc->children_lock,
&childlock);
} }
mcs_rwlock_writer_unlock_noirq(&pid1->children_lock, mcs_rwlock_writer_unlock_noirq(&child->update_lock,
&childlock1); &updatelock);
mcs_rwlock_writer_unlock_noirq(&proc->children_lock,
&childlock);
} }
mcs_rwlock_writer_unlock_noirq(&child->update_lock, mcs_rwlock_writer_unlock(&resource_set->process_hash->lock[i],
&updatelock); &lock);
} }
mcs_rwlock_writer_unlock(&resource_set->process_hash->lock[i],
&lock);
} }
dkprintf("terminate,pid=%d\n", proc->pid); dkprintf("terminate,pid=%d\n", proc->pid);