when mcexec is killed by SIGKILL, terminate mckernel process (BUG#259)

This commit is contained in:
Tomoki Shirasawa
2014-11-27 16:13:52 +09:00
parent 58e2e0a246
commit 8f30e16976
11 changed files with 164 additions and 8 deletions

View File

@@ -474,6 +474,8 @@ extern void process_procfs_request(unsigned long rarg);
extern int memcheckall();
extern int freecheck(int runcount);
extern int runcount;
extern void terminate_host(int pid);
extern void debug_log(long);
static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
void *__packet, void *ihk_os)
@@ -547,6 +549,14 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
case SCD_MSG_PROCFS_REQUEST:
process_procfs_request(packet->arg);
return 0;
case SCD_MSG_CLEANUP_PROCESS:
dkprintf("SCD_MSG_CLEANUP_PROCESS pid=%d\n", packet->pid);
terminate_host(packet->pid);
return 0;
case SCD_MSG_DEBUG_LOG:
dkprintf("SCD_MSG_DEBUG_LOG code=%lx\n", packet->arg);
debug_log(packet->arg);
return 0;
}
return 0;
}

View File

@@ -327,6 +327,7 @@ struct process {
} thread;
volatile int sigevent;
int nohost;
sigset_t sigmask;
stack_t sigstack;
ihk_spinlock_t sigpendinglock;

View File

@@ -34,12 +34,15 @@
#define SCD_MSG_SYSCALL_ONESIDE 0x4
#define SCD_MSG_SEND_SIGNAL 0x8
#define SCD_MSG_CLEANUP_PROCESS 0x9
#define SCD_MSG_PROCFS_CREATE 0x10
#define SCD_MSG_PROCFS_DELETE 0x11
#define SCD_MSG_PROCFS_REQUEST 0x12
#define SCD_MSG_PROCFS_ANSWER 0x13
#define SCD_MSG_DEBUG_LOG 0x20
#define ARCH_SET_GS 0x1001
#define ARCH_SET_FS 0x1002
#define ARCH_GET_FS 0x1003

View File

@@ -2247,3 +2247,29 @@ process_unlock(void *savelock, unsigned long irqstate)
{
ihk_mc_spinlock_unlock((ihk_spinlock_t *)savelock, irqstate);
}
void
debug_log(unsigned long arg)
{
struct cpu_local_var *v;
struct process *p;
int i;
extern int num_processors;
unsigned long irqstate;
switch(arg){
case 1:
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->ftn->pid <= 0)
continue;
kprintf("cpu=%d pid=%d tid=%d status=%d\n",
i, p->ftn->pid, p->ftn->tid, p->ftn->status);
}
ihk_mc_spinlock_unlock(&(v->runq_lock), irqstate);
}
break;
}
}

View File

@@ -546,7 +546,8 @@ terminate(int rc, int sig, ihk_mc_user_context_t *ctx)
/* XXX: send SIGKILL to all threads in this process */
flush_process_memory(proc); /* temporary hack */
do_syscall(&request, ctx, ihk_mc_get_processor_id(), 0);
if(!proc->nohost)
do_syscall(&request, ctx, ihk_mc_get_processor_id(), 0);
#define IS_DETACHED_PROCESS(proc) (1) /* should be implemented in the future */
@@ -610,6 +611,44 @@ terminate(int rc, int sig, ihk_mc_user_context_t *ctx)
schedule();
}
void terminate_host(int pid)
{
struct cpu_local_var *v;
struct process *p;
int i;
unsigned long irqstate;
extern int num_processors;
int *tids;
int n;
siginfo_t info;
memset(&info, '\0', sizeof info);
info.si_signo = SIGKILL;
info.si_code = SI_KERNEL;
tids = kmalloc(sizeof(int) * num_processors, IHK_MC_AP_NOWAIT);
if(!tids)
return;
for(n = 0, 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->ftn->pid == pid){
p->nohost = 1;
tids[n] = p->ftn->tid;
n++;
}
}
ihk_mc_spinlock_unlock(&(v->runq_lock), irqstate);
}
for(i = 0; i < n; i++){
do_kill(pid, tids[i], SIGKILL, &info);
}
kfree(tids);
}
void
interrupt_syscall(int pid, int cpuid)
{