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