fix pipe02
This commit is contained in:
@@ -344,10 +344,6 @@ do_kill(int pid, int tid, int sig)
|
||||
ihk_spinlock_t *savelock = NULL;
|
||||
int found = 0;
|
||||
|
||||
if(proc == NULL || proc->pid == 0){
|
||||
return -ESRCH;
|
||||
}
|
||||
|
||||
if(sig > 64 || sig < 0)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -359,18 +355,21 @@ do_kill(int pid, int tid, int sig)
|
||||
int n = 0;
|
||||
int sendme = 0;
|
||||
|
||||
if(pid == 0){
|
||||
if(proc == NULL || proc->pid <= 0)
|
||||
return -ESRCH;
|
||||
pgid = proc->pgid;
|
||||
}
|
||||
pids = kmalloc(sizeof(int) * num_processors, IHK_MC_AP_NOWAIT);
|
||||
if(!pids)
|
||||
return -ENOMEM;
|
||||
if(pid == 0)
|
||||
pgid = proc->pgid;
|
||||
for(i = 0; i < num_processors; i++){
|
||||
v = get_cpu_local_var(i);
|
||||
irqstate = ihk_mc_spinlock_lock(&(v->runq_lock));
|
||||
list_for_each_entry(p, &(v->runq), sched_list){
|
||||
if(p->pid <= 0)
|
||||
continue;
|
||||
if(p->pid == proc->pid){
|
||||
if(proc && p->pid == proc->pid){
|
||||
sendme = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -572,6 +572,7 @@ struct thread_data_s {
|
||||
int ret;
|
||||
pid_t tid;
|
||||
int terminate;
|
||||
int remote_tid;
|
||||
pthread_mutex_t *lock;
|
||||
pthread_barrier_t *init_ready;
|
||||
} *thread_data;
|
||||
@@ -586,6 +587,7 @@ static void *main_loop_thread_func(void *arg)
|
||||
struct thread_data_s *td = (struct thread_data_s *)arg;
|
||||
|
||||
td->tid = gettid();
|
||||
td->remote_tid = (int)td->tid;
|
||||
pthread_barrier_wait(&init_ready);
|
||||
td->ret = main_loop(td->fd, td->cpu, td->lock);
|
||||
|
||||
@@ -597,40 +599,47 @@ sendsig(int sig, siginfo_t *siginfo, void *context)
|
||||
{
|
||||
pid_t pid = getpid();
|
||||
pid_t tid = gettid();
|
||||
int remote_tid;
|
||||
int i;
|
||||
int cpu;
|
||||
struct signal_desc sigdesc;
|
||||
|
||||
|
||||
if(siginfo->si_pid == pid &&
|
||||
siginfo->si_signo == SIGINT)
|
||||
return;
|
||||
if(tid == thread_data[0].tid){
|
||||
cpu = thread_data[0].cpu;
|
||||
tid = master_tid;
|
||||
|
||||
if(tid == master_tid){
|
||||
cpu = 0;
|
||||
remote_tid = -1;
|
||||
}
|
||||
else if(tid != master_tid){
|
||||
for(i = 1; i < ncpu; i++)
|
||||
if(thread_data[i].tid == tid){
|
||||
else{
|
||||
for(i = 1; i < ncpu; i++){
|
||||
if(siginfo->si_pid == pid &&
|
||||
thread_data[i].tid == tid){
|
||||
if(thread_data[i].terminate)
|
||||
return;
|
||||
break;
|
||||
}
|
||||
if(i != ncpu)
|
||||
if(siginfo->si_pid != pid &&
|
||||
thread_data[i].remote_tid == tid){
|
||||
if(thread_data[i].terminate)
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i != ncpu){
|
||||
remote_tid = thread_data[i].remote_tid;
|
||||
cpu = thread_data[i].cpu;
|
||||
}
|
||||
else{
|
||||
cpu = 0;
|
||||
tid = -1;
|
||||
remote_tid = -1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cpu = 0;
|
||||
tid = -1;
|
||||
}
|
||||
|
||||
sigdesc.cpu = cpu;
|
||||
sigdesc.pid = (int)pid;
|
||||
sigdesc.tid = (int)tid;
|
||||
sigdesc.tid = remote_tid;
|
||||
sigdesc.sig = sig;
|
||||
if (ioctl(fd, MCEXEC_UP_SEND_SIGNAL, &sigdesc) != 0) {
|
||||
perror("send_signal");
|
||||
@@ -1171,6 +1180,27 @@ int main_loop(int fd, int cpu, pthread_mutex_t *lock)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case __NR_gettid:{
|
||||
int mode = w.sr.args[0];
|
||||
int remote_pid = w.sr.args[1];
|
||||
int newcpuid = w.sr.args[2];
|
||||
int oldcpuid = w.sr.args[3];
|
||||
int wtid = thread_data[newcpuid].remote_tid;
|
||||
|
||||
if(mode == 0){
|
||||
thread_data[ncpu].remote_tid = wtid;
|
||||
thread_data[newcpuid].remote_tid = remote_pid;
|
||||
}
|
||||
else if(mode == 2){
|
||||
thread_data[newcpuid].remote_tid = thread_data[oldcpuid].remote_tid;
|
||||
thread_data[oldcpuid].remote_tid = wtid;
|
||||
}
|
||||
|
||||
do_syscall_return(fd, cpu, thread_data[newcpuid].remote_tid, 0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case __NR_fork: {
|
||||
int child;
|
||||
|
||||
|
||||
@@ -390,7 +390,6 @@ static int process_msg_prepare_process(unsigned long rphys)
|
||||
return -ENOMEM;
|
||||
}
|
||||
proc->pid = pn->pid;
|
||||
proc->tid = pn->pid;
|
||||
proc->pgid = pn->pgid;
|
||||
proc->ftn->pid = pn->pid;
|
||||
proc->vm->region.user_start = pn->user_start;
|
||||
@@ -498,6 +497,7 @@ static void syscall_channel_send(struct ihk_ikc_channel_desc *c,
|
||||
}
|
||||
|
||||
extern unsigned long do_kill(int, int, int);
|
||||
extern void settid(struct process *proc, int mode, int newcpuid, int oldcpuid);
|
||||
|
||||
static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||
void *__packet, void *ihk_os)
|
||||
@@ -505,6 +505,7 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||
struct ikc_scd_packet *packet = __packet;
|
||||
struct ikc_scd_packet pckt;
|
||||
int rc;
|
||||
struct process *proc;
|
||||
|
||||
switch (packet->msg) {
|
||||
case SCD_MSG_INIT_CHANNEL_ACKED:
|
||||
@@ -529,9 +530,10 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||
|
||||
case SCD_MSG_SCHEDULE_PROCESS:
|
||||
dkprintf("SCD_MSG_SCHEDULE_PROCESS: %lx\n", packet->arg);
|
||||
proc = (struct process *)packet->arg;
|
||||
|
||||
runq_add_proc((struct process *)packet->arg,
|
||||
ihk_mc_get_processor_id());
|
||||
settid(proc, 0, ihk_mc_get_processor_id(), -1);
|
||||
runq_add_proc(proc, ihk_mc_get_processor_id());
|
||||
|
||||
//cpu_local_var(next) = (struct process *)packet->arg;
|
||||
return 0;
|
||||
|
||||
@@ -42,12 +42,11 @@
|
||||
#define ekprintf(...) kprintf(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
|
||||
extern long do_arch_prctl(unsigned long code, unsigned long address);
|
||||
static void insert_vm_range_list(struct process_vm *vm,
|
||||
struct vm_range *newrange);
|
||||
static int copy_user_ranges(struct process *proc, struct process *org);
|
||||
|
||||
void settid(struct process *proc, int mode, int newcpuid, int oldcpuid);
|
||||
|
||||
void hold_fork_tree_node(struct fork_tree_node *ftn)
|
||||
{
|
||||
@@ -1811,6 +1810,7 @@ static void do_migrate(void)
|
||||
cur_v->runq_len -= 1;
|
||||
old_cpu_id = req->proc->cpu_id;
|
||||
req->proc->cpu_id = cpu_id;
|
||||
settid(req->proc, 2, cpu_id, old_cpu_id);
|
||||
list_add_tail(&req->proc->sched_list, &v->runq);
|
||||
v->runq_len += 1;
|
||||
|
||||
@@ -2011,8 +2011,6 @@ void sched_request_migrate(int cpu_id, struct process *proc)
|
||||
waitq_finish_wait(&req.wq, &entry);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Runq lock must be held here */
|
||||
void __runq_add_proc(struct process *proc, int cpu_id)
|
||||
{
|
||||
|
||||
@@ -120,6 +120,7 @@ static void send_syscall(struct syscall_request *req, int cpu, int pid)
|
||||
int ret;
|
||||
|
||||
if(req->number == __NR_exit_group ||
|
||||
req->number == __NR_gettid ||
|
||||
req->number == __NR_kill){ // interrupt syscall
|
||||
extern int num_processors;
|
||||
|
||||
@@ -131,6 +132,8 @@ static void send_syscall(struct syscall_request *req, int cpu, int pid)
|
||||
cpu = num_processors;
|
||||
if(req->number == __NR_kill)
|
||||
pid = req->args[0];
|
||||
if(req->number == __NR_gettid)
|
||||
pid = req->args[1];
|
||||
}
|
||||
else{
|
||||
scp = &get_cpu_local_var(cpu)->scp;
|
||||
@@ -188,6 +191,7 @@ long do_syscall(struct syscall_request *req, ihk_mc_user_context_t *ctx,
|
||||
req->number);
|
||||
|
||||
if(req->number == __NR_exit_group ||
|
||||
req->number == __NR_gettid ||
|
||||
req->number == __NR_kill){ // interrupt syscall
|
||||
scp = &get_cpu_local_var(0)->scp2;
|
||||
islock = 1;
|
||||
@@ -1121,6 +1125,20 @@ SYSCALL_DECLARE(getpid)
|
||||
return cpu_local_var(current)->pid;
|
||||
}
|
||||
|
||||
void
|
||||
settid(struct process *proc, int mode, int newcpuid, int oldcpuid)
|
||||
{
|
||||
ihk_mc_user_context_t ctx;
|
||||
unsigned long rc;
|
||||
|
||||
ihk_mc_syscall_arg0(&ctx) = mode;
|
||||
ihk_mc_syscall_arg1(&ctx) = proc->pid;
|
||||
ihk_mc_syscall_arg2(&ctx) = newcpuid;
|
||||
ihk_mc_syscall_arg3(&ctx) = oldcpuid;
|
||||
rc = syscall_generic_forwarding(__NR_gettid, &ctx);
|
||||
proc->tid = rc;
|
||||
}
|
||||
|
||||
SYSCALL_DECLARE(gettid)
|
||||
{
|
||||
return cpu_local_var(current)->tid;
|
||||
@@ -1325,9 +1343,7 @@ SYSCALL_DECLARE(clone)
|
||||
|
||||
if (clone_flags & CLONE_VM) {
|
||||
new->pid = cpu_local_var(current)->pid;
|
||||
|
||||
request1.number = __NR_gettid;
|
||||
new->tid = do_syscall(&request1, &ctx1, cpuid, new->pid);
|
||||
settid(new, 1, cpuid, -1);
|
||||
}
|
||||
/* fork() a new process on the host */
|
||||
else {
|
||||
@@ -1342,7 +1358,7 @@ SYSCALL_DECLARE(clone)
|
||||
}
|
||||
|
||||
/* In a single threaded process TID equals to PID */
|
||||
new->tid = new->pid;
|
||||
settid(new, 0, cpuid, -1);
|
||||
|
||||
dkprintf("fork(): new pid: %d\n", new->pid);
|
||||
/* clear user space PTEs and set new rpgtable so that consequent
|
||||
|
||||
Reference in New Issue
Block a user